| 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 test.services.refactoring.inline_local; | 5 library test.services.refactoring.inline_local; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart' hide Element; | 7 import 'package:analysis_server/src/protocol.dart' hide Element; |
| 8 import 'package:analysis_server/src/services/correction/status.dart'; | 8 import 'package:analysis_server/src/services/correction/status.dart'; |
| 9 import 'package:analysis_server/src/services/refactoring/inline_local.dart'; | 9 import 'package:analysis_server/src/services/refactoring/inline_local.dart'; |
| 10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 main() { | 187 main() { |
| 188 int test = 1 + 2; | 188 int test = 1 + 2; |
| 189 print(test); | 189 print(test); |
| 190 print(test); | 190 print(test); |
| 191 } | 191 } |
| 192 '''); | 192 '''); |
| 193 _createRefactoring('test ='); | 193 _createRefactoring('test ='); |
| 194 expect(refactoring.refactoringName, 'Inline Local Variable'); | 194 expect(refactoring.refactoringName, 'Inline Local Variable'); |
| 195 // check initial conditions and access | 195 // check initial conditions and access |
| 196 return refactoring.checkInitialConditions().then((_) { | 196 return refactoring.checkInitialConditions().then((_) { |
| 197 expect(refactoring.variableName, 'test'); |
| 197 expect(refactoring.referenceCount, 2); | 198 expect(refactoring.referenceCount, 2); |
| 198 }); | 199 }); |
| 199 } | 200 } |
| 200 | 201 |
| 201 test_bad_selectionMethod() { | 202 test_bad_selectionMethod() { |
| 202 indexTestUnit(r''' | 203 indexTestUnit(r''' |
| 203 main() { | 204 main() { |
| 204 } | 205 } |
| 205 '''); | 206 '''); |
| 206 _createRefactoring('main() {'); | 207 _createRefactoring('main() {'); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 int test; | 272 int test; |
| 272 } | 273 } |
| 273 '''); | 274 '''); |
| 274 _createRefactoring('test;'); | 275 _createRefactoring('test;'); |
| 275 return refactoring.checkInitialConditions().then((status) { | 276 return refactoring.checkInitialConditions().then((status) { |
| 276 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL); | 277 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL); |
| 277 }); | 278 }); |
| 278 } | 279 } |
| 279 | 280 |
| 280 void _assert_fatalError_selection(RefactoringStatus status) { | 281 void _assert_fatalError_selection(RefactoringStatus status) { |
| 282 expect(refactoring.variableName, isNull); |
| 283 expect(refactoring.referenceCount, 0); |
| 281 assertRefactoringStatus( | 284 assertRefactoringStatus( |
| 282 status, | 285 status, |
| 283 RefactoringProblemSeverity.FATAL, | 286 RefactoringProblemSeverity.FATAL, |
| 284 expectedMessage: 'Local variable declaration or reference must be ' | 287 expectedMessage: 'Local variable declaration or reference must be ' |
| 285 'selected to activate this refactoring.'); | 288 'selected to activate this refactoring.'); |
| 286 } | 289 } |
| 287 | 290 |
| 288 void _createRefactoring(String search) { | 291 void _createRefactoring(String search) { |
| 289 int offset = findOffset(search); | 292 int offset = findOffset(search); |
| 290 refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset); | 293 refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset); |
| 291 } | 294 } |
| 292 } | 295 } |
| OLD | NEW |