| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library edit.domain; | 5 library edit.domain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/edit/assist/assist_core.dart'; | 9 import 'package:analysis_server/edit/assist/assist_core.dart'; |
| 10 import 'package:analysis_server/edit/fix/fix_core.dart'; | 10 import 'package:analysis_server/edit/fix/fix_core.dart'; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 List<SourceEdit> edits = <SourceEdit>[]; | 104 List<SourceEdit> edits = <SourceEdit>[]; |
| 105 | 105 |
| 106 if (formattedSource != unformattedSource) { | 106 if (formattedSource != unformattedSource) { |
| 107 //TODO: replace full replacements with smaller, more targeted edits | 107 //TODO: replace full replacements with smaller, more targeted edits |
| 108 SourceEdit edit = | 108 SourceEdit edit = |
| 109 new SourceEdit(0, unformattedSource.length, formattedSource); | 109 new SourceEdit(0, unformattedSource.length, formattedSource); |
| 110 edits.add(edit); | 110 edits.add(edit); |
| 111 } | 111 } |
| 112 | 112 |
| 113 return new EditFormatResult(edits, formattedResult.selectionStart, | 113 int newStart = formattedResult.selectionStart; |
| 114 formattedResult.selectionLength).toResponse(request.id); | 114 int newLength = formattedResult.selectionLength; |
| 115 |
| 116 // Sending null start/length values would violate protocol, so convert back |
| 117 // to 0. |
| 118 if (newStart == null) { |
| 119 newStart = 0; |
| 120 } |
| 121 if (newLength == null) { |
| 122 newLength = 0; |
| 123 } |
| 124 |
| 125 return new EditFormatResult(edits, newStart, |
| 126 newLength).toResponse(request.id); |
| 115 } | 127 } |
| 116 | 128 |
| 117 Response getAssists(Request request) { | 129 Response getAssists(Request request) { |
| 118 EditGetAssistsParams params = new EditGetAssistsParams.fromRequest(request); | 130 EditGetAssistsParams params = new EditGetAssistsParams.fromRequest(request); |
| 119 ContextSourcePair pair = server.getContextSourcePair(params.file); | 131 ContextSourcePair pair = server.getContextSourcePair(params.file); |
| 120 engine.AnalysisContext context = pair.context; | 132 engine.AnalysisContext context = pair.context; |
| 121 Source source = pair.source; | 133 Source source = pair.source; |
| 122 List<SourceChange> changes = <SourceChange>[]; | 134 List<SourceChange> changes = <SourceChange>[]; |
| 123 if (context != null && source != null) { | 135 if (context != null && source != null) { |
| 124 List<Assist> assists = computeAssists(plugin, context, | 136 List<Assist> assists = computeAssists(plugin, context, |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } | 645 } |
| 634 if (refactoring is RenameRefactoring) { | 646 if (refactoring is RenameRefactoring) { |
| 635 RenameRefactoring renameRefactoring = refactoring; | 647 RenameRefactoring renameRefactoring = refactoring; |
| 636 RenameOptions renameOptions = params.options; | 648 RenameOptions renameOptions = params.options; |
| 637 renameRefactoring.newName = renameOptions.newName; | 649 renameRefactoring.newName = renameOptions.newName; |
| 638 return renameRefactoring.checkNewName(); | 650 return renameRefactoring.checkNewName(); |
| 639 } | 651 } |
| 640 return new RefactoringStatus(); | 652 return new RefactoringStatus(); |
| 641 } | 653 } |
| 642 } | 654 } |
| OLD | NEW |