| 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.source.sdk_ext; | 5 library analyzer.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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return; | 148 return; |
| 149 } | 149 } |
| 150 var key = name; | 150 var key = name; |
| 151 var value = libDir.canonicalizePath(file); | 151 var value = libDir.canonicalizePath(file); |
| 152 _urlMappings[key] = value; | 152 _urlMappings[key] = value; |
| 153 } | 153 } |
| 154 | 154 |
| 155 /// Read the contents of [libDir]/[SDK_EXT_NAME] as a string. | 155 /// Read the contents of [libDir]/[SDK_EXT_NAME] as a string. |
| 156 /// Returns null if the file doesn't exist. | 156 /// Returns null if the file doesn't exist. |
| 157 String _readDotSdkExt(Folder libDir) { | 157 String _readDotSdkExt(Folder libDir) { |
| 158 var file = libDir.getChild(SDK_EXT_NAME); | 158 File file = libDir.getChild(SDK_EXT_NAME); |
| 159 try { | 159 try { |
| 160 return file.readAsStringSync(); | 160 return file.readAsStringSync(); |
| 161 } on FileSystemException { | 161 } on FileSystemException { |
| 162 // File can't be read. | 162 // File can't be read. |
| 163 return null; | 163 return null; |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 /// Resolve an import of an sdk extension. | 167 /// Resolve an import of an sdk extension. |
| 168 Source _resolveEntry(Uri libraryEntry, Uri importUri) { | 168 Source _resolveEntry(Uri libraryEntry, Uri importUri) { |
| 169 // Library entry. | 169 // Library entry. |
| 170 JavaFile javaFile = new JavaFile.fromUri(libraryEntry); | 170 JavaFile javaFile = new JavaFile.fromUri(libraryEntry); |
| 171 return new FileBasedSource(javaFile, importUri); | 171 return new FileBasedSource(javaFile, importUri); |
| 172 } | 172 } |
| 173 | 173 |
| 174 /// Resolve a 'part' statement inside an sdk extension. | 174 /// Resolve a 'part' statement inside an sdk extension. |
| 175 Source _resolvePart(Uri libraryEntry, String partPath, Uri importUri) { | 175 Source _resolvePart(Uri libraryEntry, String partPath, Uri importUri) { |
| 176 // Library part. | 176 // Library part. |
| 177 var directory = pathos.dirname(libraryEntry.path); | 177 var directory = pathos.dirname(libraryEntry.path); |
| 178 var partUri = new Uri.file(pathos.join(directory, partPath)); | 178 var partUri = new Uri.file(pathos.join(directory, partPath)); |
| 179 assert(partUri.isAbsolute); | 179 assert(partUri.isAbsolute); |
| 180 JavaFile javaFile = new JavaFile.fromUri(partUri); | 180 JavaFile javaFile = new JavaFile.fromUri(partUri); |
| 181 return new FileBasedSource(javaFile, importUri); | 181 return new FileBasedSource(javaFile, importUri); |
| 182 } | 182 } |
| 183 } | 183 } |
| OLD | NEW |