| 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'; |
| 11 import 'package:analyzer/file_system/memory_file_system.dart'; | 11 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 12 import 'package:analyzer/instrumentation/instrumentation.dart'; | 12 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 13 import 'package:analyzer/source/embedder.dart'; | 13 import 'package:analyzer/source/embedder.dart'; |
| 14 import 'package:analyzer/source/error_processor.dart'; | 14 import 'package:analyzer/source/error_processor.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/error.dart'; | 16 import 'package:analyzer/src/generated/error.dart'; |
| 17 import 'package:analyzer/src/generated/java_io.dart'; |
| 17 import 'package:analyzer/src/generated/source.dart'; | 18 import 'package:analyzer/src/generated/source.dart'; |
| 18 import 'package:analyzer/src/generated/source_io.dart'; | 19 import 'package:analyzer/src/generated/source_io.dart'; |
| 19 import 'package:analyzer/src/services/lint.dart'; | 20 import 'package:analyzer/src/services/lint.dart'; |
| 20 import 'package:linter/src/plugin/linter_plugin.dart'; | 21 import 'package:linter/src/plugin/linter_plugin.dart'; |
| 21 import 'package:linter/src/rules/avoid_as.dart'; | 22 import 'package:linter/src/rules/avoid_as.dart'; |
| 22 import 'package:package_config/packages.dart'; | 23 import 'package:package_config/packages.dart'; |
| 23 import 'package:path/path.dart'; | 24 import 'package:path/path.dart'; |
| 24 import 'package:plugin/manager.dart'; | 25 import 'package:plugin/manager.dart'; |
| 25 import 'package:plugin/plugin.dart'; | 26 import 'package:plugin/plugin.dart'; |
| 26 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 27 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 var lintNames = lints.map((lint) => lint.name); | 360 var lintNames = lints.map((lint) => lint.name); |
| 360 | 361 |
| 361 expect( | 362 expect( |
| 362 lintNames, | 363 lintNames, |
| 363 unorderedEquals( | 364 unorderedEquals( |
| 364 ['avoid_as' /* embedder */, 'camel_case_types' /* options */])); | 365 ['avoid_as' /* embedder */, 'camel_case_types' /* options */])); |
| 365 | 366 |
| 366 // Sanity check embedder libs. | 367 // Sanity check embedder libs. |
| 367 var source = context.sourceFactory.forUri('dart:foobar'); | 368 var source = context.sourceFactory.forUri('dart:foobar'); |
| 368 expect(source, isNotNull); | 369 expect(source, isNotNull); |
| 369 expect(source.fullName, '/my/proj/sdk_ext/entry.dart'); | 370 expect(source.fullName, |
| 371 '/my/proj/sdk_ext/entry.dart'.replaceAll('/', JavaFile.separator)); |
| 370 } | 372 } |
| 371 | 373 |
| 372 test_embedder_packagespec() async { | 374 test_embedder_packagespec() async { |
| 373 // Create files. | 375 // Create files. |
| 374 String libPath = newFolder([projPath, LIB_NAME]); | 376 String libPath = newFolder([projPath, LIB_NAME]); |
| 375 newFile([libPath, 'main.dart']); | 377 newFile([libPath, 'main.dart']); |
| 376 newFile([libPath, 'nope.dart']); | 378 newFile([libPath, 'nope.dart']); |
| 377 String sdkExtPath = newFolder([projPath, 'sdk_ext']); | 379 String sdkExtPath = newFolder([projPath, 'sdk_ext']); |
| 378 newFile([sdkExtPath, 'entry.dart']); | 380 newFile([sdkExtPath, 'entry.dart']); |
| 379 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); | 381 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 396 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); | 398 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); |
| 397 await pumpEventQueue(); | 399 await pumpEventQueue(); |
| 398 // Confirm that one context was created. | 400 // Confirm that one context was created. |
| 399 var contexts = | 401 var contexts = |
| 400 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); | 402 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); |
| 401 expect(contexts, isNotNull); | 403 expect(contexts, isNotNull); |
| 402 expect(contexts.length, equals(1)); | 404 expect(contexts.length, equals(1)); |
| 403 var context = contexts[0]; | 405 var context = contexts[0]; |
| 404 var source = context.sourceFactory.forUri('dart:foobar'); | 406 var source = context.sourceFactory.forUri('dart:foobar'); |
| 405 expect(source, isNotNull); | 407 expect(source, isNotNull); |
| 406 expect(source.fullName, equals('/my/proj/sdk_ext/entry.dart')); | 408 expect(source.fullName, |
| 409 '/my/proj/sdk_ext/entry.dart'.replaceAll('/', JavaFile.separator)); |
| 407 // We can't find dart:core because we didn't list it in our | 410 // We can't find dart:core because we didn't list it in our |
| 408 // embedder_libs map. | 411 // embedder_libs map. |
| 409 expect(context.sourceFactory.forUri('dart:core'), isNull); | 412 expect(context.sourceFactory.forUri('dart:core'), isNull); |
| 410 // We can find dart:typed_data because we listed it in our | 413 // We can find dart:typed_data because we listed it in our |
| 411 // embedder_libs map. | 414 // embedder_libs map. |
| 412 expect(context.sourceFactory.forUri('dart:typed_data'), isNotNull); | 415 expect(context.sourceFactory.forUri('dart:typed_data'), isNotNull); |
| 413 } | 416 } |
| 414 | 417 |
| 415 test_error_filter_analysis_option() async { | 418 test_error_filter_analysis_option() async { |
| 416 // Create files. | 419 // Create files. |
| (...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2418 class TestUriResolver extends UriResolver { | 2421 class TestUriResolver extends UriResolver { |
| 2419 Map<Uri, Source> uriMap; | 2422 Map<Uri, Source> uriMap; |
| 2420 | 2423 |
| 2421 TestUriResolver(this.uriMap); | 2424 TestUriResolver(this.uriMap); |
| 2422 | 2425 |
| 2423 @override | 2426 @override |
| 2424 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 2427 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 2425 return uriMap[uri]; | 2428 return uriMap[uri]; |
| 2426 } | 2429 } |
| 2427 } | 2430 } |
| OLD | NEW |