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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return change; | 86 return change; |
87 } | 87 } |
88 | 88 |
89 @override | 89 @override |
90 bool requiresPreview() => false; | 90 bool requiresPreview() => false; |
91 | 91 |
92 void _updateElementDeclaration(Element element) { | 92 void _updateElementDeclaration(Element element) { |
93 // prepare parameters | 93 // prepare parameters |
94 FormalParameterList parameters; | 94 FormalParameterList parameters; |
95 { | 95 { |
96 AstNode node = element.node; | 96 AstNode node = element.computeNode(); |
97 if (node is MethodDeclaration) { | 97 if (node is MethodDeclaration) { |
98 parameters = node.parameters; | 98 parameters = node.parameters; |
99 } | 99 } |
100 if (node is FunctionDeclaration) { | 100 if (node is FunctionDeclaration) { |
101 parameters = node.functionExpression.parameters; | 101 parameters = node.functionExpression.parameters; |
102 } | 102 } |
103 } | 103 } |
104 // insert "get " | 104 // insert "get " |
105 { | 105 { |
106 SourceEdit edit = new SourceEdit(element.nameOffset, 0, 'get '); | 106 SourceEdit edit = new SourceEdit(element.nameOffset, 0, 'get '); |
(...skipping 22 matching lines...) Expand all Loading... |
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 |