| 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_method; | 5 library test.services.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/refactoring/inline_method.dart'; | 10 import 'package:analysis_server/src/services/refactoring/inline_method.dart'; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 test_access_FunctionElement() { | 31 test_access_FunctionElement() { |
| 32 indexTestUnit(r''' | 32 indexTestUnit(r''' |
| 33 test(a, b) { | 33 test(a, b) { |
| 34 return a + b; | 34 return a + b; |
| 35 } | 35 } |
| 36 main() { | 36 main() { |
| 37 var res = test(1, 2); | 37 var res = test(1, 2); |
| 38 } | 38 } |
| 39 '''); | 39 '''); |
| 40 _createRefactoring('test(a, b)'); | 40 _createRefactoring('test(1, 2)'); |
| 41 // validate state | 41 // validate state |
| 42 return refactoring.checkInitialConditions().then((_) { | 42 return refactoring.checkInitialConditions().then((_) { |
| 43 expect(refactoring.refactoringName, 'Inline Function'); | 43 expect(refactoring.refactoringName, 'Inline Function'); |
| 44 expect(refactoring.className, isNull); |
| 45 expect(refactoring.methodName, 'test'); |
| 46 expect(refactoring.isDeclaration, isFalse); |
| 44 }); | 47 }); |
| 45 } | 48 } |
| 46 | 49 |
| 47 test_access_MethodElement() { | 50 test_access_MethodElement() { |
| 48 indexTestUnit(r''' | 51 indexTestUnit(r''' |
| 49 class A { | 52 class A { |
| 50 test(a, b) { | 53 test(a, b) { |
| 51 return a + b; | 54 return a + b; |
| 52 } | 55 } |
| 53 main() { | 56 main() { |
| 54 var res = test(1, 2); | 57 var res = test(1, 2); |
| 55 } | 58 } |
| 56 } | 59 } |
| 57 '''); | 60 '''); |
| 58 _createRefactoring('test(a, b)'); | 61 _createRefactoring('test(a, b)'); |
| 59 // validate state | 62 // validate state |
| 60 return refactoring.checkInitialConditions().then((_) { | 63 return refactoring.checkInitialConditions().then((_) { |
| 61 expect(refactoring.refactoringName, 'Inline Method'); | 64 expect(refactoring.refactoringName, 'Inline Method'); |
| 65 expect(refactoring.className, 'A'); |
| 66 expect(refactoring.methodName, 'test'); |
| 67 expect(refactoring.isDeclaration, isTrue); |
| 62 }); | 68 }); |
| 63 } | 69 } |
| 64 | 70 |
| 65 test_bad_cascadeInvocation() { | 71 test_bad_cascadeInvocation() { |
| 66 indexTestUnit(r''' | 72 indexTestUnit(r''' |
| 67 class A { | 73 class A { |
| 68 foo() {} | 74 foo() {} |
| 69 bar() {} | 75 bar() {} |
| 70 test() {} | 76 test() {} |
| 71 } | 77 } |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 }); | 1175 }); |
| 1170 }); | 1176 }); |
| 1171 }); | 1177 }); |
| 1172 } | 1178 } |
| 1173 | 1179 |
| 1174 void _createRefactoring(String search) { | 1180 void _createRefactoring(String search) { |
| 1175 int offset = findOffset(search); | 1181 int offset = findOffset(search); |
| 1176 refactoring = new InlineMethodRefactoring(searchEngine, testUnit, offset); | 1182 refactoring = new InlineMethodRefactoring(searchEngine, testUnit, offset); |
| 1177 } | 1183 } |
| 1178 } | 1184 } |
| OLD | NEW |