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 services.src.refactoring.convert_method_to_getter; | 5 library services.src.refactoring.convert_method_to_getter; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/protocol_server.dart' hide Element; | 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
10 import 'package:analysis_server/src/services/correction/source_range.dart'; | 10 import 'package:analysis_server/src/services/correction/source_range.dart'; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 List<SearchMatch> matches = await searchEngine.searchReferences(element); | 117 List<SearchMatch> matches = await searchEngine.searchReferences(element); |
118 List<SourceReference> references = getSourceReferences(matches); | 118 List<SourceReference> references = getSourceReferences(matches); |
119 for (SourceReference reference in references) { | 119 for (SourceReference reference in references) { |
120 Element refElement = reference.element; | 120 Element refElement = reference.element; |
121 SourceRange refRange = reference.range; | 121 SourceRange refRange = reference.range; |
122 // prepare invocation | 122 // prepare invocation |
123 MethodInvocation invocation; | 123 MethodInvocation invocation; |
124 { | 124 { |
125 CompilationUnit refUnit = refElement.unit; | 125 CompilationUnit refUnit = refElement.unit; |
126 AstNode refNode = | 126 AstNode refNode = |
127 new NodeLocator.con1(refRange.offset).searchWithin(refUnit); | 127 new NodeLocator(refRange.offset).searchWithin(refUnit); |
128 invocation = refNode.getAncestor((node) => node is MethodInvocation); | 128 invocation = refNode.getAncestor((node) => node is MethodInvocation); |
129 } | 129 } |
130 // we need invocation | 130 // we need invocation |
131 if (invocation != null) { | 131 if (invocation != null) { |
132 SourceRange range = rangeEndEnd(refRange, invocation); | 132 SourceRange range = rangeEndEnd(refRange, invocation); |
133 SourceEdit edit = newSourceEdit_range(range, ''); | 133 SourceEdit edit = newSourceEdit_range(range, ''); |
134 doSourceChange_addElementEdit(change, refElement, edit); | 134 doSourceChange_addElementEdit(change, refElement, edit); |
135 } | 135 } |
136 } | 136 } |
137 } | 137 } |
138 } | 138 } |
OLD | NEW |