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 library test.context.directory.manager; | 5 library test.context.directory.manager; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analysis_server/src/context_manager.dart'; | 9 import 'package:analysis_server/src/context_manager.dart'; |
10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // Setup sdk extension mapping. | 359 // Setup sdk extension mapping. |
360 newFile( | 360 newFile( |
361 [libPath, '_sdkext'], | 361 [libPath, '_sdkext'], |
362 r''' | 362 r''' |
363 { | 363 { |
364 "dart:foobar": "../sdk_ext/entry.dart" | 364 "dart:foobar": "../sdk_ext/entry.dart" |
365 } | 365 } |
366 '''); | 366 '''); |
367 // Setup .packages file | 367 // Setup .packages file |
368 newFile( | 368 newFile( |
369 [projPath, '.packages'], | 369 [projPath, '.packages'], |
370 r''' | 370 r''' |
371 test_pack:lib/ | 371 test_pack:lib/ |
372 '''); | 372 '''); |
373 // Setup context. | 373 // Setup context. |
374 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 374 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
375 // Confirm that one context was created. | 375 // Confirm that one context was created. |
376 var contexts = | 376 var contexts = |
377 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); | 377 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); |
378 expect(contexts, isNotNull); | 378 expect(contexts, isNotNull); |
379 expect(contexts.length, equals(1)); | 379 expect(contexts.length, equals(1)); |
380 var context = contexts[0]; | 380 var context = contexts[0]; |
381 var source = context.sourceFactory.forUri('dart:foobar'); | 381 var source = context.sourceFactory.forUri('dart:foobar'); |
382 expect(source.fullName, equals('/my/proj/sdk_ext/entry.dart')); | 382 expect(source.fullName, equals('/my/proj/sdk_ext/entry.dart')); |
383 } | 383 } |
384 | 384 |
385 | |
386 test_refresh_folder_with_packagespec() { | 385 test_refresh_folder_with_packagespec() { |
387 // create a context with a .packages file | 386 // create a context with a .packages file |
388 String packagespecFile = posix.join(projPath, '.packages'); | 387 String packagespecFile = posix.join(projPath, '.packages'); |
389 resourceProvider.newFile(packagespecFile, ''); | 388 resourceProvider.newFile(packagespecFile, ''); |
390 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 389 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
391 return pumpEventQueue().then((_) { | 390 return pumpEventQueue().then((_) { |
392 expect(callbacks.currentContextPaths.toList(), [projPath]); | 391 expect(callbacks.currentContextPaths.toList(), [projPath]); |
393 callbacks.now++; | 392 callbacks.now++; |
394 manager.refresh(null); | 393 manager.refresh(null); |
395 return pumpEventQueue().then((_) { | 394 return pumpEventQueue().then((_) { |
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 class TestUriResolver extends UriResolver { | 1718 class TestUriResolver extends UriResolver { |
1720 Map<Uri, Source> uriMap; | 1719 Map<Uri, Source> uriMap; |
1721 | 1720 |
1722 TestUriResolver(this.uriMap); | 1721 TestUriResolver(this.uriMap); |
1723 | 1722 |
1724 @override | 1723 @override |
1725 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 1724 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
1726 return uriMap[uri]; | 1725 return uriMap[uri]; |
1727 } | 1726 } |
1728 } | 1727 } |
OLD | NEW |