| 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.src.generated.source_io; | 5 library analyzer.src.generated.source_io; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/java_core.dart'; | |
| 11 import 'package:analyzer/src/generated/java_engine.dart'; | 10 import 'package:analyzer/src/generated/java_engine.dart'; |
| 12 import 'package:analyzer/src/generated/java_io.dart'; | 11 import 'package:analyzer/src/generated/java_io.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
| 14 | 13 |
| 15 export 'package:analyzer/src/generated/source.dart'; | 14 export 'package:analyzer/src/generated/source.dart'; |
| 16 | 15 |
| 17 /** | 16 /** |
| 18 * Instances of the class [DirectoryBasedSourceContainer] represent a source con
tainer that | 17 * Instances of the class [DirectoryBasedSourceContainer] represent a source con
tainer that |
| 19 * contains all sources within a given directory. | 18 * contains all sources within a given directory. |
| 20 */ | 19 */ |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 Uri restoreAbsolute(Source source) { | 472 Uri restoreAbsolute(Source source) { |
| 474 String sourceUri = _toFileUri(source.fullName); | 473 String sourceUri = _toFileUri(source.fullName); |
| 475 for (JavaFile packagesDirectory in _packagesDirectories) { | 474 for (JavaFile packagesDirectory in _packagesDirectories) { |
| 476 List<JavaFile> pkgFolders = packagesDirectory.listFiles(); | 475 List<JavaFile> pkgFolders = packagesDirectory.listFiles(); |
| 477 if (pkgFolders != null) { | 476 if (pkgFolders != null) { |
| 478 for (JavaFile pkgFolder in pkgFolders) { | 477 for (JavaFile pkgFolder in pkgFolders) { |
| 479 try { | 478 try { |
| 480 String pkgCanonicalUri = _toFileUri(pkgFolder.getCanonicalPath()); | 479 String pkgCanonicalUri = _toFileUri(pkgFolder.getCanonicalPath()); |
| 481 if (sourceUri.startsWith(pkgCanonicalUri)) { | 480 if (sourceUri.startsWith(pkgCanonicalUri)) { |
| 482 String relPath = sourceUri.substring(pkgCanonicalUri.length); | 481 String relPath = sourceUri.substring(pkgCanonicalUri.length); |
| 483 return parseUriWithException( | 482 return Uri |
| 484 "$PACKAGE_SCHEME:${pkgFolder.getName()}$relPath"); | 483 .parse("$PACKAGE_SCHEME:${pkgFolder.getName()}$relPath"); |
| 485 } | 484 } |
| 486 } catch (e) {} | 485 } catch (e) {} |
| 487 } | 486 } |
| 488 } | 487 } |
| 489 } | 488 } |
| 490 return null; | 489 return null; |
| 491 } | 490 } |
| 492 | 491 |
| 493 /** | 492 /** |
| 494 * @return `true` if "file" was found in "packagesDir", and it is part of the
"lib" folder | 493 * @return `true` if "file" was found in "packagesDir", and it is part of the
"lib" folder |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 567 } |
| 569 | 568 |
| 570 /** | 569 /** |
| 571 * Return `true` if the given URI is a `file` URI. | 570 * Return `true` if the given URI is a `file` URI. |
| 572 * | 571 * |
| 573 * @param uri the URI being tested | 572 * @param uri the URI being tested |
| 574 * @return `true` if the given URI is a `file` URI | 573 * @return `true` if the given URI is a `file` URI |
| 575 */ | 574 */ |
| 576 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; | 575 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
| 577 } | 576 } |
| OLD | NEW |