Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1127)

Unified Diff: pkg/kernel/lib/repository.dart

Issue 2532053005: Store library paths relative to a given application root folder. (Closed)
Patch Set: Revert changes to testcase baseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/test/baseline_tester.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/repository.dart
diff --git a/pkg/kernel/lib/repository.dart b/pkg/kernel/lib/repository.dart
index 7689d90f162bf639101e33c76f5e594955c8ccf7..265a75c25e39b9db88a3a4de2c22758bf2a3a329 100644
--- a/pkg/kernel/lib/repository.dart
+++ b/pkg/kernel/lib/repository.dart
@@ -3,10 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
library kernel.repository;
-import 'dart:io';
-
-import 'package:path/path.dart' as pathlib;
-
import 'ast.dart';
/// Keeps track of which [Library] objects have been created for a given URI.
@@ -14,61 +10,16 @@ import 'ast.dart';
/// To load different files into the same IR, pass in the same repository
/// object to the loaders.
class Repository {
- final String workingDirectory;
final Map<Uri, Library> _uriToLibrary = <Uri, Library>{};
final List<Library> libraries = <Library>[];
- Repository({String workingDirectory})
- : this.workingDirectory = workingDirectory ?? Directory.current.path;
-
- /// Get the [Library] object for the library addresesd by [path]; possibly
- /// as an external library.
- ///
- /// The [path] may be a relative or absolute file path, or a URI string with a
- /// `dart:`, `package:` or `file:` scheme.
- ///
- /// Note that this method does not check if the library can be loaded at all.
- Library getLibrary(String path) {
- return getLibraryReference(normalizePath(path));
- }
-
- String normalizeFileExtension(String path) {
- if (path.endsWith('.dill')) {
- return path.substring(0, path.length - '.dill'.length) + '.dart';
- } else {
- return path;
- }
- }
-
- /// Get the canonical URI for the library addressed by the given [path].
- ///
- /// The [path] may be a relative or absolute file path, or a URI string with a
- /// `dart:`, `package:` or `file:` scheme.
- Uri normalizePath(String path) {
- var uri = Uri.parse(path);
- if (!uri.hasScheme) {
- if (!pathlib.isAbsolute(path)) {
- path = pathlib.join(workingDirectory, path);
- }
- uri = new Uri(scheme: 'file', path: normalizeFileExtension(path));
- } else if (uri.scheme == 'file') {
- var path = normalizeFileExtension(uri.path);
- if (!uri.hasAbsolutePath) {
- uri = uri.replace(path: pathlib.join(workingDirectory, path));
- } else {
- uri = uri.replace(path: path);
- }
- }
- return uri;
- }
-
Library getLibraryReference(Uri uri) {
assert(uri.hasScheme);
- assert(uri.scheme != 'file' || uri.hasAbsolutePath);
return _uriToLibrary.putIfAbsent(uri, () => _buildLibraryReference(uri));
}
Library _buildLibraryReference(Uri uri) {
+ assert(uri.hasScheme);
var library = new Library(uri, isExternal: true);
libraries.add(library);
return library;
« no previous file with comments | « pkg/kernel/lib/ast.dart ('k') | pkg/kernel/test/baseline_tester.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698