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.convert_getter_to_method; | 5 library test.services.refactoring.convert_getter_to_method; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/protocol.dart' hide ElementKind; | 9 import 'package:analysis_server/src/protocol.dart' hide ElementKind; |
10 import 'package:analysis_server/src/services/correction/status.dart'; | 10 import 'package:analysis_server/src/services/correction/status.dart'; |
11 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 11 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
12 import 'package:analyzer/src/generated/element.dart'; | 12 import 'package:analyzer/src/generated/element.dart'; |
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 13 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
14 import 'package:unittest/unittest.dart'; | |
15 | 14 |
| 15 import '../../utils.dart'; |
16 import 'abstract_refactoring.dart'; | 16 import 'abstract_refactoring.dart'; |
17 | 17 |
18 main() { | 18 main() { |
19 groupSep = ' | '; | 19 initializeTestEnvironment(); |
20 defineReflectiveTests(ConvertGetterToMethodTest); | 20 defineReflectiveTests(ConvertGetterToMethodTest); |
21 } | 21 } |
22 | 22 |
23 @reflectiveTest | 23 @reflectiveTest |
24 class ConvertGetterToMethodTest extends RefactoringTest { | 24 class ConvertGetterToMethodTest extends RefactoringTest { |
25 ConvertGetterToMethodRefactoring refactoring; | 25 ConvertGetterToMethodRefactoring refactoring; |
26 | 26 |
27 test_change_function() { | 27 test_change_function() { |
28 indexTestUnit(''' | 28 indexTestUnit(''' |
29 int get test => 42; | 29 int get test => 42; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 main(A a, B b, C c, D d) { | 82 main(A a, B b, C c, D d) { |
83 var va = a.test(); | 83 var va = a.test(); |
84 var vb = b.test(); | 84 var vb = b.test(); |
85 var vc = c.test(); | 85 var vc = c.test(); |
86 var vd = d.test(); | 86 var vd = d.test(); |
87 } | 87 } |
88 '''); | 88 '''); |
89 } | 89 } |
90 | 90 |
91 test_change_multipleFiles() { | 91 test_change_multipleFiles() { |
92 indexUnit('/other.dart', r''' | 92 indexUnit( |
| 93 '/other.dart', |
| 94 r''' |
93 class A { | 95 class A { |
94 int get test => 1; | 96 int get test => 1; |
95 } | 97 } |
96 '''); | 98 '''); |
97 indexTestUnit(''' | 99 indexTestUnit(''' |
98 import 'other.dart'; | 100 import 'other.dart'; |
99 class B extends A { | 101 class B extends A { |
100 int get test => 2; | 102 int get test => 2; |
101 } | 103 } |
102 main(A a, B b) { | 104 main(A a, B b) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 157 |
156 void _createRefactoringForElement(ExecutableElement element) { | 158 void _createRefactoringForElement(ExecutableElement element) { |
157 refactoring = new ConvertGetterToMethodRefactoring(searchEngine, element); | 159 refactoring = new ConvertGetterToMethodRefactoring(searchEngine, element); |
158 } | 160 } |
159 | 161 |
160 void _createRefactoringForString(String search) { | 162 void _createRefactoringForString(String search) { |
161 ExecutableElement element = findNodeElementAtString(search); | 163 ExecutableElement element = findNodeElementAtString(search); |
162 _createRefactoringForElement(element); | 164 _createRefactoringForElement(element); |
163 } | 165 } |
164 } | 166 } |
OLD | NEW |