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 source.sdk_ext; | 5 library source.sdk_ext; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:core' hide Resource; | 8 import 'dart:core' hide Resource; |
9 | 9 |
10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 /// Return the path mapping for [libName] or null if there is none. | 44 /// Return the path mapping for [libName] or null if there is none. |
45 String operator[](String libName) => _urlMappings[libName]; | 45 String operator[](String libName) => _urlMappings[libName]; |
46 | 46 |
47 /// Programmatically add a new SDK extension given a JSON description | 47 /// Programmatically add a new SDK extension given a JSON description |
48 /// ([sdkExtJSON]) and a lib directory ([libDir]). | 48 /// ([sdkExtJSON]) and a lib directory ([libDir]). |
49 void addSdkExt(String sdkExtJSON, Folder libDir) { | 49 void addSdkExt(String sdkExtJSON, Folder libDir) { |
50 _processSdkExt(sdkExtJSON, libDir); | 50 _processSdkExt(sdkExtJSON, libDir); |
51 } | 51 } |
52 | 52 |
53 @override | 53 @override |
54 Source resolveAbsolute(Uri importUri) { | 54 Source resolveAbsolute(Uri importUri, [Uri actualUri]) { |
55 String libraryName = _libraryName(importUri); | 55 String libraryName = _libraryName(importUri); |
56 String partPath = _partPath(importUri); | 56 String partPath = _partPath(importUri); |
57 // Lookup library name in mappings. | 57 // Lookup library name in mappings. |
58 String mapping = _urlMappings[libraryName]; | 58 String mapping = _urlMappings[libraryName]; |
59 if (mapping == null) { | 59 if (mapping == null) { |
60 // Not found. | 60 // Not found. |
61 return null; | 61 return null; |
62 } | 62 } |
63 // This mapping points to the main entry file of the sdk extension. | 63 // This mapping points to the main entry file of the sdk extension. |
64 Uri libraryEntry = new Uri.file(mapping); | 64 Uri libraryEntry = new Uri.file(mapping); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 /// Resolve a 'part' statement inside an sdk extension. | 167 /// Resolve a 'part' statement inside an sdk extension. |
168 Source _resolvePart(Uri libraryEntry, String partPath, Uri importUri) { | 168 Source _resolvePart(Uri libraryEntry, String partPath, Uri importUri) { |
169 // Library part. | 169 // Library part. |
170 var directory = pathos.dirname(libraryEntry.path); | 170 var directory = pathos.dirname(libraryEntry.path); |
171 var partUri = new Uri.file(pathos.join(directory, partPath)); | 171 var partUri = new Uri.file(pathos.join(directory, partPath)); |
172 assert(partUri.isAbsolute); | 172 assert(partUri.isAbsolute); |
173 JavaFile javaFile = new JavaFile.fromUri(partUri); | 173 JavaFile javaFile = new JavaFile.fromUri(partUri); |
174 return new FileBasedSource(javaFile, importUri); | 174 return new FileBasedSource(javaFile, importUri); |
175 } | 175 } |
176 } | 176 } |
OLD | NEW |