| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.generated.test.generated.source_factory; | 5 library analyzer.test.generated.test.generated.source_factory; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; | 11 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 11 import 'package:analyzer/source/package_map_resolver.dart'; | 12 import 'package:analyzer/source/package_map_resolver.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine, Logger; | 13 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine, Logger; |
| 13 import 'package:analyzer/src/generated/java_core.dart'; | 14 import 'package:analyzer/src/generated/java_core.dart'; |
| 14 import 'package:analyzer/src/generated/java_engine_io.dart'; | 15 import 'package:analyzer/src/generated/java_engine_io.dart'; |
| 15 import 'package:analyzer/src/generated/java_io.dart'; | 16 import 'package:analyzer/src/generated/java_io.dart'; |
| 16 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
| 17 import 'package:analyzer/src/generated/source_io.dart'; | 18 import 'package:analyzer/src/generated/source_io.dart'; |
| 18 import 'package:analyzer/src/generated/utilities_dart.dart' as utils; | 19 import 'package:analyzer/src/generated/utilities_dart.dart' as utils; |
| 19 import 'package:package_config/packages.dart'; | 20 import 'package:package_config/packages.dart'; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 33 } | 34 } |
| 34 | 35 |
| 35 Source createSource({String path, String uri}) => | 36 Source createSource({String path, String uri}) => |
| 36 //TODO(pquitslund): find some way to pass an actual URI into source creation | 37 //TODO(pquitslund): find some way to pass an actual URI into source creation |
| 37 new MemoryResourceProvider() | 38 new MemoryResourceProvider() |
| 38 .getFile(path) | 39 .getFile(path) |
| 39 .createSource(uri != null ? Uri.parse(uri) : null); | 40 .createSource(uri != null ? Uri.parse(uri) : null); |
| 40 | 41 |
| 41 void runPackageMapTests() { | 42 void runPackageMapTests() { |
| 42 final Uri baseUri = new Uri.file('test/base'); | 43 final Uri baseUri = new Uri.file('test/base'); |
| 43 final List<UriResolver> testResolvers = [new FileUriResolver()]; | 44 final List<UriResolver> testResolvers = [ |
| 45 new ResourceUriResolver(PhysicalResourceProvider.INSTANCE) |
| 46 ]; |
| 44 | 47 |
| 45 Packages createPackageMap(Uri base, String configFileContents) { | 48 Packages createPackageMap(Uri base, String configFileContents) { |
| 46 List<int> bytes = UTF8.encode(configFileContents); | 49 List<int> bytes = UTF8.encode(configFileContents); |
| 47 Map<String, Uri> map = pkgfile.parse(bytes, base); | 50 Map<String, Uri> map = pkgfile.parse(bytes, base); |
| 48 return new MapPackages(map); | 51 return new MapPackages(map); |
| 49 } | 52 } |
| 50 | 53 |
| 51 Map<String, List<Folder>> getPackageMap(String config) { | 54 Map<String, List<Folder>> getPackageMap(String config) { |
| 52 Packages packages = createPackageMap(baseUri, config); | 55 Packages packages = createPackageMap(baseUri, config); |
| 53 SourceFactory factory = new SourceFactory(testResolvers, packages); | 56 SourceFactory factory = new SourceFactory(testResolvers, packages); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); | 360 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); |
| 358 | 361 |
| 359 @override | 362 @override |
| 360 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 363 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 361 if (uri.toString() == encoding) { | 364 if (uri.toString() == encoding) { |
| 362 return new TestSource(); | 365 return new TestSource(); |
| 363 } | 366 } |
| 364 return null; | 367 return null; |
| 365 } | 368 } |
| 366 } | 369 } |
| OLD | NEW |