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

Side by Side Diff: pkg/analysis_server/lib/src/services/refactoring/inline_local.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.inline_local; 5 library services.src.refactoring.inline_local;
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 _variableElement = element; 77 _variableElement = element;
78 _variableNode = element.computeNode(); 78 _variableNode = element.computeNode();
79 } 79 }
80 } 80 }
81 } 81 }
82 // validate node declaration 82 // validate node declaration
83 if (!_isVariableDeclaredInStatement()) { 83 if (!_isVariableDeclaredInStatement()) {
84 result = new RefactoringStatus.fatal( 84 result = new RefactoringStatus.fatal(
85 'Local variable declaration or reference must be selected ' 85 'Local variable declaration or reference must be selected '
86 'to activate this refactoring.'); 86 'to activate this refactoring.');
87 return new Future.value(result); 87 return new Future<RefactoringStatus>.value(result);
88 } 88 }
89 // should have initializer at declaration 89 // should have initializer at declaration
90 if (_variableNode.initializer == null) { 90 if (_variableNode.initializer == null) {
91 String message = format( 91 String message = format(
92 "Local variable '{0}' is not initialized at declaration.", 92 "Local variable '{0}' is not initialized at declaration.",
93 _variableElement.displayName); 93 _variableElement.displayName);
94 result = new RefactoringStatus.fatal( 94 result = new RefactoringStatus.fatal(
95 message, newLocation_fromNode(_variableNode)); 95 message, newLocation_fromNode(_variableNode));
96 return new Future.value(result); 96 return new Future<RefactoringStatus>.value(result);
97 } 97 }
98 // prepare references 98 // prepare references
99 _references = await searchEngine.searchReferences(_variableElement); 99 _references = await searchEngine.searchReferences(_variableElement);
100 // should not have assignments 100 // should not have assignments
101 for (SearchMatch reference in _references) { 101 for (SearchMatch reference in _references) {
102 if (reference.kind != MatchKind.READ) { 102 if (reference.kind != MatchKind.READ) {
103 String message = format( 103 String message = format(
104 "Local variable '{0}' is assigned more than once.", 104 "Local variable '{0}' is assigned more than once.",
105 [_variableElement.displayName]); 105 [_variableElement.displayName]);
106 return new RefactoringStatus.fatal( 106 return new RefactoringStatus.fatal(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (initializerOperator == TokenType.MINUS || 202 if (initializerOperator == TokenType.MINUS ||
203 initializerOperator == TokenType.MINUS_MINUS) { 203 initializerOperator == TokenType.MINUS_MINUS) {
204 return true; 204 return true;
205 } 205 }
206 } 206 }
207 } 207 }
208 // no () is needed 208 // no () is needed
209 return false; 209 return false;
210 } 210 }
211 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698