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

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

Issue 1509373005: do not suggest import uri reaching out of lib (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.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.contributor.dart.importuri; 5 library test.services.completion.contributor.dart.importuri;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart'; 8 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart';
9 import 'package:analysis_server/src/services/completion/dart/uri_contributor.dar t'; 9 import 'package:analysis_server/src/services/completion/dart/uri_contributor.dar t';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 10 import 'package:analyzer/file_system/memory_file_system.dart';
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 expect(replacementOffset, completionOffset - 4); 166 expect(replacementOffset, completionOffset - 4);
167 expect(replacementLength, 4); 167 expect(replacementLength, 4);
168 assertNotSuggested('completion.dart'); 168 assertNotSuggested('completion.dart');
169 assertNotSuggested('other.dart'); 169 assertNotSuggested('other.dart');
170 assertNotSuggested('foo'); 170 assertNotSuggested('foo');
171 assertNotSuggested('foo/'); 171 assertNotSuggested('foo/');
172 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); 172 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT);
173 assertNotSuggested('../blat.dart'); 173 assertNotSuggested('../blat.dart');
174 } 174 }
175 175
176 test_import_file_outside_lib() async {
177 testFile = '/proj/lib/completion.dart';
178 addSource('/proj/lib/other.dart', 'library other;');
179 addSource('/proj/lib/foo/bar.dart', 'library bar;');
180 addSource('/proj/blat.dart', 'library blat;');
181 addSource('/proj/bin/boo.dart', 'library boo;');
182 addTestSource('import "../^" import');
183 await computeSuggestions();
184 expect(replacementOffset, completionOffset - 3);
185 expect(replacementLength, 3);
186 assertNotSuggested('completion.dart');
187 assertNotSuggested('other.dart');
188 assertNotSuggested('foo');
189 assertNotSuggested('foo/');
190 assertNotSuggested('foo/bar.dart');
191 assertNotSuggested('../bin');
192 assertNotSuggested('../bin/');
193 assertNotSuggested('../blat.dart');
194 }
195
176 test_import_file_parent() async { 196 test_import_file_parent() async {
177 testFile = '/proj/completion.dart'; 197 testFile = '/proj/completion.dart';
178 addSource('/proj/other.dart', 'library other;'); 198 addSource('/proj/other.dart', 'library other;');
179 addSource('/proj/foo/bar.dart', 'library bar;'); 199 addSource('/proj/foo/bar.dart', 'library bar;');
180 addSource('/blat.dart', 'library blat;'); 200 addSource('/blat.dart', 'library blat;');
201 addSource('/proj2/boo.dart', 'library boo;');
181 addTestSource('import "../^" import'); 202 addTestSource('import "../^" import');
182 await computeSuggestions(); 203 await computeSuggestions();
183 expect(replacementOffset, completionOffset - 3); 204 expect(replacementOffset, completionOffset - 3);
184 expect(replacementLength, 3); 205 expect(replacementLength, 3);
185 assertNotSuggested('completion.dart'); 206 assertNotSuggested('completion.dart');
186 assertNotSuggested('other.dart'); 207 assertNotSuggested('other.dart');
187 assertNotSuggested('foo'); 208 assertNotSuggested('foo');
188 assertNotSuggested('foo/'); 209 assertNotSuggested('foo/');
189 assertNotSuggested('foo/bar.dart'); 210 assertNotSuggested('foo/bar.dart');
190 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 211 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
212 assertSuggest('../proj2/', csKind: CompletionSuggestionKind.IMPORT);
191 } 213 }
192 214
193 test_import_file_parent2() async { 215 test_import_file_parent2() async {
194 testFile = '/proj/completion.dart'; 216 testFile = '/proj/completion.dart';
195 addSource('/proj/other.dart', 'library other;'); 217 addSource('/proj/other.dart', 'library other;');
196 addSource('/proj/foo/bar.dart', 'library bar;'); 218 addSource('/proj/foo/bar.dart', 'library bar;');
197 addSource('/blat.dart', 'library blat;'); 219 addSource('/blat.dart', 'library blat;');
198 addTestSource('import "../b^" import'); 220 addTestSource('import "../b^" import');
199 await computeSuggestions(); 221 await computeSuggestions();
200 expect(replacementOffset, completionOffset - 4); 222 expect(replacementOffset, completionOffset - 4);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 assertNotSuggested('foo/'); 552 assertNotSuggested('foo/');
531 assertNotSuggested('foo/bar.dart'); 553 assertNotSuggested('foo/bar.dart');
532 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); 554 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
533 } 555 }
534 } 556 }
535 557
536 class _TestWinResourceProvider extends MemoryResourceProvider { 558 class _TestWinResourceProvider extends MemoryResourceProvider {
537 @override 559 @override
538 Context get pathContext => windows; 560 Context get pathContext => windows;
539 } 561 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698