| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 analyzer.test.src.context.context_builder_test; | 5 library analyzer.test.src.context.context_builder_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/source/package_map_resolver.dart'; |
| 9 import 'package:analyzer/src/command_line/arguments.dart'; | 10 import 'package:analyzer/src/command_line/arguments.dart'; |
| 10 import 'package:analyzer/src/context/builder.dart'; | 11 import 'package:analyzer/src/context/builder.dart'; |
| 11 import 'package:analyzer/src/context/source.dart'; | 12 import 'package:analyzer/src/context/source.dart'; |
| 12 import 'package:analyzer/src/generated/bazel.dart'; | 13 import 'package:analyzer/src/generated/bazel.dart'; |
| 13 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
| 14 import 'package:analyzer/src/generated/sdk.dart'; | 15 import 'package:analyzer/src/generated/sdk.dart'; |
| 15 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
| 16 import 'package:analyzer/src/lint/linter.dart'; | 17 import 'package:analyzer/src/lint/linter.dart'; |
| 17 import 'package:analyzer/src/lint/registry.dart'; | 18 import 'package:analyzer/src/lint/registry.dart'; |
| 18 import 'package:analyzer/src/services/lint.dart'; | 19 import 'package:analyzer/src/services/lint.dart'; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 325 |
| 325 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 326 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 326 SourceFactoryImpl factory = | 327 SourceFactoryImpl factory = |
| 327 builder.createSourceFactory(projectPath, options); | 328 builder.createSourceFactory(projectPath, options); |
| 328 expect(factory.resolvers, | 329 expect(factory.resolvers, |
| 329 contains(predicate((r) => r is BazelFileUriResolver))); | 330 contains(predicate((r) => r is BazelFileUriResolver))); |
| 330 expect(factory.resolvers, | 331 expect(factory.resolvers, |
| 331 contains(predicate((r) => r is BazelPackageUriResolver))); | 332 contains(predicate((r) => r is BazelPackageUriResolver))); |
| 332 } | 333 } |
| 333 | 334 |
| 335 void test_createSourceFactory_bazelWorkspace_withPackagesFile() { |
| 336 String _p(String path) => resourceProvider.convertPath(path); |
| 337 |
| 338 String projectPath = _p('/workspace/my/module'); |
| 339 resourceProvider.newFile(_p('/workspace/WORKSPACE'), ''); |
| 340 resourceProvider.newFolder(_p('/workspace/bazel-bin')); |
| 341 resourceProvider.newFolder(_p('/workspace/bazel-genfiles')); |
| 342 resourceProvider.newFolder(projectPath); |
| 343 resourceProvider.newFile(_p(path.join(projectPath, '.packages')), ''); |
| 344 |
| 345 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 346 SourceFactoryImpl factory = |
| 347 builder.createSourceFactory(projectPath, options); |
| 348 expect(factory.resolvers, |
| 349 contains(predicate((r) => r is ResourceUriResolver))); |
| 350 expect(factory.resolvers, |
| 351 contains(predicate((r) => r is PackageMapUriResolver))); |
| 352 } |
| 353 |
| 334 void test_createSourceFactory_noProvider_packages_embedder_extensions() { | 354 void test_createSourceFactory_noProvider_packages_embedder_extensions() { |
| 335 String rootPath = resourceProvider.convertPath('/root'); | 355 String rootPath = resourceProvider.convertPath('/root'); |
| 336 Folder rootFolder = resourceProvider.getFolder(rootPath); | 356 Folder rootFolder = resourceProvider.getFolder(rootPath); |
| 337 createDefaultSdk(rootFolder); | 357 createDefaultSdk(rootFolder); |
| 338 String projectPath = pathContext.join(rootPath, 'project'); | 358 String projectPath = pathContext.join(rootPath, 'project'); |
| 339 String packageFilePath = pathContext.join(projectPath, '.packages'); | 359 String packageFilePath = pathContext.join(projectPath, '.packages'); |
| 340 String packageA = pathContext.join(rootPath, 'pkgs', 'a'); | 360 String packageA = pathContext.join(rootPath, 'pkgs', 'a'); |
| 341 String embedderPath = pathContext.join(packageA, '_embedder.yaml'); | 361 String embedderPath = pathContext.join(packageA, '_embedder.yaml'); |
| 342 String packageB = pathContext.join(rootPath, 'pkgs', 'b'); | 362 String packageB = pathContext.join(rootPath, 'pkgs', 'b'); |
| 343 String extensionPath = pathContext.join(packageB, '_sdkext'); | 363 String extensionPath = pathContext.join(packageB, '_sdkext'); |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 class MockLintRule implements LintRule { | 874 class MockLintRule implements LintRule { |
| 855 final String _name; | 875 final String _name; |
| 856 | 876 |
| 857 MockLintRule(this._name); | 877 MockLintRule(this._name); |
| 858 | 878 |
| 859 @override | 879 @override |
| 860 String get name => _name; | 880 String get name => _name; |
| 861 | 881 |
| 862 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 882 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 863 } | 883 } |
| OLD | NEW |