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

Side by Side Diff: pkg/analysis_server/test/services/completion/completion_test_util.dart

Issue 802233002: refine when suggestions are limited to types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and address comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/completion_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.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;
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 assertSuggestLocalVariable('a', 'int'); 923 assertSuggestLocalVariable('a', 'int');
924 assertSuggestLocalFunction('main', null); 924 assertSuggestLocalFunction('main', null);
925 assertSuggestLocalClass('A'); 925 assertSuggestLocalClass('A');
926 assertSuggestImportedClass('Object'); 926 assertSuggestImportedClass('Object');
927 }); 927 });
928 } 928 }
929 929
930 test_AssignmentExpression_type() { 930 test_AssignmentExpression_type() {
931 // SimpleIdentifier TypeName VariableDeclarationList 931 // SimpleIdentifier TypeName VariableDeclarationList
932 // VariableDeclarationStatement Block 932 // VariableDeclarationStatement Block
933 addTestSource('class A {} main() {int a; int^ b = 1;}'); 933 addTestSource('''
934 class A {} main() {
935 int a;
936 ^ b = 1;}''');
934 computeFast(); 937 computeFast();
935 return computeFull((bool result) { 938 return computeFull((bool result) {
936 assertSuggestLocalClass('A'); 939 assertSuggestLocalClass('A');
937 assertSuggestImportedClass('int'); 940 assertSuggestImportedClass('int');
938 assertNotSuggested('a'); 941 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS
939 assertNotSuggested('main'); 942 // the user may be either (1) entering a type for the assignment
943 // or (2) starting a new statement.
944 // Consider suggesting only types
945 // if only spaces separates the 1st and 2nd identifiers.
946 //assertNotSuggested('a');
947 //assertNotSuggested('main');
948 //assertNotSuggested('identical');
940 }); 949 });
941 } 950 }
942 951
952 test_AssignmentExpression_type_partial() {
953 // SimpleIdentifier TypeName VariableDeclarationList
954 // VariableDeclarationStatement Block
955 addTestSource('''
956 class A {} main() {
957 int a;
958 int^ b = 1;}''');
959 computeFast();
960 return computeFull((bool result) {
961 assertSuggestLocalClass('A');
962 assertSuggestImportedClass('int');
963 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS
964 // the user may be either (1) entering a type for the assignment
965 // or (2) starting a new statement.
966 // Consider suggesting only types
967 // if only spaces separates the 1st and 2nd identifiers.
968 //assertNotSuggested('a');
969 //assertNotSuggested('main');
970 //assertNotSuggested('identical');
971 });
972 }
973
974 test_AssignmentExpression_type_newline() {
975 // SimpleIdentifier TypeName VariableDeclarationList
976 // VariableDeclarationStatement Block
977 addTestSource('''
978 class A {} main() {
979 int a;
980 ^
981 b = 1;}''');
982 computeFast();
983 return computeFull((bool result) {
984 assertSuggestLocalClass('A');
985 assertSuggestImportedClass('int');
986 // Allow non-types preceding an identifier on LHS of assignment
987 // if newline follows first identifier
988 // because user is probably starting a new statement
989 assertSuggestLocalVariable('a', 'int');
990 assertSuggestLocalFunction('main', null);
991 assertSuggestImportedFunction('identical', 'bool');
992 });
993 }
994
995 test_AssignmentExpression_type_partial_newline() {
996 // SimpleIdentifier TypeName VariableDeclarationList
997 // VariableDeclarationStatement Block
998 addTestSource('''
999 class A {} main() {
1000 int a;
1001 i^
1002 b = 1;}''');
1003 computeFast();
1004 return computeFull((bool result) {
1005 assertSuggestLocalClass('A');
1006 assertSuggestImportedClass('int');
1007 // Allow non-types preceding an identifier on LHS of assignment
1008 // if newline follows first identifier
1009 // because user is probably starting a new statement
1010 assertSuggestLocalVariable('a', 'int');
1011 assertSuggestLocalFunction('main', null);
1012 assertSuggestImportedFunction('identical', 'bool');
1013 });
1014 }
1015
943 test_AwaitExpression() { 1016 test_AwaitExpression() {
944 // SimpleIdentifier AwaitExpression ExpressionStatement 1017 // SimpleIdentifier AwaitExpression ExpressionStatement
945 addTestSource(''' 1018 addTestSource('''
946 class A {int x; int y() => 0;} 1019 class A {int x; int y() => 0;}
947 main(){A a; await ^}'''); 1020 main(){A a; await ^}''');
948 computeFast(); 1021 computeFast();
949 return computeFull((bool result) { 1022 return computeFull((bool result) {
950 assertSuggestLocalVariable('a', 'A'); 1023 assertSuggestLocalVariable('a', 'A');
951 assertSuggestLocalFunction('main', null); 1024 assertSuggestLocalFunction('main', null);
952 assertSuggestLocalClass('A'); 1025 assertSuggestLocalClass('A');
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 assertSuggestLocalVariable('f', null); 1100 assertSuggestLocalVariable('f', null);
1028 // Don't suggest locals out of scope 1101 // Don't suggest locals out of scope
1029 assertNotSuggested('r'); 1102 assertNotSuggested('r');
1030 assertNotSuggested('x'); 1103 assertNotSuggested('x');
1031 1104
1032 assertSuggestImportedClass('A'); 1105 assertSuggestImportedClass('A');
1033 assertNotSuggested('_B'); 1106 assertNotSuggested('_B');
1034 assertSuggestImportedClass('C'); 1107 assertSuggestImportedClass('C');
1035 // hidden element suggested as low relevance 1108 // hidden element suggested as low relevance
1036 // but imported results are partially filtered 1109 // but imported results are partially filtered
1037 //assertSuggestImportedClass('D', CompletionRelevance.LOW) 1110 //assertSuggestImportedClass('D', CompletionRelevance.LOW);
1038 //assertSuggestImportedFunction( 1111 //assertSuggestImportedFunction(
1039 // 'D1', null, true, CompletionRelevance.LOW); 1112 // 'D1', null, true, CompletionRelevance.LOW);
1040 assertSuggestLocalFunction('D2', 'Z'); 1113 assertSuggestLocalFunction('D2', 'Z');
1041 assertSuggestImportedClass('EE'); 1114 assertSuggestImportedClass('EE');
1042 // hidden element suggested as low relevance 1115 // hidden element suggested as low relevance
1043 //assertSuggestImportedClass('F', CompletionRelevance.LOW); 1116 //assertSuggestImportedClass('F', CompletionRelevance.LOW);
1044 assertSuggestLibraryPrefix('g'); 1117 assertSuggestLibraryPrefix('g');
1045 assertNotSuggested('G'); 1118 assertNotSuggested('G');
1046 //assertSuggestImportedClass('H', CompletionRelevance.LOW); 1119 //assertSuggestImportedClass('H', CompletionRelevance.LOW);
1047 assertSuggestImportedClass('Object'); 1120 assertSuggestImportedClass('Object');
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 assertNotSuggested('bar2'); 2411 assertNotSuggested('bar2');
2339 assertNotSuggested('_B'); 2412 assertNotSuggested('_B');
2340 assertSuggestLocalClass('Y'); 2413 assertSuggestLocalClass('Y');
2341 assertSuggestLocalClass('C'); 2414 assertSuggestLocalClass('C');
2342 assertSuggestLocalVariable('f', null); 2415 assertSuggestLocalVariable('f', null);
2343 assertNotSuggested('x'); 2416 assertNotSuggested('x');
2344 assertNotSuggested('e'); 2417 assertNotSuggested('e');
2345 }); 2418 });
2346 } 2419 }
2347 } 2420 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/completion_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698