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 analyzer.file_system.file_system; | 5 library analyzer.file_system.file_system; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
10 import 'package:analyzer/src/util/absolute_path.dart'; | 10 import 'package:analyzer/src/util/absolute_path.dart'; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 File getFile(String path); | 191 File getFile(String path); |
192 | 192 |
193 /** | 193 /** |
194 * Return a [Folder] that corresponds to the given [path]. | 194 * Return a [Folder] that corresponds to the given [path]. |
195 * | 195 * |
196 * A folder may or may not exist at this location. | 196 * A folder may or may not exist at this location. |
197 */ | 197 */ |
198 Folder getFolder(String path); | 198 Folder getFolder(String path); |
199 | 199 |
200 /** | 200 /** |
| 201 * Complete with a list of modification times for the given [sources]. |
| 202 */ |
| 203 Future<List<int>> getModificationTimes(List<Source> sources); |
| 204 |
| 205 /** |
201 * Return the [Resource] that corresponds to the given [path]. | 206 * Return the [Resource] that corresponds to the given [path]. |
202 */ | 207 */ |
203 Resource getResource(String path); | 208 Resource getResource(String path); |
204 | 209 |
205 /** | 210 /** |
206 * Return the folder in which the plugin with the given [pluginId] can store | 211 * Return the folder in which the plugin with the given [pluginId] can store |
207 * state that will persist across sessions. The folder returned for a given id | 212 * state that will persist across sessions. The folder returned for a given id |
208 * will not be returned for a different id, ensuring that plugins do not need | 213 * will not be returned for a different id, ensuring that plugins do not need |
209 * to be concerned with file name collisions with other plugins, assuming that | 214 * to be concerned with file name collisions with other plugins, assuming that |
210 * the plugin ids are unique. The plugin ids must be valid folder names. | 215 * the plugin ids are unique. The plugin ids must be valid folder names. |
211 */ | 216 */ |
212 Folder getStateLocation(String pluginId); | 217 Folder getStateLocation(String pluginId); |
213 } | 218 } |
214 | 219 |
215 /** | 220 /** |
216 * A [UriResolver] for [Resource]s. | 221 * A [UriResolver] for [Resource]s. |
217 */ | 222 */ |
218 class ResourceUriResolver extends UriResolver { | 223 class ResourceUriResolver extends UriResolver { |
219 /** | 224 /** |
220 * The name of the `file` scheme. | 225 * The name of the `file` scheme. |
221 */ | 226 */ |
222 static final String FILE_SCHEME = "file"; | 227 static final String FILE_SCHEME = "file"; |
223 | 228 |
224 final ResourceProvider _provider; | 229 final ResourceProvider _provider; |
225 | 230 |
226 ResourceUriResolver(this._provider); | 231 ResourceUriResolver(this._provider); |
227 | 232 |
| 233 ResourceProvider get provider => _provider; |
| 234 |
228 @override | 235 @override |
229 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 236 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
230 if (!isFileUri(uri)) { | 237 if (!isFileUri(uri)) { |
231 return null; | 238 return null; |
232 } | 239 } |
233 Resource resource = | 240 Resource resource = |
234 _provider.getResource(_provider.pathContext.fromUri(uri)); | 241 _provider.getResource(_provider.pathContext.fromUri(uri)); |
235 if (resource is File) { | 242 if (resource is File) { |
236 return resource.createSource(actualUri ?? uri); | 243 return resource.createSource(actualUri ?? uri); |
237 } | 244 } |
238 return null; | 245 return null; |
239 } | 246 } |
240 | 247 |
241 @override | 248 @override |
242 Uri restoreAbsolute(Source source) => | 249 Uri restoreAbsolute(Source source) => |
243 _provider.pathContext.toUri(source.fullName); | 250 _provider.pathContext.toUri(source.fullName); |
244 | 251 |
245 ResourceProvider get provider => _provider; | |
246 | |
247 /** | 252 /** |
248 * Return `true` if the given [uri] is a `file` URI. | 253 * Return `true` if the given [uri] is a `file` URI. |
249 */ | 254 */ |
250 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; | 255 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
251 } | 256 } |
OLD | NEW |