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

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

Issue 626303002: filter undesired suggestions from prefix expression (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | 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.toplevel; 5 library test.services.completion.toplevel;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/completion/imported_computer.dart'; 8 import 'package:analysis_server/src/services/completion/imported_computer.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 assertSuggestClass('H', CompletionRelevance.LOW); 60 assertSuggestClass('H', CompletionRelevance.LOW);
61 // Should not suggest compilation unit elements 61 // Should not suggest compilation unit elements
62 // which are returned by the LocalComputer 62 // which are returned by the LocalComputer
63 assertNotSuggested('X'); 63 assertNotSuggested('X');
64 assertSuggestClass('Object'); 64 assertSuggestClass('Object');
65 // TODO (danrubel) suggest HtmlElement as low relevance 65 // TODO (danrubel) suggest HtmlElement as low relevance
66 assertNotSuggested('HtmlElement'); 66 assertNotSuggested('HtmlElement');
67 }); 67 });
68 } 68 }
69 69
70 test_PrefixedIdentifier() {
71 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
72 addTestSource('''
73 class A {var b; X _c;}
74 class X{}
75 main() {A a; a.^}''');
76 return computeFull(true).then((_) {
77 // PrefixedIdentifier is handled by InvocationComputer
78 assertNotSuggested('b');
79 assertNotSuggested('_c');
80 assertNotSuggested('Object');
81 });
82 }
83
84 test_Block_function() { 70 test_Block_function() {
71 // Block BlockFunctionBody MethodDeclaration ClassDeclaration
85 addSource('/testA.dart', ''' 72 addSource('/testA.dart', '''
86 export "dart:math" hide max; 73 export "dart:math" hide max;
87 @deprecated A() {int x;} 74 @deprecated A() {int x;}
88 _B() {}'''); 75 _B() {}''');
89 addTestSource(''' 76 addTestSource('''
90 import "/testA.dart"; 77 import "/testA.dart";
91 class X {foo(){^}}'''); 78 class X {foo(){^}}''');
92 return computeFull().then((_) { 79 return computeFull().then((_) {
93 assertSuggestFunction('A', null, true); 80 assertSuggestFunction('A', null, true);
94 assertNotSuggested('x'); 81 assertNotSuggested('x');
95 assertNotSuggested('_B'); 82 assertNotSuggested('_B');
96 assertSuggestFunction('min', 'num', false); 83 assertSuggestFunction('min', 'num', false);
97 assertSuggestFunction('max', 'num', false, CompletionRelevance.LOW); 84 assertSuggestFunction('max', 'num', false, CompletionRelevance.LOW);
98 // Should not suggest compilation unit elements 85 // Should not suggest compilation unit elements
99 // which are returned by the LocalComputer 86 // which are returned by the LocalComputer
100 assertNotSuggested('X'); 87 assertNotSuggested('X');
88 assertNotSuggested('foo');
101 }); 89 });
102 } 90 }
103 91
104 test_Block_topLevelVar() { 92 test_Block_topLevelVar() {
105 // Block BlockFunctionBody MethodDeclaration 93 // Block BlockFunctionBody MethodDeclaration
106 addSource('/testA.dart', ''' 94 addSource('/testA.dart', '''
107 String T1; 95 String T1;
108 var _T2;'''); 96 var _T2;''');
109 addSource('/testB.dart', /* not imported */ ''' 97 addSource('/testB.dart', /* not imported */ '''
110 int T3; 98 int T3;
111 var _T4;'''); 99 var _T4;''');
112 addTestSource(''' 100 addTestSource('''
113 import "/testA.dart"; 101 import "/testA.dart";
114 class C {foo(){^}}'''); 102 class C {foo(){^}}''');
115 // pass true for full analysis to pick up unimported source 103 // pass true for full analysis to pick up unimported source
116 return computeFull(true).then((_) { 104 return computeFull(true).then((_) {
117 assertSuggestTopLevelVarGetterSetter('T1', 'String'); 105 assertSuggestTopLevelVarGetterSetter('T1', 'String');
118 assertNotSuggested('_T2'); 106 assertNotSuggested('_T2');
119 assertSuggestTopLevelVar('T3', 'int', CompletionRelevance.LOW); 107 assertSuggestTopLevelVar('T3', 'int', CompletionRelevance.LOW);
120 assertNotSuggested('_T4'); 108 assertNotSuggested('_T4');
109 // LocalComputer provides local suggestions
110 assertNotSuggested('C');
111 assertNotSuggested('foo');
121 }); 112 });
122 } 113 }
123 114
124 test_ExpressionStatement_class() { 115 test_ExpressionStatement_class() {
125 // SimpleIdentifier ExpressionStatement Block 116 // SimpleIdentifier ExpressionStatement Block
126 addSource('/testA.dart', ''' 117 addSource('/testA.dart', '''
127 class A {int x;} 118 class A {int x;}
128 class _B { }'''); 119 class _B { }''');
129 addTestSource(''' 120 addTestSource('''
130 import "/testA.dart"; 121 import "/testA.dart";
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 test_ImportDirective_dart() { 197 test_ImportDirective_dart() {
207 // SimpleStringLiteral ImportDirective 198 // SimpleStringLiteral ImportDirective
208 addTestSource(''' 199 addTestSource('''
209 import "dart^"; 200 import "dart^";
210 main() {}'''); 201 main() {}''');
211 return computeFull().then((_) { 202 return computeFull().then((_) {
212 assertNotSuggested('Object'); 203 assertNotSuggested('Object');
213 }); 204 });
214 } 205 }
215 206
207 test_PrefixedIdentifier() {
208 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
209 addSource('/testA.dart', '''
210 class A() {int x;}
211 _B() {}''');
212 addTestSource('''
213 import "/testA.dart";
214 class X {foo(){A a; a.^}}''');
215 return computeFull().then((_) {
216 // InvocationComputer provides suggestions for prefixed expressions
217 assertNotSuggested('A');
218 assertNotSuggested('x');
219 assertNotSuggested('X');
220 assertNotSuggested('Object');
221 });
222 }
223
224 test_PrefixedIdentifier_prefix() {
225 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
226 addSource('/testA.dart', '''
227 class A {static int bar = 10;}
228 _B() {}''');
229 addTestSource('''
230 import "/testA.dart";
231 class X {foo(){A^.bar}}''');
232 return computeFull().then((_) {
233 // InvocationComputer provides suggestions for prefixed expressions
234 assertSuggestClass('A');
235 assertNotSuggested('bar');
236 assertNotSuggested('_B');
237 assertNotSuggested('X');
238 assertNotSuggested('foo');
239 });
240 }
241
216 test_ShowCombinator_class() { 242 test_ShowCombinator_class() {
217 // SimpleIdentifier ShowCombinator ImportDirective 243 // SimpleIdentifier ShowCombinator ImportDirective
218 addSource('/testAB.dart', ''' 244 addSource('/testAB.dart', '''
219 class A { } 245 class A { }
220 class B { }'''); 246 class B { }''');
221 addSource('/testCD.dart', ''' 247 addSource('/testCD.dart', '''
222 class C { } 248 class C { }
223 class D { }'''); 249 class D { }''');
224 addTestSource(''' 250 addTestSource('''
225 import "/testAB.dart" show ^; 251 import "/testAB.dart" show ^;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 return computeFull().then((_) { 326 return computeFull().then((_) {
301 assertSuggestClass('A'); 327 assertSuggestClass('A');
302 assertNotSuggested('x'); 328 assertNotSuggested('x');
303 assertNotSuggested('_B'); 329 assertNotSuggested('_B');
304 // Should not suggest compilation unit elements 330 // Should not suggest compilation unit elements
305 // which are returned by the LocalComputer 331 // which are returned by the LocalComputer
306 assertNotSuggested('C'); 332 assertNotSuggested('C');
307 }); 333 });
308 } 334 }
309 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698