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

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

Issue 695773003: move import combinator suggestions into a separate computer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 1 month 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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 class PB { }'''); 1061 class PB { }''');
1062 addSource('/testCD.dart', ''' 1062 addSource('/testCD.dart', '''
1063 class C { } 1063 class C { }
1064 class D { }'''); 1064 class D { }''');
1065 addTestSource(''' 1065 addTestSource('''
1066 import "/testAB.dart" hide ^; 1066 import "/testAB.dart" hide ^;
1067 import "/testCD.dart"; 1067 import "/testCD.dart";
1068 class X {}'''); 1068 class X {}''');
1069 computeFast(); 1069 computeFast();
1070 return computeFull(true).then((_) { 1070 return computeFull(true).then((_) {
1071 assertSuggestImportedClass( 1071 assertNoSuggestions();
1072 'A',
1073 CompletionRelevance.DEFAULT,
1074 CompletionSuggestionKind.IDENTIFIER);
1075 assertSuggestImportedClass(
1076 'B',
1077 CompletionRelevance.DEFAULT,
1078 CompletionSuggestionKind.IDENTIFIER);
1079 assertSuggestImportedClass(
1080 'PB',
1081 CompletionRelevance.DEFAULT,
1082 CompletionSuggestionKind.IDENTIFIER);
1083 assertSuggestImportedTopLevelVar(
1084 'T1',
1085 null,
1086 CompletionRelevance.DEFAULT,
1087 CompletionSuggestionKind.IDENTIFIER);
1088 assertSuggestImportedFunction(
1089 'F1',
1090 'PB',
1091 false,
1092 CompletionRelevance.DEFAULT,
1093 CompletionSuggestionKind.IDENTIFIER);
1094 assertNotSuggested('C');
1095 assertNotSuggested('D');
1096 assertNotSuggested('X');
1097 assertNotSuggested('Object');
1098 }); 1072 });
1099 } 1073 }
1100 1074
1101 test_Combinator_show() { 1075 test_Combinator_show() {
1102 // SimpleIdentifier HideCombinator ImportDirective 1076 // SimpleIdentifier HideCombinator ImportDirective
1103 addSource('/testAB.dart', ''' 1077 addSource('/testAB.dart', '''
1104 library libAB; 1078 library libAB;
1105 part '/partAB.dart'; 1079 part '/partAB.dart';
1106 class A { } 1080 class A { }
1107 class B { }'''); 1081 class B { }''');
1108 addSource('/partAB.dart', ''' 1082 addSource('/partAB.dart', '''
1109 part of libAB; 1083 part of libAB;
1110 var T1; 1084 var T1;
1111 PB F1() => new PB(); 1085 PB F1() => new PB();
1112 typedef PB2 F2(int blat); 1086 typedef PB2 F2(int blat);
1113 class Clz = Object with Object; 1087 class Clz = Object with Object;
1114 class PB { }'''); 1088 class PB { }''');
1115 addSource('/testCD.dart', ''' 1089 addSource('/testCD.dart', '''
1116 class C { } 1090 class C { }
1117 class D { }'''); 1091 class D { }''');
1118 addTestSource(''' 1092 addTestSource('''
1119 import "/testAB.dart" show ^; 1093 import "/testAB.dart" show ^;
1120 import "/testCD.dart"; 1094 import "/testCD.dart";
1121 class X {}'''); 1095 class X {}''');
1122 computeFast(); 1096 computeFast();
1123 return computeFull(true).then((_) { 1097 return computeFull(true).then((_) {
1124 assertSuggestImportedClass( 1098 assertNoSuggestions();
1125 'A',
1126 CompletionRelevance.DEFAULT,
1127 CompletionSuggestionKind.IDENTIFIER);
1128 assertSuggestImportedClass(
1129 'B',
1130 CompletionRelevance.DEFAULT,
1131 CompletionSuggestionKind.IDENTIFIER);
1132 assertSuggestImportedClass(
1133 'PB',
1134 CompletionRelevance.DEFAULT,
1135 CompletionSuggestionKind.IDENTIFIER);
1136 assertSuggestImportedTopLevelVar(
1137 'T1',
1138 null,
1139 CompletionRelevance.DEFAULT,
1140 CompletionSuggestionKind.IDENTIFIER);
1141 assertSuggestImportedFunction(
1142 'F1',
1143 'PB',
1144 false,
1145 CompletionRelevance.DEFAULT,
1146 CompletionSuggestionKind.IDENTIFIER);
1147 assertSuggestImportedClass(
1148 'Clz',
1149 CompletionRelevance.DEFAULT,
1150 CompletionSuggestionKind.IDENTIFIER);
1151 assertSuggestImportedFunctionTypeAlias(
1152 'F2',
1153 null,
1154 false,
1155 CompletionRelevance.DEFAULT,
1156 CompletionSuggestionKind.IDENTIFIER);
1157 assertNotSuggested('C');
1158 assertNotSuggested('D');
1159 assertNotSuggested('X');
1160 assertNotSuggested('Object');
1161 }); 1099 });
1162 } 1100 }
1163 1101
1164 test_ConstructorName_importedClass() { 1102 test_ConstructorName_importedClass() {
1165 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName 1103 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
1166 // InstanceCreationExpression 1104 // InstanceCreationExpression
1167 addSource('/testB.dart', ''' 1105 addSource('/testB.dart', '''
1168 lib B; 1106 lib B;
1169 int T1; 1107 int T1;
1170 F1() { } 1108 F1() { }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 test_ForEachStatement_body_untyped() { 1220 test_ForEachStatement_body_untyped() {
1283 // Block ForEachStatement 1221 // Block ForEachStatement
1284 addTestSource('main(args) {for (foo in bar) {^}}'); 1222 addTestSource('main(args) {for (foo in bar) {^}}');
1285 computeFast(); 1223 computeFast();
1286 return computeFull(true).then((_) { 1224 return computeFull(true).then((_) {
1287 assertSuggestLocalVariable('foo', null); 1225 assertSuggestLocalVariable('foo', null);
1288 assertSuggestImportedClass('Object'); 1226 assertSuggestImportedClass('Object');
1289 }); 1227 });
1290 } 1228 }
1291 1229
1230 test_FormalParameterList() {
1231 // FormalParameterList MethodDeclaration
1232 addTestSource('''
1233 foo() { }
1234 void bar() { }
1235 class A {a(^) { }}''');
1236 computeFast();
1237 return computeFull(true).then((_) {
1238 assertSuggestLocalFunction('foo', null);
1239 assertSuggestLocalMethod('a', 'A', null);
1240 assertSuggestLocalClass('A');
1241 assertSuggestImportedClass('String');
1242 assertSuggestImportedFunction('identical', 'bool');
1243 assertNotSuggested('bar');
1244 });
1245 }
1246
1292 test_ForStatement_body() { 1247 test_ForStatement_body() {
1293 // Block ForStatement 1248 // Block ForStatement
1294 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); 1249 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
1295 computeFast(); 1250 computeFast();
1296 return computeFull(true).then((_) { 1251 return computeFull(true).then((_) {
1297 assertSuggestLocalVariable('i', 'int'); 1252 assertSuggestLocalVariable('i', 'int');
1298 assertSuggestImportedClass('Object'); 1253 assertSuggestImportedClass('Object');
1299 }); 1254 });
1300 } 1255 }
1301 1256
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 return computeFull(true).then((_) { 1549 return computeFull(true).then((_) {
1595 assertSuggestLocalFunction('foo', null); 1550 assertSuggestLocalFunction('foo', null);
1596 assertSuggestLocalFunction('bar', 'void'); 1551 assertSuggestLocalFunction('bar', 'void');
1597 assertSuggestLocalMethod('a', 'A', 'Z'); 1552 assertSuggestLocalMethod('a', 'A', 'Z');
1598 assertSuggestParameter('x', 'X'); 1553 assertSuggestParameter('x', 'X');
1599 assertSuggestParameter('y', 'int'); 1554 assertSuggestParameter('y', 'int');
1600 assertSuggestImportedClass('String'); 1555 assertSuggestImportedClass('String');
1601 }); 1556 });
1602 } 1557 }
1603 1558
1604 test_FormalParameterList() {
1605 // FormalParameterList MethodDeclaration
1606 addTestSource('''
1607 foo() { }
1608 void bar() { }
1609 class A {a(^) { }}''');
1610 computeFast();
1611 return computeFull(true).then((_) {
1612 assertSuggestLocalFunction('foo', null);
1613 assertSuggestLocalMethod('a', 'A', null);
1614 assertSuggestLocalClass('A');
1615 assertSuggestImportedClass('String');
1616 assertSuggestImportedFunction('identical', 'bool');
1617 assertNotSuggested('bar');
1618 });
1619 }
1620
1621 test_MethodInvocation_no_semicolon() { 1559 test_MethodInvocation_no_semicolon() {
1622 // MethodInvocation ExpressionStatement Block 1560 // MethodInvocation ExpressionStatement Block
1623 addTestSource(''' 1561 addTestSource('''
1624 main() { } 1562 main() { }
1625 class I {X get f => new A();get _g => new A();} 1563 class I {X get f => new A();get _g => new A();}
1626 class A implements I { 1564 class A implements I {
1627 var b; X _c; 1565 var b; X _c;
1628 X get d => new A();get _e => new A(); 1566 X get d => new A();get _e => new A();
1629 // no semicolon between completion point and next statement 1567 // no semicolon between completion point and next statement
1630 set s1(I x) {} set _s2(I x) {x.^ m(null);} 1568 set s1(I x) {} set _s2(I x) {x.^ m(null);}
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 assertNotSuggested('bar2'); 1885 assertNotSuggested('bar2');
1948 assertNotSuggested('_B'); 1886 assertNotSuggested('_B');
1949 assertSuggestLocalClass('Y'); 1887 assertSuggestLocalClass('Y');
1950 assertSuggestLocalClass('C'); 1888 assertSuggestLocalClass('C');
1951 assertSuggestLocalVariable('f', null); 1889 assertSuggestLocalVariable('f', null);
1952 assertNotSuggested('x'); 1890 assertNotSuggested('x');
1953 assertNotSuggested('e'); 1891 assertNotSuggested('e');
1954 }); 1892 });
1955 } 1893 }
1956 } 1894 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698