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

Side by Side Diff: pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 expect(fileEditBuilder, new isInstanceOf<DartFileEditBuilder>()); 67 expect(fileEditBuilder, new isInstanceOf<DartFileEditBuilder>());
68 SourceFileEdit fileEdit = fileEditBuilder.fileEdit; 68 SourceFileEdit fileEdit = fileEditBuilder.fileEdit;
69 expect(fileEdit.file, path); 69 expect(fileEdit.file, path);
70 } 70 }
71 } 71 }
72 72
73 @reflectiveTest 73 @reflectiveTest
74 class DartEditBuilderImplTest extends AbstractContextTest 74 class DartEditBuilderImplTest extends AbstractContextTest
75 with BuilderTestMixin { 75 with BuilderTestMixin {
76 test_importLibraries_DP() async { 76 test_importLibraries_DP() async {
77 await _assertImportLibraries( 77 await _assertImportLibraries('''
78 '''
79 import 'dart:aaa'; 78 import 'dart:aaa';
80 import 'dart:ccc'; 79 import 'dart:ccc';
81 80
82 import 'package:aaa/aaa.dart'; 81 import 'package:aaa/aaa.dart';
83 import 'package:ccc/ccc.dart'; 82 import 'package:ccc/ccc.dart';
84 ''', 83 ''', ['dart:bbb', 'package:bbb/bbb.dart'], '''
85 ['dart:bbb', 'package:bbb/bbb.dart'],
86 '''
87 import 'dart:aaa'; 84 import 'dart:aaa';
88 import 'dart:bbb'; 85 import 'dart:bbb';
89 import 'dart:ccc'; 86 import 'dart:ccc';
90 87
91 import 'package:aaa/aaa.dart'; 88 import 'package:aaa/aaa.dart';
92 import 'package:bbb/bbb.dart'; 89 import 'package:bbb/bbb.dart';
93 import 'package:ccc/ccc.dart'; 90 import 'package:ccc/ccc.dart';
94 '''); 91 ''');
95 } 92 }
96 93
97 test_importLibraries_PD() async { 94 test_importLibraries_PD() async {
98 await _assertImportLibraries( 95 await _assertImportLibraries('''
99 '''
100 import 'dart:aaa'; 96 import 'dart:aaa';
101 import 'dart:ccc'; 97 import 'dart:ccc';
102 98
103 import 'package:aaa/aaa.dart'; 99 import 'package:aaa/aaa.dart';
104 import 'package:ccc/ccc.dart'; 100 import 'package:ccc/ccc.dart';
105 ''', 101 ''', ['package:bbb/bbb.dart', 'dart:bbb'], '''
106 ['package:bbb/bbb.dart', 'dart:bbb'],
107 '''
108 import 'dart:aaa'; 102 import 'dart:aaa';
109 import 'dart:bbb'; 103 import 'dart:bbb';
110 import 'dart:ccc'; 104 import 'dart:ccc';
111 105
112 import 'package:aaa/aaa.dart'; 106 import 'package:aaa/aaa.dart';
113 import 'package:bbb/bbb.dart'; 107 import 'package:bbb/bbb.dart';
114 import 'package:ccc/ccc.dart'; 108 import 'package:ccc/ccc.dart';
115 '''); 109 ''');
116 } 110 }
117 111
118 test_importLibrary_afterLibraryDirective_dart() async { 112 test_importLibrary_afterLibraryDirective_dart() async {
119 await _assertImportLibraries( 113 await _assertImportLibraries('''
120 '''
121 library test; 114 library test;
122 115
123 class A {} 116 class A {}
124 ''', 117 ''', ['dart:async'], '''
125 ['dart:async'],
126 '''
127 library test; 118 library test;
128 119
129 import 'dart:async'; 120 import 'dart:async';
130 121
131 122
132 class A {} 123 class A {}
133 '''); 124 ''');
134 } 125 }
135 126
136 test_importLibrary_dart_beforeDart() async { 127 test_importLibrary_dart_beforeDart() async {
137 await _assertImportLibraries( 128 await _assertImportLibraries('''
138 '''
139 import 'dart:aaa'; 129 import 'dart:aaa';
140 import 'dart:ccc'; 130 import 'dart:ccc';
141 ''', 131 ''', ['dart:bbb'], '''
142 ['dart:bbb'],
143 '''
144 import 'dart:aaa'; 132 import 'dart:aaa';
145 import 'dart:bbb'; 133 import 'dart:bbb';
146 import 'dart:ccc'; 134 import 'dart:ccc';
147 '''); 135 ''');
148 } 136 }
149 137
150 test_importLibrary_dart_beforeDart_first() async { 138 test_importLibrary_dart_beforeDart_first() async {
151 await _assertImportLibraries( 139 await _assertImportLibraries('''
152 '''
153 import 'dart:bbb'; 140 import 'dart:bbb';
154 ''', 141 ''', ['dart:aaa'], '''
155 ['dart:aaa'],
156 '''
157 import 'dart:aaa'; 142 import 'dart:aaa';
158 import 'dart:bbb'; 143 import 'dart:bbb';
159 '''); 144 ''');
160 } 145 }
161 146
162 test_importLibrary_dart_beforePackage() async { 147 test_importLibrary_dart_beforePackage() async {
163 await _assertImportLibraries( 148 await _assertImportLibraries('''
164 '''
165 import 'package:foo/foo.dart'; 149 import 'package:foo/foo.dart';
166 ''', 150 ''', ['dart:async'], '''
167 ['dart:async'],
168 '''
169 import 'dart:async'; 151 import 'dart:async';
170 152
171 import 'package:foo/foo.dart'; 153 import 'package:foo/foo.dart';
172 '''); 154 ''');
173 } 155 }
174 156
175 test_importLibrary_package_afterDart() async { 157 test_importLibrary_package_afterDart() async {
176 await _assertImportLibraries( 158 await _assertImportLibraries('''
177 '''
178 import 'dart:async'; 159 import 'dart:async';
179 ''', 160 ''', ['package:aaa/aaa.dart'], '''
180 ['package:aaa/aaa.dart'],
181 '''
182 import 'dart:async'; 161 import 'dart:async';
183 162
184 import 'package:aaa/aaa.dart'; 163 import 'package:aaa/aaa.dart';
185 '''); 164 ''');
186 } 165 }
187 166
188 test_importLibrary_package_afterPackage() async { 167 test_importLibrary_package_afterPackage() async {
189 await _assertImportLibraries( 168 await _assertImportLibraries('''
190 '''
191 import 'package:aaa/a1.dart'; 169 import 'package:aaa/a1.dart';
192 170
193 import 'foo.dart'; 171 import 'foo.dart';
194 ''', 172 ''', ['package:aaa/a2.dart'], '''
195 ['package:aaa/a2.dart'],
196 '''
197 import 'package:aaa/a1.dart'; 173 import 'package:aaa/a1.dart';
198 import 'package:aaa/a2.dart'; 174 import 'package:aaa/a2.dart';
199 175
200 import 'foo.dart'; 176 import 'foo.dart';
201 '''); 177 ''');
202 } 178 }
203 179
204 test_importLibrary_package_beforePackage() async { 180 test_importLibrary_package_beforePackage() async {
205 await _assertImportLibraries( 181 await _assertImportLibraries('''
206 '''
207 import 'package:aaa/a1.dart'; 182 import 'package:aaa/a1.dart';
208 import 'package:aaa/a3.dart'; 183 import 'package:aaa/a3.dart';
209 184
210 import 'foo.dart'; 185 import 'foo.dart';
211 ''', 186 ''', ['package:aaa/a2.dart'], '''
212 ['package:aaa/a2.dart'],
213 '''
214 import 'package:aaa/a1.dart'; 187 import 'package:aaa/a1.dart';
215 import 'package:aaa/a2.dart'; 188 import 'package:aaa/a2.dart';
216 import 'package:aaa/a3.dart'; 189 import 'package:aaa/a3.dart';
217 190
218 import 'foo.dart'; 191 import 'foo.dart';
219 '''); 192 ''');
220 } 193 }
221 194
222 test_importLibrary_package_beforePackage_first() async { 195 test_importLibrary_package_beforePackage_first() async {
223 await _assertImportLibraries( 196 await _assertImportLibraries('''
224 '''
225 import 'package:aaa/a2.dart'; 197 import 'package:aaa/a2.dart';
226 198
227 import 'foo.dart'; 199 import 'foo.dart';
228 ''', 200 ''', ['package:aaa/a1.dart'], '''
229 ['package:aaa/a1.dart'],
230 '''
231 import 'package:aaa/a1.dart'; 201 import 'package:aaa/a1.dart';
232 import 'package:aaa/a2.dart'; 202 import 'package:aaa/a2.dart';
233 203
234 import 'foo.dart'; 204 import 'foo.dart';
235 '''); 205 ''');
236 } 206 }
237 207
238 test_importLibrary_package_beforeRelative() async { 208 test_importLibrary_package_beforeRelative() async {
239 await _assertImportLibraries( 209 await _assertImportLibraries('''
240 '''
241 import 'foo.dart'; 210 import 'foo.dart';
242 ''', 211 ''', ['package:aaa/aaa.dart'], '''
243 ['package:aaa/aaa.dart'],
244 '''
245 import 'package:aaa/aaa.dart'; 212 import 'package:aaa/aaa.dart';
246 213
247 import 'foo.dart'; 214 import 'foo.dart';
248 '''); 215 ''');
249 } 216 }
250 217
251 test_importLibrary_relative_afterDart() async { 218 test_importLibrary_relative_afterDart() async {
252 await _assertImportLibraries( 219 await _assertImportLibraries('''
253 '''
254 import 'dart:async'; 220 import 'dart:async';
255 ''', 221 ''', ['aaa.dart'], '''
256 ['aaa.dart'],
257 '''
258 import 'dart:async'; 222 import 'dart:async';
259 223
260 import 'aaa.dart'; 224 import 'aaa.dart';
261 '''); 225 ''');
262 } 226 }
263 227
264 test_importLibrary_relative_afterPackage() async { 228 test_importLibrary_relative_afterPackage() async {
265 await _assertImportLibraries( 229 await _assertImportLibraries('''
266 '''
267 import 'package:foo/foo.dart'; 230 import 'package:foo/foo.dart';
268 ''', 231 ''', ['aaa.dart'], '''
269 ['aaa.dart'],
270 '''
271 import 'package:foo/foo.dart'; 232 import 'package:foo/foo.dart';
272 233
273 import 'aaa.dart'; 234 import 'aaa.dart';
274 '''); 235 ''');
275 } 236 }
276 237
277 test_importLibrary_relative_beforeRelative() async { 238 test_importLibrary_relative_beforeRelative() async {
278 await _assertImportLibraries( 239 await _assertImportLibraries('''
279 '''
280 import 'dart:async'; 240 import 'dart:async';
281 241
282 import 'package:foo/foo.dart'; 242 import 'package:foo/foo.dart';
283 243
284 import 'aaa.dart'; 244 import 'aaa.dart';
285 import 'ccc.dart'; 245 import 'ccc.dart';
286 ''', 246 ''', ['bbb.dart'], '''
287 ['bbb.dart'],
288 '''
289 import 'dart:async'; 247 import 'dart:async';
290 248
291 import 'package:foo/foo.dart'; 249 import 'package:foo/foo.dart';
292 250
293 import 'aaa.dart'; 251 import 'aaa.dart';
294 import 'bbb.dart'; 252 import 'bbb.dart';
295 import 'ccc.dart'; 253 import 'ccc.dart';
296 '''); 254 ''');
297 } 255 }
298 256
299 test_importLibrary_relative_beforeRelative_first() async { 257 test_importLibrary_relative_beforeRelative_first() async {
300 await _assertImportLibraries( 258 await _assertImportLibraries('''
301 '''
302 import 'dart:async'; 259 import 'dart:async';
303 260
304 import 'package:foo/foo.dart'; 261 import 'package:foo/foo.dart';
305 262
306 import 'bbb.dart'; 263 import 'bbb.dart';
307 ''', 264 ''', ['aaa.dart'], '''
308 ['aaa.dart'],
309 '''
310 import 'dart:async'; 265 import 'dart:async';
311 266
312 import 'package:foo/foo.dart'; 267 import 'package:foo/foo.dart';
313 268
314 import 'aaa.dart'; 269 import 'aaa.dart';
315 import 'bbb.dart'; 270 import 'bbb.dart';
316 '''); 271 ''');
317 } 272 }
318 273
319 test_importLibrary_relative_last() async { 274 test_importLibrary_relative_last() async {
320 await _assertImportLibraries( 275 await _assertImportLibraries('''
321 '''
322 import 'dart:async'; 276 import 'dart:async';
323 277
324 import 'package:foo/foo.dart'; 278 import 'package:foo/foo.dart';
325 ''', 279 ''', ['aaa.dart'], '''
326 ['aaa.dart'],
327 '''
328 import 'dart:async'; 280 import 'dart:async';
329 281
330 import 'package:foo/foo.dart'; 282 import 'package:foo/foo.dart';
331 283
332 import 'aaa.dart'; 284 import 'aaa.dart';
333 '''); 285 ''');
334 } 286 }
335 287
336 test_writeClassDeclaration_interfaces() async { 288 test_writeClassDeclaration_interfaces() async {
337 String path = provider.convertPath('/test.dart'); 289 String path = provider.convertPath('/test.dart');
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 expect( 1406 expect(
1455 edits[0].replacement, equalsIgnoringWhitespace("import 'dart:async';")); 1407 edits[0].replacement, equalsIgnoringWhitespace("import 'dart:async';"));
1456 expect(edits[1].replacement, equalsIgnoringWhitespace('Future<String>')); 1408 expect(edits[1].replacement, equalsIgnoringWhitespace('Future<String>'));
1457 } 1409 }
1458 } 1410 }
1459 1411
1460 @reflectiveTest 1412 @reflectiveTest
1461 class DartLinkedEditBuilderImplTest extends AbstractContextTest { 1413 class DartLinkedEditBuilderImplTest extends AbstractContextTest {
1462 test_addSuperTypesAsSuggestions() async { 1414 test_addSuperTypesAsSuggestions() async {
1463 String path = provider.convertPath('/test.dart'); 1415 String path = provider.convertPath('/test.dart');
1464 addSource( 1416 addSource(path, '''
1465 path,
1466 '''
1467 class A {} 1417 class A {}
1468 class B extends A {} 1418 class B extends A {}
1469 class C extends B {} 1419 class C extends B {}
1470 '''); 1420 ''');
1471 CompilationUnit unit = (await driver.getResult(path))?.unit; 1421 CompilationUnit unit = (await driver.getResult(path))?.unit;
1472 ClassDeclaration classC = unit.declarations[2]; 1422 ClassDeclaration classC = unit.declarations[2];
1473 DartLinkedEditBuilderImpl builder = new DartLinkedEditBuilderImpl(null); 1423 DartLinkedEditBuilderImpl builder = new DartLinkedEditBuilderImpl(null);
1474 builder.addSuperTypesAsSuggestions(classC.element.type); 1424 builder.addSuperTypesAsSuggestions(classC.element.type);
1475 List<LinkedEditSuggestion> suggestions = builder.suggestions; 1425 List<LinkedEditSuggestion> suggestions = builder.suggestions;
1476 expect(suggestions, hasLength(4)); 1426 expect(suggestions, hasLength(4));
1477 expect(suggestions.map((s) => s.value), 1427 expect(suggestions.map((s) => s.value),
1478 unorderedEquals(['Object', 'A', 'B', 'C'])); 1428 unorderedEquals(['Object', 'A', 'B', 'C']));
1479 } 1429 }
1480 } 1430 }
1481 1431
1482 class _MockSource implements Source { 1432 class _MockSource implements Source {
1483 @override 1433 @override
1484 final String fullName; 1434 final String fullName;
1485 1435
1486 @override 1436 @override
1487 final Uri uri; 1437 final Uri uri;
1488 1438
1489 _MockSource(this.fullName, this.uri); 1439 _MockSource(this.fullName, this.uri);
1490 1440
1491 @override 1441 @override
1492 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 1442 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
1493 } 1443 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/strong_mode_test.dart ('k') | pkg/analyzer_plugin/test/support/abstract_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698