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

Side by Side Diff: pkg/analysis_server/test/services/correction/assist_test.dart

Issue 2143023002: Issue 26764. Insert required imports in the correct sorting order. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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) 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.correction.assist; 5 library test.services.correction.assist;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart';
10 import 'package:analysis_server/plugin/protocol/protocol.dart'; 10 import 'package:analysis_server/plugin/protocol/protocol.dart';
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 import 'my_lib.dart'; 319 import 'my_lib.dart';
320 main() { 320 main() {
321 for (var future in getFutures()) { 321 for (var future in getFutures()) {
322 } 322 }
323 } 323 }
324 '''); 324 ''');
325 await assertHasAssistAt( 325 await assertHasAssistAt(
326 'future in', 326 'future in',
327 DartAssistKind.ADD_TYPE_ANNOTATION, 327 DartAssistKind.ADD_TYPE_ANNOTATION,
328 ''' 328 '''
329 import 'dart:async';
329 import 'my_lib.dart'; 330 import 'my_lib.dart';
330 import 'dart:async';
331 main() { 331 main() {
332 for (Future<int> future in getFutures()) { 332 for (Future<int> future in getFutures()) {
333 } 333 }
334 } 334 }
335 '''); 335 ''');
336 } 336 }
337 337
338 test_addTypeAnnotation_declaredIdentifier_OK_final() async { 338 test_addTypeAnnotation_declaredIdentifier_OK_final() async {
339 resolveTestUnit(''' 339 resolveTestUnit('''
340 main(List<String> items) { 340 main(List<String> items) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 resolveTestUnit(''' 459 resolveTestUnit('''
460 import 'my_lib.dart'; 460 import 'my_lib.dart';
461 main() { 461 main() {
462 var v = getFutureInt(); 462 var v = getFutureInt();
463 } 463 }
464 '''); 464 ''');
465 await assertHasAssistAt( 465 await assertHasAssistAt(
466 'v =', 466 'v =',
467 DartAssistKind.ADD_TYPE_ANNOTATION, 467 DartAssistKind.ADD_TYPE_ANNOTATION,
468 ''' 468 '''
469 import 'dart:async';
469 import 'my_lib.dart'; 470 import 'my_lib.dart';
470 import 'dart:async';
471 main() { 471 main() {
472 Future<int> v = getFutureInt(); 472 Future<int> v = getFutureInt();
473 } 473 }
474 '''); 474 ''');
475 } 475 }
476 476
477 test_addTypeAnnotation_local_OK_addImport_notLibraryUnit() async { 477 test_addTypeAnnotation_local_OK_addImport_notLibraryUnit() async {
478 // prepare library 478 // prepare library
479 addSource( 479 addSource(
480 '/my_lib.dart', 480 '/my_lib.dart',
(...skipping 27 matching lines...) Expand all
508 assist = await _assertHasAssist(DartAssistKind.ADD_TYPE_ANNOTATION); 508 assist = await _assertHasAssist(DartAssistKind.ADD_TYPE_ANNOTATION);
509 change = assist.change; 509 change = assist.change;
510 // verify 510 // verify
511 { 511 {
512 var testFileEdit = change.getFileEdit('/app.dart'); 512 var testFileEdit = change.getFileEdit('/app.dart');
513 var resultCode = SourceEdit.applySequence(appCode, testFileEdit.edits); 513 var resultCode = SourceEdit.applySequence(appCode, testFileEdit.edits);
514 expect( 514 expect(
515 resultCode, 515 resultCode,
516 ''' 516 '''
517 library my_app; 517 library my_app;
518 import 'dart:async';
518 import 'my_lib.dart'; 519 import 'my_lib.dart';
519 import 'dart:async';
520 part 'test.dart'; 520 part 'test.dart';
521 '''); 521 ''');
522 } 522 }
523 { 523 {
524 var testFileEdit = change.getFileEdit('/test.dart'); 524 var testFileEdit = change.getFileEdit('/test.dart');
525 var resultCode = SourceEdit.applySequence(testCode, testFileEdit.edits); 525 var resultCode = SourceEdit.applySequence(testCode, testFileEdit.edits);
526 expect( 526 expect(
527 resultCode, 527 resultCode,
528 ''' 528 '''
529 part of my_app; 529 part of my_app;
(...skipping 19 matching lines...) Expand all
549 resolveTestUnit(''' 549 resolveTestUnit('''
550 import 'ccc/lib_b.dart'; 550 import 'ccc/lib_b.dart';
551 main() { 551 main() {
552 var v = newMyClass(); 552 var v = newMyClass();
553 } 553 }
554 '''); 554 ''');
555 await assertHasAssistAt( 555 await assertHasAssistAt(
556 'v =', 556 'v =',
557 DartAssistKind.ADD_TYPE_ANNOTATION, 557 DartAssistKind.ADD_TYPE_ANNOTATION,
558 ''' 558 '''
559 import 'aa/bbb/lib_a.dart';
559 import 'ccc/lib_b.dart'; 560 import 'ccc/lib_b.dart';
560 import 'aa/bbb/lib_a.dart';
561 main() { 561 main() {
562 MyClass v = newMyClass(); 562 MyClass v = newMyClass();
563 } 563 }
564 '''); 564 ''');
565 } 565 }
566 566
567 test_addTypeAnnotation_local_OK_Function() async { 567 test_addTypeAnnotation_local_OK_Function() async {
568 resolveTestUnit(''' 568 resolveTestUnit('''
569 main() { 569 main() {
570 var v = () => 1; 570 var v = () => 1;
(...skipping 3378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3949 positions.add(new Position(testFile, offset)); 3949 positions.add(new Position(testFile, offset));
3950 } 3950 }
3951 return positions; 3951 return positions;
3952 } 3952 }
3953 3953
3954 void _setStartEndSelection() { 3954 void _setStartEndSelection() {
3955 offset = findOffset('// start\n') + '// start\n'.length; 3955 offset = findOffset('// start\n') + '// start\n'.length;
3956 length = findOffset('// end') - offset; 3956 length = findOffset('// end') - offset;
3957 } 3957 }
3958 } 3958 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698