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

Unified Diff: pkg/analyzer/lib/src/generated/source_io.dart

Issue 257773008: New analyzer snapshot, based on r35422. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update pubspec.yaml Created 6 years, 8 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
Index: pkg/analyzer/lib/src/generated/source_io.dart
diff --git a/pkg/analyzer/lib/src/generated/source_io.dart b/pkg/analyzer/lib/src/generated/source_io.dart
index fc96b6483fdbfa9160607abc1486f5cf1bd1d69d..4d23c42ba9e468e31c12806ed7c3c11170b35f39 100644
--- a/pkg/analyzer/lib/src/generated/source_io.dart
+++ b/pkg/analyzer/lib/src/generated/source_io.dart
@@ -15,48 +15,61 @@ import 'engine.dart';
export 'source.dart';
/**
- * Instances of interface `LocalSourcePredicate` are used to determine if the given
- * [Source] is "local" in some sense, so can be updated.
+ * Instances of the class `RelativeFileUriResolver` resolve `file` URI's.
*/
-abstract class LocalSourcePredicate {
+class RelativeFileUriResolver extends UriResolver {
/**
- * Instance of [LocalSourcePredicate] that always returns `false`.
+ * The name of the `file` scheme.
*/
- static final LocalSourcePredicate FALSE = new LocalSourcePredicate_FALSE();
+ static String FILE_SCHEME = "file";
/**
- * Instance of [LocalSourcePredicate] that always returns `true`.
+ * Return `true` if the given URI is a `file` URI.
+ *
+ * @param uri the URI being tested
+ * @return `true` if the given URI is a `file` URI
*/
- static final LocalSourcePredicate TRUE = new LocalSourcePredicate_TRUE();
+ static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
/**
- * Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
- * except of SDK.
+ * The directories for the relatvie URI's
*/
- static final LocalSourcePredicate NOT_SDK = new LocalSourcePredicate_NOT_SDK();
+ final List<JavaFile> _relativeDirectories;
/**
- * Determines if the given [Source] is local.
- *
- * @param source the [Source] to analyze
- * @return `true` if the given [Source] is local
+ * The root directory for all the source trees
*/
- bool isLocal(Source source);
-}
+ final JavaFile _rootDirectory;
-class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
- @override
- bool isLocal(Source source) => false;
-}
+ /**
+ * Initialize a newly created resolver to resolve `file` URI's relative to the given root
+ * directory.
+ */
+ RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories) : super();
-class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
@override
- bool isLocal(Source source) => true;
-}
+ Source fromEncoding(UriKind kind, Uri uri) {
+ if (kind == UriKind.FILE_URI) {
+ return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
+ }
+ return null;
+ }
-class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
@override
- bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
+ Source resolveAbsolute(Uri uri) {
+ String rootPath = _rootDirectory.toURI().path;
+ String uriPath = uri.path;
+ if (uriPath != null && uriPath.startsWith(rootPath)) {
+ String filePath = uri.path.substring(rootPath.length);
+ for (JavaFile dir in _relativeDirectories) {
+ JavaFile file = new JavaFile.relative(dir, filePath);
+ if (file.exists()) {
+ return new FileBasedSource.con2(file, UriKind.FILE_URI);
+ }
+ }
+ }
+ return null;
+ }
}
/**
@@ -113,7 +126,7 @@ class FileBasedSource implements Source {
@override
String get encoding {
if (_encoding == null) {
- _encoding = "${uriKind.encoding}${file.toURI().toString()}";
+ _encoding = "${new String.fromCharCode(uriKind.encoding)}${file.toURI().toString()}";
}
return _encoding;
}
@@ -168,6 +181,40 @@ class FileBasedSource implements Source {
}
/**
+ * Instances of the class `FileUriResolver` resolve `file` URI's.
+ */
+class FileUriResolver extends UriResolver {
+ /**
+ * The name of the `file` scheme.
+ */
+ static String FILE_SCHEME = "file";
+
+ /**
+ * Return `true` if the given URI is a `file` URI.
+ *
+ * @param uri the URI being tested
+ * @return `true` if the given URI is a `file` URI
+ */
+ static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
+
+ @override
+ Source fromEncoding(UriKind kind, Uri uri) {
+ if (kind == UriKind.FILE_URI) {
+ return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
+ }
+ return null;
+ }
+
+ @override
+ Source resolveAbsolute(Uri uri) {
+ if (!isFileUri(uri)) {
+ return null;
+ }
+ return new FileBasedSource.con1(new JavaFile.fromUri(uri));
+ }
+}
+
+/**
* An implementation of an non-existing [Source].
*/
class NonExistingSource implements Source {
@@ -209,61 +256,48 @@ class NonExistingSource implements Source {
}
/**
- * Instances of the class `RelativeFileUriResolver` resolve `file` URI's.
+ * Instances of interface `LocalSourcePredicate` are used to determine if the given
+ * [Source] is "local" in some sense, so can be updated.
*/
-class RelativeFileUriResolver extends UriResolver {
+abstract class LocalSourcePredicate {
/**
- * The name of the `file` scheme.
+ * Instance of [LocalSourcePredicate] that always returns `false`.
*/
- static String FILE_SCHEME = "file";
+ static final LocalSourcePredicate FALSE = new LocalSourcePredicate_FALSE();
/**
- * Return `true` if the given URI is a `file` URI.
- *
- * @param uri the URI being tested
- * @return `true` if the given URI is a `file` URI
+ * Instance of [LocalSourcePredicate] that always returns `true`.
*/
- static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
+ static final LocalSourcePredicate TRUE = new LocalSourcePredicate_TRUE();
/**
- * The directories for the relatvie URI's
+ * Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
+ * except of SDK.
*/
- final List<JavaFile> _relativeDirectories;
+ static final LocalSourcePredicate NOT_SDK = new LocalSourcePredicate_NOT_SDK();
/**
- * The root directory for all the source trees
+ * Determines if the given [Source] is local.
+ *
+ * @param source the [Source] to analyze
+ * @return `true` if the given [Source] is local
*/
- final JavaFile _rootDirectory;
+ bool isLocal(Source source);
+}
- /**
- * Initialize a newly created resolver to resolve `file` URI's relative to the given root
- * directory.
- */
- RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories) : super();
+class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
+ @override
+ bool isLocal(Source source) => false;
+}
+class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
@override
- Source fromEncoding(UriKind kind, Uri uri) {
- if (kind == UriKind.FILE_URI) {
- return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
- }
- return null;
- }
+ bool isLocal(Source source) => true;
+}
+class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
@override
- Source resolveAbsolute(Uri uri) {
- String rootPath = _rootDirectory.toURI().path;
- String uriPath = uri.path;
- if (uriPath != null && uriPath.startsWith(rootPath)) {
- String filePath = uri.path.substring(rootPath.length);
- for (JavaFile dir in _relativeDirectories) {
- JavaFile file = new JavaFile.relative(dir, filePath);
- if (file.exists()) {
- return new FileBasedSource.con2(file, UriKind.FILE_URI);
- }
- }
- }
- return null;
- }
+ bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
}
/**
@@ -481,38 +515,4 @@ class DirectoryBasedSourceContainer implements SourceContainer {
@override
String toString() => "SourceContainer[${_path}]";
-}
-
-/**
- * Instances of the class `FileUriResolver` resolve `file` URI's.
- */
-class FileUriResolver extends UriResolver {
- /**
- * The name of the `file` scheme.
- */
- static String FILE_SCHEME = "file";
-
- /**
- * Return `true` if the given URI is a `file` URI.
- *
- * @param uri the URI being tested
- * @return `true` if the given URI is a `file` URI
- */
- static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
-
- @override
- Source fromEncoding(UriKind kind, Uri uri) {
- if (kind == UriKind.FILE_URI) {
- return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
- }
- return null;
- }
-
- @override
- Source resolveAbsolute(Uri uri) {
- if (!isFileUri(uri)) {
- return null;
- }
- return new FileBasedSource.con1(new JavaFile.fromUri(uri));
- }
}

Powered by Google App Engine
This is Rietveld 408576698