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

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

Issue 1737563002: Make add/remove type Quick Assists less obtrusive. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 test_addTypeAnnotation_local_BAD_null() async { 384 test_addTypeAnnotation_local_BAD_null() async {
385 resolveTestUnit(''' 385 resolveTestUnit('''
386 main() { 386 main() {
387 var v = null; 387 var v = null;
388 } 388 }
389 '''); 389 ''');
390 await assertNoAssistAt('var ', DartAssistKind.ADD_TYPE_ANNOTATION); 390 await assertNoAssistAt('var ', DartAssistKind.ADD_TYPE_ANNOTATION);
391 } 391 }
392 392
393 test_addTypeAnnotation_local_BAD_onInitializer() async {
394 resolveTestUnit('''
395 main() {
396 var abc = 0;
397 }
398 ''');
399 await assertNoAssistAt('0;', DartAssistKind.ADD_TYPE_ANNOTATION);
400 }
401
393 test_addTypeAnnotation_local_BAD_unknown() async { 402 test_addTypeAnnotation_local_BAD_unknown() async {
394 verifyNoTestUnitErrors = false; 403 verifyNoTestUnitErrors = false;
395 resolveTestUnit(''' 404 resolveTestUnit('''
396 main() { 405 main() {
397 var v = unknownVar; 406 var v = unknownVar;
398 } 407 }
399 '''); 408 ''');
400 await assertNoAssistAt('var ', DartAssistKind.ADD_TYPE_ANNOTATION); 409 await assertNoAssistAt('var ', DartAssistKind.ADD_TYPE_ANNOTATION);
401 } 410 }
402 411
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 DartAssistKind.ADD_TYPE_ANNOTATION, 625 DartAssistKind.ADD_TYPE_ANNOTATION,
617 ''' 626 '''
618 class C {} 627 class C {}
619 C f() => null; 628 C f() => null;
620 main() { 629 main() {
621 C x = f(); 630 C x = f();
622 } 631 }
623 '''); 632 ''');
624 } 633 }
625 634
626 test_addTypeAnnotation_local_OK_onInitializer() async {
627 resolveTestUnit('''
628 main() {
629 var v = 123;
630 }
631 ''');
632 await assertHasAssistAt(
633 '23',
634 DartAssistKind.ADD_TYPE_ANNOTATION,
635 '''
636 main() {
637 int v = 123;
638 }
639 ''');
640 }
641
642 test_addTypeAnnotation_local_OK_onName() async { 635 test_addTypeAnnotation_local_OK_onName() async {
643 resolveTestUnit(''' 636 resolveTestUnit('''
644 main() { 637 main() {
645 var abc = 0; 638 var abc = 0;
646 } 639 }
647 '''); 640 ''');
648 await assertHasAssistAt( 641 await assertHasAssistAt(
649 'bc', 642 'bc',
650 DartAssistKind.ADD_TYPE_ANNOTATION, 643 DartAssistKind.ADD_TYPE_ANNOTATION,
651 ''' 644 '''
(...skipping 12 matching lines...) Expand all
664 await assertHasAssistAt( 657 await assertHasAssistAt(
665 'var ', 658 'var ',
666 DartAssistKind.ADD_TYPE_ANNOTATION, 659 DartAssistKind.ADD_TYPE_ANNOTATION,
667 ''' 660 '''
668 main() { 661 main() {
669 int v = 0; 662 int v = 0;
670 } 663 }
671 '''); 664 ''');
672 } 665 }
673 666
674 test_addTypeAnnotation_local_OK_onVariableDeclarationStatement() async {
675 resolveTestUnit('''
676 main() {
677 var v = 123; // marker
678 }
679 ''');
680 await assertHasAssistAt(
681 ' // marker',
682 DartAssistKind.ADD_TYPE_ANNOTATION,
683 '''
684 main() {
685 int v = 123; // marker
686 }
687 ''');
688 }
689
690 test_addTypeAnnotation_OK_privateType_sameLibrary() async { 667 test_addTypeAnnotation_OK_privateType_sameLibrary() async {
691 resolveTestUnit(''' 668 resolveTestUnit('''
692 class _A {} 669 class _A {}
693 _A getValue() => new _A(); 670 _A getValue() => new _A();
694 main() { 671 main() {
695 var v = getValue(); 672 var v = getValue();
696 } 673 }
697 '''); 674 ''');
698 await assertHasAssistAt( 675 await assertHasAssistAt(
699 'var ', 676 'var ',
(...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after
3276 await assertHasAssistAt( 3253 await assertHasAssistAt(
3277 'v = ', 3254 'v = ',
3278 DartAssistKind.REMOVE_TYPE_ANNOTATION, 3255 DartAssistKind.REMOVE_TYPE_ANNOTATION,
3279 ''' 3256 '''
3280 class A { 3257 class A {
3281 final v = 1; 3258 final v = 1;
3282 } 3259 }
3283 '''); 3260 ''');
3284 } 3261 }
3285 3262
3263 test_removeTypeAnnotation_localVariable_BAD_onInitializer() async {
3264 resolveTestUnit('''
3265 main() {
3266 final int v = 1;
3267 }
3268 ''');
3269 await assertNoAssistAt('1;', DartAssistKind.REMOVE_TYPE_ANNOTATION);
3270 }
3271
3286 test_removeTypeAnnotation_localVariable_OK() async { 3272 test_removeTypeAnnotation_localVariable_OK() async {
3287 resolveTestUnit(''' 3273 resolveTestUnit('''
3288 main() { 3274 main() {
3289 int a = 1, b = 2; 3275 int a = 1, b = 2;
3290 } 3276 }
3291 '''); 3277 ''');
3292 await assertHasAssistAt( 3278 await assertHasAssistAt(
3293 'int ', 3279 'int ',
3294 DartAssistKind.REMOVE_TYPE_ANNOTATION, 3280 DartAssistKind.REMOVE_TYPE_ANNOTATION,
3295 ''' 3281 '''
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
3955 positions.add(new Position(testFile, offset)); 3941 positions.add(new Position(testFile, offset));
3956 } 3942 }
3957 return positions; 3943 return positions;
3958 } 3944 }
3959 3945
3960 void _setStartEndSelection() { 3946 void _setStartEndSelection() {
3961 offset = findOffset('// start\n') + '// start\n'.length; 3947 offset = findOffset('// start\n') + '// start\n'.length;
3962 length = findOffset('// end') - offset; 3948 length = findOffset('// end') - offset;
3963 } 3949 }
3964 } 3950 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698