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.move_files; | 5 library test.services.refactoring.move_files; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 assertFileChangeResult(pathA, ''' | 138 assertFileChangeResult(pathA, ''' |
139 import 'new_name.dart'; | 139 import 'new_name.dart'; |
140 '''); | 140 '''); |
141 assertNoFileChange(testFile); | 141 assertNoFileChange(testFile); |
142 } | 142 } |
143 | 143 |
144 test_file_sourcedUnit() async { | 144 test_file_sourcedUnit() async { |
145 String pathA = '/project/000/1111/a.dart'; | 145 String pathA = '/project/000/1111/a.dart'; |
146 testFile = '/project/000/1111/22/test.dart'; | 146 testFile = '/project/000/1111/22/test.dart'; |
147 addSource(pathA, ''' | 147 addSource(pathA, ''' |
| 148 library lib; |
148 part '22/test.dart'; | 149 part '22/test.dart'; |
149 '''); | 150 '''); |
150 addTestSource(''); | 151 addTestSource(''' |
| 152 part of lib; |
| 153 '''); |
151 _performAnalysis(); | 154 _performAnalysis(); |
152 // perform refactoring | 155 // perform refactoring |
153 _createRefactoring('/project/000/1111/22/new_name.dart'); | 156 _createRefactoring('/project/000/1111/22/new_name.dart'); |
154 await _assertSuccessfulRefactoring(); | 157 await _assertSuccessfulRefactoring(); |
155 assertFileChangeResult(pathA, ''' | 158 assertFileChangeResult(pathA, ''' |
| 159 library lib; |
156 part '22/new_name.dart'; | 160 part '22/new_name.dart'; |
157 '''); | 161 '''); |
158 assertNoFileChange(testFile); | 162 assertNoFileChange(testFile); |
159 } | 163 } |
160 | 164 |
161 test_file_sourcedUnit_multipleLibraries() async { | 165 test_file_sourcedUnit_multipleLibraries() async { |
162 String pathA = '/project/000/1111/a.dart'; | 166 String pathA = '/project/000/1111/a.dart'; |
163 String pathB = '/project/000/b.dart'; | 167 String pathB = '/project/000/b.dart'; |
164 testFile = '/project/000/1111/22/test.dart'; | 168 testFile = '/project/000/1111/22/test.dart'; |
165 addSource(pathA, ''' | 169 addSource(pathA, ''' |
| 170 library lib; |
166 part '22/test.dart'; | 171 part '22/test.dart'; |
167 '''); | 172 '''); |
168 addSource(pathB, ''' | 173 addSource(pathB, ''' |
| 174 library lib; |
169 part '1111/22/test.dart'; | 175 part '1111/22/test.dart'; |
170 '''); | 176 '''); |
171 addTestSource(''); | 177 addTestSource(''' |
| 178 part of lib; |
| 179 '''); |
172 _performAnalysis(); | 180 _performAnalysis(); |
173 // perform refactoring | 181 // perform refactoring |
174 _createRefactoring('/project/000/1111/22/new_name.dart'); | 182 _createRefactoring('/project/000/1111/22/new_name.dart'); |
175 await _assertSuccessfulRefactoring(); | 183 await _assertSuccessfulRefactoring(); |
176 assertFileChangeResult(pathA, ''' | 184 assertFileChangeResult(pathA, ''' |
| 185 library lib; |
177 part '22/new_name.dart'; | 186 part '22/new_name.dart'; |
178 '''); | 187 '''); |
179 assertFileChangeResult(pathB, ''' | 188 assertFileChangeResult(pathB, ''' |
| 189 library lib; |
180 part '1111/22/new_name.dart'; | 190 part '1111/22/new_name.dart'; |
181 '''); | 191 '''); |
182 assertNoFileChange(testFile); | 192 assertNoFileChange(testFile); |
183 } | 193 } |
184 | 194 |
185 test_project() async { | 195 test_project() async { |
186 String pubspecPath = '/testName/pubspec.yaml'; | 196 String pubspecPath = '/testName/pubspec.yaml'; |
187 String appPath = '/testName/bin/myApp.dart'; | 197 String appPath = '/testName/bin/myApp.dart'; |
188 provider.newFile(pubspecPath, ''' | 198 provider.newFile(pubspecPath, ''' |
189 name: testName | 199 name: testName |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 break; | 252 break; |
243 } | 253 } |
244 for (ChangeNotice notice in result.changeNotices) { | 254 for (ChangeNotice notice in result.changeNotices) { |
245 if (notice.source.fullName.startsWith('/project/')) { | 255 if (notice.source.fullName.startsWith('/project/')) { |
246 index.indexUnit(context, notice.resolvedDartUnit); | 256 index.indexUnit(context, notice.resolvedDartUnit); |
247 } | 257 } |
248 } | 258 } |
249 } | 259 } |
250 } | 260 } |
251 } | 261 } |
OLD | NEW |