| OLD | NEW |
| 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 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 5 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 6 import 'package:analysis_server/src/services/completion/dart/uri_contributor.dar
t'; | 6 import 'package:analysis_server/src/services/completion/dart/uri_contributor.dar
t'; |
| 7 import 'package:analyzer/file_system/memory_file_system.dart'; | 7 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 8 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 8 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 9 import 'package:path/path.dart'; | 9 import 'package:path/path.dart'; |
| 10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 test_export_package2() async { | 69 test_export_package2() async { |
| 70 addPackageSource('foo', 'foo.dart', 'library foo;'); | 70 addPackageSource('foo', 'foo.dart', 'library foo;'); |
| 71 addPackageSource('foo', 'baz/too.dart', 'library too;'); | 71 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
| 72 addPackageSource('bar', 'bar.dart', 'library bar;'); | 72 addPackageSource('bar', 'bar.dart', 'library bar;'); |
| 73 addTestSource('export "package:foo/baz/^" import'); | 73 addTestSource('export "package:foo/baz/^" import'); |
| 74 await computeSuggestions(); | 74 await computeSuggestions(); |
| 75 assertSuggest('package:foo/baz/too.dart', | 75 assertSuggest('package:foo/baz/too.dart', |
| 76 csKind: CompletionSuggestionKind.IMPORT); | 76 csKind: CompletionSuggestionKind.IMPORT); |
| 77 } | 77 } |
| 78 | 78 |
| 79 test_export_package2_off() async { |
| 80 try { |
| 81 UriContributor.suggestFilePaths = false; |
| 82 addPackageSource('foo', 'foo.dart', 'library foo;'); |
| 83 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
| 84 addPackageSource('bar', 'bar.dart', 'library bar;'); |
| 85 addTestSource('export "package:foo/baz/^" import'); |
| 86 await computeSuggestions(); |
| 87 assertNotSuggested('package:foo/baz/too.dart'); |
| 88 } finally { |
| 89 UriContributor.suggestFilePaths = true; |
| 90 } |
| 91 } |
| 92 |
| 79 test_import() async { | 93 test_import() async { |
| 80 addTestSource('import "^"'); | 94 addTestSource('import "^"'); |
| 81 await computeSuggestions(); | 95 await computeSuggestions(); |
| 82 expect(replacementOffset, completionOffset); | 96 expect(replacementOffset, completionOffset); |
| 83 expect(replacementLength, 0); | 97 expect(replacementLength, 0); |
| 84 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); | 98 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); |
| 85 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | 99 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); |
| 86 } | 100 } |
| 87 | 101 |
| 88 test_import2() async { | 102 test_import2() async { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 expect(replacementOffset, completionOffset - 2); | 170 expect(replacementOffset, completionOffset - 2); |
| 157 expect(replacementLength, 2); | 171 expect(replacementLength, 2); |
| 158 assertNotSuggested('completion.dart'); | 172 assertNotSuggested('completion.dart'); |
| 159 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | 173 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); |
| 160 assertNotSuggested('foo'); | 174 assertNotSuggested('foo'); |
| 161 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | 175 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); |
| 162 assertNotSuggested('foo/bar.dart'); | 176 assertNotSuggested('foo/bar.dart'); |
| 163 assertNotSuggested('../blat.dart'); | 177 assertNotSuggested('../blat.dart'); |
| 164 } | 178 } |
| 165 | 179 |
| 180 test_import_file2_off() async { |
| 181 try { |
| 182 UriContributor.suggestFilePaths = false; |
| 183 testFile = '/proj/completion.dart'; |
| 184 addSource('/proj/other.dart', 'library other;'); |
| 185 addSource('/proj/foo/bar.dart', 'library bar;'); |
| 186 addSource('/blat.dart', 'library blat;'); |
| 187 addTestSource('import "..^" import'); |
| 188 await computeSuggestions(); |
| 189 expect(replacementOffset, completionOffset - 2); |
| 190 expect(replacementLength, 2); |
| 191 assertNotSuggested('completion.dart'); |
| 192 assertNotSuggested('other.dart'); |
| 193 assertNotSuggested('foo'); |
| 194 assertNotSuggested('foo/'); |
| 195 assertNotSuggested('foo/bar.dart'); |
| 196 assertNotSuggested('../blat.dart'); |
| 197 } finally { |
| 198 UriContributor.suggestFilePaths = true; |
| 199 } |
| 200 } |
| 201 |
| 166 test_import_file_child() async { | 202 test_import_file_child() async { |
| 167 testFile = '/proj/completion.dart'; | 203 testFile = '/proj/completion.dart'; |
| 168 addSource('/proj/other.dart', 'library other;'); | 204 addSource('/proj/other.dart', 'library other;'); |
| 169 addSource('/proj/foo/bar.dart', 'library bar;'); | 205 addSource('/proj/foo/bar.dart', 'library bar;'); |
| 170 addSource('/blat.dart', 'library blat;'); | 206 addSource('/blat.dart', 'library blat;'); |
| 171 addTestSource('import "foo/^" import'); | 207 addTestSource('import "foo/^" import'); |
| 172 await computeSuggestions(); | 208 await computeSuggestions(); |
| 173 expect(replacementOffset, completionOffset - 4); | 209 expect(replacementOffset, completionOffset - 4); |
| 174 expect(replacementLength, 4); | 210 expect(replacementLength, 4); |
| 175 assertNotSuggested('completion.dart'); | 211 assertNotSuggested('completion.dart'); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 test_import_package2() async { | 294 test_import_package2() async { |
| 259 addPackageSource('foo', 'foo.dart', 'library foo;'); | 295 addPackageSource('foo', 'foo.dart', 'library foo;'); |
| 260 addPackageSource('foo', 'baz/too.dart', 'library too;'); | 296 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
| 261 addPackageSource('bar', 'bar.dart', 'library bar;'); | 297 addPackageSource('bar', 'bar.dart', 'library bar;'); |
| 262 addTestSource('import "package:foo/baz/^" import'); | 298 addTestSource('import "package:foo/baz/^" import'); |
| 263 await computeSuggestions(); | 299 await computeSuggestions(); |
| 264 assertSuggest('package:foo/baz/too.dart', | 300 assertSuggest('package:foo/baz/too.dart', |
| 265 csKind: CompletionSuggestionKind.IMPORT); | 301 csKind: CompletionSuggestionKind.IMPORT); |
| 266 } | 302 } |
| 267 | 303 |
| 304 test_import_package2_off() async { |
| 305 try { |
| 306 UriContributor.suggestFilePaths = false; |
| 307 addPackageSource('foo', 'foo.dart', 'library foo;'); |
| 308 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
| 309 addPackageSource('bar', 'bar.dart', 'library bar;'); |
| 310 addTestSource('import "package:foo/baz/^" import'); |
| 311 await computeSuggestions(); |
| 312 assertNotSuggested('package:foo/baz/too.dart'); |
| 313 } finally { |
| 314 UriContributor.suggestFilePaths = true; |
| 315 } |
| 316 } |
| 317 |
| 268 test_import_package2_raw() async { | 318 test_import_package2_raw() async { |
| 269 addPackageSource('foo', 'foo.dart', 'library foo;'); | 319 addPackageSource('foo', 'foo.dart', 'library foo;'); |
| 270 addPackageSource('foo', 'baz/too.dart', 'library too;'); | 320 addPackageSource('foo', 'baz/too.dart', 'library too;'); |
| 271 addPackageSource('bar', 'bar.dart', 'library bar;'); | 321 addPackageSource('bar', 'bar.dart', 'library bar;'); |
| 272 addTestSource('import r"package:foo/baz/^" import'); | 322 addTestSource('import r"package:foo/baz/^" import'); |
| 273 await computeSuggestions(); | 323 await computeSuggestions(); |
| 274 assertSuggest('package:foo/baz/too.dart', | 324 assertSuggest('package:foo/baz/too.dart', |
| 275 csKind: CompletionSuggestionKind.IMPORT); | 325 csKind: CompletionSuggestionKind.IMPORT); |
| 276 } | 326 } |
| 277 | 327 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 assertNotSuggested('foo/'); | 673 assertNotSuggested('foo/'); |
| 624 assertNotSuggested('foo/bar.dart'); | 674 assertNotSuggested('foo/bar.dart'); |
| 625 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | 675 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); |
| 626 } | 676 } |
| 627 } | 677 } |
| 628 | 678 |
| 629 class _TestWinResourceProvider extends MemoryResourceProvider { | 679 class _TestWinResourceProvider extends MemoryResourceProvider { |
| 630 @override | 680 @override |
| 631 Context get pathContext => windows; | 681 Context get pathContext => windows; |
| 632 } | 682 } |
| OLD | NEW |