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

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

Issue 554053002: Return a feedback for the INLINE_METHOD refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
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.inline_method; 5 library services.src.refactoring.inline_method;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' hide Element; 9 import 'package:analysis_server/src/protocol.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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 */ 166 */
167 class InlineMethodRefactoringImpl extends RefactoringImpl implements 167 class InlineMethodRefactoringImpl extends RefactoringImpl implements
168 InlineMethodRefactoring { 168 InlineMethodRefactoring {
169 final SearchEngine searchEngine; 169 final SearchEngine searchEngine;
170 final CompilationUnit unit; 170 final CompilationUnit unit;
171 final int offset; 171 final int offset;
172 String file; 172 String file;
173 CorrectionUtils utils; 173 CorrectionUtils utils;
174 SourceChange change; 174 SourceChange change;
175 175
176 bool isDeclaration = false;
176 bool deleteSource = false; 177 bool deleteSource = false;
177 bool inlineAll = true; 178 bool inlineAll = true;
178 179
179 ExecutableElement _methodElement; 180 ExecutableElement _methodElement;
180 String _methodFile; 181 String _methodFile;
181 CompilationUnit _methodUnit; 182 CompilationUnit _methodUnit;
182 CorrectionUtils _methodUtils; 183 CorrectionUtils _methodUtils;
183 AstNode _methodNode; 184 AstNode _methodNode;
184 FormalParameterList _methodParameters; 185 FormalParameterList _methodParameters;
185 FunctionBody _methodBody; 186 FunctionBody _methodBody;
186 Expression _methodExpression; 187 Expression _methodExpression;
187 _SourcePart _methodExpressionPart; 188 _SourcePart _methodExpressionPart;
188 _SourcePart _methodStatementsPart; 189 _SourcePart _methodStatementsPart;
189 List<_ReferenceProcessor> _referenceProcessors = []; 190 List<_ReferenceProcessor> _referenceProcessors = [];
190 191
191 InlineMethodRefactoringImpl(this.searchEngine, this.unit, this.offset) { 192 InlineMethodRefactoringImpl(this.searchEngine, this.unit, this.offset) {
192 file = unit.element.source.fullName; 193 file = unit.element.source.fullName;
193 utils = new CorrectionUtils(unit); 194 utils = new CorrectionUtils(unit);
194 } 195 }
195 196
196 @override 197 @override
198 String get className {
199 if (_methodElement == null) {
200 return null;
201 }
202 Element classElement = _methodElement.enclosingElement;
203 if (classElement is ClassElement) {
204 return classElement.displayName;
205 }
206 return null;
207 }
208
209 @override
210 String get methodName {
211 if (_methodElement == null) {
212 return null;
213 }
214 return _methodElement.displayName;
215 }
216
217 @override
197 String get refactoringName { 218 String get refactoringName {
198 if (_methodElement is MethodElement) { 219 if (_methodElement is MethodElement) {
199 return "Inline Method"; 220 return "Inline Method";
200 } else { 221 } else {
201 return "Inline Function"; 222 return "Inline Function";
202 } 223 }
203 } 224 }
204 225
205 @override 226 @override
206 Future<RefactoringStatus> checkFinalConditions() { 227 Future<RefactoringStatus> checkFinalConditions() {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 _methodUnit = selectedElement.unit; 318 _methodUnit = selectedElement.unit;
298 _methodUtils = new CorrectionUtils(_methodUnit); 319 _methodUtils = new CorrectionUtils(_methodUnit);
299 if (selectedElement is MethodElement || 320 if (selectedElement is MethodElement ||
300 selectedElement is PropertyAccessorElement) { 321 selectedElement is PropertyAccessorElement) {
301 MethodDeclaration methodDeclaration = 322 MethodDeclaration methodDeclaration =
302 _methodElement.node as MethodDeclaration; 323 _methodElement.node as MethodDeclaration;
303 _methodNode = methodDeclaration; 324 _methodNode = methodDeclaration;
304 _methodParameters = methodDeclaration.parameters; 325 _methodParameters = methodDeclaration.parameters;
305 _methodBody = methodDeclaration.body; 326 _methodBody = methodDeclaration.body;
306 // prepare mode 327 // prepare mode
307 deleteSource = selectedNode == methodDeclaration.name; 328 isDeclaration = selectedNode == methodDeclaration.name;
329 deleteSource = isDeclaration;
308 inlineAll = deleteSource; 330 inlineAll = deleteSource;
309 } 331 }
310 if (selectedElement is FunctionElement) { 332 if (selectedElement is FunctionElement) {
311 FunctionDeclaration functionDeclaration = 333 FunctionDeclaration functionDeclaration =
312 _methodElement.node as FunctionDeclaration; 334 _methodElement.node as FunctionDeclaration;
313 _methodNode = functionDeclaration; 335 _methodNode = functionDeclaration;
314 _methodParameters = functionDeclaration.functionExpression.parameters; 336 _methodParameters = functionDeclaration.functionExpression.parameters;
315 _methodBody = functionDeclaration.functionExpression.body; 337 _methodBody = functionDeclaration.functionExpression.body;
316 // prepare mode 338 // prepare mode
317 deleteSource = selectedNode == functionDeclaration.name; 339 isDeclaration = selectedNode == functionDeclaration.name;
340 deleteSource = isDeclaration;
318 inlineAll = deleteSource; 341 inlineAll = deleteSource;
319 } 342 }
320 // OK 343 // OK
321 return new RefactoringStatus(); 344 return new RefactoringStatus();
322 } 345 }
323 346
324 /** 347 /**
325 * Analyze [_methodBody] to fill [_methodExpressionPart] and 348 * Analyze [_methodBody] to fill [_methodExpressionPart] and
326 * [_methodStatementsPart]. 349 * [_methodStatementsPart].
327 */ 350 */
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 } 793 }
771 794
772 void _addVariable(SimpleIdentifier node) { 795 void _addVariable(SimpleIdentifier node) {
773 VariableElement variableElement = getLocalVariableElement(node); 796 VariableElement variableElement = getLocalVariableElement(node);
774 if (variableElement != null) { 797 if (variableElement != null) {
775 SourceRange nodeRange = rangeNode(node); 798 SourceRange nodeRange = rangeNode(node);
776 result.addVariable(variableElement, nodeRange); 799 result.addVariable(variableElement, nodeRange);
777 } 800 }
778 } 801 }
779 } 802 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | pkg/analysis_server/lib/src/services/refactoring/refactoring.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698