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

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: 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
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 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2201 assertNotSuggested('bar2'); 2274 assertNotSuggested('bar2');
2202 assertNotSuggested('_B'); 2275 assertNotSuggested('_B');
2203 assertSuggestLocalClass('Y'); 2276 assertSuggestLocalClass('Y');
2204 assertSuggestLocalClass('C'); 2277 assertSuggestLocalClass('C');
2205 assertSuggestLocalVariable('f', null); 2278 assertSuggestLocalVariable('f', null);
2206 assertNotSuggested('x'); 2279 assertNotSuggested('x');
2207 assertNotSuggested('e'); 2280 assertNotSuggested('e');
2208 }); 2281 });
2209 } 2282 }
2210 } 2283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698