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

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

Issue 12502002: Update analyzer-experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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-experimental/lib/src/generated/source_io.dart
diff --git a/pkg/analyzer-experimental/lib/src/generated/source_io.dart b/pkg/analyzer-experimental/lib/src/generated/source_io.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7a9c0093f6a98d32816dce587b0cbe5769bcd753
--- /dev/null
+++ b/pkg/analyzer-experimental/lib/src/generated/source_io.dart
@@ -0,0 +1,251 @@
+// This code was auto-generated, is not intended to be edited, and is subject to
+// significant change. Please see the README file for more information.
+
+library engine.source.io;
+
+import 'source.dart';
+import 'dart:io';
+import 'dart:uri';
+import 'java_core.dart';
+import 'java_io.dart';
+import 'package:analyzer-experimental/src/generated/sdk.dart' show DartSdk;
+export 'source.dart';
+
+/**
+ * Instances of the class {@code FileBasedSource} implement a source that represents a file.
+ */
+class FileBasedSource implements Source {
+ /**
+ * The source factory that created this source and that should be used to resolve URI's against
+ * this source.
+ */
+ SourceFactory _factory;
+ /**
+ * The file represented by this source.
+ */
+ File _file;
+ /**
+ * A flag indicating whether this source is in one of the system libraries.
+ */
+ bool _inSystemLibrary = false;
+ /**
+ * Initialize a newly created source object. The source object is assumed to not be in a system
+ * library.
+ * @param factory the source factory that created this source
+ * @param file the file represented by this source
+ */
+ FileBasedSource.con1(SourceFactory factory, File file) {
+ _jtd_constructor_278_impl(factory, file);
+ }
+ _jtd_constructor_278_impl(SourceFactory factory, File file) {
+ _jtd_constructor_279_impl(factory, file, false);
+ }
+ /**
+ * Initialize a newly created source object.
+ * @param factory the source factory that created this source
+ * @param file the file represented by this source
+ * @param inSystemLibrary {@code true} if this source is in one of the system libraries
+ */
+ FileBasedSource.con2(SourceFactory factory2, File file3, bool inSystemLibrary2) {
+ _jtd_constructor_279_impl(factory2, file3, inSystemLibrary2);
+ }
+ _jtd_constructor_279_impl(SourceFactory factory2, File file3, bool inSystemLibrary2) {
+ this._factory = factory2;
+ this._file = file3;
+ this._inSystemLibrary = inSystemLibrary2;
+ }
+ bool operator ==(Object object) => object != null && identical(this.runtimeType, object.runtimeType) && _file == ((object as FileBasedSource))._file;
+ bool exists() => _file.existsSync();
+ void getContents(Source_ContentReceiver receiver) {
+ receiver.accept2(_file.readAsStringSync());
+ }
+ String get encoding => newUriFromFile(_file).toString();
+ String get fullName => _file.fullPathSync();
+ String get shortName => _file.path;
+ int get hashCode => _file.hashCode;
+ bool isInSystemLibrary() => _inSystemLibrary;
+ Source resolve(String uri) => _factory.resolveUri(this, uri);
+ Source resolveRelative(Uri containedUri) {
+ try {
+ Uri resolvedUri = newUriFromFile(file).resolveUri(containedUri);
+ return new FileBasedSource.con1(_factory, newFileFromUri(resolvedUri));
+ } on JavaException catch (exception) {
+ }
+ return null;
+ }
+ String toString() {
+ if (_file == null) {
+ return "<unknown source>";
+ }
+ return _file.fullPathSync();
+ }
+ /**
+ * Return the file represented by this source. This is an internal method that is only intended to
+ * be used by {@link UriResolver}.
+ * @return the file represented by this source
+ */
+ File get file => _file;
+}
+/**
+ * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's.
+ */
+class DartUriResolver extends UriResolver {
+ /**
+ * The Dart SDK against which URI's are to be resolved.
+ */
+ DartSdk _sdk;
+ /**
+ * The name of the {@code dart} scheme.
+ */
+ static String _DART_SCHEME = "dart";
+ /**
+ * Return {@code true} if the given URI is a {@code dart:} URI.
+ * @param uri the URI being tested
+ * @return {@code true} if the given URI is a {@code dart:} URI
+ */
+ static bool isDartUri(Uri uri) => uri.scheme == _DART_SCHEME;
+ /**
+ * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
+ * given Dart SDK.
+ * @param sdk the Dart SDK against which URI's are to be resolved
+ */
+ DartUriResolver(DartSdk sdk) {
+ this._sdk = sdk;
+ }
+ Source resolveAbsolute(SourceFactory factory, Uri uri) {
+ if (!isDartUri(uri)) {
+ return null;
+ }
+ File resolvedFile = _sdk.mapDartUri(uri.toString());
+ return new FileBasedSource.con2(factory, resolvedFile, true);
+ }
+}
+/**
+ * Instances of the class {@code PackageUriResolver} resolve {@code package} URI's in the context of
+ * an application.
+ */
+class PackageUriResolver extends UriResolver {
+ /**
+ * The package directories that {@code package} URI's are assumed to be relative to.
+ */
+ List<File> _packagesDirectories;
+ /**
+ * The name of the {@code package} scheme.
+ */
+ static String _PACKAGE_SCHEME = "package";
+ /**
+ * Return {@code true} if the given URI is a {@code package} URI.
+ * @param uri the URI being tested
+ * @return {@code true} if the given URI is a {@code package} URI
+ */
+ static bool isPackageUri(Uri uri) => uri.scheme == _PACKAGE_SCHEME;
+ /**
+ * Initialize a newly created resolver to resolve {@code package} URI's relative to the given
+ * package directories.
+ * @param packagesDirectories the package directories that {@code package} URI's are assumed to be
+ * relative to
+ */
+ PackageUriResolver(List<File> packagesDirectories) {
+ if (packagesDirectories.length < 1) {
+ throw new IllegalArgumentException("At least one package directory must be provided");
+ }
+ this._packagesDirectories = packagesDirectories;
+ }
+ Source resolveAbsolute(SourceFactory factory, Uri uri) {
+ if (!isPackageUri(uri)) {
+ return null;
+ }
+ String path4 = uri.path;
+ if (path4 == null) {
+ path4 = uri.path;
+ if (path4 == null) {
+ return null;
+ }
+ }
+ for (File packagesDirectory in _packagesDirectories) {
+ File resolvedFile = newRelativeFile(packagesDirectory, path4);
+ if (resolvedFile.existsSync()) {
+ return new FileBasedSource.con1(factory, resolvedFile);
+ }
+ }
+ return new FileBasedSource.con1(factory, newRelativeFile(_packagesDirectories[0], path4));
+ }
+}
+/**
+ * Instances of the class {@link DirectoryBasedSourceContainer} represent a source container that
+ * contains all sources within a given directory.
+ */
+class DirectoryBasedSourceContainer implements SourceContainer {
+ /**
+ * Append the system file separator to the given path unless the path already ends with a
+ * separator.
+ * @param path the path to which the file separator is to be added
+ * @return a path that ends with the system file separator
+ */
+ static String appendFileSeparator(String path) {
+ if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaSystemIO.pathSeparatorChar) {
+ return path;
+ }
+ return "${path}${JavaSystemIO.pathSeparator}";
+ }
+ /**
+ * The container's path (not {@code null}).
+ */
+ String _path;
+ /**
+ * Construct a container representing the specified directory and containing any sources whose{@link Source#getFullName()} starts with the directory's path. This is a convenience method,
+ * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSourceContainer(String)}.
+ * @param directory the directory (not {@code null})
+ */
+ DirectoryBasedSourceContainer.con1(File directory) {
+ _jtd_constructor_276_impl(directory);
+ }
+ _jtd_constructor_276_impl(File directory) {
+ _jtd_constructor_277_impl(directory.fullPathSync());
+ }
+ /**
+ * Construct a container representing the specified path and containing any sources whose{@link Source#getFullName()} starts with the specified path.
+ * @param path the path (not {@code null} and not empty)
+ */
+ DirectoryBasedSourceContainer.con2(String path3) {
+ _jtd_constructor_277_impl(path3);
+ }
+ _jtd_constructor_277_impl(String path3) {
+ this._path = appendFileSeparator(path3);
+ }
+ bool contains(Source source) => source.fullName.startsWith(_path);
+ bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && ((obj as DirectoryBasedSourceContainer)).path == path;
+ /**
+ * Answer the receiver's path, used to determine if a source is contained in the receiver.
+ * @return the path (not {@code null}, not empty)
+ */
+ String get path => _path;
+ int get hashCode => _path.hashCode;
+}
+/**
+ * Instances of the class {@code FileUriResolver} resolve {@code file} URI's.
+ */
+class FileUriResolver extends UriResolver {
+ /**
+ * The name of the {@code file} scheme.
+ */
+ static String _FILE_SCHEME = "file";
+ /**
+ * Return {@code true} if the given URI is a {@code file} URI.
+ * @param uri the URI being tested
+ * @return {@code true} if the given URI is a {@code file} URI
+ */
+ static bool isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
+ /**
+ * Initialize a newly created resolver to resolve {@code file} URI's relative to the given root
+ * directory.
+ */
+ FileUriResolver() : super() {
+ }
+ Source resolveAbsolute(SourceFactory factory, Uri uri) {
+ if (!isFileUri(uri)) {
+ return null;
+ }
+ return new FileBasedSource.con1(factory, newFileFromUri(uri));
+ }
+}
« no previous file with comments | « pkg/analyzer-experimental/lib/src/generated/source.dart ('k') | pkg/analyzer-experimental/test/generated/ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698