| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library test.services.completion.contributor.dart.importuri; | |
| 6 | |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | |
| 8 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | |
| 9 import 'package:analysis_server/src/services/completion/uri_contributor.dart'; | |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; | |
| 11 import 'package:path/path.dart'; | |
| 12 import 'package:test_reflective_loader/test_reflective_loader.dart'; | |
| 13 import 'package:unittest/unittest.dart'; | |
| 14 | |
| 15 import '../../utils.dart'; | |
| 16 import 'completion_test_util.dart'; | |
| 17 | |
| 18 main() { | |
| 19 initializeTestEnvironment(); | |
| 20 defineReflectiveTests(UriContributorTest); | |
| 21 defineReflectiveTests(UriContributorWindowsTest); | |
| 22 } | |
| 23 | |
| 24 @reflectiveTest | |
| 25 class UriContributorTest extends AbstractCompletionTest { | |
| 26 @override | |
| 27 void setUpContributor() { | |
| 28 contributor = new UriContributor(); | |
| 29 } | |
| 30 | |
| 31 test_after_import() { | |
| 32 addTestSource('import "p"^'); | |
| 33 computeFast(); | |
| 34 expect(request.replacementOffset, completionOffset); | |
| 35 expect(request.replacementLength, 0); | |
| 36 assertNoSuggestions(); | |
| 37 } | |
| 38 | |
| 39 test_after_import_raw() { | |
| 40 addTestSource('import r"p"^'); | |
| 41 computeFast(); | |
| 42 expect(request.replacementOffset, completionOffset); | |
| 43 expect(request.replacementLength, 0); | |
| 44 assertNoSuggestions(); | |
| 45 } | |
| 46 | |
| 47 test_before_import() { | |
| 48 addTestSource('import ^"p"'); | |
| 49 computeFast(); | |
| 50 expect(request.replacementOffset, completionOffset); | |
| 51 expect(request.replacementLength, 0); | |
| 52 assertNoSuggestions(); | |
| 53 } | |
| 54 | |
| 55 test_before_import_raw() { | |
| 56 addTestSource('import ^r"p"'); | |
| 57 computeFast(); | |
| 58 expect(request.replacementOffset, completionOffset); | |
| 59 expect(request.replacementLength, 0); | |
| 60 assertNoSuggestions(); | |
| 61 } | |
| 62 | |
| 63 test_before_import_raw2() { | |
| 64 addTestSource('import r^"p"'); | |
| 65 computeFast(); | |
| 66 expect(request.replacementOffset, completionOffset); | |
| 67 expect(request.replacementLength, 0); | |
| 68 assertNoSuggestions(); | |
| 69 } | |
| 70 | |
| 71 test_export_package2() { | |
| 72 addPackageSource('foo', 'foo.dart', 'library foo;'); | |
| 73 addPackageSource('foo', 'baz/too.dart', 'library too;'); | |
| 74 addPackageSource('bar', 'bar.dart', 'library bar;'); | |
| 75 addTestSource('export "package:foo/baz/^" import'); | |
| 76 computeFast(); | |
| 77 assertSuggest('package:foo/baz/too.dart', | |
| 78 csKind: CompletionSuggestionKind.IMPORT); | |
| 79 } | |
| 80 | |
| 81 test_import() { | |
| 82 addTestSource('import "^"'); | |
| 83 computeFast(); | |
| 84 expect(request.replacementOffset, completionOffset); | |
| 85 expect(request.replacementLength, 0); | |
| 86 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); | |
| 87 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | |
| 88 } | |
| 89 | |
| 90 test_import2() { | |
| 91 addTestSource('import "^" import'); | |
| 92 computeFast(); | |
| 93 expect(request.replacementOffset, completionOffset); | |
| 94 expect(request.replacementLength, 0); | |
| 95 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); | |
| 96 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | |
| 97 } | |
| 98 | |
| 99 test_import_dart() { | |
| 100 addTestSource('import "d^" import'); | |
| 101 computeFast(); | |
| 102 expect(request.replacementOffset, completionOffset - 1); | |
| 103 expect(request.replacementLength, 1); | |
| 104 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); | |
| 105 assertSuggest('dart:core', | |
| 106 csKind: CompletionSuggestionKind.IMPORT, relevance: DART_RELEVANCE_LOW); | |
| 107 assertNotSuggested('dart:_internal'); | |
| 108 assertSuggest('dart:async', csKind: CompletionSuggestionKind.IMPORT); | |
| 109 assertSuggest('dart:math', csKind: CompletionSuggestionKind.IMPORT); | |
| 110 } | |
| 111 | |
| 112 test_import_dart2() { | |
| 113 addTestSource('import "dart:async"; import "d^"'); | |
| 114 computeFast(); | |
| 115 expect(request.replacementOffset, completionOffset - 1); | |
| 116 expect(request.replacementLength, 1); | |
| 117 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); | |
| 118 assertSuggest('dart:core', | |
| 119 csKind: CompletionSuggestionKind.IMPORT, relevance: DART_RELEVANCE_LOW); | |
| 120 assertNotSuggested('dart:_internal'); | |
| 121 assertSuggest('dart:async', csKind: CompletionSuggestionKind.IMPORT); | |
| 122 assertSuggest('dart:math', csKind: CompletionSuggestionKind.IMPORT); | |
| 123 } | |
| 124 | |
| 125 test_import_file() { | |
| 126 testFile = '/proj/completion.dart'; | |
| 127 addSource('/proj/other.dart', 'library other;'); | |
| 128 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 129 addSource('/blat.dart', 'library blat;'); | |
| 130 addTestSource('import "^" import'); | |
| 131 computeFast(); | |
| 132 expect(request.replacementOffset, completionOffset); | |
| 133 expect(request.replacementLength, 0); | |
| 134 assertNotSuggested('completion.dart'); | |
| 135 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 136 assertNotSuggested('foo'); | |
| 137 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 138 assertNotSuggested('foo/bar.dart'); | |
| 139 assertNotSuggested('../blat.dart'); | |
| 140 } | |
| 141 | |
| 142 test_import_file2() { | |
| 143 testFile = '/proj/completion.dart'; | |
| 144 addSource('/proj/other.dart', 'library other;'); | |
| 145 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 146 addSource('/blat.dart', 'library blat;'); | |
| 147 addTestSource('import "..^" import'); | |
| 148 computeFast(); | |
| 149 expect(request.replacementOffset, completionOffset - 2); | |
| 150 expect(request.replacementLength, 2); | |
| 151 assertNotSuggested('completion.dart'); | |
| 152 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 153 assertNotSuggested('foo'); | |
| 154 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 155 assertNotSuggested('foo/bar.dart'); | |
| 156 assertNotSuggested('../blat.dart'); | |
| 157 } | |
| 158 | |
| 159 test_import_file_child() { | |
| 160 testFile = '/proj/completion.dart'; | |
| 161 addSource('/proj/other.dart', 'library other;'); | |
| 162 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 163 addSource('/blat.dart', 'library blat;'); | |
| 164 addTestSource('import "foo/^" import'); | |
| 165 computeFast(); | |
| 166 expect(request.replacementOffset, completionOffset - 4); | |
| 167 expect(request.replacementLength, 4); | |
| 168 assertNotSuggested('completion.dart'); | |
| 169 assertNotSuggested('other.dart'); | |
| 170 assertNotSuggested('foo'); | |
| 171 assertNotSuggested('foo/'); | |
| 172 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 173 assertNotSuggested('../blat.dart'); | |
| 174 } | |
| 175 | |
| 176 test_import_file_parent() { | |
| 177 testFile = '/proj/completion.dart'; | |
| 178 addSource('/proj/other.dart', 'library other;'); | |
| 179 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 180 addSource('/blat.dart', 'library blat;'); | |
| 181 addTestSource('import "../^" import'); | |
| 182 computeFast(); | |
| 183 expect(request.replacementOffset, completionOffset - 3); | |
| 184 expect(request.replacementLength, 3); | |
| 185 assertNotSuggested('completion.dart'); | |
| 186 assertNotSuggested('other.dart'); | |
| 187 assertNotSuggested('foo'); | |
| 188 assertNotSuggested('foo/'); | |
| 189 assertNotSuggested('foo/bar.dart'); | |
| 190 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 191 } | |
| 192 | |
| 193 test_import_file_parent2() { | |
| 194 testFile = '/proj/completion.dart'; | |
| 195 addSource('/proj/other.dart', 'library other;'); | |
| 196 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 197 addSource('/blat.dart', 'library blat;'); | |
| 198 addTestSource('import "../b^" import'); | |
| 199 computeFast(); | |
| 200 expect(request.replacementOffset, completionOffset - 4); | |
| 201 expect(request.replacementLength, 4); | |
| 202 assertNotSuggested('completion.dart'); | |
| 203 assertNotSuggested('other.dart'); | |
| 204 assertNotSuggested('foo'); | |
| 205 assertNotSuggested('foo/'); | |
| 206 assertNotSuggested('foo/bar.dart'); | |
| 207 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 208 } | |
| 209 | |
| 210 test_import_package() { | |
| 211 addPackageSource('foo', 'foo.dart', 'library foo;'); | |
| 212 addPackageSource('foo', 'baz/too.dart', 'library too;'); | |
| 213 addPackageSource('bar', 'bar.dart', 'library bar;'); | |
| 214 addTestSource('import "p^" import'); | |
| 215 computeFast(); | |
| 216 expect(request.replacementOffset, completionOffset - 1); | |
| 217 expect(request.replacementLength, 1); | |
| 218 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | |
| 219 assertSuggest('package:foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 220 assertSuggest('package:foo/foo.dart', | |
| 221 csKind: CompletionSuggestionKind.IMPORT); | |
| 222 assertSuggest('package:foo/baz/', csKind: CompletionSuggestionKind.IMPORT); | |
| 223 assertNotSuggested('package:foo/baz/too.dart'); | |
| 224 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); | |
| 225 assertSuggest('package:bar/bar.dart', | |
| 226 csKind: CompletionSuggestionKind.IMPORT); | |
| 227 } | |
| 228 | |
| 229 test_import_package2() { | |
| 230 addPackageSource('foo', 'foo.dart', 'library foo;'); | |
| 231 addPackageSource('foo', 'baz/too.dart', 'library too;'); | |
| 232 addPackageSource('bar', 'bar.dart', 'library bar;'); | |
| 233 addTestSource('import "package:foo/baz/^" import'); | |
| 234 computeFast(); | |
| 235 assertSuggest('package:foo/baz/too.dart', | |
| 236 csKind: CompletionSuggestionKind.IMPORT); | |
| 237 } | |
| 238 | |
| 239 test_import_package2_raw() { | |
| 240 addPackageSource('foo', 'foo.dart', 'library foo;'); | |
| 241 addPackageSource('foo', 'baz/too.dart', 'library too;'); | |
| 242 addPackageSource('bar', 'bar.dart', 'library bar;'); | |
| 243 addTestSource('import r"package:foo/baz/^" import'); | |
| 244 computeFast(); | |
| 245 assertSuggest('package:foo/baz/too.dart', | |
| 246 csKind: CompletionSuggestionKind.IMPORT); | |
| 247 } | |
| 248 | |
| 249 test_import_package_missing_lib() { | |
| 250 var pkgSrc = addPackageSource('bar', 'bar.dart', 'library bar;'); | |
| 251 provider.deleteFolder(dirname(pkgSrc.fullName)); | |
| 252 addTestSource('import "p^" class'); | |
| 253 computeFast(); | |
| 254 expect(request.replacementOffset, completionOffset - 1); | |
| 255 expect(request.replacementLength, 1); | |
| 256 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | |
| 257 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); | |
| 258 assertNotSuggested('package:bar/bar.dart'); | |
| 259 } | |
| 260 | |
| 261 test_import_package_raw() { | |
| 262 addPackageSource('foo', 'foo.dart', 'library foo;'); | |
| 263 addPackageSource('foo', 'baz/too.dart', 'library too;'); | |
| 264 addPackageSource('bar', 'bar.dart', 'library bar;'); | |
| 265 addTestSource('import r"p^" import'); | |
| 266 computeFast(); | |
| 267 expect(request.replacementOffset, completionOffset - 1); | |
| 268 expect(request.replacementLength, 1); | |
| 269 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | |
| 270 assertSuggest('package:foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 271 assertSuggest('package:foo/foo.dart', | |
| 272 csKind: CompletionSuggestionKind.IMPORT); | |
| 273 assertSuggest('package:foo/baz/', csKind: CompletionSuggestionKind.IMPORT); | |
| 274 assertNotSuggested('package:foo/baz/too.dart'); | |
| 275 assertSuggest('package:bar/', csKind: CompletionSuggestionKind.IMPORT); | |
| 276 assertSuggest('package:bar/bar.dart', | |
| 277 csKind: CompletionSuggestionKind.IMPORT); | |
| 278 } | |
| 279 | |
| 280 test_import_raw() { | |
| 281 addTestSource('import r"^" import'); | |
| 282 computeFast(); | |
| 283 expect(request.replacementOffset, completionOffset); | |
| 284 expect(request.replacementLength, 0); | |
| 285 assertSuggest('dart:', csKind: CompletionSuggestionKind.IMPORT); | |
| 286 assertSuggest('package:', csKind: CompletionSuggestionKind.IMPORT); | |
| 287 } | |
| 288 | |
| 289 test_outside_import() { | |
| 290 addTestSource('import ^"d" import'); | |
| 291 computeFast(); | |
| 292 computeFull((_) { | |
| 293 assertNoSuggestions(); | |
| 294 }); | |
| 295 } | |
| 296 | |
| 297 test_outside_import2() { | |
| 298 addTestSource('import "d"^ import'); | |
| 299 computeFast(); | |
| 300 computeFull((_) { | |
| 301 assertNoSuggestions(); | |
| 302 }); | |
| 303 } | |
| 304 | |
| 305 test_part_file() { | |
| 306 testFile = '/proj/completion.dart'; | |
| 307 addSource('/proj/other.dart', 'library other;'); | |
| 308 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 309 addSource('/blat.dart', 'library blat;'); | |
| 310 addTestSource('library x; part "^" import'); | |
| 311 computeFast(); | |
| 312 expect(request.replacementOffset, completionOffset); | |
| 313 expect(request.replacementLength, 0); | |
| 314 assertNotSuggested('completion.dart'); | |
| 315 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 316 assertNotSuggested('foo'); | |
| 317 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 318 assertNotSuggested('foo/bar.dart'); | |
| 319 assertNotSuggested('../blat.dart'); | |
| 320 } | |
| 321 | |
| 322 test_part_file2() { | |
| 323 testFile = '/proj/completion.dart'; | |
| 324 addSource('/proj/other.dart', 'library other;'); | |
| 325 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 326 addSource('/blat.dart', 'library blat;'); | |
| 327 addTestSource('library x; part "..^" import'); | |
| 328 computeFast(); | |
| 329 expect(request.replacementOffset, completionOffset - 2); | |
| 330 expect(request.replacementLength, 2); | |
| 331 assertNotSuggested('completion.dart'); | |
| 332 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 333 assertNotSuggested('foo'); | |
| 334 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 335 assertNotSuggested('foo/bar.dart'); | |
| 336 assertNotSuggested('../blat.dart'); | |
| 337 } | |
| 338 | |
| 339 test_part_file_child() { | |
| 340 testFile = '/proj/completion.dart'; | |
| 341 addSource('/proj/other.dart', 'library other;'); | |
| 342 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 343 addSource('/blat.dart', 'library blat;'); | |
| 344 addTestSource('library x; part "foo/^" import'); | |
| 345 computeFast(); | |
| 346 expect(request.replacementOffset, completionOffset - 4); | |
| 347 expect(request.replacementLength, 4); | |
| 348 assertNotSuggested('completion.dart'); | |
| 349 assertNotSuggested('other.dart'); | |
| 350 assertNotSuggested('foo'); | |
| 351 assertNotSuggested('foo/'); | |
| 352 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 353 assertNotSuggested('../blat.dart'); | |
| 354 } | |
| 355 | |
| 356 test_part_file_parent() { | |
| 357 testFile = '/proj/completion.dart'; | |
| 358 addSource('/proj/other.dart', 'library other;'); | |
| 359 addSource('/proj/foo/bar.dart', 'library bar;'); | |
| 360 addSource('/blat.dart', 'library blat;'); | |
| 361 addTestSource('library x; part "../^" import'); | |
| 362 computeFast(); | |
| 363 expect(request.replacementOffset, completionOffset - 3); | |
| 364 expect(request.replacementLength, 3); | |
| 365 assertNotSuggested('completion.dart'); | |
| 366 assertNotSuggested('other.dart'); | |
| 367 assertNotSuggested('foo'); | |
| 368 assertNotSuggested('foo/'); | |
| 369 assertNotSuggested('foo/bar.dart'); | |
| 370 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 371 } | |
| 372 } | |
| 373 | |
| 374 @reflectiveTest | |
| 375 class UriContributorWindowsTest extends AbstractCompletionTest { | |
| 376 @override | |
| 377 void setUpContributor() { | |
| 378 contributor = new UriContributor(); | |
| 379 } | |
| 380 | |
| 381 @override | |
| 382 void setupResourceProvider() { | |
| 383 provider = new _TestWinResourceProvider(); | |
| 384 } | |
| 385 | |
| 386 test_import_file() { | |
| 387 testFile = '\\proj\\completion.dart'; | |
| 388 addSource('\\proj\\other.dart', 'library other;'); | |
| 389 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 390 addSource('\\blat.dart', 'library blat;'); | |
| 391 addTestSource('import "^" import'); | |
| 392 computeFast(); | |
| 393 expect(request.replacementOffset, completionOffset); | |
| 394 expect(request.replacementLength, 0); | |
| 395 assertNotSuggested('completion.dart'); | |
| 396 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 397 assertNotSuggested('foo'); | |
| 398 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 399 assertNotSuggested('foo/bar.dart'); | |
| 400 assertNotSuggested('../blat.dart'); | |
| 401 } | |
| 402 | |
| 403 test_import_file2() { | |
| 404 testFile = '\\proj\\completion.dart'; | |
| 405 addSource('\\proj\\other.dart', 'library other;'); | |
| 406 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 407 addSource('\\blat.dart', 'library blat;'); | |
| 408 addTestSource('import "..^" import'); | |
| 409 computeFast(); | |
| 410 expect(request.replacementOffset, completionOffset - 2); | |
| 411 expect(request.replacementLength, 2); | |
| 412 assertNotSuggested('completion.dart'); | |
| 413 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 414 assertNotSuggested('foo'); | |
| 415 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 416 assertNotSuggested('foo/bar.dart'); | |
| 417 assertNotSuggested('../blat.dart'); | |
| 418 } | |
| 419 | |
| 420 test_import_file_child() { | |
| 421 testFile = '\\proj\\completion.dart'; | |
| 422 addSource('\\proj\\other.dart', 'library other;'); | |
| 423 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 424 addSource('\\blat.dart', 'library blat;'); | |
| 425 addTestSource('import "foo/^" import'); | |
| 426 computeFast(); | |
| 427 expect(request.replacementOffset, completionOffset - 4); | |
| 428 expect(request.replacementLength, 4); | |
| 429 assertNotSuggested('completion.dart'); | |
| 430 assertNotSuggested('other.dart'); | |
| 431 assertNotSuggested('foo'); | |
| 432 assertNotSuggested('foo/'); | |
| 433 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 434 assertNotSuggested('../blat.dart'); | |
| 435 } | |
| 436 | |
| 437 test_import_file_parent() { | |
| 438 testFile = '\\proj\\completion.dart'; | |
| 439 addSource('\\proj\\other.dart', 'library other;'); | |
| 440 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 441 addSource('\\blat.dart', 'library blat;'); | |
| 442 addTestSource('import "../^" import'); | |
| 443 computeFast(); | |
| 444 expect(request.replacementOffset, completionOffset - 3); | |
| 445 expect(request.replacementLength, 3); | |
| 446 assertNotSuggested('completion.dart'); | |
| 447 assertNotSuggested('other.dart'); | |
| 448 assertNotSuggested('foo'); | |
| 449 assertNotSuggested('foo/'); | |
| 450 assertNotSuggested('foo/bar.dart'); | |
| 451 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 452 } | |
| 453 | |
| 454 test_import_file_parent2() { | |
| 455 testFile = '\\proj\\completion.dart'; | |
| 456 addSource('\\proj\\other.dart', 'library other;'); | |
| 457 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 458 addSource('\\blat.dart', 'library blat;'); | |
| 459 addTestSource('import "../b^" import'); | |
| 460 computeFast(); | |
| 461 expect(request.replacementOffset, completionOffset - 4); | |
| 462 expect(request.replacementLength, 4); | |
| 463 assertNotSuggested('completion.dart'); | |
| 464 assertNotSuggested('other.dart'); | |
| 465 assertNotSuggested('foo'); | |
| 466 assertNotSuggested('foo/'); | |
| 467 assertNotSuggested('foo/bar.dart'); | |
| 468 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 469 } | |
| 470 | |
| 471 test_part_file() { | |
| 472 testFile = '\\proj\\completion.dart'; | |
| 473 addSource('\\proj\\other.dart', 'library other;'); | |
| 474 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 475 addSource('\\blat.dart', 'library blat;'); | |
| 476 addTestSource('library x; part "^" import'); | |
| 477 computeFast(); | |
| 478 expect(request.replacementOffset, completionOffset); | |
| 479 expect(request.replacementLength, 0); | |
| 480 assertNotSuggested('completion.dart'); | |
| 481 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 482 assertNotSuggested('foo'); | |
| 483 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 484 assertNotSuggested('foo/bar.dart'); | |
| 485 assertNotSuggested('../blat.dart'); | |
| 486 } | |
| 487 | |
| 488 test_part_file2() { | |
| 489 testFile = '\\proj\\completion.dart'; | |
| 490 addSource('\\proj\\other.dart', 'library other;'); | |
| 491 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 492 addSource('\\blat.dart', 'library blat;'); | |
| 493 addTestSource('library x; part "..^" import'); | |
| 494 computeFast(); | |
| 495 expect(request.replacementOffset, completionOffset - 2); | |
| 496 expect(request.replacementLength, 2); | |
| 497 assertNotSuggested('completion.dart'); | |
| 498 assertSuggest('other.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 499 assertNotSuggested('foo'); | |
| 500 assertSuggest('foo/', csKind: CompletionSuggestionKind.IMPORT); | |
| 501 assertNotSuggested('foo/bar.dart'); | |
| 502 assertNotSuggested('../blat.dart'); | |
| 503 } | |
| 504 | |
| 505 test_part_file_child() { | |
| 506 testFile = '\\proj\\completion.dart'; | |
| 507 addSource('\\proj\\other.dart', 'library other;'); | |
| 508 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 509 addSource('\\blat.dart', 'library blat;'); | |
| 510 addTestSource('library x; part "foo/^" import'); | |
| 511 computeFast(); | |
| 512 expect(request.replacementOffset, completionOffset - 4); | |
| 513 expect(request.replacementLength, 4); | |
| 514 assertNotSuggested('completion.dart'); | |
| 515 assertNotSuggested('other.dart'); | |
| 516 assertNotSuggested('foo'); | |
| 517 assertNotSuggested('foo/'); | |
| 518 assertSuggest('foo/bar.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 519 assertNotSuggested('../blat.dart'); | |
| 520 } | |
| 521 | |
| 522 test_part_file_parent() { | |
| 523 testFile = '\\proj\\completion.dart'; | |
| 524 addSource('\\proj\\other.dart', 'library other;'); | |
| 525 addSource('\\proj\\foo\\bar.dart', 'library bar;'); | |
| 526 addSource('\\blat.dart', 'library blat;'); | |
| 527 addTestSource('library x; part "../^" import'); | |
| 528 computeFast(); | |
| 529 expect(request.replacementOffset, completionOffset - 3); | |
| 530 expect(request.replacementLength, 3); | |
| 531 assertNotSuggested('completion.dart'); | |
| 532 assertNotSuggested('other.dart'); | |
| 533 assertNotSuggested('foo'); | |
| 534 assertNotSuggested('foo/'); | |
| 535 assertNotSuggested('foo/bar.dart'); | |
| 536 assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT); | |
| 537 } | |
| 538 } | |
| 539 | |
| 540 class _TestWinResourceProvider extends MemoryResourceProvider { | |
| 541 @override | |
| 542 Context get pathContext => windows; | |
| 543 } | |
| OLD | NEW |