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

Unified Diff: pkg/analyzer/lib/src/context/builder.dart

Issue 2266763002: Remove changes that were accidentally entangled with an earlier CL (TBD) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months 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/analysis_server/test/analysis_server_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/builder.dart
diff --git a/pkg/analyzer/lib/src/context/builder.dart b/pkg/analyzer/lib/src/context/builder.dart
index 7d0ae3b11f1d378c81b18505fc714ed96d73b4e4..51c0a219a16a528dcbe222b42eace0dad093a0a1 100644
--- a/pkg/analyzer/lib/src/context/builder.dart
+++ b/pkg/analyzer/lib/src/context/builder.dart
@@ -17,7 +17,6 @@ import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/task/options.dart';
-import 'package:charcode/ascii.dart';
import 'package:package_config/packages.dart';
import 'package:package_config/packages_file.dart';
import 'package:package_config/src/packages_impl.dart';
@@ -216,11 +215,9 @@ class ContextBuilder {
packageResolver,
fileResolver
];
- return new SourceFactory(resolvers, null, resourceProvider);
+ return new SourceFactory(resolvers);
}
}
-// Packages packages = new _ResolvedLinkPackages(
-// resourceProvider, createPackageMap(rootDirectoryPath));
Packages packages = createPackageMap(rootDirectoryPath);
Map<String, List<Folder>> packageMap = convertPackagesToMap(packages);
List<UriResolver> resolvers = <UriResolver>[];
@@ -231,7 +228,7 @@ class ContextBuilder {
resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap));
}
resolvers.add(fileResolver);
- return new SourceFactory(resolvers, packages, resourceProvider);
+ return new SourceFactory(resolvers);
}
/**
@@ -541,130 +538,3 @@ class EmbedderYamlLocator {
}
}
}
-
-/// Can we remove this class by resolving symbolic links when creating the
-/// original Packages object?
-class _ResolvedLinkPackages implements Packages {
- /// All ASCII characters that are valid in a package name, with space
- /// for all the invalid ones (including space).
- static const String _validPackageNameCharacters =
- r" ! $ &'()*+,-. 0123456789 ; = "
- r"@ABCDEFGHIJKLMNOPQRSTUVWXYZ _ abcdefghijklmnopqrstuvwxyz ~ ";
-
- final ResourceProvider resourceProvider;
-
- final Packages basePackages;
-
- Map<String, Uri> map;
-
- _ResolvedLinkPackages(this.resourceProvider, this.basePackages);
-
- @override
- Iterable<String> get packages => asMap().keys;
-
- @override
- Map<String, Uri> asMap() {
- if (map == null) {
- map = new HashMap<String, Uri>();
- basePackages.asMap().forEach((String packageName, Uri uri) {
- File file =
- resourceProvider.getFile(resourceProvider.pathContext.fromUri(uri));
- map[packageName] =
- resourceProvider.pathContext.toUri(file.resolveSymbolicLinksSync());
- });
- }
- return map;
- }
-
- /// Validate that a Uri is a valid package:URI.
- String checkValidPackageUri(Uri packageUri) {
- if (packageUri.scheme != "package") {
- throw new ArgumentError.value(
- packageUri, "packageUri", "Not a package: URI");
- }
- if (packageUri.hasAuthority) {
- throw new ArgumentError.value(
- packageUri, "packageUri", "Package URIs must not have a host part");
- }
- if (packageUri.hasQuery) {
- // A query makes no sense if resolved to a file: URI.
- throw new ArgumentError.value(
- packageUri, "packageUri", "Package URIs must not have a query part");
- }
- if (packageUri.hasFragment) {
- // We could leave the fragment after the URL when resolving,
- // but it would be odd if "package:foo/foo.dart#1" and
- // "package:foo/foo.dart#2" were considered different libraries.
- // Keep the syntax open in case we ever get multiple libraries in one file.
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package URIs must not have a fragment part");
- }
- if (packageUri.path.startsWith('/')) {
- throw new ArgumentError.value(
- packageUri, "packageUri", "Package URIs must not start with a '/'");
- }
- int firstSlash = packageUri.path.indexOf('/');
- if (firstSlash == -1) {
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package URIs must start with the package name followed by a '/'");
- }
- String packageName = packageUri.path.substring(0, firstSlash);
- int badIndex = _findInvalidCharacter(packageName);
- if (badIndex >= 0) {
- if (packageName.isEmpty) {
- throw new ArgumentError.value(
- packageUri, "packageUri", "Package names mus be non-empty");
- }
- if (badIndex == packageName.length) {
- throw new ArgumentError.value(packageUri, "packageUri",
- "Package names must contain at least one non-'.' character");
- }
- assert(badIndex < packageName.length);
- int badCharCode = packageName.codeUnitAt(badIndex);
- var badChar = "U+" + badCharCode.toRadixString(16).padLeft(4, '0');
- if (badCharCode >= 0x20 && badCharCode <= 0x7e) {
- // Printable character.
- badChar = "'${packageName[badIndex]}' ($badChar)";
- }
- throw new ArgumentError.value(
- packageUri, "packageUri", "Package names must not contain $badChar");
- }
- return packageName;
- }
-
- @override
- Uri resolve(Uri packageUri, {Uri notFound(Uri packageUri)}) {
- packageUri = new Uri().resolveUri(packageUri);
- String packageName = checkValidPackageUri(packageUri);
- Uri packageBase = asMap()[packageName];
- if (packageBase == null) {
- if (notFound != null) return notFound(packageUri);
- throw new ArgumentError.value(
- packageUri, "packageUri", 'No package named "$packageName"');
- }
- String packagePath = packageUri.path.substring(packageName.length + 1);
- return packageBase.resolve(packagePath);
- }
-
- /// Check if a string is a valid package name.
- ///
- /// Valid package names contain only characters in [_validPackageNameCharacters]
- /// and must contain at least one non-'.' character.
- ///
- /// Returns `-1` if the string is valid.
- /// Otherwise returns the index of the first invalid character,
- /// or `string.length` if the string contains no non-'.' character.
- int _findInvalidCharacter(String string) {
- // Becomes non-zero if any non-'.' character is encountered.
- int nonDot = 0;
- for (int i = 0; i < string.length; i++) {
- var c = string.codeUnitAt(i);
- if (c > 0x7f || _validPackageNameCharacters.codeUnitAt(c) <= $space) {
- return i;
- }
- nonDot += c ^ $dot;
- }
- if (nonDot == 0) return string.length;
- return -1;
- }
-}
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698