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

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

Issue 1855643002: More strong mode changes to analysis_server (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Backout changes to options file Created 4 years, 8 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.extract_method; 5 library services.src.refactoring.extract_method;
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/name_suggestion.dart'; 10 import 'package:analysis_server/src/services/correction/name_suggestion.dart';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 * from tokens, so ignores all the comments and spaces. 48 * from tokens, so ignores all the comments and spaces.
49 */ 49 */
50 String _getNormalizedSource(String src) { 50 String _getNormalizedSource(String src) {
51 List<Token> selectionTokens = TokenUtils.getTokens(src); 51 List<Token> selectionTokens = TokenUtils.getTokens(src);
52 return StringUtils.join(selectionTokens, _TOKEN_SEPARATOR); 52 return StringUtils.join(selectionTokens, _TOKEN_SEPARATOR);
53 } 53 }
54 54
55 /** 55 /**
56 * Returns the [Map] which maps [map] values to their keys. 56 * Returns the [Map] which maps [map] values to their keys.
57 */ 57 */
58 Map<String, String> _inverseMap(Map map) { 58 Map<String, String> _inverseMap(Map<String, String> map) {
59 Map result = {}; 59 Map<String, String> result = <String, String>{};
60 map.forEach((key, value) { 60 map.forEach((String key, String value) {
61 result[value] = key; 61 result[value] = key;
62 }); 62 });
63 return result; 63 return result;
64 } 64 }
65 65
66 /** 66 /**
67 * [ExtractMethodRefactoring] implementation. 67 * [ExtractMethodRefactoring] implementation.
68 */ 68 */
69 class ExtractMethodRefactoringImpl extends RefactoringImpl 69 class ExtractMethodRefactoringImpl extends RefactoringImpl
70 implements ExtractMethodRefactoring { 70 implements ExtractMethodRefactoring {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 if (parent is CompilationUnit) { 413 if (parent is CompilationUnit) {
414 LibraryElement libraryElement = parent.element.library; 414 LibraryElement libraryElement = parent.element.library;
415 return validateCreateFunction(searchEngine, libraryElement, name); 415 return validateCreateFunction(searchEngine, libraryElement, name);
416 } 416 }
417 // method of class 417 // method of class
418 if (parent is ClassDeclaration) { 418 if (parent is ClassDeclaration) {
419 ClassElement classElement = parent.element; 419 ClassElement classElement = parent.element;
420 return validateCreateMethod(searchEngine, classElement, name); 420 return validateCreateMethod(searchEngine, classElement, name);
421 } 421 }
422 // OK 422 // OK
423 return new Future.value(result); 423 return new Future<RefactoringStatus>.value(result);
424 } 424 }
425 425
426 /** 426 /**
427 * Checks if [selectionRange] selects [Expression] which can be extracted, and 427 * Checks if [selectionRange] selects [Expression] which can be extracted, and
428 * location of this [DartExpression] in AST allows extracting. 428 * location of this [DartExpression] in AST allows extracting.
429 */ 429 */
430 RefactoringStatus _checkSelection() { 430 RefactoringStatus _checkSelection() {
431 _ExtractMethodAnalyzer selectionAnalyzer = 431 _ExtractMethodAnalyzer selectionAnalyzer =
432 new _ExtractMethodAnalyzer(unit, selectionRange); 432 new _ExtractMethodAnalyzer(unit, selectionRange);
433 unit.accept(selectionAnalyzer); 433 unit.accept(selectionAnalyzer);
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 return false; 1240 return false;
1241 } 1241 }
1242 for (int i = 0; i < parameterTypes.length; i++) { 1242 for (int i = 0; i < parameterTypes.length; i++) {
1243 if (other.parameterTypes[i] != parameterTypes[i]) { 1243 if (other.parameterTypes[i] != parameterTypes[i]) {
1244 return false; 1244 return false;
1245 } 1245 }
1246 } 1246 }
1247 return true; 1247 return true;
1248 } 1248 }
1249 } 1249 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/server/driver.dart ('k') | pkg/analysis_server/lib/src/services/refactoring/inline_local.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698