| 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.completion.util; | 5 library test.services.completion.util; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| 11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; | 11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; |
| 12 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 12 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| 13 import 'package:analysis_server/src/services/completion/completion_target.dart'; | |
| 14 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; | 13 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; |
| 15 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 14 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 16 import 'package:analysis_server/src/services/completion/imported_computer.dart'; | 15 import 'package:analysis_server/src/services/completion/imported_computer.dart'; |
| 17 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; | 16 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; |
| 18 import 'package:analysis_server/src/services/completion/local_computer.dart'; | 17 import 'package:analysis_server/src/services/completion/local_computer.dart'; |
| 19 import 'package:analysis_server/src/services/index/index.dart'; | 18 import 'package:analysis_server/src/services/index/index.dart'; |
| 20 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 19 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 21 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 20 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 22 import 'package:analyzer/src/generated/ast.dart'; | 21 import 'package:analyzer/src/generated/ast.dart'; |
| 23 import 'package:analyzer/src/generated/element.dart'; | 22 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 38 SearchEngineImpl searchEngine; | 37 SearchEngineImpl searchEngine; |
| 39 DartCompletionComputer computer; | 38 DartCompletionComputer computer; |
| 40 String testFile = '/completionTest.dart'; | 39 String testFile = '/completionTest.dart'; |
| 41 Source testSource; | 40 Source testSource; |
| 42 CompilationUnit testUnit; | 41 CompilationUnit testUnit; |
| 43 int completionOffset; | 42 int completionOffset; |
| 44 AstNode completionNode; | 43 AstNode completionNode; |
| 45 bool _computeFastCalled = false; | 44 bool _computeFastCalled = false; |
| 46 DartCompletionRequest request; | 45 DartCompletionRequest request; |
| 47 DartCompletionCache cache; | 46 DartCompletionCache cache; |
| 47 DartCompletionManager _completionManager; |
| 48 | 48 |
| 49 void addResolvedUnit(String file, String code) { | 49 void addResolvedUnit(String file, String code) { |
| 50 Source source = addSource(file, code); | 50 Source source = addSource(file, code); |
| 51 CompilationUnit unit = resolveLibraryUnit(source); | 51 CompilationUnit unit = resolveLibraryUnit(source); |
| 52 index.indexUnit(context, unit); | 52 index.indexUnit(context, unit); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void addTestSource(String content) { | 55 void addTestSource(String content) { |
| 56 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once'); | 56 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once'); |
| 57 completionOffset = content.indexOf('^'); | 57 completionOffset = content.indexOf('^'); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 if (computer is ImportedComputer) { | 478 if (computer is ImportedComputer) { |
| 479 assertSuggestGetter(name, returnType); | 479 assertSuggestGetter(name, returnType); |
| 480 assertSuggestSetter(name); | 480 assertSuggestSetter(name); |
| 481 } else { | 481 } else { |
| 482 assertNotSuggested(name); | 482 assertNotSuggested(name); |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 | 485 |
| 486 bool computeFast() { | 486 bool computeFast() { |
| 487 _computeFastCalled = true; | 487 _computeFastCalled = true; |
| 488 testUnit = context.parseCompilationUnit(testSource); | 488 _completionManager = new DartCompletionManager( |
| 489 completionNode = | 489 context, |
| 490 new NodeLocator.con1(completionOffset).searchWithin(testUnit); | 490 searchEngine, |
| 491 request.unit = testUnit; | 491 testSource, |
| 492 request.node = completionNode; | 492 cache, |
| 493 request.target = new CompletionTarget.forOffset(testUnit, completionOffset); | 493 [computer]); |
| 494 return computer.computeFast(request); | 494 var result = _completionManager.computeFast(request); |
| 495 if (request.replacementOffset == null) { |
| 496 fail('expected non null'); |
| 497 } |
| 498 return result.isEmpty; |
| 495 } | 499 } |
| 496 | 500 |
| 497 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { | 501 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { |
| 498 if (!_computeFastCalled) { | 502 if (!_computeFastCalled) { |
| 499 expect(computeFast(), isFalse); | 503 expect(computeFast(), isFalse); |
| 500 } | 504 } |
| 501 | 505 |
| 502 // Index SDK | 506 // Index SDK |
| 503 for (Source librarySource in context.librarySources) { | 507 for (Source librarySource in context.librarySources) { |
| 504 CompilationUnit unit = | 508 CompilationUnit unit = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 524 List<Source> libSourceList = context.getLibrariesContaining(testSource); | 528 List<Source> libSourceList = context.getLibrariesContaining(testSource); |
| 525 if (libSourceList.length > 0) { | 529 if (libSourceList.length > 0) { |
| 526 LibraryElement library = context.getLibraryElement(libSourceList[0]); | 530 LibraryElement library = context.getLibraryElement(libSourceList[0]); |
| 527 if (library != null) { | 531 if (library != null) { |
| 528 CompilationUnit unit = | 532 CompilationUnit unit = |
| 529 context.getResolvedCompilationUnit(testSource, library); | 533 context.getResolvedCompilationUnit(testSource, library); |
| 530 if (unit != null) { | 534 if (unit != null) { |
| 531 request.unit = unit; | 535 request.unit = unit; |
| 532 request.node = | 536 request.node = |
| 533 new NodeLocator.con1(completionOffset).searchWithin(unit); | 537 new NodeLocator.con1(completionOffset).searchWithin(unit); |
| 534 if (request.node is SimpleIdentifier) { | |
| 535 request.replacementOffset = request.node.offset; | |
| 536 request.replacementLength = request.node.length; | |
| 537 } else { | |
| 538 request.replacementOffset = request.offset; | |
| 539 request.replacementLength = 0; | |
| 540 } | |
| 541 if (request.replacementOffset == null) { | |
| 542 fail('expected non null'); | |
| 543 } | |
| 544 resolved = true; | 538 resolved = true; |
| 545 if (!fullAnalysis) { | 539 if (!fullAnalysis) { |
| 546 break; | 540 break; |
| 547 } | 541 } |
| 548 } | 542 } |
| 549 } | 543 } |
| 550 } | 544 } |
| 551 | 545 |
| 552 result = context.performAnalysisTask(); | 546 result = context.performAnalysisTask(); |
| 553 } | 547 } |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 library A; | 878 library A; |
| 885 bool hasLength(int expected) { } | 879 bool hasLength(int expected) { } |
| 886 void baz() { }'''); | 880 void baz() { }'''); |
| 887 addTestSource(''' | 881 addTestSource(''' |
| 888 import '/libA.dart'; | 882 import '/libA.dart'; |
| 889 class B { } | 883 class B { } |
| 890 String bar() => true; | 884 String bar() => true; |
| 891 void main() {expect(^)}'''); | 885 void main() {expect(^)}'''); |
| 892 computeFast(); | 886 computeFast(); |
| 893 return computeFull((bool result) { | 887 return computeFull((bool result) { |
| 888 expect(request.replacementOffset, completionOffset); |
| 889 expect(request.replacementLength, 0); |
| 894 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | 890 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); |
| 895 assertSuggestLocalFunction('bar', 'String'); | 891 assertSuggestLocalFunction('bar', 'String'); |
| 896 assertSuggestImportedFunction('hasLength', 'bool'); | 892 assertSuggestImportedFunction('hasLength', 'bool'); |
| 897 assertSuggestImportedFunction('identical', 'bool'); | 893 assertSuggestImportedFunction('identical', 'bool'); |
| 898 assertSuggestLocalClass('B'); | 894 assertSuggestLocalClass('B'); |
| 899 assertSuggestImportedClass('Object'); | 895 assertSuggestImportedClass('Object'); |
| 900 assertNotSuggested('main'); | 896 assertNotSuggested('main'); |
| 901 assertNotSuggested('baz'); | 897 assertNotSuggested('baz'); |
| 902 assertNotSuggested('print'); | 898 assertNotSuggested('print'); |
| 903 }); | 899 }); |
| 904 } | 900 } |
| 905 | 901 |
| 906 test_ArgumentList_imported_function() { | 902 test_ArgumentList_imported_function() { |
| 907 // ArgumentList MethodInvocation ExpressionStatement Block | 903 // ArgumentList MethodInvocation ExpressionStatement Block |
| 908 addSource('/libA.dart', ''' | 904 addSource('/libA.dart', ''' |
| 909 library A; | 905 library A; |
| 910 bool hasLength(int expected) { } | 906 bool hasLength(int expected) { } |
| 911 expect(arg) { } | 907 expect(arg) { } |
| 912 void baz() { }'''); | 908 void baz() { }'''); |
| 913 addTestSource(''' | 909 addTestSource(''' |
| 914 import '/libA.dart' | 910 import '/libA.dart' |
| 915 class B { } | 911 class B { } |
| 916 String bar() => true; | 912 String bar() => true; |
| 917 void main() {expect(^)}'''); | 913 void main() {expect(^)}'''); |
| 918 computeFast(); | 914 computeFast(); |
| 919 return computeFull((bool result) { | 915 return computeFull((bool result) { |
| 916 expect(request.replacementOffset, completionOffset); |
| 917 expect(request.replacementLength, 0); |
| 920 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | 918 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); |
| 921 assertSuggestLocalFunction('bar', 'String'); | 919 assertSuggestLocalFunction('bar', 'String'); |
| 922 assertSuggestImportedFunction('hasLength', 'bool'); | 920 assertSuggestImportedFunction('hasLength', 'bool'); |
| 923 assertSuggestImportedFunction('identical', 'bool'); | 921 assertSuggestImportedFunction('identical', 'bool'); |
| 924 assertSuggestLocalClass('B'); | 922 assertSuggestLocalClass('B'); |
| 925 assertSuggestImportedClass('Object'); | 923 assertSuggestImportedClass('Object'); |
| 926 assertNotSuggested('main'); | 924 assertNotSuggested('main'); |
| 927 assertNotSuggested('baz'); | 925 assertNotSuggested('baz'); |
| 928 assertNotSuggested('print'); | 926 assertNotSuggested('print'); |
| 929 }); | 927 }); |
| 930 } | 928 } |
| 931 | 929 |
| 932 test_ArgumentList_local_function() { | 930 test_ArgumentList_local_function() { |
| 933 // ArgumentList MethodInvocation ExpressionStatement Block | 931 // ArgumentList MethodInvocation ExpressionStatement Block |
| 934 addSource('/libA.dart', ''' | 932 addSource('/libA.dart', ''' |
| 935 library A; | 933 library A; |
| 936 bool hasLength(int expected) { } | 934 bool hasLength(int expected) { } |
| 937 void baz() { }'''); | 935 void baz() { }'''); |
| 938 addTestSource(''' | 936 addTestSource(''' |
| 939 import '/libA.dart' | 937 import '/libA.dart' |
| 940 expect(arg) { } | 938 expect(arg) { } |
| 941 class B { } | 939 class B { } |
| 942 String bar() => true; | 940 String bar() => true; |
| 943 void main() {expect(^)}'''); | 941 void main() {expect(^)}'''); |
| 944 computeFast(); | 942 computeFast(); |
| 945 return computeFull((bool result) { | 943 return computeFull((bool result) { |
| 944 expect(request.replacementOffset, completionOffset); |
| 945 expect(request.replacementLength, 0); |
| 946 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | 946 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); |
| 947 assertSuggestLocalFunction('bar', 'String'); | 947 assertSuggestLocalFunction('bar', 'String'); |
| 948 assertSuggestImportedFunction('hasLength', 'bool'); | 948 assertSuggestImportedFunction('hasLength', 'bool'); |
| 949 assertSuggestImportedFunction('identical', 'bool'); | 949 assertSuggestImportedFunction('identical', 'bool'); |
| 950 assertSuggestLocalClass('B'); | 950 assertSuggestLocalClass('B'); |
| 951 assertSuggestImportedClass('Object'); | 951 assertSuggestImportedClass('Object'); |
| 952 assertNotSuggested('main'); | 952 assertNotSuggested('main'); |
| 953 assertNotSuggested('baz'); | 953 assertNotSuggested('baz'); |
| 954 assertNotSuggested('print'); | 954 assertNotSuggested('print'); |
| 955 }); | 955 }); |
| 956 } | 956 } |
| 957 | 957 |
| 958 test_ArgumentList_local_method() { | 958 test_ArgumentList_local_method() { |
| 959 // ArgumentList MethodInvocation ExpressionStatement Block | 959 // ArgumentList MethodInvocation ExpressionStatement Block |
| 960 addSource('/libA.dart', ''' | 960 addSource('/libA.dart', ''' |
| 961 library A; | 961 library A; |
| 962 bool hasLength(int expected) { } | 962 bool hasLength(int expected) { } |
| 963 void baz() { }'''); | 963 void baz() { }'''); |
| 964 addTestSource(''' | 964 addTestSource(''' |
| 965 import '/libA.dart' | 965 import '/libA.dart' |
| 966 class B { | 966 class B { |
| 967 expect(arg) { } | 967 expect(arg) { } |
| 968 void foo() {expect(^)}} | 968 void foo() {expect(^)}} |
| 969 String bar() => true;'''); | 969 String bar() => true;'''); |
| 970 computeFast(); | 970 computeFast(); |
| 971 return computeFull((bool result) { | 971 return computeFull((bool result) { |
| 972 expect(request.replacementOffset, completionOffset); |
| 973 expect(request.replacementLength, 0); |
| 972 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | 974 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); |
| 973 assertSuggestLocalFunction('bar', 'String'); | 975 assertSuggestLocalFunction('bar', 'String'); |
| 974 assertSuggestImportedFunction('hasLength', 'bool'); | 976 assertSuggestImportedFunction('hasLength', 'bool'); |
| 975 assertSuggestImportedFunction('identical', 'bool'); | 977 assertSuggestImportedFunction('identical', 'bool'); |
| 976 assertSuggestLocalClass('B'); | 978 assertSuggestLocalClass('B'); |
| 977 assertSuggestImportedClass('Object'); | 979 assertSuggestImportedClass('Object'); |
| 978 assertNotSuggested('main'); | 980 assertNotSuggested('main'); |
| 979 assertNotSuggested('baz'); | 981 assertNotSuggested('baz'); |
| 980 assertNotSuggested('print'); | 982 assertNotSuggested('print'); |
| 981 }); | 983 }); |
| 982 } | 984 } |
| 983 | 985 |
| 984 test_ArgumentList_namedParam() { | 986 test_ArgumentList_namedParam() { |
| 985 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation | 987 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation |
| 986 // ExpressionStatement | 988 // ExpressionStatement |
| 987 addSource('/libA.dart', ''' | 989 addSource('/libA.dart', ''' |
| 988 library A; | 990 library A; |
| 989 bool hasLength(int expected) { }'''); | 991 bool hasLength(int expected) { }'''); |
| 990 addTestSource(''' | 992 addTestSource(''' |
| 991 import '/libA.dart' | 993 import '/libA.dart' |
| 992 String bar() => true; | 994 String bar() => true; |
| 993 void main() {expect(foo: ^)}'''); | 995 void main() {expect(foo: ^)}'''); |
| 994 computeFast(); | 996 computeFast(); |
| 995 return computeFull((bool result) { | 997 return computeFull((bool result) { |
| 998 expect(request.replacementOffset, completionOffset); |
| 999 expect(request.replacementLength, 0); |
| 996 assertSuggestLocalFunction('bar', 'String'); | 1000 assertSuggestLocalFunction('bar', 'String'); |
| 997 assertSuggestImportedFunction('hasLength', 'bool'); | 1001 assertSuggestImportedFunction('hasLength', 'bool'); |
| 998 assertNotSuggested('main'); | 1002 assertNotSuggested('main'); |
| 999 }); | 1003 }); |
| 1000 } | 1004 } |
| 1001 | 1005 |
| 1002 test_AsExpression() { | 1006 test_AsExpression() { |
| 1003 // SimpleIdentifier TypeName AsExpression | 1007 // SimpleIdentifier TypeName AsExpression |
| 1004 addTestSource(''' | 1008 addTestSource(''' |
| 1005 class A {var b; X _c; foo() {var a; (a as ^).foo();}'''); | 1009 class A {var b; X _c; foo() {var a; (a as ^).foo();}'''); |
| 1006 computeFast(); | 1010 computeFast(); |
| 1007 return computeFull((bool result) { | 1011 return computeFull((bool result) { |
| 1012 expect(request.replacementOffset, completionOffset); |
| 1013 expect(request.replacementLength, 0); |
| 1008 assertNotSuggested('b'); | 1014 assertNotSuggested('b'); |
| 1009 assertNotSuggested('_c'); | 1015 assertNotSuggested('_c'); |
| 1010 assertSuggestImportedClass('Object'); | 1016 assertSuggestImportedClass('Object'); |
| 1011 assertSuggestLocalClass('A'); | 1017 assertSuggestLocalClass('A'); |
| 1012 assertNotSuggested('=='); | 1018 assertNotSuggested('=='); |
| 1013 }); | 1019 }); |
| 1014 } | 1020 } |
| 1015 | 1021 |
| 1016 test_AssignmentExpression_name() { | 1022 test_AssignmentExpression_name() { |
| 1017 // SimpleIdentifier VariableDeclaration VariableDeclarationList | 1023 // SimpleIdentifier VariableDeclaration VariableDeclarationList |
| 1018 // VariableDeclarationStatement Block | 1024 // VariableDeclarationStatement Block |
| 1019 addTestSource('class A {} main() {int a; int ^b = 1;}'); | 1025 addTestSource('class A {} main() {int a; int ^b = 1;}'); |
| 1020 computeFast(); | 1026 computeFast(); |
| 1021 return computeFull((bool result) { | 1027 return computeFull((bool result) { |
| 1022 assertNoSuggestions(); | 1028 assertNoSuggestions(); |
| 1023 }); | 1029 }); |
| 1024 } | 1030 } |
| 1025 | 1031 |
| 1026 test_AssignmentExpression_RHS() { | 1032 test_AssignmentExpression_RHS() { |
| 1027 // SimpleIdentifier VariableDeclaration VariableDeclarationList | 1033 // SimpleIdentifier VariableDeclaration VariableDeclarationList |
| 1028 // VariableDeclarationStatement Block | 1034 // VariableDeclarationStatement Block |
| 1029 addTestSource('class A {} main() {int a; int b = ^}'); | 1035 addTestSource('class A {} main() {int a; int b = ^}'); |
| 1030 computeFast(); | 1036 computeFast(); |
| 1031 return computeFull((bool result) { | 1037 return computeFull((bool result) { |
| 1038 expect(request.replacementOffset, completionOffset); |
| 1039 expect(request.replacementLength, 0); |
| 1032 assertSuggestLocalVariable('a', 'int'); | 1040 assertSuggestLocalVariable('a', 'int'); |
| 1033 assertSuggestLocalFunction('main', null); | 1041 assertSuggestLocalFunction('main', null); |
| 1034 assertSuggestLocalClass('A'); | 1042 assertSuggestLocalClass('A'); |
| 1035 assertSuggestImportedClass('Object'); | 1043 assertSuggestImportedClass('Object'); |
| 1036 }); | 1044 }); |
| 1037 } | 1045 } |
| 1038 | 1046 |
| 1039 test_AssignmentExpression_type() { | 1047 test_AssignmentExpression_type() { |
| 1040 // SimpleIdentifier TypeName VariableDeclarationList | 1048 // SimpleIdentifier TypeName VariableDeclarationList |
| 1041 // VariableDeclarationStatement Block | 1049 // VariableDeclarationStatement Block |
| 1042 addTestSource(''' | 1050 addTestSource(''' |
| 1043 class A {} main() { | 1051 class A {} main() { |
| 1044 int a; | 1052 int a; |
| 1045 ^ b = 1;}'''); | 1053 ^ b = 1;}'''); |
| 1046 computeFast(); | 1054 computeFast(); |
| 1047 return computeFull((bool result) { | 1055 return computeFull((bool result) { |
| 1056 expect(request.replacementOffset, completionOffset); |
| 1057 expect(request.replacementLength, 0); |
| 1048 assertSuggestLocalClass('A'); | 1058 assertSuggestLocalClass('A'); |
| 1049 assertSuggestImportedClass('int'); | 1059 assertSuggestImportedClass('int'); |
| 1050 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS | 1060 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS |
| 1051 // the user may be either (1) entering a type for the assignment | 1061 // the user may be either (1) entering a type for the assignment |
| 1052 // or (2) starting a new statement. | 1062 // or (2) starting a new statement. |
| 1053 // Consider suggesting only types | 1063 // Consider suggesting only types |
| 1054 // if only spaces separates the 1st and 2nd identifiers. | 1064 // if only spaces separates the 1st and 2nd identifiers. |
| 1055 //assertNotSuggested('a'); | 1065 //assertNotSuggested('a'); |
| 1056 //assertNotSuggested('main'); | 1066 //assertNotSuggested('main'); |
| 1057 //assertNotSuggested('identical'); | 1067 //assertNotSuggested('identical'); |
| 1058 }); | 1068 }); |
| 1059 } | 1069 } |
| 1060 | 1070 |
| 1061 test_AssignmentExpression_type_newline() { | 1071 test_AssignmentExpression_type_newline() { |
| 1062 // SimpleIdentifier TypeName VariableDeclarationList | 1072 // SimpleIdentifier TypeName VariableDeclarationList |
| 1063 // VariableDeclarationStatement Block | 1073 // VariableDeclarationStatement Block |
| 1064 addTestSource(''' | 1074 addTestSource(''' |
| 1065 class A {} main() { | 1075 class A {} main() { |
| 1066 int a; | 1076 int a; |
| 1067 ^ | 1077 ^ |
| 1068 b = 1;}'''); | 1078 b = 1;}'''); |
| 1069 computeFast(); | 1079 computeFast(); |
| 1070 return computeFull((bool result) { | 1080 return computeFull((bool result) { |
| 1081 expect(request.replacementOffset, completionOffset); |
| 1082 expect(request.replacementLength, 0); |
| 1071 assertSuggestLocalClass('A'); | 1083 assertSuggestLocalClass('A'); |
| 1072 assertSuggestImportedClass('int'); | 1084 assertSuggestImportedClass('int'); |
| 1073 // Allow non-types preceding an identifier on LHS of assignment | 1085 // Allow non-types preceding an identifier on LHS of assignment |
| 1074 // if newline follows first identifier | 1086 // if newline follows first identifier |
| 1075 // because user is probably starting a new statement | 1087 // because user is probably starting a new statement |
| 1076 assertSuggestLocalVariable('a', 'int'); | 1088 assertSuggestLocalVariable('a', 'int'); |
| 1077 assertSuggestLocalFunction('main', null); | 1089 assertSuggestLocalFunction('main', null); |
| 1078 assertSuggestImportedFunction('identical', 'bool'); | 1090 assertSuggestImportedFunction('identical', 'bool'); |
| 1079 }); | 1091 }); |
| 1080 } | 1092 } |
| 1081 | 1093 |
| 1082 test_AssignmentExpression_type_partial() { | 1094 test_AssignmentExpression_type_partial() { |
| 1083 // SimpleIdentifier TypeName VariableDeclarationList | 1095 // SimpleIdentifier TypeName VariableDeclarationList |
| 1084 // VariableDeclarationStatement Block | 1096 // VariableDeclarationStatement Block |
| 1085 addTestSource(''' | 1097 addTestSource(''' |
| 1086 class A {} main() { | 1098 class A {} main() { |
| 1087 int a; | 1099 int a; |
| 1088 int^ b = 1;}'''); | 1100 int^ b = 1;}'''); |
| 1089 computeFast(); | 1101 computeFast(); |
| 1090 return computeFull((bool result) { | 1102 return computeFull((bool result) { |
| 1103 expect(request.replacementOffset, completionOffset - 3); |
| 1104 expect(request.replacementLength, 3); |
| 1091 assertSuggestLocalClass('A'); | 1105 assertSuggestLocalClass('A'); |
| 1092 assertSuggestImportedClass('int'); | 1106 assertSuggestImportedClass('int'); |
| 1093 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS | 1107 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS |
| 1094 // the user may be either (1) entering a type for the assignment | 1108 // the user may be either (1) entering a type for the assignment |
| 1095 // or (2) starting a new statement. | 1109 // or (2) starting a new statement. |
| 1096 // Consider suggesting only types | 1110 // Consider suggesting only types |
| 1097 // if only spaces separates the 1st and 2nd identifiers. | 1111 // if only spaces separates the 1st and 2nd identifiers. |
| 1098 //assertNotSuggested('a'); | 1112 //assertNotSuggested('a'); |
| 1099 //assertNotSuggested('main'); | 1113 //assertNotSuggested('main'); |
| 1100 //assertNotSuggested('identical'); | 1114 //assertNotSuggested('identical'); |
| 1101 }); | 1115 }); |
| 1102 } | 1116 } |
| 1103 | 1117 |
| 1104 test_AssignmentExpression_type_partial_newline() { | 1118 test_AssignmentExpression_type_partial_newline() { |
| 1105 // SimpleIdentifier TypeName VariableDeclarationList | 1119 // SimpleIdentifier TypeName VariableDeclarationList |
| 1106 // VariableDeclarationStatement Block | 1120 // VariableDeclarationStatement Block |
| 1107 addTestSource(''' | 1121 addTestSource(''' |
| 1108 class A {} main() { | 1122 class A {} main() { |
| 1109 int a; | 1123 int a; |
| 1110 i^ | 1124 i^ |
| 1111 b = 1;}'''); | 1125 b = 1;}'''); |
| 1112 computeFast(); | 1126 computeFast(); |
| 1113 return computeFull((bool result) { | 1127 return computeFull((bool result) { |
| 1128 expect(request.replacementOffset, completionOffset - 1); |
| 1129 expect(request.replacementLength, 1); |
| 1114 assertSuggestLocalClass('A'); | 1130 assertSuggestLocalClass('A'); |
| 1115 assertSuggestImportedClass('int'); | 1131 assertSuggestImportedClass('int'); |
| 1116 // Allow non-types preceding an identifier on LHS of assignment | 1132 // Allow non-types preceding an identifier on LHS of assignment |
| 1117 // if newline follows first identifier | 1133 // if newline follows first identifier |
| 1118 // because user is probably starting a new statement | 1134 // because user is probably starting a new statement |
| 1119 assertSuggestLocalVariable('a', 'int'); | 1135 assertSuggestLocalVariable('a', 'int'); |
| 1120 assertSuggestLocalFunction('main', null); | 1136 assertSuggestLocalFunction('main', null); |
| 1121 assertSuggestImportedFunction('identical', 'bool'); | 1137 assertSuggestImportedFunction('identical', 'bool'); |
| 1122 }); | 1138 }); |
| 1123 } | 1139 } |
| 1124 | 1140 |
| 1125 test_AwaitExpression() { | 1141 test_AwaitExpression() { |
| 1126 // SimpleIdentifier AwaitExpression ExpressionStatement | 1142 // SimpleIdentifier AwaitExpression ExpressionStatement |
| 1127 addTestSource(''' | 1143 addTestSource(''' |
| 1128 class A {int x; int y() => 0;} | 1144 class A {int x; int y() => 0;} |
| 1129 main(){A a; await ^}'''); | 1145 main(){A a; await ^}'''); |
| 1130 computeFast(); | 1146 computeFast(); |
| 1131 return computeFull((bool result) { | 1147 return computeFull((bool result) { |
| 1148 expect(request.replacementOffset, completionOffset); |
| 1149 expect(request.replacementLength, 0); |
| 1132 assertSuggestLocalVariable('a', 'A'); | 1150 assertSuggestLocalVariable('a', 'A'); |
| 1133 assertSuggestLocalFunction('main', null); | 1151 assertSuggestLocalFunction('main', null); |
| 1134 assertSuggestLocalClass('A'); | 1152 assertSuggestLocalClass('A'); |
| 1135 assertSuggestImportedClass('Object'); | 1153 assertSuggestImportedClass('Object'); |
| 1136 }); | 1154 }); |
| 1137 } | 1155 } |
| 1138 | 1156 |
| 1139 test_BinaryExpression_LHS() { | 1157 test_BinaryExpression_LHS() { |
| 1140 // SimpleIdentifier BinaryExpression VariableDeclaration | 1158 // SimpleIdentifier BinaryExpression VariableDeclaration |
| 1141 // VariableDeclarationList VariableDeclarationStatement | 1159 // VariableDeclarationList VariableDeclarationStatement |
| 1142 addTestSource('main() {int a = 1, b = ^ + 2;}'); | 1160 addTestSource('main() {int a = 1, b = ^ + 2;}'); |
| 1143 computeFast(); | 1161 computeFast(); |
| 1144 return computeFull((bool result) { | 1162 return computeFull((bool result) { |
| 1163 expect(request.replacementOffset, completionOffset); |
| 1164 expect(request.replacementLength, 0); |
| 1145 assertSuggestLocalVariable('a', 'int'); | 1165 assertSuggestLocalVariable('a', 'int'); |
| 1146 assertSuggestImportedClass('Object'); | 1166 assertSuggestImportedClass('Object'); |
| 1147 assertNotSuggested('b'); | 1167 assertNotSuggested('b'); |
| 1148 }); | 1168 }); |
| 1149 } | 1169 } |
| 1150 | 1170 |
| 1151 test_BinaryExpression_RHS() { | 1171 test_BinaryExpression_RHS() { |
| 1152 // SimpleIdentifier BinaryExpression VariableDeclaration | 1172 // SimpleIdentifier BinaryExpression VariableDeclaration |
| 1153 // VariableDeclarationList VariableDeclarationStatement | 1173 // VariableDeclarationList VariableDeclarationStatement |
| 1154 addTestSource('main() {int a = 1, b = 2 + ^;}'); | 1174 addTestSource('main() {int a = 1, b = 2 + ^;}'); |
| 1155 computeFast(); | 1175 computeFast(); |
| 1156 return computeFull((bool result) { | 1176 return computeFull((bool result) { |
| 1177 expect(request.replacementOffset, completionOffset); |
| 1178 expect(request.replacementLength, 0); |
| 1157 assertSuggestLocalVariable('a', 'int'); | 1179 assertSuggestLocalVariable('a', 'int'); |
| 1158 assertSuggestImportedClass('Object'); | 1180 assertSuggestImportedClass('Object'); |
| 1159 assertNotSuggested('b'); | 1181 assertNotSuggested('b'); |
| 1160 assertNotSuggested('=='); | 1182 assertNotSuggested('=='); |
| 1161 }); | 1183 }); |
| 1162 } | 1184 } |
| 1163 | 1185 |
| 1164 test_Block() { | 1186 test_Block() { |
| 1165 // Block BlockFunctionBody MethodDeclaration | 1187 // Block BlockFunctionBody MethodDeclaration |
| 1166 addSource('/testAB.dart', ''' | 1188 addSource('/testAB.dart', ''' |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1197 a() { | 1219 a() { |
| 1198 var f; | 1220 var f; |
| 1199 localF(int arg1) { } | 1221 localF(int arg1) { } |
| 1200 {var x;} | 1222 {var x;} |
| 1201 ^ var r; | 1223 ^ var r; |
| 1202 } | 1224 } |
| 1203 void b() { }} | 1225 void b() { }} |
| 1204 class Z { }'''); | 1226 class Z { }'''); |
| 1205 computeFast(); | 1227 computeFast(); |
| 1206 return computeFull((bool result) { | 1228 return computeFull((bool result) { |
| 1229 expect(request.replacementOffset, completionOffset); |
| 1230 expect(request.replacementLength, 0); |
| 1207 | 1231 |
| 1208 assertSuggestLocalClass('X'); | 1232 assertSuggestLocalClass('X'); |
| 1209 assertSuggestLocalClass('Z'); | 1233 assertSuggestLocalClass('Z'); |
| 1210 assertLocalSuggestMethod('a', 'X', null); | 1234 assertLocalSuggestMethod('a', 'X', null); |
| 1211 assertLocalSuggestMethod('b', 'X', 'void'); | 1235 assertLocalSuggestMethod('b', 'X', 'void'); |
| 1212 assertSuggestLocalFunction('localF', null); | 1236 assertSuggestLocalFunction('localF', null); |
| 1213 assertSuggestLocalVariable('f', null); | 1237 assertSuggestLocalVariable('f', null); |
| 1214 // Don't suggest locals out of scope | 1238 // Don't suggest locals out of scope |
| 1215 assertNotSuggested('r'); | 1239 assertNotSuggested('r'); |
| 1216 assertNotSuggested('x'); | 1240 assertNotSuggested('x'); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 import "/testCD.dart" hide D; | 1301 import "/testCD.dart" hide D; |
| 1278 import "/testEEF.dart" show EE; | 1302 import "/testEEF.dart" show EE; |
| 1279 import "/testG.dart" as g; | 1303 import "/testG.dart" as g; |
| 1280 int T5; | 1304 int T5; |
| 1281 var _T6; | 1305 var _T6; |
| 1282 Z D2() {int x;} | 1306 Z D2() {int x;} |
| 1283 class X {a() {var f; {var x;} D^ var r;} void b() { }} | 1307 class X {a() {var f; {var x;} D^ var r;} void b() { }} |
| 1284 class Z { }'''); | 1308 class Z { }'''); |
| 1285 computeFast(); | 1309 computeFast(); |
| 1286 return computeFull((bool result) { | 1310 return computeFull((bool result) { |
| 1311 expect(request.replacementOffset, completionOffset - 1); |
| 1312 expect(request.replacementLength, 1); |
| 1287 | 1313 |
| 1288 assertSuggestLocalClass('X'); | 1314 assertSuggestLocalClass('X'); |
| 1289 assertSuggestLocalClass('Z'); | 1315 assertSuggestLocalClass('Z'); |
| 1290 assertLocalSuggestMethod('a', 'X', null); | 1316 assertLocalSuggestMethod('a', 'X', null); |
| 1291 assertLocalSuggestMethod('b', 'X', 'void'); | 1317 assertLocalSuggestMethod('b', 'X', 'void'); |
| 1292 assertSuggestLocalVariable('f', null); | 1318 assertSuggestLocalVariable('f', null); |
| 1293 // Don't suggest locals out of scope | 1319 // Don't suggest locals out of scope |
| 1294 assertNotSuggested('r'); | 1320 assertNotSuggested('r'); |
| 1295 assertNotSuggested('x'); | 1321 assertNotSuggested('x'); |
| 1296 | 1322 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 lib B; | 1359 lib B; |
| 1334 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } | 1360 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } |
| 1335 class E extends F { var e1; e2() { } } | 1361 class E extends F { var e1; e2() { } } |
| 1336 class I { int i1; i2() { } } | 1362 class I { int i1; i2() { } } |
| 1337 class M { var m1; int m2() { } }'''); | 1363 class M { var m1; int m2() { } }'''); |
| 1338 addTestSource(''' | 1364 addTestSource(''' |
| 1339 import "/testB.dart"; | 1365 import "/testB.dart"; |
| 1340 class A extends E implements I with M {a() {^}}'''); | 1366 class A extends E implements I with M {a() {^}}'''); |
| 1341 computeFast(); | 1367 computeFast(); |
| 1342 return computeFull((bool result) { | 1368 return computeFull((bool result) { |
| 1369 expect(request.replacementOffset, completionOffset); |
| 1370 expect(request.replacementLength, 0); |
| 1343 // TODO (danrubel) prefer fields over getters | 1371 // TODO (danrubel) prefer fields over getters |
| 1344 // If add `get e1;` to interface I | 1372 // If add `get e1;` to interface I |
| 1345 // then suggestions include getter e1 rather than field e1 | 1373 // then suggestions include getter e1 rather than field e1 |
| 1346 assertSuggestImportedField('e1', null); | 1374 assertSuggestImportedField('e1', null); |
| 1347 assertSuggestImportedField('f1', null); | 1375 assertSuggestImportedField('f1', null); |
| 1348 assertSuggestImportedField('i1', 'int'); | 1376 assertSuggestImportedField('i1', 'int'); |
| 1349 assertSuggestImportedField('m1', null); | 1377 assertSuggestImportedField('m1', null); |
| 1350 assertSuggestImportedGetter('f3', null); | 1378 assertSuggestImportedGetter('f3', null); |
| 1351 assertSuggestImportedSetter('f4'); | 1379 assertSuggestImportedSetter('f4'); |
| 1352 assertSuggestImportedMethod('e2', 'E', null); | 1380 assertSuggestImportedMethod('e2', 'E', null); |
| 1353 assertSuggestImportedMethod('f2', 'F', null); | 1381 assertSuggestImportedMethod('f2', 'F', null); |
| 1354 assertSuggestImportedMethod('i2', 'I', null); | 1382 assertSuggestImportedMethod('i2', 'I', null); |
| 1355 //assertSuggestImportedMethod('m2', null, null); | 1383 //assertSuggestImportedMethod('m2', null, null); |
| 1356 assertNotSuggested('=='); | 1384 assertNotSuggested('=='); |
| 1357 }); | 1385 }); |
| 1358 } | 1386 } |
| 1359 | 1387 |
| 1360 test_Block_inherited_local() { | 1388 test_Block_inherited_local() { |
| 1361 // Block BlockFunctionBody MethodDeclaration ClassDeclaration | 1389 // Block BlockFunctionBody MethodDeclaration ClassDeclaration |
| 1362 addTestSource(''' | 1390 addTestSource(''' |
| 1363 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } | 1391 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } |
| 1364 class E extends F { var e1; e2() { } } | 1392 class E extends F { var e1; e2() { } } |
| 1365 class I { int i1; i2() { } } | 1393 class I { int i1; i2() { } } |
| 1366 class M { var m1; int m2() { } } | 1394 class M { var m1; int m2() { } } |
| 1367 class A extends E implements I with M {a() {^}}'''); | 1395 class A extends E implements I with M {a() {^}}'''); |
| 1368 computeFast(); | 1396 computeFast(); |
| 1369 return computeFull((bool result) { | 1397 return computeFull((bool result) { |
| 1398 expect(request.replacementOffset, completionOffset); |
| 1399 expect(request.replacementLength, 0); |
| 1370 assertSuggestLocalField('e1', null); | 1400 assertSuggestLocalField('e1', null); |
| 1371 assertSuggestLocalField('f1', null); | 1401 assertSuggestLocalField('f1', null); |
| 1372 assertSuggestLocalField('i1', 'int'); | 1402 assertSuggestLocalField('i1', 'int'); |
| 1373 assertSuggestLocalField('m1', null); | 1403 assertSuggestLocalField('m1', null); |
| 1374 assertSuggestLocalGetter('f3', null); | 1404 assertSuggestLocalGetter('f3', null); |
| 1375 assertSuggestLocalSetter('f4'); | 1405 assertSuggestLocalSetter('f4'); |
| 1376 assertSuggestLocalMethod('e2', 'E', null); | 1406 assertSuggestLocalMethod('e2', 'E', null); |
| 1377 assertSuggestLocalMethod('f2', 'F', null); | 1407 assertSuggestLocalMethod('f2', 'F', null); |
| 1378 assertSuggestLocalMethod('i2', 'I', null); | 1408 assertSuggestLocalMethod('i2', 'I', null); |
| 1379 assertSuggestLocalMethod('m2', 'M', 'int'); | 1409 assertSuggestLocalMethod('m2', 'M', 'int'); |
| 1380 }); | 1410 }); |
| 1381 } | 1411 } |
| 1382 | 1412 |
| 1383 test_CascadeExpression_selector1() { | 1413 test_CascadeExpression_selector1() { |
| 1384 // PropertyAccess CascadeExpression ExpressionStatement Block | 1414 // PropertyAccess CascadeExpression ExpressionStatement Block |
| 1385 addSource('/testB.dart', ''' | 1415 addSource('/testB.dart', ''' |
| 1386 class B { }'''); | 1416 class B { }'''); |
| 1387 addTestSource(''' | 1417 addTestSource(''' |
| 1388 import "/testB.dart"; | 1418 import "/testB.dart"; |
| 1389 class A {var b; X _c;} | 1419 class A {var b; X _c;} |
| 1390 class X{} | 1420 class X{} |
| 1391 // looks like a cascade to the parser | 1421 // looks like a cascade to the parser |
| 1392 // but the user is trying to get completions for a non-cascade | 1422 // but the user is trying to get completions for a non-cascade |
| 1393 main() {A a; a.^.z}'''); | 1423 main() {A a; a.^.z}'''); |
| 1394 computeFast(); | 1424 computeFast(); |
| 1395 return computeFull((bool result) { | 1425 return computeFull((bool result) { |
| 1426 expect(request.replacementOffset, completionOffset); |
| 1427 expect(request.replacementLength, 0); |
| 1396 assertSuggestInvocationField('b', null); | 1428 assertSuggestInvocationField('b', null); |
| 1397 assertSuggestInvocationField('_c', 'X'); | 1429 assertSuggestInvocationField('_c', 'X'); |
| 1398 assertNotSuggested('Object'); | 1430 assertNotSuggested('Object'); |
| 1399 assertNotSuggested('A'); | 1431 assertNotSuggested('A'); |
| 1400 assertNotSuggested('B'); | 1432 assertNotSuggested('B'); |
| 1401 assertNotSuggested('X'); | 1433 assertNotSuggested('X'); |
| 1402 assertNotSuggested('z'); | 1434 assertNotSuggested('z'); |
| 1403 assertNotSuggested('=='); | 1435 assertNotSuggested('=='); |
| 1404 }); | 1436 }); |
| 1405 } | 1437 } |
| 1406 | 1438 |
| 1407 test_CascadeExpression_selector2() { | 1439 test_CascadeExpression_selector2() { |
| 1408 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement | 1440 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement |
| 1409 addSource('/testB.dart', ''' | 1441 addSource('/testB.dart', ''' |
| 1410 class B { }'''); | 1442 class B { }'''); |
| 1411 addTestSource(''' | 1443 addTestSource(''' |
| 1412 import "/testB.dart"; | 1444 import "/testB.dart"; |
| 1413 class A {var b; X _c;} | 1445 class A {var b; X _c;} |
| 1414 class X{} | 1446 class X{} |
| 1415 main() {A a; a..^z}'''); | 1447 main() {A a; a..^z}'''); |
| 1416 computeFast(); | 1448 computeFast(); |
| 1417 return computeFull((bool result) { | 1449 return computeFull((bool result) { |
| 1450 expect(request.replacementOffset, completionOffset); |
| 1451 expect(request.replacementLength, 1); |
| 1418 assertSuggestInvocationField('b', null); | 1452 assertSuggestInvocationField('b', null); |
| 1419 assertSuggestInvocationField('_c', 'X'); | 1453 assertSuggestInvocationField('_c', 'X'); |
| 1420 assertNotSuggested('Object'); | 1454 assertNotSuggested('Object'); |
| 1421 assertNotSuggested('A'); | 1455 assertNotSuggested('A'); |
| 1422 assertNotSuggested('B'); | 1456 assertNotSuggested('B'); |
| 1423 assertNotSuggested('X'); | 1457 assertNotSuggested('X'); |
| 1424 assertNotSuggested('z'); | 1458 assertNotSuggested('z'); |
| 1425 assertNotSuggested('=='); | 1459 assertNotSuggested('=='); |
| 1426 }); | 1460 }); |
| 1427 } | 1461 } |
| 1428 | 1462 |
| 1429 test_CascadeExpression_selector2_withTrailingReturn() { | 1463 test_CascadeExpression_selector2_withTrailingReturn() { |
| 1430 // PropertyAccess CascadeExpression ExpressionStatement Block | 1464 // PropertyAccess CascadeExpression ExpressionStatement Block |
| 1431 addSource('/testB.dart', ''' | 1465 addSource('/testB.dart', ''' |
| 1432 class B { }'''); | 1466 class B { }'''); |
| 1433 addTestSource(''' | 1467 addTestSource(''' |
| 1434 import "/testB.dart"; | 1468 import "/testB.dart"; |
| 1435 class A {var b; X _c;} | 1469 class A {var b; X _c;} |
| 1436 class X{} | 1470 class X{} |
| 1437 main() {A a; a..^ return}'''); | 1471 main() {A a; a..^ return}'''); |
| 1438 computeFast(); | 1472 computeFast(); |
| 1439 return computeFull((bool result) { | 1473 return computeFull((bool result) { |
| 1474 expect(request.replacementOffset, completionOffset); |
| 1475 expect(request.replacementLength, 0); |
| 1440 assertSuggestInvocationField('b', null); | 1476 assertSuggestInvocationField('b', null); |
| 1441 assertSuggestInvocationField('_c', 'X'); | 1477 assertSuggestInvocationField('_c', 'X'); |
| 1442 assertNotSuggested('Object'); | 1478 assertNotSuggested('Object'); |
| 1443 assertNotSuggested('A'); | 1479 assertNotSuggested('A'); |
| 1444 assertNotSuggested('B'); | 1480 assertNotSuggested('B'); |
| 1445 assertNotSuggested('X'); | 1481 assertNotSuggested('X'); |
| 1446 assertNotSuggested('z'); | 1482 assertNotSuggested('z'); |
| 1447 assertNotSuggested('=='); | 1483 assertNotSuggested('=='); |
| 1448 }); | 1484 }); |
| 1449 } | 1485 } |
| 1450 | 1486 |
| 1451 test_CascadeExpression_target() { | 1487 test_CascadeExpression_target() { |
| 1452 // SimpleIdentifier CascadeExpression ExpressionStatement | 1488 // SimpleIdentifier CascadeExpression ExpressionStatement |
| 1453 addTestSource(''' | 1489 addTestSource(''' |
| 1454 class A {var b; X _c;} | 1490 class A {var b; X _c;} |
| 1455 class X{} | 1491 class X{} |
| 1456 main() {A a; a^..b}'''); | 1492 main() {A a; a^..b}'''); |
| 1457 computeFast(); | 1493 computeFast(); |
| 1458 return computeFull((bool result) { | 1494 return computeFull((bool result) { |
| 1495 expect(request.replacementOffset, completionOffset - 1); |
| 1496 expect(request.replacementLength, 1); |
| 1459 assertNotSuggested('b'); | 1497 assertNotSuggested('b'); |
| 1460 assertNotSuggested('_c'); | 1498 assertNotSuggested('_c'); |
| 1461 assertSuggestLocalVariable('a', 'A'); | 1499 assertSuggestLocalVariable('a', 'A'); |
| 1462 assertSuggestLocalClass('A'); | 1500 assertSuggestLocalClass('A'); |
| 1463 assertSuggestLocalClass('X'); | 1501 assertSuggestLocalClass('X'); |
| 1464 // top level results are partially filtered | 1502 // top level results are partially filtered |
| 1465 //assertSuggestImportedClass('Object'); | 1503 //assertSuggestImportedClass('Object'); |
| 1466 assertNotSuggested('=='); | 1504 assertNotSuggested('=='); |
| 1467 }); | 1505 }); |
| 1468 } | 1506 } |
| 1469 | 1507 |
| 1470 test_CatchClause_typed() { | 1508 test_CatchClause_typed() { |
| 1471 // Block CatchClause TryStatement | 1509 // Block CatchClause TryStatement |
| 1472 addTestSource('class A {a() {try{var x;} on E catch (e) {^}}}'); | 1510 addTestSource('class A {a() {try{var x;} on E catch (e) {^}}}'); |
| 1473 computeFast(); | 1511 computeFast(); |
| 1474 return computeFull((bool result) { | 1512 return computeFull((bool result) { |
| 1513 expect(request.replacementOffset, completionOffset); |
| 1514 expect(request.replacementLength, 0); |
| 1475 assertSuggestParameter('e', 'E'); | 1515 assertSuggestParameter('e', 'E'); |
| 1476 assertSuggestLocalMethod('a', 'A', null); | 1516 assertSuggestLocalMethod('a', 'A', null); |
| 1477 assertSuggestImportedClass('Object'); | 1517 assertSuggestImportedClass('Object'); |
| 1478 assertNotSuggested('x'); | 1518 assertNotSuggested('x'); |
| 1479 }); | 1519 }); |
| 1480 } | 1520 } |
| 1481 | 1521 |
| 1482 test_CatchClause_untyped() { | 1522 test_CatchClause_untyped() { |
| 1483 // Block CatchClause TryStatement | 1523 // Block CatchClause TryStatement |
| 1484 addTestSource('class A {a() {try{var x;} catch (e, s) {^}}}'); | 1524 addTestSource('class A {a() {try{var x;} catch (e, s) {^}}}'); |
| 1485 computeFast(); | 1525 computeFast(); |
| 1486 return computeFull((bool result) { | 1526 return computeFull((bool result) { |
| 1527 expect(request.replacementOffset, completionOffset); |
| 1528 expect(request.replacementLength, 0); |
| 1487 assertSuggestParameter('e', null); | 1529 assertSuggestParameter('e', null); |
| 1488 assertSuggestParameter('s', 'StackTrace'); | 1530 assertSuggestParameter('s', 'StackTrace'); |
| 1489 assertSuggestLocalMethod('a', 'A', null); | 1531 assertSuggestLocalMethod('a', 'A', null); |
| 1490 assertSuggestImportedClass('Object'); | 1532 assertSuggestImportedClass('Object'); |
| 1491 assertNotSuggested('x'); | 1533 assertNotSuggested('x'); |
| 1492 }); | 1534 }); |
| 1493 } | 1535 } |
| 1494 | 1536 |
| 1495 test_ClassDeclaration_body() { | 1537 test_ClassDeclaration_body() { |
| 1496 // ClassDeclaration CompilationUnit | 1538 // ClassDeclaration CompilationUnit |
| 1497 addSource('/testB.dart', ''' | 1539 addSource('/testB.dart', ''' |
| 1498 class B { }'''); | 1540 class B { }'''); |
| 1499 addTestSource(''' | 1541 addTestSource(''' |
| 1500 import "testB.dart" as x; | 1542 import "testB.dart" as x; |
| 1501 @deprecated class A {^} | 1543 @deprecated class A {^} |
| 1502 class _B {} | 1544 class _B {} |
| 1503 A T;'''); | 1545 A T;'''); |
| 1504 computeFast(); | 1546 computeFast(); |
| 1505 return computeFull((bool result) { | 1547 return computeFull((bool result) { |
| 1548 expect(request.replacementOffset, completionOffset); |
| 1549 expect(request.replacementLength, 0); |
| 1506 CompletionSuggestion suggestionA = assertSuggestLocalClass( | 1550 CompletionSuggestion suggestionA = assertSuggestLocalClass( |
| 1507 'A', | 1551 'A', |
| 1508 relevance: COMPLETION_RELEVANCE_LOW, | 1552 relevance: COMPLETION_RELEVANCE_LOW, |
| 1509 isDeprecated: true); | 1553 isDeprecated: true); |
| 1510 if (suggestionA != null) { | 1554 if (suggestionA != null) { |
| 1511 expect(suggestionA.element.isDeprecated, isTrue); | 1555 expect(suggestionA.element.isDeprecated, isTrue); |
| 1512 expect(suggestionA.element.isPrivate, isFalse); | 1556 expect(suggestionA.element.isPrivate, isFalse); |
| 1513 } | 1557 } |
| 1514 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); | 1558 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); |
| 1515 if (suggestionB != null) { | 1559 if (suggestionB != null) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 assertNoSuggestions(); | 1621 assertNoSuggestions(); |
| 1578 }); | 1622 }); |
| 1579 } | 1623 } |
| 1580 | 1624 |
| 1581 test_ConditionalExpression_empty() { | 1625 test_ConditionalExpression_empty() { |
| 1582 // SimpleIdentifier PrefixIdentifier IfStatement | 1626 // SimpleIdentifier PrefixIdentifier IfStatement |
| 1583 addTestSource(''' | 1627 addTestSource(''' |
| 1584 class A {var b; X _c; foo() {A a; if (^) something}}'''); | 1628 class A {var b; X _c; foo() {A a; if (^) something}}'''); |
| 1585 computeFast(); | 1629 computeFast(); |
| 1586 return computeFull((bool result) { | 1630 return computeFull((bool result) { |
| 1631 expect(request.replacementOffset, completionOffset); |
| 1632 expect(request.replacementLength, 0); |
| 1587 assertSuggestLocalField('b', null); | 1633 assertSuggestLocalField('b', null); |
| 1588 assertSuggestLocalField('_c', 'X'); | 1634 assertSuggestLocalField('_c', 'X'); |
| 1589 assertSuggestImportedClass('Object'); | 1635 assertSuggestImportedClass('Object'); |
| 1590 assertSuggestLocalClass('A'); | 1636 assertSuggestLocalClass('A'); |
| 1591 assertNotSuggested('=='); | 1637 assertNotSuggested('=='); |
| 1592 }); | 1638 }); |
| 1593 } | 1639 } |
| 1594 | 1640 |
| 1595 test_ConditionalExpression_invocation() { | 1641 test_ConditionalExpression_invocation() { |
| 1596 // SimpleIdentifier PrefixIdentifier IfStatement | 1642 // SimpleIdentifier PrefixIdentifier IfStatement |
| 1597 addTestSource(''' | 1643 addTestSource(''' |
| 1598 main() {var a; if (a.^) something}'''); | 1644 main() {var a; if (a.^) something}'''); |
| 1599 computeFast(); | 1645 computeFast(); |
| 1600 return computeFull((bool result) { | 1646 return computeFull((bool result) { |
| 1647 expect(request.replacementOffset, completionOffset); |
| 1648 expect(request.replacementLength, 0); |
| 1601 assertSuggestInvocationMethod('toString', 'Object', 'String'); | 1649 assertSuggestInvocationMethod('toString', 'Object', 'String'); |
| 1602 //TODO (danrubel) type for '_c' should be 'X' not null | 1650 //TODO (danrubel) type for '_c' should be 'X' not null |
| 1603 assertNotSuggested('Object'); | 1651 assertNotSuggested('Object'); |
| 1604 assertNotSuggested('A'); | 1652 assertNotSuggested('A'); |
| 1605 assertNotSuggested('=='); | 1653 assertNotSuggested('=='); |
| 1606 }); | 1654 }); |
| 1607 } | 1655 } |
| 1608 | 1656 |
| 1609 test_ConstructorName_importedClass() { | 1657 test_ConstructorName_importedClass() { |
| 1610 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | 1658 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 1611 // InstanceCreationExpression | 1659 // InstanceCreationExpression |
| 1612 addSource('/testB.dart', ''' | 1660 addSource('/testB.dart', ''' |
| 1613 lib B; | 1661 lib B; |
| 1614 int T1; | 1662 int T1; |
| 1615 F1() { } | 1663 F1() { } |
| 1616 class X {X.c(); X._d(); z() {}}'''); | 1664 class X {X.c(); X._d(); z() {}}'''); |
| 1617 addTestSource(''' | 1665 addTestSource(''' |
| 1618 import "/testB.dart"; | 1666 import "/testB.dart"; |
| 1619 var m; | 1667 var m; |
| 1620 main() {new X.^}'''); | 1668 main() {new X.^}'''); |
| 1621 computeFast(); | 1669 computeFast(); |
| 1622 return computeFull((bool result) { | 1670 return computeFull((bool result) { |
| 1671 expect(request.replacementOffset, completionOffset); |
| 1672 expect(request.replacementLength, 0); |
| 1623 assertSuggestNamedConstructor('c', 'X'); | 1673 assertSuggestNamedConstructor('c', 'X'); |
| 1624 assertNotSuggested('F1'); | 1674 assertNotSuggested('F1'); |
| 1625 assertNotSuggested('T1'); | 1675 assertNotSuggested('T1'); |
| 1626 assertNotSuggested('_d'); | 1676 assertNotSuggested('_d'); |
| 1627 assertNotSuggested('z'); | 1677 assertNotSuggested('z'); |
| 1628 assertNotSuggested('m'); | 1678 assertNotSuggested('m'); |
| 1629 }); | 1679 }); |
| 1630 } | 1680 } |
| 1631 | 1681 |
| 1632 test_ConstructorName_importedFactory() { | 1682 test_ConstructorName_importedFactory() { |
| 1633 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | 1683 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 1634 // InstanceCreationExpression | 1684 // InstanceCreationExpression |
| 1635 addSource('/testB.dart', ''' | 1685 addSource('/testB.dart', ''' |
| 1636 lib B; | 1686 lib B; |
| 1637 int T1; | 1687 int T1; |
| 1638 F1() { } | 1688 F1() { } |
| 1639 class X {factory X.c(); factory X._d(); z() {}}'''); | 1689 class X {factory X.c(); factory X._d(); z() {}}'''); |
| 1640 addTestSource(''' | 1690 addTestSource(''' |
| 1641 import "/testB.dart"; | 1691 import "/testB.dart"; |
| 1642 var m; | 1692 var m; |
| 1643 main() {new X.^}'''); | 1693 main() {new X.^}'''); |
| 1644 computeFast(); | 1694 computeFast(); |
| 1645 return computeFull((bool result) { | 1695 return computeFull((bool result) { |
| 1696 expect(request.replacementOffset, completionOffset); |
| 1697 expect(request.replacementLength, 0); |
| 1646 assertSuggestNamedConstructor('c', 'X'); | 1698 assertSuggestNamedConstructor('c', 'X'); |
| 1647 assertNotSuggested('F1'); | 1699 assertNotSuggested('F1'); |
| 1648 assertNotSuggested('T1'); | 1700 assertNotSuggested('T1'); |
| 1649 assertNotSuggested('_d'); | 1701 assertNotSuggested('_d'); |
| 1650 assertNotSuggested('z'); | 1702 assertNotSuggested('z'); |
| 1651 assertNotSuggested('m'); | 1703 assertNotSuggested('m'); |
| 1652 }); | 1704 }); |
| 1653 } | 1705 } |
| 1654 | 1706 |
| 1655 test_ConstructorName_importedFactory2() { | 1707 test_ConstructorName_importedFactory2() { |
| 1656 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | 1708 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 1657 // InstanceCreationExpression | 1709 // InstanceCreationExpression |
| 1658 addTestSource(''' | 1710 addTestSource(''' |
| 1659 main() {new String.fr^omCharCodes([]);}'''); | 1711 main() {new String.fr^omCharCodes([]);}'''); |
| 1660 computeFast(); | 1712 computeFast(); |
| 1661 return computeFull((bool result) { | 1713 return computeFull((bool result) { |
| 1714 expect(request.replacementOffset, completionOffset - 2); |
| 1715 expect(request.replacementLength, 13); |
| 1662 assertSuggestNamedConstructor('fromCharCodes', 'String'); | 1716 assertSuggestNamedConstructor('fromCharCodes', 'String'); |
| 1663 assertNotSuggested('isEmpty'); | 1717 assertNotSuggested('isEmpty'); |
| 1664 assertNotSuggested('isNotEmpty'); | 1718 assertNotSuggested('isNotEmpty'); |
| 1665 assertNotSuggested('length'); | 1719 assertNotSuggested('length'); |
| 1666 assertNotSuggested('Object'); | 1720 assertNotSuggested('Object'); |
| 1667 assertNotSuggested('String'); | 1721 assertNotSuggested('String'); |
| 1668 }); | 1722 }); |
| 1669 } | 1723 } |
| 1670 | 1724 |
| 1671 test_ConstructorName_localClass() { | 1725 test_ConstructorName_localClass() { |
| 1672 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | 1726 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 1673 // InstanceCreationExpression | 1727 // InstanceCreationExpression |
| 1674 addTestSource(''' | 1728 addTestSource(''' |
| 1675 int T1; | 1729 int T1; |
| 1676 F1() { } | 1730 F1() { } |
| 1677 class X {X.c(); X._d(); z() {}} | 1731 class X {X.c(); X._d(); z() {}} |
| 1678 main() {new X.^}'''); | 1732 main() {new X.^}'''); |
| 1679 computeFast(); | 1733 computeFast(); |
| 1680 return computeFull((bool result) { | 1734 return computeFull((bool result) { |
| 1735 expect(request.replacementOffset, completionOffset); |
| 1736 expect(request.replacementLength, 0); |
| 1681 assertSuggestNamedConstructor('c', 'X'); | 1737 assertSuggestNamedConstructor('c', 'X'); |
| 1682 assertSuggestNamedConstructor('_d', 'X'); | 1738 assertSuggestNamedConstructor('_d', 'X'); |
| 1683 assertNotSuggested('F1'); | 1739 assertNotSuggested('F1'); |
| 1684 assertNotSuggested('T1'); | 1740 assertNotSuggested('T1'); |
| 1685 assertNotSuggested('z'); | 1741 assertNotSuggested('z'); |
| 1686 assertNotSuggested('m'); | 1742 assertNotSuggested('m'); |
| 1687 }); | 1743 }); |
| 1688 } | 1744 } |
| 1689 | 1745 |
| 1690 test_ConstructorName_localFactory() { | 1746 test_ConstructorName_localFactory() { |
| 1691 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | 1747 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 1692 // InstanceCreationExpression | 1748 // InstanceCreationExpression |
| 1693 addTestSource(''' | 1749 addTestSource(''' |
| 1694 int T1; | 1750 int T1; |
| 1695 F1() { } | 1751 F1() { } |
| 1696 class X {factory X.c(); factory X._d(); z() {}} | 1752 class X {factory X.c(); factory X._d(); z() {}} |
| 1697 main() {new X.^}'''); | 1753 main() {new X.^}'''); |
| 1698 computeFast(); | 1754 computeFast(); |
| 1699 return computeFull((bool result) { | 1755 return computeFull((bool result) { |
| 1756 expect(request.replacementOffset, completionOffset); |
| 1757 expect(request.replacementLength, 0); |
| 1700 assertSuggestNamedConstructor('c', 'X'); | 1758 assertSuggestNamedConstructor('c', 'X'); |
| 1701 assertSuggestNamedConstructor('_d', 'X'); | 1759 assertSuggestNamedConstructor('_d', 'X'); |
| 1702 assertNotSuggested('F1'); | 1760 assertNotSuggested('F1'); |
| 1703 assertNotSuggested('T1'); | 1761 assertNotSuggested('T1'); |
| 1704 assertNotSuggested('z'); | 1762 assertNotSuggested('z'); |
| 1705 assertNotSuggested('m'); | 1763 assertNotSuggested('m'); |
| 1706 }); | 1764 }); |
| 1707 } | 1765 } |
| 1708 | 1766 |
| 1709 test_ExpressionStatement_identifier() { | 1767 test_ExpressionStatement_identifier() { |
| 1710 // SimpleIdentifier ExpressionStatement Block | 1768 // SimpleIdentifier ExpressionStatement Block |
| 1711 addSource('/testA.dart', ''' | 1769 addSource('/testA.dart', ''' |
| 1712 _B F1() { } | 1770 _B F1() { } |
| 1713 class A {int x;} | 1771 class A {int x;} |
| 1714 class _B { }'''); | 1772 class _B { }'''); |
| 1715 addTestSource(''' | 1773 addTestSource(''' |
| 1716 import "/testA.dart"; | 1774 import "/testA.dart"; |
| 1717 typedef int F2(int blat); | 1775 typedef int F2(int blat); |
| 1718 class Clz = Object with Object; | 1776 class Clz = Object with Object; |
| 1719 class C {foo(){^} void bar() {}}'''); | 1777 class C {foo(){^} void bar() {}}'''); |
| 1720 computeFast(); | 1778 computeFast(); |
| 1721 return computeFull((bool result) { | 1779 return computeFull((bool result) { |
| 1780 expect(request.replacementOffset, completionOffset); |
| 1781 expect(request.replacementLength, 0); |
| 1722 assertSuggestImportedClass('A'); | 1782 assertSuggestImportedClass('A'); |
| 1723 assertSuggestImportedFunction('F1', '_B', false); | 1783 assertSuggestImportedFunction('F1', '_B', false); |
| 1724 assertSuggestLocalClass('C'); | 1784 assertSuggestLocalClass('C'); |
| 1725 assertSuggestLocalMethod('foo', 'C', null); | 1785 assertSuggestLocalMethod('foo', 'C', null); |
| 1726 assertSuggestLocalMethod('bar', 'C', 'void'); | 1786 assertSuggestLocalMethod('bar', 'C', 'void'); |
| 1727 assertSuggestLocalFunctionTypeAlias('F2', 'int'); | 1787 assertSuggestLocalFunctionTypeAlias('F2', 'int'); |
| 1728 assertSuggestLocalClassTypeAlias('Clz'); | 1788 assertSuggestLocalClassTypeAlias('Clz'); |
| 1729 assertSuggestLocalClass('C'); | 1789 assertSuggestLocalClass('C'); |
| 1730 assertNotSuggested('x'); | 1790 assertNotSuggested('x'); |
| 1731 assertNotSuggested('_B'); | 1791 assertNotSuggested('_B'); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 return computeFull((bool result) { | 1830 return computeFull((bool result) { |
| 1771 assertNoSuggestions(); | 1831 assertNoSuggestions(); |
| 1772 }); | 1832 }); |
| 1773 } | 1833 } |
| 1774 | 1834 |
| 1775 test_ForEachStatement_body_typed() { | 1835 test_ForEachStatement_body_typed() { |
| 1776 // Block ForEachStatement | 1836 // Block ForEachStatement |
| 1777 addTestSource('main(args) {for (int foo in bar) {^}}'); | 1837 addTestSource('main(args) {for (int foo in bar) {^}}'); |
| 1778 computeFast(); | 1838 computeFast(); |
| 1779 return computeFull((bool result) { | 1839 return computeFull((bool result) { |
| 1840 expect(request.replacementOffset, completionOffset); |
| 1841 expect(request.replacementLength, 0); |
| 1780 assertSuggestLocalVariable('foo', 'int'); | 1842 assertSuggestLocalVariable('foo', 'int'); |
| 1781 assertSuggestImportedClass('Object'); | 1843 assertSuggestImportedClass('Object'); |
| 1782 }); | 1844 }); |
| 1783 } | 1845 } |
| 1784 | 1846 |
| 1785 test_ForEachStatement_body_untyped() { | 1847 test_ForEachStatement_body_untyped() { |
| 1786 // Block ForEachStatement | 1848 // Block ForEachStatement |
| 1787 addTestSource('main(args) {for (foo in bar) {^}}'); | 1849 addTestSource('main(args) {for (foo in bar) {^}}'); |
| 1788 computeFast(); | 1850 computeFast(); |
| 1789 return computeFull((bool result) { | 1851 return computeFull((bool result) { |
| 1852 expect(request.replacementOffset, completionOffset); |
| 1853 expect(request.replacementLength, 0); |
| 1790 assertSuggestLocalVariable('foo', null); | 1854 assertSuggestLocalVariable('foo', null); |
| 1791 assertSuggestImportedClass('Object'); | 1855 assertSuggestImportedClass('Object'); |
| 1792 }); | 1856 }); |
| 1793 } | 1857 } |
| 1794 | 1858 |
| 1795 test_FormalParameterList() { | 1859 test_FormalParameterList() { |
| 1796 // FormalParameterList MethodDeclaration | 1860 // FormalParameterList MethodDeclaration |
| 1797 addTestSource(''' | 1861 addTestSource(''' |
| 1798 foo() { } | 1862 foo() { } |
| 1799 void bar() { } | 1863 void bar() { } |
| 1800 class A {a(^) { }}'''); | 1864 class A {a(^) { }}'''); |
| 1801 computeFast(); | 1865 computeFast(); |
| 1802 return computeFull((bool result) { | 1866 return computeFull((bool result) { |
| 1867 expect(request.replacementOffset, completionOffset); |
| 1868 expect(request.replacementLength, 0); |
| 1803 assertSuggestLocalFunction('foo', null); | 1869 assertSuggestLocalFunction('foo', null); |
| 1804 assertSuggestLocalMethod('a', 'A', null); | 1870 assertSuggestLocalMethod('a', 'A', null); |
| 1805 assertSuggestLocalClass('A'); | 1871 assertSuggestLocalClass('A'); |
| 1806 assertSuggestImportedClass('String'); | 1872 assertSuggestImportedClass('String'); |
| 1807 assertSuggestImportedFunction('identical', 'bool'); | 1873 assertSuggestImportedFunction('identical', 'bool'); |
| 1808 assertNotSuggested('bar'); | 1874 assertNotSuggested('bar'); |
| 1809 }); | 1875 }); |
| 1810 } | 1876 } |
| 1811 | 1877 |
| 1812 test_ForStatement_body() { | 1878 test_ForStatement_body() { |
| 1813 // Block ForStatement | 1879 // Block ForStatement |
| 1814 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); | 1880 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); |
| 1815 computeFast(); | 1881 computeFast(); |
| 1816 return computeFull((bool result) { | 1882 return computeFull((bool result) { |
| 1883 expect(request.replacementOffset, completionOffset); |
| 1884 expect(request.replacementLength, 0); |
| 1817 assertSuggestLocalVariable('i', 'int'); | 1885 assertSuggestLocalVariable('i', 'int'); |
| 1818 assertSuggestImportedClass('Object'); | 1886 assertSuggestImportedClass('Object'); |
| 1819 }); | 1887 }); |
| 1820 } | 1888 } |
| 1821 | 1889 |
| 1822 test_ForStatement_condition() { | 1890 test_ForStatement_condition() { |
| 1823 // SimpleIdentifier ForStatement | 1891 // SimpleIdentifier ForStatement |
| 1824 addTestSource('main() {for (int index = 0; i^)}'); | 1892 addTestSource('main() {for (int index = 0; i^)}'); |
| 1825 computeFast(); | 1893 computeFast(); |
| 1826 return computeFull((bool result) { | 1894 return computeFull((bool result) { |
| 1895 expect(request.replacementOffset, completionOffset - 1); |
| 1896 expect(request.replacementLength, 1); |
| 1827 assertSuggestLocalVariable('index', 'int'); | 1897 assertSuggestLocalVariable('index', 'int'); |
| 1828 }); | 1898 }); |
| 1829 } | 1899 } |
| 1830 | 1900 |
| 1831 test_ForStatement_initializer() { | 1901 test_ForStatement_initializer() { |
| 1832 // SimpleIdentifier ForStatement | 1902 // SimpleIdentifier ForStatement |
| 1833 addTestSource('main() {List a; for (^)}'); | 1903 addTestSource('main() {List a; for (^)}'); |
| 1834 computeFast(); | 1904 computeFast(); |
| 1835 return computeFull((bool result) { | 1905 return computeFull((bool result) { |
| 1906 expect(request.replacementOffset, completionOffset); |
| 1907 expect(request.replacementLength, 0); |
| 1836 assertSuggestLocalVariable('a', 'List'); | 1908 assertSuggestLocalVariable('a', 'List'); |
| 1837 assertSuggestImportedClass('Object'); | 1909 assertSuggestImportedClass('Object'); |
| 1838 assertSuggestImportedClass('int'); | 1910 assertSuggestImportedClass('int'); |
| 1839 }); | 1911 }); |
| 1840 } | 1912 } |
| 1841 | 1913 |
| 1842 test_ForStatement_updaters() { | 1914 test_ForStatement_updaters() { |
| 1843 // SimpleIdentifier ForStatement | 1915 // SimpleIdentifier ForStatement |
| 1844 addTestSource('main() {for (int index = 0; index < 10; i^)}'); | 1916 addTestSource('main() {for (int index = 0; index < 10; i^)}'); |
| 1845 computeFast(); | 1917 computeFast(); |
| 1846 return computeFull((bool result) { | 1918 return computeFull((bool result) { |
| 1919 expect(request.replacementOffset, completionOffset - 1); |
| 1920 expect(request.replacementLength, 1); |
| 1847 assertSuggestLocalVariable('index', 'int'); | 1921 assertSuggestLocalVariable('index', 'int'); |
| 1848 }); | 1922 }); |
| 1849 } | 1923 } |
| 1850 | 1924 |
| 1851 test_ForStatement_updaters_prefix_expression() { | 1925 test_ForStatement_updaters_prefix_expression() { |
| 1852 // SimpleIdentifier PrefixExpression ForStatement | 1926 // SimpleIdentifier PrefixExpression ForStatement |
| 1853 addTestSource(''' | 1927 addTestSource(''' |
| 1854 void bar() { } | 1928 void bar() { } |
| 1855 main() {for (int index = 0; index < 10; ++i^)}'''); | 1929 main() {for (int index = 0; index < 10; ++i^)}'''); |
| 1856 computeFast(); | 1930 computeFast(); |
| 1857 return computeFull((bool result) { | 1931 return computeFull((bool result) { |
| 1932 expect(request.replacementOffset, completionOffset - 1); |
| 1933 expect(request.replacementLength, 1); |
| 1858 assertSuggestLocalVariable('index', 'int'); | 1934 assertSuggestLocalVariable('index', 'int'); |
| 1859 assertSuggestLocalFunction('main', null); | 1935 assertSuggestLocalFunction('main', null); |
| 1860 assertNotSuggested('bar'); | 1936 assertNotSuggested('bar'); |
| 1861 }); | 1937 }); |
| 1862 } | 1938 } |
| 1863 | 1939 |
| 1864 test_FunctionExpression_body_function() { | 1940 test_FunctionExpression_body_function() { |
| 1865 // Block BlockFunctionBody FunctionExpression | 1941 // Block BlockFunctionBody FunctionExpression |
| 1866 addTestSource(''' | 1942 addTestSource(''' |
| 1867 void bar() { } | 1943 void bar() { } |
| 1868 String foo(List args) {x.then((R b) {^});}'''); | 1944 String foo(List args) {x.then((R b) {^});}'''); |
| 1869 computeFast(); | 1945 computeFast(); |
| 1870 return computeFull((bool result) { | 1946 return computeFull((bool result) { |
| 1947 expect(request.replacementOffset, completionOffset); |
| 1948 expect(request.replacementLength, 0); |
| 1871 var f = assertSuggestLocalFunction('foo', 'String', false); | 1949 var f = assertSuggestLocalFunction('foo', 'String', false); |
| 1872 if (f != null) { | 1950 if (f != null) { |
| 1873 expect(f.element.isPrivate, isFalse); | 1951 expect(f.element.isPrivate, isFalse); |
| 1874 } | 1952 } |
| 1875 assertSuggestLocalFunction('bar', 'void'); | 1953 assertSuggestLocalFunction('bar', 'void'); |
| 1876 assertSuggestParameter('args', 'List'); | 1954 assertSuggestParameter('args', 'List'); |
| 1877 assertSuggestParameter('b', 'R'); | 1955 assertSuggestParameter('b', 'R'); |
| 1878 assertSuggestImportedClass('Object'); | 1956 assertSuggestImportedClass('Object'); |
| 1879 }); | 1957 }); |
| 1880 } | 1958 } |
| 1881 | 1959 |
| 1882 test_IfStatement_condition() { | 1960 test_IfStatement_condition() { |
| 1883 // SimpleIdentifier IfStatement Block BlockFunctionBody | 1961 // SimpleIdentifier IfStatement Block BlockFunctionBody |
| 1884 addTestSource(''' | 1962 addTestSource(''' |
| 1885 class A {int x; int y() => 0;} | 1963 class A {int x; int y() => 0;} |
| 1886 main(){var a; if (^)}'''); | 1964 main(){var a; if (^)}'''); |
| 1887 computeFast(); | 1965 computeFast(); |
| 1888 return computeFull((bool result) { | 1966 return computeFull((bool result) { |
| 1967 expect(request.replacementOffset, completionOffset); |
| 1968 expect(request.replacementLength, 0); |
| 1889 assertSuggestLocalVariable('a', null); | 1969 assertSuggestLocalVariable('a', null); |
| 1890 assertSuggestLocalFunction('main', null); | 1970 assertSuggestLocalFunction('main', null); |
| 1891 assertSuggestLocalClass('A'); | 1971 assertSuggestLocalClass('A'); |
| 1892 assertSuggestImportedClass('Object'); | 1972 assertSuggestImportedClass('Object'); |
| 1893 }); | 1973 }); |
| 1894 } | 1974 } |
| 1895 | 1975 |
| 1896 test_ImportDirective_dart() { | 1976 test_ImportDirective_dart() { |
| 1897 // SimpleStringLiteral ImportDirective | 1977 // SimpleStringLiteral ImportDirective |
| 1898 addTestSource(''' | 1978 addTestSource(''' |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1911 F1() { } | 1991 F1() { } |
| 1912 class A {int x;}'''); | 1992 class A {int x;}'''); |
| 1913 addTestSource(''' | 1993 addTestSource(''' |
| 1914 import "/testA.dart"; | 1994 import "/testA.dart"; |
| 1915 int T2; | 1995 int T2; |
| 1916 F2() { } | 1996 F2() { } |
| 1917 class B {int x;} | 1997 class B {int x;} |
| 1918 class C {foo(){var f; {var x;} new ^}}'''); | 1998 class C {foo(){var f; {var x;} new ^}}'''); |
| 1919 computeFast(); | 1999 computeFast(); |
| 1920 return computeFull((bool result) { | 2000 return computeFull((bool result) { |
| 2001 expect(request.replacementOffset, completionOffset); |
| 2002 expect(request.replacementLength, 0); |
| 1921 assertSuggestImportedClass('Object'); | 2003 assertSuggestImportedClass('Object'); |
| 1922 assertSuggestImportedClass('A'); | 2004 assertSuggestImportedClass('A'); |
| 1923 assertSuggestLocalClass('B'); | 2005 assertSuggestLocalClass('B'); |
| 1924 assertSuggestLocalClass('C'); | 2006 assertSuggestLocalClass('C'); |
| 1925 assertNotSuggested('f'); | 2007 assertNotSuggested('f'); |
| 1926 assertNotSuggested('x'); | 2008 assertNotSuggested('x'); |
| 1927 assertNotSuggested('foo'); | 2009 assertNotSuggested('foo'); |
| 1928 assertNotSuggested('F1'); | 2010 assertNotSuggested('F1'); |
| 1929 assertNotSuggested('F2'); | 2011 assertNotSuggested('F2'); |
| 1930 assertNotSuggested('T1'); | 2012 assertNotSuggested('T1'); |
| 1931 assertNotSuggested('T2'); | 2013 assertNotSuggested('T2'); |
| 1932 }); | 2014 }); |
| 1933 } | 2015 } |
| 1934 | 2016 |
| 1935 test_InterpolationExpression() { | 2017 test_InterpolationExpression() { |
| 1936 // SimpleIdentifier InterpolationExpression StringInterpolation | 2018 // SimpleIdentifier InterpolationExpression StringInterpolation |
| 1937 addTestSource('main() {String name; print("hello \$^");}'); | 2019 addTestSource('main() {String name; print("hello \$^");}'); |
| 1938 computeFast(); | 2020 computeFast(); |
| 1939 return computeFull((bool result) { | 2021 return computeFull((bool result) { |
| 2022 expect(request.replacementOffset, completionOffset); |
| 2023 expect(request.replacementLength, 0); |
| 1940 assertSuggestLocalVariable('name', 'String'); | 2024 assertSuggestLocalVariable('name', 'String'); |
| 1941 assertSuggestImportedClass('Object'); | 2025 assertSuggestImportedClass('Object'); |
| 1942 }); | 2026 }); |
| 1943 } | 2027 } |
| 1944 | 2028 |
| 1945 test_InterpolationExpression_block() { | 2029 test_InterpolationExpression_block() { |
| 1946 // SimpleIdentifier InterpolationExpression StringInterpolation | 2030 // SimpleIdentifier InterpolationExpression StringInterpolation |
| 1947 addTestSource('main() {String name; print("hello \${n^}");}'); | 2031 addTestSource('main() {String name; print("hello \${n^}");}'); |
| 1948 computeFast(); | 2032 computeFast(); |
| 1949 return computeFull((bool result) { | 2033 return computeFull((bool result) { |
| 1950 assertSuggestLocalVariable('name', 'String'); | 2034 assertSuggestLocalVariable('name', 'String'); |
| 1951 // top level results are partially filtered | 2035 // top level results are partially filtered |
| 1952 //assertSuggestImportedClass('Object'); | 2036 //assertSuggestImportedClass('Object'); |
| 1953 }); | 2037 }); |
| 1954 } | 2038 } |
| 1955 | 2039 |
| 1956 test_InterpolationExpression_prefix_selector() { | 2040 test_InterpolationExpression_prefix_selector() { |
| 1957 // SimpleIdentifier PrefixedIdentifier InterpolationExpression | 2041 // SimpleIdentifier PrefixedIdentifier InterpolationExpression |
| 1958 addTestSource('main() {String name; print("hello \${name.^}");}'); | 2042 addTestSource('main() {String name; print("hello \${name.^}");}'); |
| 1959 computeFast(); | 2043 computeFast(); |
| 1960 return computeFull((bool result) { | 2044 return computeFull((bool result) { |
| 2045 expect(request.replacementOffset, completionOffset); |
| 2046 expect(request.replacementLength, 0); |
| 1961 assertSuggestInvocationGetter('length', 'int'); | 2047 assertSuggestInvocationGetter('length', 'int'); |
| 1962 assertNotSuggested('name'); | 2048 assertNotSuggested('name'); |
| 1963 assertNotSuggested('Object'); | 2049 assertNotSuggested('Object'); |
| 1964 assertNotSuggested('=='); | 2050 assertNotSuggested('=='); |
| 1965 }); | 2051 }); |
| 1966 } | 2052 } |
| 1967 | 2053 |
| 1968 test_InterpolationExpression_prefix_target() { | 2054 test_InterpolationExpression_prefix_target() { |
| 1969 // SimpleIdentifier PrefixedIdentifier InterpolationExpression | 2055 // SimpleIdentifier PrefixedIdentifier InterpolationExpression |
| 1970 addTestSource('main() {String name; print("hello \${nam^e.length}");}'); | 2056 addTestSource('main() {String name; print("hello \${nam^e.length}");}'); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1982 addSource('/testB.dart', ''' | 2068 addSource('/testB.dart', ''' |
| 1983 lib B; | 2069 lib B; |
| 1984 foo() { } | 2070 foo() { } |
| 1985 class X {X.c(); X._d(); z() {}}'''); | 2071 class X {X.c(); X._d(); z() {}}'''); |
| 1986 addTestSource(''' | 2072 addTestSource(''' |
| 1987 import "/testB.dart"; | 2073 import "/testB.dart"; |
| 1988 class Y {Y.c(); Y._d(); z() {}} | 2074 class Y {Y.c(); Y._d(); z() {}} |
| 1989 main() {var x; if (x is ^) { }}'''); | 2075 main() {var x; if (x is ^) { }}'''); |
| 1990 computeFast(); | 2076 computeFast(); |
| 1991 return computeFull((bool result) { | 2077 return computeFull((bool result) { |
| 2078 expect(request.replacementOffset, completionOffset); |
| 2079 expect(request.replacementLength, 0); |
| 1992 assertSuggestImportedClass('X'); | 2080 assertSuggestImportedClass('X'); |
| 1993 assertSuggestLocalClass('Y'); | 2081 assertSuggestLocalClass('Y'); |
| 1994 assertNotSuggested('x'); | 2082 assertNotSuggested('x'); |
| 1995 assertNotSuggested('main'); | 2083 assertNotSuggested('main'); |
| 1996 assertNotSuggested('foo'); | 2084 assertNotSuggested('foo'); |
| 1997 }); | 2085 }); |
| 1998 } | 2086 } |
| 1999 | 2087 |
| 2000 test_IsExpression_target() { | 2088 test_IsExpression_target() { |
| 2001 // IfStatement Block BlockFunctionBody | 2089 // IfStatement Block BlockFunctionBody |
| 2002 addTestSource(''' | 2090 addTestSource(''' |
| 2003 foo() { } | 2091 foo() { } |
| 2004 void bar() { } | 2092 void bar() { } |
| 2005 class A {int x; int y() => 0;} | 2093 class A {int x; int y() => 0;} |
| 2006 main(){var a; if (^ is A)}'''); | 2094 main(){var a; if (^ is A)}'''); |
| 2007 computeFast(); | 2095 computeFast(); |
| 2008 return computeFull((bool result) { | 2096 return computeFull((bool result) { |
| 2097 expect(request.replacementOffset, completionOffset); |
| 2098 expect(request.replacementLength, 0); |
| 2009 assertSuggestLocalVariable('a', null); | 2099 assertSuggestLocalVariable('a', null); |
| 2010 assertSuggestLocalFunction('main', null); | 2100 assertSuggestLocalFunction('main', null); |
| 2011 assertSuggestLocalFunction('foo', null); | 2101 assertSuggestLocalFunction('foo', null); |
| 2012 assertNotSuggested('bar'); | 2102 assertNotSuggested('bar'); |
| 2013 assertSuggestLocalClass('A'); | 2103 assertSuggestLocalClass('A'); |
| 2014 assertSuggestImportedClass('Object'); | 2104 assertSuggestImportedClass('Object'); |
| 2015 }); | 2105 }); |
| 2016 } | 2106 } |
| 2017 | 2107 |
| 2018 test_IsExpression_type() { | 2108 test_IsExpression_type() { |
| 2019 // SimpleIdentifier TypeName IsExpression IfStatement | 2109 // SimpleIdentifier TypeName IsExpression IfStatement |
| 2020 addTestSource(''' | 2110 addTestSource(''' |
| 2021 class A {int x; int y() => 0;} | 2111 class A {int x; int y() => 0;} |
| 2022 main(){var a; if (a is ^)}'''); | 2112 main(){var a; if (a is ^)}'''); |
| 2023 computeFast(); | 2113 computeFast(); |
| 2024 return computeFull((bool result) { | 2114 return computeFull((bool result) { |
| 2115 expect(request.replacementOffset, completionOffset); |
| 2116 expect(request.replacementLength, 0); |
| 2025 assertNotSuggested('a'); | 2117 assertNotSuggested('a'); |
| 2026 assertNotSuggested('main'); | 2118 assertNotSuggested('main'); |
| 2027 assertSuggestLocalClass('A'); | 2119 assertSuggestLocalClass('A'); |
| 2028 assertSuggestImportedClass('Object'); | 2120 assertSuggestImportedClass('Object'); |
| 2029 }); | 2121 }); |
| 2030 } | 2122 } |
| 2031 | 2123 |
| 2032 test_IsExpression_type_partial() { | 2124 test_IsExpression_type_partial() { |
| 2033 // SimpleIdentifier TypeName IsExpression IfStatement | 2125 // SimpleIdentifier TypeName IsExpression IfStatement |
| 2034 addTestSource(''' | 2126 addTestSource(''' |
| 2035 class A {int x; int y() => 0;} | 2127 class A {int x; int y() => 0;} |
| 2036 main(){var a; if (a is Obj^)}'''); | 2128 main(){var a; if (a is Obj^)}'''); |
| 2037 computeFast(); | 2129 computeFast(); |
| 2038 return computeFull((bool result) { | 2130 return computeFull((bool result) { |
| 2131 expect(request.replacementOffset, completionOffset - 3); |
| 2132 expect(request.replacementLength, 3); |
| 2039 assertNotSuggested('a'); | 2133 assertNotSuggested('a'); |
| 2040 assertNotSuggested('main'); | 2134 assertNotSuggested('main'); |
| 2041 assertSuggestLocalClass('A'); | 2135 assertSuggestLocalClass('A'); |
| 2042 assertSuggestImportedClass('Object'); | 2136 assertSuggestImportedClass('Object'); |
| 2043 }); | 2137 }); |
| 2044 } | 2138 } |
| 2045 | 2139 |
| 2046 test_Literal_string() { | 2140 test_Literal_string() { |
| 2047 // SimpleStringLiteral ExpressionStatement Block | 2141 // SimpleStringLiteral ExpressionStatement Block |
| 2048 addTestSource('class A {a() {"hel^lo"}}'); | 2142 addTestSource('class A {a() {"hel^lo"}}'); |
| 2049 computeFast(); | 2143 computeFast(); |
| 2050 return computeFull((bool result) { | 2144 return computeFull((bool result) { |
| 2051 assertNoSuggestions(); | 2145 assertNoSuggestions(); |
| 2052 }); | 2146 }); |
| 2053 } | 2147 } |
| 2054 | 2148 |
| 2055 test_MethodDeclaration_body_getters() { | 2149 test_MethodDeclaration_body_getters() { |
| 2056 // Block BlockFunctionBody MethodDeclaration | 2150 // Block BlockFunctionBody MethodDeclaration |
| 2057 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); | 2151 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); |
| 2058 computeFast(); | 2152 computeFast(); |
| 2059 return computeFull((bool result) { | 2153 return computeFull((bool result) { |
| 2154 expect(request.replacementOffset, completionOffset); |
| 2155 expect(request.replacementLength, 0); |
| 2060 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); | 2156 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); |
| 2061 if (methodA != null) { | 2157 if (methodA != null) { |
| 2062 expect(methodA.element.isDeprecated, isFalse); | 2158 expect(methodA.element.isDeprecated, isFalse); |
| 2063 expect(methodA.element.isPrivate, isFalse); | 2159 expect(methodA.element.isPrivate, isFalse); |
| 2064 } | 2160 } |
| 2065 CompletionSuggestion getterF = assertSuggestLocalGetter( | 2161 CompletionSuggestion getterF = assertSuggestLocalGetter( |
| 2066 'f', | 2162 'f', |
| 2067 'X', | 2163 'X', |
| 2068 relevance: COMPLETION_RELEVANCE_LOW, | 2164 relevance: COMPLETION_RELEVANCE_LOW, |
| 2069 isDeprecated: true); | 2165 isDeprecated: true); |
| 2070 if (getterF != null) { | 2166 if (getterF != null) { |
| 2071 expect(getterF.element.isDeprecated, isTrue); | 2167 expect(getterF.element.isDeprecated, isTrue); |
| 2072 expect(getterF.element.isPrivate, isFalse); | 2168 expect(getterF.element.isPrivate, isFalse); |
| 2073 } | 2169 } |
| 2074 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); | 2170 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); |
| 2075 if (getterG != null) { | 2171 if (getterG != null) { |
| 2076 expect(getterG.element.isDeprecated, isFalse); | 2172 expect(getterG.element.isDeprecated, isFalse); |
| 2077 expect(getterG.element.isPrivate, isTrue); | 2173 expect(getterG.element.isPrivate, isTrue); |
| 2078 } | 2174 } |
| 2079 }); | 2175 }); |
| 2080 } | 2176 } |
| 2081 | 2177 |
| 2082 test_MethodDeclaration_members() { | 2178 test_MethodDeclaration_members() { |
| 2083 // Block BlockFunctionBody MethodDeclaration | 2179 // Block BlockFunctionBody MethodDeclaration |
| 2084 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); | 2180 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); |
| 2085 computeFast(); | 2181 computeFast(); |
| 2086 return computeFull((bool result) { | 2182 return computeFull((bool result) { |
| 2183 expect(request.replacementOffset, completionOffset); |
| 2184 expect(request.replacementLength, 0); |
| 2087 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); | 2185 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); |
| 2088 if (methodA != null) { | 2186 if (methodA != null) { |
| 2089 expect(methodA.element.isDeprecated, isFalse); | 2187 expect(methodA.element.isDeprecated, isFalse); |
| 2090 expect(methodA.element.isPrivate, isTrue); | 2188 expect(methodA.element.isPrivate, isTrue); |
| 2091 } | 2189 } |
| 2092 CompletionSuggestion getterF = assertSuggestLocalField( | 2190 CompletionSuggestion getterF = assertSuggestLocalField( |
| 2093 'f', | 2191 'f', |
| 2094 'X', | 2192 'X', |
| 2095 relevance: COMPLETION_RELEVANCE_LOW, | 2193 relevance: COMPLETION_RELEVANCE_LOW, |
| 2096 isDeprecated: true); | 2194 isDeprecated: true); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2107 } | 2205 } |
| 2108 assertSuggestImportedClass('bool'); | 2206 assertSuggestImportedClass('bool'); |
| 2109 }); | 2207 }); |
| 2110 } | 2208 } |
| 2111 | 2209 |
| 2112 test_MethodDeclaration_parameters_named() { | 2210 test_MethodDeclaration_parameters_named() { |
| 2113 // Block BlockFunctionBody MethodDeclaration | 2211 // Block BlockFunctionBody MethodDeclaration |
| 2114 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); | 2212 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); |
| 2115 computeFast(); | 2213 computeFast(); |
| 2116 return computeFull((bool result) { | 2214 return computeFull((bool result) { |
| 2215 expect(request.replacementOffset, completionOffset); |
| 2216 expect(request.replacementLength, 0); |
| 2117 CompletionSuggestion methodA = assertSuggestLocalMethod( | 2217 CompletionSuggestion methodA = assertSuggestLocalMethod( |
| 2118 'a', | 2218 'a', |
| 2119 'A', | 2219 'A', |
| 2120 'Z', | 2220 'Z', |
| 2121 relevance: COMPLETION_RELEVANCE_LOW, | 2221 relevance: COMPLETION_RELEVANCE_LOW, |
| 2122 isDeprecated: true); | 2222 isDeprecated: true); |
| 2123 if (methodA != null) { | 2223 if (methodA != null) { |
| 2124 expect(methodA.element.isDeprecated, isTrue); | 2224 expect(methodA.element.isDeprecated, isTrue); |
| 2125 expect(methodA.element.isPrivate, isFalse); | 2225 expect(methodA.element.isPrivate, isFalse); |
| 2126 } | 2226 } |
| 2127 assertSuggestParameter('x', 'X'); | 2227 assertSuggestParameter('x', 'X'); |
| 2128 assertSuggestParameter('y', null); | 2228 assertSuggestParameter('y', null); |
| 2129 assertSuggestParameter('b', null); | 2229 assertSuggestParameter('b', null); |
| 2130 assertSuggestImportedClass('int'); | 2230 assertSuggestImportedClass('int'); |
| 2131 assertNotSuggested('_'); | 2231 assertNotSuggested('_'); |
| 2132 }); | 2232 }); |
| 2133 } | 2233 } |
| 2134 | 2234 |
| 2135 test_MethodDeclaration_parameters_positional() { | 2235 test_MethodDeclaration_parameters_positional() { |
| 2136 // Block BlockFunctionBody MethodDeclaration | 2236 // Block BlockFunctionBody MethodDeclaration |
| 2137 addTestSource(''' | 2237 addTestSource(''' |
| 2138 foo() { } | 2238 foo() { } |
| 2139 void bar() { } | 2239 void bar() { } |
| 2140 class A {Z a(X x, [int y=1]) {^}}'''); | 2240 class A {Z a(X x, [int y=1]) {^}}'''); |
| 2141 computeFast(); | 2241 computeFast(); |
| 2142 return computeFull((bool result) { | 2242 return computeFull((bool result) { |
| 2243 expect(request.replacementOffset, completionOffset); |
| 2244 expect(request.replacementLength, 0); |
| 2143 assertSuggestLocalFunction('foo', null); | 2245 assertSuggestLocalFunction('foo', null); |
| 2144 assertSuggestLocalFunction('bar', 'void'); | 2246 assertSuggestLocalFunction('bar', 'void'); |
| 2145 assertSuggestLocalMethod('a', 'A', 'Z'); | 2247 assertSuggestLocalMethod('a', 'A', 'Z'); |
| 2146 assertSuggestParameter('x', 'X'); | 2248 assertSuggestParameter('x', 'X'); |
| 2147 assertSuggestParameter('y', 'int'); | 2249 assertSuggestParameter('y', 'int'); |
| 2148 assertSuggestImportedClass('String'); | 2250 assertSuggestImportedClass('String'); |
| 2149 }); | 2251 }); |
| 2150 } | 2252 } |
| 2151 | 2253 |
| 2152 test_MethodInvocation_no_semicolon() { | 2254 test_MethodInvocation_no_semicolon() { |
| 2153 // MethodInvocation ExpressionStatement Block | 2255 // MethodInvocation ExpressionStatement Block |
| 2154 addTestSource(''' | 2256 addTestSource(''' |
| 2155 main() { } | 2257 main() { } |
| 2156 class I {X get f => new A();get _g => new A();} | 2258 class I {X get f => new A();get _g => new A();} |
| 2157 class A implements I { | 2259 class A implements I { |
| 2158 var b; X _c; | 2260 var b; X _c; |
| 2159 X get d => new A();get _e => new A(); | 2261 X get d => new A();get _e => new A(); |
| 2160 // no semicolon between completion point and next statement | 2262 // no semicolon between completion point and next statement |
| 2161 set s1(I x) {} set _s2(I x) {x.^ m(null);} | 2263 set s1(I x) {} set _s2(I x) {x.^ m(null);} |
| 2162 m(X x) {} I _n(X x) {}} | 2264 m(X x) {} I _n(X x) {}} |
| 2163 class X{}'''); | 2265 class X{}'''); |
| 2164 computeFast(); | 2266 computeFast(); |
| 2165 return computeFull((bool result) { | 2267 return computeFull((bool result) { |
| 2268 expect(request.replacementOffset, completionOffset); |
| 2269 expect(request.replacementLength, 0); |
| 2166 assertSuggestInvocationGetter('f', 'X'); | 2270 assertSuggestInvocationGetter('f', 'X'); |
| 2167 assertSuggestInvocationGetter('_g', null); | 2271 assertSuggestInvocationGetter('_g', null); |
| 2168 assertNotSuggested('b'); | 2272 assertNotSuggested('b'); |
| 2169 assertNotSuggested('_c'); | 2273 assertNotSuggested('_c'); |
| 2170 assertNotSuggested('d'); | 2274 assertNotSuggested('d'); |
| 2171 assertNotSuggested('_e'); | 2275 assertNotSuggested('_e'); |
| 2172 assertNotSuggested('s1'); | 2276 assertNotSuggested('s1'); |
| 2173 assertNotSuggested('_s2'); | 2277 assertNotSuggested('_s2'); |
| 2174 assertNotSuggested('m'); | 2278 assertNotSuggested('m'); |
| 2175 assertNotSuggested('_n'); | 2279 assertNotSuggested('_n'); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2193 import "/testB.dart"; | 2297 import "/testB.dart"; |
| 2194 part "$testFile"; | 2298 part "$testFile"; |
| 2195 class A { } | 2299 class A { } |
| 2196 var m;'''); | 2300 var m;'''); |
| 2197 addTestSource(''' | 2301 addTestSource(''' |
| 2198 part of libA; | 2302 part of libA; |
| 2199 class B { } | 2303 class B { } |
| 2200 main() {new ^}'''); | 2304 main() {new ^}'''); |
| 2201 computeFast(); | 2305 computeFast(); |
| 2202 return computeFull((bool result) { | 2306 return computeFull((bool result) { |
| 2307 expect(request.replacementOffset, completionOffset); |
| 2308 expect(request.replacementLength, 0); |
| 2203 assertSuggestLocalClass('B'); | 2309 assertSuggestLocalClass('B'); |
| 2204 assertSuggestImportedClass('Object'); | 2310 assertSuggestImportedClass('Object'); |
| 2205 assertSuggestImportedClass('X'); | 2311 assertSuggestImportedClass('X'); |
| 2206 assertSuggestNonLocalClass('A'); | 2312 assertSuggestNonLocalClass('A'); |
| 2207 assertNotSuggested('F1'); | 2313 assertNotSuggested('F1'); |
| 2208 assertNotSuggested('T1'); | 2314 assertNotSuggested('T1'); |
| 2209 assertNotSuggested('_d'); | 2315 assertNotSuggested('_d'); |
| 2210 assertNotSuggested('z'); | 2316 assertNotSuggested('z'); |
| 2211 assertNotSuggested('m'); | 2317 assertNotSuggested('m'); |
| 2212 }); | 2318 }); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2224 class B { }'''); | 2330 class B { }'''); |
| 2225 addTestSource(''' | 2331 addTestSource(''' |
| 2226 library libA; | 2332 library libA; |
| 2227 import "/testB.dart"; | 2333 import "/testB.dart"; |
| 2228 part "/testA.dart"; | 2334 part "/testA.dart"; |
| 2229 class A { } | 2335 class A { } |
| 2230 main() {new ^} | 2336 main() {new ^} |
| 2231 var m;'''); | 2337 var m;'''); |
| 2232 computeFast(); | 2338 computeFast(); |
| 2233 return computeFull((bool result) { | 2339 return computeFull((bool result) { |
| 2340 expect(request.replacementOffset, completionOffset); |
| 2341 expect(request.replacementLength, 0); |
| 2234 assertSuggestLocalClass('A'); | 2342 assertSuggestLocalClass('A'); |
| 2235 assertSuggestImportedClass('Object'); | 2343 assertSuggestImportedClass('Object'); |
| 2236 assertSuggestImportedClass('X'); | 2344 assertSuggestImportedClass('X'); |
| 2237 assertSuggestNonLocalClass('B'); | 2345 assertSuggestNonLocalClass('B'); |
| 2238 assertNotSuggested('F1'); | 2346 assertNotSuggested('F1'); |
| 2239 assertNotSuggested('T1'); | 2347 assertNotSuggested('T1'); |
| 2240 assertNotSuggested('_d'); | 2348 assertNotSuggested('_d'); |
| 2241 assertNotSuggested('z'); | 2349 assertNotSuggested('z'); |
| 2242 assertNotSuggested('m'); | 2350 assertNotSuggested('m'); |
| 2243 }); | 2351 }); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2259 m(X x) {} I _n(X x) {}} | 2367 m(X x) {} I _n(X x) {}} |
| 2260 class X{}'''); | 2368 class X{}'''); |
| 2261 addTestSource(''' | 2369 addTestSource(''' |
| 2262 import "/testB.dart"; | 2370 import "/testB.dart"; |
| 2263 class A extends B { | 2371 class A extends B { |
| 2264 static const String scA = 'foo'; | 2372 static const String scA = 'foo'; |
| 2265 w() { }} | 2373 w() { }} |
| 2266 main() {A.^}'''); | 2374 main() {A.^}'''); |
| 2267 computeFast(); | 2375 computeFast(); |
| 2268 return computeFull((bool result) { | 2376 return computeFull((bool result) { |
| 2377 expect(request.replacementOffset, completionOffset); |
| 2378 expect(request.replacementLength, 0); |
| 2269 assertSuggestInvocationField('scA', 'String'); | 2379 assertSuggestInvocationField('scA', 'String'); |
| 2270 assertSuggestInvocationField('scB', 'int'); | 2380 assertSuggestInvocationField('scB', 'int'); |
| 2271 assertSuggestInvocationField('scI', null); | 2381 assertSuggestInvocationField('scI', null); |
| 2272 assertNotSuggested('b'); | 2382 assertNotSuggested('b'); |
| 2273 assertNotSuggested('_c'); | 2383 assertNotSuggested('_c'); |
| 2274 assertNotSuggested('d'); | 2384 assertNotSuggested('d'); |
| 2275 assertNotSuggested('_e'); | 2385 assertNotSuggested('_e'); |
| 2276 assertNotSuggested('f'); | 2386 assertNotSuggested('f'); |
| 2277 assertNotSuggested('_g'); | 2387 assertNotSuggested('_g'); |
| 2278 assertNotSuggested('s1'); | 2388 assertNotSuggested('s1'); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2298 @deprecated var b; X _c; | 2408 @deprecated var b; X _c; |
| 2299 X get d => new A();get _e => new A(); | 2409 X get d => new A();get _e => new A(); |
| 2300 set s1(I x) {} set _s2(I x) {} | 2410 set s1(I x) {} set _s2(I x) {} |
| 2301 m(X x) {} I _n(X x) {}} | 2411 m(X x) {} I _n(X x) {}} |
| 2302 class X{}'''); | 2412 class X{}'''); |
| 2303 addTestSource(''' | 2413 addTestSource(''' |
| 2304 import "/testB.dart"; | 2414 import "/testB.dart"; |
| 2305 main() {A a; a.^}'''); | 2415 main() {A a; a.^}'''); |
| 2306 computeFast(); | 2416 computeFast(); |
| 2307 return computeFull((bool result) { | 2417 return computeFull((bool result) { |
| 2418 expect(request.replacementOffset, completionOffset); |
| 2419 expect(request.replacementLength, 0); |
| 2308 assertSuggestInvocationField('sc', 'int'); | 2420 assertSuggestInvocationField('sc', 'int'); |
| 2309 assertSuggestInvocationField('b', null, isDeprecated: true); | 2421 assertSuggestInvocationField('b', null, isDeprecated: true); |
| 2310 assertNotSuggested('_c'); | 2422 assertNotSuggested('_c'); |
| 2311 assertSuggestInvocationGetter('d', 'X'); | 2423 assertSuggestInvocationGetter('d', 'X'); |
| 2312 assertNotSuggested('_e'); | 2424 assertNotSuggested('_e'); |
| 2313 assertSuggestInvocationGetter('f', 'X'); | 2425 assertSuggestInvocationGetter('f', 'X'); |
| 2314 assertNotSuggested('_g'); | 2426 assertNotSuggested('_g'); |
| 2315 assertSuggestInvocationSetter('s1'); | 2427 assertSuggestInvocationSetter('s1'); |
| 2316 assertNotSuggested('_s2'); | 2428 assertNotSuggested('_s2'); |
| 2317 assertSuggestInvocationMethod('m', 'A', null); | 2429 assertSuggestInvocationMethod('m', 'A', null); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2331 class I {X get f => new A();get _g => new A();} | 2443 class I {X get f => new A();get _g => new A();} |
| 2332 class A implements I { | 2444 class A implements I { |
| 2333 static const int sc = 12; | 2445 static const int sc = 12; |
| 2334 var b; X _c; | 2446 var b; X _c; |
| 2335 X get d => new A();get _e => new A(); | 2447 X get d => new A();get _e => new A(); |
| 2336 set s1(I x) {} set _s2(I x) {} | 2448 set s1(I x) {} set _s2(I x) {} |
| 2337 m(X x) {} I _n(X x) {}} | 2449 m(X x) {} I _n(X x) {}} |
| 2338 class X{}'''); | 2450 class X{}'''); |
| 2339 computeFast(); | 2451 computeFast(); |
| 2340 return computeFull((bool result) { | 2452 return computeFull((bool result) { |
| 2453 expect(request.replacementOffset, completionOffset); |
| 2454 expect(request.replacementLength, 0); |
| 2341 assertSuggestInvocationField('sc', 'int'); | 2455 assertSuggestInvocationField('sc', 'int'); |
| 2342 assertSuggestInvocationField('b', null); | 2456 assertSuggestInvocationField('b', null); |
| 2343 assertSuggestInvocationField('_c', 'X'); | 2457 assertSuggestInvocationField('_c', 'X'); |
| 2344 assertSuggestInvocationGetter('d', 'X'); | 2458 assertSuggestInvocationGetter('d', 'X'); |
| 2345 assertSuggestInvocationGetter('_e', null); | 2459 assertSuggestInvocationGetter('_e', null); |
| 2346 assertSuggestInvocationGetter('f', 'X'); | 2460 assertSuggestInvocationGetter('f', 'X'); |
| 2347 assertSuggestInvocationGetter('_g', null); | 2461 assertSuggestInvocationGetter('_g', null); |
| 2348 assertSuggestInvocationSetter('s1'); | 2462 assertSuggestInvocationSetter('s1'); |
| 2349 assertSuggestInvocationSetter('_s2'); | 2463 assertSuggestInvocationSetter('_s2'); |
| 2350 assertSuggestInvocationMethod('m', 'A', null); | 2464 assertSuggestInvocationMethod('m', 'A', null); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2364 var T1; | 2478 var T1; |
| 2365 class X { } | 2479 class X { } |
| 2366 class Y { }'''); | 2480 class Y { }'''); |
| 2367 addTestSource(''' | 2481 addTestSource(''' |
| 2368 import "/testB.dart" as b; | 2482 import "/testB.dart" as b; |
| 2369 var T2; | 2483 var T2; |
| 2370 class A { } | 2484 class A { } |
| 2371 main() {b.^}'''); | 2485 main() {b.^}'''); |
| 2372 computeFast(); | 2486 computeFast(); |
| 2373 return computeFull((bool result) { | 2487 return computeFull((bool result) { |
| 2488 expect(request.replacementOffset, completionOffset); |
| 2489 expect(request.replacementLength, 0); |
| 2374 assertSuggestInvocationClass('X'); | 2490 assertSuggestInvocationClass('X'); |
| 2375 assertSuggestInvocationClass('Y'); | 2491 assertSuggestInvocationClass('Y'); |
| 2376 assertSuggestInvocationTopLevelVar('T1', null); | 2492 assertSuggestInvocationTopLevelVar('T1', null); |
| 2377 assertNotSuggested('T2'); | 2493 assertNotSuggested('T2'); |
| 2378 assertNotSuggested('Object'); | 2494 assertNotSuggested('Object'); |
| 2379 assertNotSuggested('b'); | 2495 assertNotSuggested('b'); |
| 2380 assertNotSuggested('A'); | 2496 assertNotSuggested('A'); |
| 2381 assertNotSuggested('=='); | 2497 assertNotSuggested('=='); |
| 2382 }); | 2498 }); |
| 2383 } | 2499 } |
| 2384 | 2500 |
| 2385 test_PrefixedIdentifier_parameter() { | 2501 test_PrefixedIdentifier_parameter() { |
| 2386 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 2502 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2387 addSource('/testB.dart', ''' | 2503 addSource('/testB.dart', ''' |
| 2388 lib B; | 2504 lib B; |
| 2389 class _W {M y; var _z;} | 2505 class _W {M y; var _z;} |
| 2390 class X extends _W {} | 2506 class X extends _W {} |
| 2391 class M{}'''); | 2507 class M{}'''); |
| 2392 addTestSource(''' | 2508 addTestSource(''' |
| 2393 import "/testB.dart"; | 2509 import "/testB.dart"; |
| 2394 foo(X x) {x.^}'''); | 2510 foo(X x) {x.^}'''); |
| 2395 computeFast(); | 2511 computeFast(); |
| 2396 return computeFull((bool result) { | 2512 return computeFull((bool result) { |
| 2513 expect(request.replacementOffset, completionOffset); |
| 2514 expect(request.replacementLength, 0); |
| 2397 assertSuggestInvocationField('y', 'M'); | 2515 assertSuggestInvocationField('y', 'M'); |
| 2398 assertNotSuggested('_z'); | 2516 assertNotSuggested('_z'); |
| 2399 assertNotSuggested('=='); | 2517 assertNotSuggested('=='); |
| 2400 }); | 2518 }); |
| 2401 } | 2519 } |
| 2402 | 2520 |
| 2403 test_PrefixedIdentifier_prefix() { | 2521 test_PrefixedIdentifier_prefix() { |
| 2404 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 2522 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2405 addSource('/testA.dart', ''' | 2523 addSource('/testA.dart', ''' |
| 2406 class A {static int bar = 10;} | 2524 class A {static int bar = 10;} |
| 2407 _B() {}'''); | 2525 _B() {}'''); |
| 2408 addTestSource(''' | 2526 addTestSource(''' |
| 2409 import "/testA.dart"; | 2527 import "/testA.dart"; |
| 2410 class X {foo(){A^.bar}}'''); | 2528 class X {foo(){A^.bar}}'''); |
| 2411 computeFast(); | 2529 computeFast(); |
| 2412 return computeFull((bool result) { | 2530 return computeFull((bool result) { |
| 2531 expect(request.replacementOffset, completionOffset - 1); |
| 2532 expect(request.replacementLength, 1); |
| 2413 assertSuggestImportedClass('A'); | 2533 assertSuggestImportedClass('A'); |
| 2414 assertSuggestLocalClass('X'); | 2534 assertSuggestLocalClass('X'); |
| 2415 assertSuggestLocalMethod('foo', 'X', null); | 2535 assertSuggestLocalMethod('foo', 'X', null); |
| 2416 assertNotSuggested('bar'); | 2536 assertNotSuggested('bar'); |
| 2417 assertNotSuggested('_B'); | 2537 assertNotSuggested('_B'); |
| 2418 }); | 2538 }); |
| 2419 } | 2539 } |
| 2420 | 2540 |
| 2421 test_PrefixedIdentifier_propertyAccess() { | 2541 test_PrefixedIdentifier_propertyAccess() { |
| 2422 // PrefixedIdentifier ExpressionStatement Block BlockFunctionBody | 2542 // PrefixedIdentifier ExpressionStatement Block BlockFunctionBody |
| 2423 addTestSource('class A {String x; int get foo {x.^}'); | 2543 addTestSource('class A {String x; int get foo {x.^}'); |
| 2424 computeFast(); | 2544 computeFast(); |
| 2425 return computeFull((bool result) { | 2545 return computeFull((bool result) { |
| 2546 expect(request.replacementOffset, completionOffset); |
| 2547 expect(request.replacementLength, 0); |
| 2426 assertSuggestInvocationGetter('isEmpty', 'bool'); | 2548 assertSuggestInvocationGetter('isEmpty', 'bool'); |
| 2427 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); | 2549 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); |
| 2428 }); | 2550 }); |
| 2429 } | 2551 } |
| 2430 | 2552 |
| 2431 test_PrefixedIdentifier_propertyAccess_newStmt() { | 2553 test_PrefixedIdentifier_propertyAccess_newStmt() { |
| 2432 // PrefixedIdentifier ExpressionStatement Block BlockFunctionBody | 2554 // PrefixedIdentifier ExpressionStatement Block BlockFunctionBody |
| 2433 addTestSource('class A {String x; int get foo {x.^ int y = 0;}'); | 2555 addTestSource('class A {String x; int get foo {x.^ int y = 0;}'); |
| 2434 computeFast(); | 2556 computeFast(); |
| 2435 return computeFull((bool result) { | 2557 return computeFull((bool result) { |
| 2558 expect(request.replacementOffset, completionOffset); |
| 2559 expect(request.replacementLength, 0); |
| 2436 assertSuggestInvocationGetter('isEmpty', 'bool'); | 2560 assertSuggestInvocationGetter('isEmpty', 'bool'); |
| 2437 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); | 2561 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); |
| 2438 }); | 2562 }); |
| 2439 } | 2563 } |
| 2440 | 2564 |
| 2441 test_PropertyAccess_expression() { | 2565 test_PropertyAccess_expression() { |
| 2442 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement | 2566 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement |
| 2443 addTestSource('class A {a() {"hello".to^String().length}}'); | 2567 addTestSource('class A {a() {"hello".to^String().length}}'); |
| 2444 computeFast(); | 2568 computeFast(); |
| 2445 return computeFull((bool result) { | 2569 return computeFull((bool result) { |
| 2570 expect(request.replacementOffset, completionOffset - 2); |
| 2571 expect(request.replacementLength, 8); |
| 2446 assertSuggestInvocationGetter('length', 'int'); | 2572 assertSuggestInvocationGetter('length', 'int'); |
| 2447 assertNotSuggested('A'); | 2573 assertNotSuggested('A'); |
| 2448 assertNotSuggested('a'); | 2574 assertNotSuggested('a'); |
| 2449 assertNotSuggested('Object'); | 2575 assertNotSuggested('Object'); |
| 2450 assertNotSuggested('=='); | 2576 assertNotSuggested('=='); |
| 2451 }); | 2577 }); |
| 2452 } | 2578 } |
| 2453 | 2579 |
| 2454 test_PropertyAccess_selector() { | 2580 test_PropertyAccess_selector() { |
| 2455 // SimpleIdentifier PropertyAccess ExpressionStatement Block | 2581 // SimpleIdentifier PropertyAccess ExpressionStatement Block |
| 2456 addTestSource('class A {a() {"hello".length.^}}'); | 2582 addTestSource('class A {a() {"hello".length.^}}'); |
| 2457 computeFast(); | 2583 computeFast(); |
| 2458 return computeFull((bool result) { | 2584 return computeFull((bool result) { |
| 2585 expect(request.replacementOffset, completionOffset); |
| 2586 expect(request.replacementLength, 0); |
| 2459 assertSuggestInvocationGetter('isEven', 'bool'); | 2587 assertSuggestInvocationGetter('isEven', 'bool'); |
| 2460 assertNotSuggested('A'); | 2588 assertNotSuggested('A'); |
| 2461 assertNotSuggested('a'); | 2589 assertNotSuggested('a'); |
| 2462 assertNotSuggested('Object'); | 2590 assertNotSuggested('Object'); |
| 2463 assertNotSuggested('=='); | 2591 assertNotSuggested('=='); |
| 2464 }); | 2592 }); |
| 2465 } | 2593 } |
| 2466 | 2594 |
| 2467 test_ThisExpression_block() { | 2595 test_ThisExpression_block() { |
| 2468 // MethodInvocation ExpressionStatement Block | 2596 // MethodInvocation ExpressionStatement Block |
| 2469 addTestSource(''' | 2597 addTestSource(''' |
| 2470 main() { } | 2598 main() { } |
| 2471 class I {X get f => new A();get _g => new A();} | 2599 class I {X get f => new A();get _g => new A();} |
| 2472 class A implements I { | 2600 class A implements I { |
| 2473 A() {} | 2601 A() {} |
| 2474 A.z() {} | 2602 A.z() {} |
| 2475 var b; X _c; | 2603 var b; X _c; |
| 2476 X get d => new A();get _e => new A(); | 2604 X get d => new A();get _e => new A(); |
| 2477 // no semicolon between completion point and next statement | 2605 // no semicolon between completion point and next statement |
| 2478 set s1(I x) {} set _s2(I x) {this.^ m(null);} | 2606 set s1(I x) {} set _s2(I x) {this.^ m(null);} |
| 2479 m(X x) {} I _n(X x) {}} | 2607 m(X x) {} I _n(X x) {}} |
| 2480 class X{}'''); | 2608 class X{}'''); |
| 2481 computeFast(); | 2609 computeFast(); |
| 2482 return computeFull((bool result) { | 2610 return computeFull((bool result) { |
| 2611 expect(request.replacementOffset, completionOffset); |
| 2612 expect(request.replacementLength, 0); |
| 2483 assertSuggestInvocationField('b', null); | 2613 assertSuggestInvocationField('b', null); |
| 2484 assertSuggestInvocationField('_c', 'X'); | 2614 assertSuggestInvocationField('_c', 'X'); |
| 2485 assertSuggestInvocationGetter('d', 'X'); | 2615 assertSuggestInvocationGetter('d', 'X'); |
| 2486 assertSuggestInvocationGetter('_e', null); | 2616 assertSuggestInvocationGetter('_e', null); |
| 2487 assertSuggestInvocationGetter('f', 'X'); | 2617 assertSuggestInvocationGetter('f', 'X'); |
| 2488 assertSuggestInvocationGetter('_g', null); | 2618 assertSuggestInvocationGetter('_g', null); |
| 2489 assertSuggestInvocationMethod('m', 'A', null); | 2619 assertSuggestInvocationMethod('m', 'A', null); |
| 2490 assertSuggestInvocationMethod('_n', 'A', 'I'); | 2620 assertSuggestInvocationMethod('_n', 'A', 'I'); |
| 2491 assertSuggestInvocationSetter('s1'); | 2621 assertSuggestInvocationSetter('s1'); |
| 2492 assertSuggestInvocationSetter('_s2'); | 2622 assertSuggestInvocationSetter('_s2'); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2508 A() {this.^} | 2638 A() {this.^} |
| 2509 A.z() {} | 2639 A.z() {} |
| 2510 var b; X _c; | 2640 var b; X _c; |
| 2511 X get d => new A();get _e => new A(); | 2641 X get d => new A();get _e => new A(); |
| 2512 // no semicolon between completion point and next statement | 2642 // no semicolon between completion point and next statement |
| 2513 set s1(I x) {} set _s2(I x) {m(null);} | 2643 set s1(I x) {} set _s2(I x) {m(null);} |
| 2514 m(X x) {} I _n(X x) {}} | 2644 m(X x) {} I _n(X x) {}} |
| 2515 class X{}'''); | 2645 class X{}'''); |
| 2516 computeFast(); | 2646 computeFast(); |
| 2517 return computeFull((bool result) { | 2647 return computeFull((bool result) { |
| 2648 expect(request.replacementOffset, completionOffset); |
| 2649 expect(request.replacementLength, 0); |
| 2518 assertSuggestInvocationField('b', null); | 2650 assertSuggestInvocationField('b', null); |
| 2519 assertSuggestInvocationField('_c', 'X'); | 2651 assertSuggestInvocationField('_c', 'X'); |
| 2520 assertSuggestInvocationGetter('d', 'X'); | 2652 assertSuggestInvocationGetter('d', 'X'); |
| 2521 assertSuggestInvocationGetter('_e', null); | 2653 assertSuggestInvocationGetter('_e', null); |
| 2522 assertSuggestInvocationGetter('f', 'X'); | 2654 assertSuggestInvocationGetter('f', 'X'); |
| 2523 assertSuggestInvocationGetter('_g', null); | 2655 assertSuggestInvocationGetter('_g', null); |
| 2524 assertSuggestInvocationMethod('m', 'A', null); | 2656 assertSuggestInvocationMethod('m', 'A', null); |
| 2525 assertSuggestInvocationMethod('_n', 'A', 'I'); | 2657 assertSuggestInvocationMethod('_n', 'A', 'I'); |
| 2526 assertSuggestInvocationSetter('s1'); | 2658 assertSuggestInvocationSetter('s1'); |
| 2527 assertSuggestInvocationSetter('_s2'); | 2659 assertSuggestInvocationSetter('_s2'); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2579 lib B; | 2711 lib B; |
| 2580 foo() { } | 2712 foo() { } |
| 2581 class _B { } | 2713 class _B { } |
| 2582 class X {X.c(); X._d(); z() {}}'''); | 2714 class X {X.c(); X._d(); z() {}}'''); |
| 2583 addTestSource(''' | 2715 addTestSource(''' |
| 2584 import "/testB.dart"; | 2716 import "/testB.dart"; |
| 2585 class Y {Y.c(); Y._d(); z() {}} | 2717 class Y {Y.c(); Y._d(); z() {}} |
| 2586 class C {bar(){var f; {var x;} var e = ^}}'''); | 2718 class C {bar(){var f; {var x;} var e = ^}}'''); |
| 2587 computeFast(); | 2719 computeFast(); |
| 2588 return computeFull((bool result) { | 2720 return computeFull((bool result) { |
| 2721 expect(request.replacementOffset, completionOffset); |
| 2722 expect(request.replacementLength, 0); |
| 2589 assertSuggestImportedClass('X'); | 2723 assertSuggestImportedClass('X'); |
| 2590 assertNotSuggested('_B'); | 2724 assertNotSuggested('_B'); |
| 2591 assertSuggestLocalClass('Y'); | 2725 assertSuggestLocalClass('Y'); |
| 2592 assertSuggestLocalClass('C'); | 2726 assertSuggestLocalClass('C'); |
| 2593 assertSuggestLocalVariable('f', null); | 2727 assertSuggestLocalVariable('f', null); |
| 2594 assertNotSuggested('x'); | 2728 assertNotSuggested('x'); |
| 2595 assertNotSuggested('e'); | 2729 assertNotSuggested('e'); |
| 2596 }); | 2730 }); |
| 2597 } | 2731 } |
| 2598 | 2732 |
| 2599 test_VariableDeclarationStatement_RHS_missing_semicolon() { | 2733 test_VariableDeclarationStatement_RHS_missing_semicolon() { |
| 2600 // VariableDeclaration VariableDeclarationList | 2734 // VariableDeclaration VariableDeclarationList |
| 2601 // VariableDeclarationStatement | 2735 // VariableDeclarationStatement |
| 2602 addSource('/testB.dart', ''' | 2736 addSource('/testB.dart', ''' |
| 2603 lib B; | 2737 lib B; |
| 2604 foo1() { } | 2738 foo1() { } |
| 2605 void bar1() { } | 2739 void bar1() { } |
| 2606 class _B { } | 2740 class _B { } |
| 2607 class X {X.c(); X._d(); z() {}}'''); | 2741 class X {X.c(); X._d(); z() {}}'''); |
| 2608 addTestSource(''' | 2742 addTestSource(''' |
| 2609 import "/testB.dart"; | 2743 import "/testB.dart"; |
| 2610 foo2() { } | 2744 foo2() { } |
| 2611 void bar2() { } | 2745 void bar2() { } |
| 2612 class Y {Y.c(); Y._d(); z() {}} | 2746 class Y {Y.c(); Y._d(); z() {}} |
| 2613 class C {bar(){var f; {var x;} var e = ^ var g}}'''); | 2747 class C {bar(){var f; {var x;} var e = ^ var g}}'''); |
| 2614 computeFast(); | 2748 computeFast(); |
| 2615 return computeFull((bool result) { | 2749 return computeFull((bool result) { |
| 2750 expect(request.replacementOffset, completionOffset); |
| 2751 expect(request.replacementLength, 0); |
| 2616 assertSuggestImportedClass('X'); | 2752 assertSuggestImportedClass('X'); |
| 2617 assertSuggestImportedFunction('foo1', null); | 2753 assertSuggestImportedFunction('foo1', null); |
| 2618 assertNotSuggested('bar1'); | 2754 assertNotSuggested('bar1'); |
| 2619 assertSuggestLocalFunction('foo2', null); | 2755 assertSuggestLocalFunction('foo2', null); |
| 2620 assertNotSuggested('bar2'); | 2756 assertNotSuggested('bar2'); |
| 2621 assertNotSuggested('_B'); | 2757 assertNotSuggested('_B'); |
| 2622 assertSuggestLocalClass('Y'); | 2758 assertSuggestLocalClass('Y'); |
| 2623 assertSuggestLocalClass('C'); | 2759 assertSuggestLocalClass('C'); |
| 2624 assertSuggestLocalVariable('f', null); | 2760 assertSuggestLocalVariable('f', null); |
| 2625 assertNotSuggested('x'); | 2761 assertNotSuggested('x'); |
| 2626 assertNotSuggested('e'); | 2762 assertNotSuggested('e'); |
| 2627 }); | 2763 }); |
| 2628 } | 2764 } |
| 2629 } | 2765 } |
| OLD | NEW |