Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: pkg/analysis_server/lib/src/services/refactoring/rename_constructor.dart

Issue 2677833002: Don't search for 'declaration' of elements, just name is usually enough. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.rename_constructor; 5 library services.src.refactoring.rename_constructor;
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 element.library.source.uri.toString(), 105 element.library.source.uri.toString(),
106 element.source.uri.toString(), 106 element.source.uri.toString(),
107 MatchKind.DECLARATION, 107 MatchKind.DECLARATION,
108 sourceRange, 108 sourceRange,
109 true, 109 true,
110 true)); 110 true));
111 } 111 }
112 112
113 Future<Null> _replaceSynthetic() async { 113 Future<Null> _replaceSynthetic() async {
114 ClassElement classElement = element.enclosingElement; 114 ClassElement classElement = element.enclosingElement;
115 ClassDeclaration classNode = 115 AstNode name = await astProvider.getResolvedNameForElement(classElement);
116 await astProvider.getResolvedNodeForElement(classElement); 116 ClassDeclaration classNode = name.parent as ClassDeclaration;
117 CorrectionUtils utils = new CorrectionUtils(classNode.parent); 117 CorrectionUtils utils = new CorrectionUtils(classNode.parent);
118 ClassMemberLocation location = 118 ClassMemberLocation location =
119 utils.prepareNewConstructorLocation(classNode); 119 utils.prepareNewConstructorLocation(classNode);
120 doSourceChange_addElementEdit( 120 doSourceChange_addElementEdit(
121 change, 121 change,
122 classElement, 122 classElement,
123 new SourceEdit( 123 new SourceEdit(
124 location.offset, 124 location.offset,
125 0, 125 0,
126 location.prefix + 126 location.prefix +
127 '${classElement.name}.$newName();' + 127 '${classElement.name}.$newName();' +
128 location.suffix)); 128 location.suffix));
129 } 129 }
130 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698