| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.source.io; | 8 library engine.source.io; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 /** | 269 /** |
| 270 * Instances of the class `FileUriResolver` resolve `file` URI's. | 270 * Instances of the class `FileUriResolver` resolve `file` URI's. |
| 271 */ | 271 */ |
| 272 class FileUriResolver extends UriResolver { | 272 class FileUriResolver extends UriResolver { |
| 273 /** | 273 /** |
| 274 * The name of the `file` scheme. | 274 * The name of the `file` scheme. |
| 275 */ | 275 */ |
| 276 static String FILE_SCHEME = "file"; | 276 static String FILE_SCHEME = "file"; |
| 277 | 277 |
| 278 @override | 278 @override |
| 279 Source resolveAbsolute(Uri uri) { | 279 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 280 if (!isFileUri(uri)) { | 280 if (!isFileUri(uri)) { |
| 281 return null; | 281 return null; |
| 282 } | 282 } |
| 283 return new FileBasedSource(new JavaFile.fromUri(uri), uri); | 283 return new FileBasedSource( |
| 284 new JavaFile.fromUri(uri), actualUri != null ? actualUri : uri); |
| 284 } | 285 } |
| 285 | 286 |
| 286 @override | 287 @override |
| 287 Uri restoreAbsolute(Source source) { | 288 Uri restoreAbsolute(Source source) { |
| 288 if (source is FileBasedSource) { | 289 if (source is FileBasedSource) { |
| 289 return new Uri.file(source.fullName); | 290 return new Uri.file(source.fullName); |
| 290 } | 291 } |
| 291 return null; | 292 return null; |
| 292 } | 293 } |
| 293 | 294 |
| 294 /** | 295 /** |
| 295 * Return `true` if the given URI is a `file` URI. | 296 * Return `true` if the given URI is a `file` URI. |
| 296 * | 297 * |
| 297 * @param uri the URI being tested | 298 * @param uri the URI being tested |
| 298 * @return `true` if the given URI is a `file` URI | 299 * @return `true` if the given URI is a `file` URI |
| 299 */ | 300 */ |
| 300 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; | 301 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
| 301 } | 302 } |
| 302 | 303 |
| 303 /** | 304 /** |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 _CanLogRequiredKeyIoException = false; | 419 _CanLogRequiredKeyIoException = false; |
| 419 AnalysisEngine.instance.logger.logError("Canonical failed: $pkgDir", | 420 AnalysisEngine.instance.logger.logError("Canonical failed: $pkgDir", |
| 420 new CaughtException(exception, stackTrace)); | 421 new CaughtException(exception, stackTrace)); |
| 421 } | 422 } |
| 422 } | 423 } |
| 423 return new JavaFile.relative(pkgDir, relPath.replaceAll( | 424 return new JavaFile.relative(pkgDir, relPath.replaceAll( |
| 424 '/', new String.fromCharCode(JavaFile.separatorChar))); | 425 '/', new String.fromCharCode(JavaFile.separatorChar))); |
| 425 } | 426 } |
| 426 | 427 |
| 427 @override | 428 @override |
| 428 Source resolveAbsolute(Uri uri) { | 429 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 429 if (!isPackageUri(uri)) { | 430 if (!isPackageUri(uri)) { |
| 430 return null; | 431 return null; |
| 431 } | 432 } |
| 432 String path = uri.path; | 433 String path = uri.path; |
| 433 if (path == null) { | 434 if (path == null) { |
| 434 path = uri.path; | 435 path = uri.path; |
| 435 if (path == null) { | 436 if (path == null) { |
| 436 return null; | 437 return null; |
| 437 } | 438 } |
| 438 } | 439 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 456 if (resolvedFile.exists()) { | 457 if (resolvedFile.exists()) { |
| 457 JavaFile canonicalFile = | 458 JavaFile canonicalFile = |
| 458 getCanonicalFile(packagesDirectory, pkgName, relPath); | 459 getCanonicalFile(packagesDirectory, pkgName, relPath); |
| 459 if (_isSelfReference(packagesDirectory, canonicalFile)) { | 460 if (_isSelfReference(packagesDirectory, canonicalFile)) { |
| 460 uri = canonicalFile.toURI(); | 461 uri = canonicalFile.toURI(); |
| 461 } | 462 } |
| 462 return new FileBasedSource(canonicalFile, uri); | 463 return new FileBasedSource(canonicalFile, uri); |
| 463 } | 464 } |
| 464 } | 465 } |
| 465 return new FileBasedSource( | 466 return new FileBasedSource( |
| 466 getCanonicalFile(_packagesDirectories[0], pkgName, relPath), uri); | 467 getCanonicalFile(_packagesDirectories[0], pkgName, relPath), |
| 468 actualUri != null ? actualUri : uri); |
| 467 } | 469 } |
| 468 | 470 |
| 469 @override | 471 @override |
| 470 Uri restoreAbsolute(Source source) { | 472 Uri restoreAbsolute(Source source) { |
| 471 String sourcePath = source.fullName; | 473 String sourcePath = source.fullName; |
| 472 for (JavaFile packagesDirectory in _packagesDirectories) { | 474 for (JavaFile packagesDirectory in _packagesDirectories) { |
| 473 List<JavaFile> pkgFolders = packagesDirectory.listFiles(); | 475 List<JavaFile> pkgFolders = packagesDirectory.listFiles(); |
| 474 if (pkgFolders != null) { | 476 if (pkgFolders != null) { |
| 475 for (JavaFile pkgFolder in pkgFolders) { | 477 for (JavaFile pkgFolder in pkgFolders) { |
| 476 try { | 478 try { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 final JavaFile _rootDirectory; | 532 final JavaFile _rootDirectory; |
| 531 | 533 |
| 532 /** | 534 /** |
| 533 * Initialize a newly created resolver to resolve `file` URI's relative to the
given root | 535 * Initialize a newly created resolver to resolve `file` URI's relative to the
given root |
| 534 * directory. | 536 * directory. |
| 535 */ | 537 */ |
| 536 RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories) | 538 RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories) |
| 537 : super(); | 539 : super(); |
| 538 | 540 |
| 539 @override | 541 @override |
| 540 Source resolveAbsolute(Uri uri) { | 542 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 541 String rootPath = _rootDirectory.toURI().path; | 543 String rootPath = _rootDirectory.toURI().path; |
| 542 String uriPath = uri.path; | 544 String uriPath = uri.path; |
| 543 if (uriPath != null && uriPath.startsWith(rootPath)) { | 545 if (uriPath != null && uriPath.startsWith(rootPath)) { |
| 544 String filePath = uri.path.substring(rootPath.length); | 546 String filePath = uri.path.substring(rootPath.length); |
| 545 for (JavaFile dir in _relativeDirectories) { | 547 for (JavaFile dir in _relativeDirectories) { |
| 546 JavaFile file = new JavaFile.relative(dir, filePath); | 548 JavaFile file = new JavaFile.relative(dir, filePath); |
| 547 if (file.exists()) { | 549 if (file.exists()) { |
| 548 return new FileBasedSource(file, uri); | 550 return new FileBasedSource(file, actualUri != null ? actualUri : uri); |
| 549 } | 551 } |
| 550 } | 552 } |
| 551 } | 553 } |
| 552 return null; | 554 return null; |
| 553 } | 555 } |
| 554 | 556 |
| 555 /** | 557 /** |
| 556 * Return `true` if the given URI is a `file` URI. | 558 * Return `true` if the given URI is a `file` URI. |
| 557 * | 559 * |
| 558 * @param uri the URI being tested | 560 * @param uri the URI being tested |
| 559 * @return `true` if the given URI is a `file` URI | 561 * @return `true` if the given URI is a `file` URI |
| 560 */ | 562 */ |
| 561 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; | 563 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
| 562 } | 564 } |
| OLD | NEW |