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

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

Issue 259773005: New analyzer snapshot. Sorted unit members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/lib/src/generated/source_io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/source.dart
diff --git a/pkg/analyzer/lib/src/generated/source.dart b/pkg/analyzer/lib/src/generated/source.dart
index 767ff56495cfff0e57facaefecf8e615d409afcf..3e41f46a0afb2391ea6fb47b7b4f51beca808b58 100644
--- a/pkg/analyzer/lib/src/generated/source.dart
+++ b/pkg/analyzer/lib/src/generated/source.dart
@@ -12,247 +12,137 @@ import 'sdk.dart' show DartSdk;
import 'engine.dart' show AnalysisContext, TimestampedData;
/**
- * The abstract class `UriResolver` defines the behavior of objects that are used to resolve
- * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
- * absolute URI.
- */
-abstract class UriResolver {
- /**
- * If this resolver should be used for URI's of the given kind, resolve the given absolute URI.
- * The URI does not need to have the scheme handled by this resolver if the kind matches. Return a
- * [Source] representing the file to which it was resolved, whether or not the
- * resulting source exists, or `null` if it could not be resolved because the URI is
- * invalid.
- *
- * @param kind the kind of URI that was originally resolved in order to produce an encoding with
- * the given URI
- * @param uri the URI to be resolved
- * @return a [Source] representing the file to which given URI was resolved
- */
- Source fromEncoding(UriKind kind, Uri uri);
-
- /**
- * Resolve the given absolute URI. Return a [Source] representing the file to which
- * it was resolved, whether or not the resulting source exists, or `null` if it could not be
- * resolved because the URI is invalid.
- *
- * @param uri the URI to be resolved
- * @return a [Source] representing the file to which given URI was resolved
- */
- Source resolveAbsolute(Uri uri);
-
- /**
- * Return an absolute URI that represents the given source, or `null` if a valid URI cannot
- * be computed.
- *
- * @param source the source to get URI for
- * @return the absolute URI representing the given source
- */
- Uri restoreAbsolute(Source source) => null;
-}
-
-/**
- * The interface `Source` defines the behavior of objects representing source code that can be
- * analyzed by the analysis engine.
- *
- * Implementations of this interface need to be aware of some assumptions made by the analysis
- * engine concerning sources:
- * * Sources are not required to be unique. That is, there can be multiple instances representing
- * the same source.
- * * Sources are long lived. That is, the engine is allowed to hold on to a source for an extended
- * period of time and that source must continue to report accurate and up-to-date information.
- * Because of these assumptions, most implementations will not maintain any state but will delegate
- * to an authoritative system of record in order to implement this API. For example, a source that
- * represents files on disk would typically query the file system to determine the state of the
- * file.
- *
- * If the instances that implement this API are the system of record, then they will typically be
- * unique. In that case, sources that are created that represent non-existent files must also be
- * retained so that if those files are created at a later date the long-lived sources representing
- * those files will know that they now exist.
+ * Instances of class `ContentCache` hold content used to override the default content of a
+ * [Source].
*/
-abstract class Source {
- /**
- * An empty array of sources.
- */
- static final List<Source> EMPTY_ARRAY = new List<Source>(0);
-
+class ContentCache {
/**
- * Return `true` if the given object is a source that represents the same source code as
- * this source.
- *
- * @param object the object to be compared with this object
- * @return `true` if the given object is a source that represents the same source code as
- * this source
- * @see Object#equals(Object)
+ * A table mapping sources to the contents of those sources. This is used to override the default
+ * contents of a source.
*/
- @override
- bool operator ==(Object object);
+ Map<Source, String> _contentMap = new Map<Source, String>();
/**
- * Return `true` if this source exists.
- *
- * Clients should consider using the the method [AnalysisContext#exists] because
- * contexts can have local overrides of the content of a source that the source is not aware of
- * and a source with local content is considered to exist even if there is no file on disk.
- *
- * @return `true` if this source exists
+ * A table mapping sources to the modification stamps of those sources. This is used when the
+ * default contents of a source has been overridden.
*/
- bool exists();
+ Map<Source, int> _stampMap = new Map<Source, int>();
/**
- * Get the contents and timestamp of this source.
+ * Return the contents of the given source, or `null` if this cache does not override the
+ * contents of the source.
*
- * Clients should consider using the the method [AnalysisContext#getContents]
- * because contexts can have local overrides of the content of a source that the source is not
- * aware of.
+ * <b>Note:</b> This method is not intended to be used except by
+ * [AnalysisContext#getContents].
*
- * @return the contents and timestamp of the source
- * @throws Exception if the contents of this source could not be accessed
+ * @param source the source whose content is to be returned
+ * @return the contents of the given source
*/
- TimestampedData<String> get contents;
+ String getContents(Source source) => _contentMap[source];
/**
- * Return an encoded representation of this source that can be used to create a source that is
- * equal to this source.
+ * Return the modification stamp of the given source, or `null` if this cache does not
+ * override the contents of the source.
*
- * @return an encoded representation of this source
- * @see SourceFactory#fromEncoding(String)
- */
- String get encoding;
-
- /**
- * Return the full (long) version of the name that can be displayed to the user to denote this
- * source. For example, for a source representing a file this would typically be the absolute path
- * of the file.
+ * <b>Note:</b> This method is not intended to be used except by
+ * [AnalysisContext#getModificationStamp].
*
- * @return a name that can be displayed to the user to denote this source
+ * @param source the source whose modification stamp is to be returned
+ * @return the modification stamp of the given source
*/
- String get fullName;
+ int getModificationStamp(Source source) => _stampMap[source];
/**
- * Return the modification stamp for this source. A modification stamp is a non-negative integer
- * with the property that if the contents of the source have not been modified since the last time
- * the modification stamp was accessed then the same value will be returned, but if the contents
- * of the source have been modified one or more times (even if the net change is zero) the stamps
- * will be different.
- *
- * Clients should consider using the the method
- * [AnalysisContext#getModificationStamp] because contexts can have local overrides
- * of the content of a source that the source is not aware of.
+ * Set the contents of the given source to the given contents. This has the effect of overriding
+ * the default contents of the source. If the contents are `null` the override is removed so
+ * that the default contents will be returned.
*
- * @return the modification stamp for this source
+ * @param source the source whose contents are being overridden
+ * @param contents the new contents of the source
+ * @return the original cached contents or `null` if none
*/
- int get modificationStamp;
+ String setContents(Source source, String contents) {
+ if (contents == null) {
+ _stampMap.remove(source);
+ return _contentMap.remove(source);
+ } else {
+ int newStamp = JavaSystem.currentTimeMillis();
+ int oldStamp = javaMapPut(_stampMap, source, newStamp);
+ // Occasionally, if this method is called in rapid succession, the timestamps are equal.
+ // Guard against this by artificially incrementing the new timestamp
+ if (newStamp == oldStamp) {
+ _stampMap[source] = newStamp + 1;
+ }
+ return javaMapPut(_contentMap, source, contents);
+ }
+ }
+}
+/**
+ * Instances of the class `DartUriResolver` resolve `dart` URI's.
+ */
+class DartUriResolver extends UriResolver {
/**
- * Return a short version of the name that can be displayed to the user to denote this source. For
- * example, for a source representing a file this would typically be the name of the file.
+ * Return `true` if the given URI is a `dart-ext:` URI.
*
- * @return a name that can be displayed to the user to denote this source
+ * @param uriContent the textual representation of the URI being tested
+ * @return `true` if the given URI is a `dart-ext:` URI
*/
- String get shortName;
+ static bool isDartExtUri(String uriContent) => uriContent != null && uriContent.startsWith(_DART_EXT_SCHEME);
/**
- * Return the kind of URI from which this source was originally derived. If this source was
- * created from an absolute URI, then the returned kind will reflect the scheme of the absolute
- * URI. If it was created from a relative URI, then the returned kind will be the same as the kind
- * of the source against which the relative URI was resolved.
- *
- * @return the kind of URI from which this source was originally derived
+ * The Dart SDK against which URI's are to be resolved.
*/
- UriKind get uriKind;
+ final DartSdk _sdk;
/**
- * Return a hash code for this source.
- *
- * @return a hash code for this source
- * @see Object#hashCode()
+ * The name of the `dart` scheme.
*/
- @override
- int get hashCode;
+ static String _DART_SCHEME = "dart";
/**
- * Return `true` if this source is in one of the system libraries.
- *
- * @return `true` if this is in a system library
+ * The prefix of a URI using the dart-ext scheme to reference a native code library.
*/
- bool get isInSystemLibrary;
+ static String _DART_EXT_SCHEME = "dart-ext:";
/**
- * Resolve the relative URI against the URI associated with this source object. Return a
- * [Source] representing the URI to which it was resolved, or `null` if it
- * could not be resolved.
- *
- * Note: This method is not intended for public use, it is only visible out of necessity. It is
- * only intended to be invoked by a [SourceFactory]. Source factories will
- * only invoke this method if the URI is relative, so implementations of this method are not
- * required to, and generally do not, verify the argument. The result of invoking this method with
- * an absolute URI is intentionally left unspecified.
+ * Return `true` if the given URI is a `dart:` URI.
*
- * @param relativeUri the relative URI to be resolved against the containing source
- * @return a [Source] representing the URI to which given URI was resolved
+ * @param uri the URI being tested
+ * @return `true` if the given URI is a `dart:` URI
*/
- Source resolveRelative(Uri relativeUri);
-}
+ static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme;
-/**
- * The interface `ContentReceiver` defines the behavior of objects that can receive the
- * content of a source.
- */
-abstract class Source_ContentReceiver {
/**
- * Accept the contents of a source.
+ * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
+ * given Dart SDK.
*
- * @param contents the contents of the source
- * @param modificationTime the time at which the contents were last set
- */
- void accept(String contents, int modificationTime);
-}
-
-/**
- * Instances of interface `LocalSourcePredicate` are used to determine if the given
- * [Source] is "local" in some sense, so can be updated.
- */
-abstract class LocalSourcePredicate {
- /**
- * Instance of [LocalSourcePredicate] that always returns `false`.
- */
- static final LocalSourcePredicate FALSE = new LocalSourcePredicate_FALSE();
-
- /**
- * Instance of [LocalSourcePredicate] that always returns `true`.
+ * @param sdk the Dart SDK against which URI's are to be resolved
*/
- static final LocalSourcePredicate TRUE = new LocalSourcePredicate_TRUE();
+ DartUriResolver(this._sdk);
- /**
- * Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
- * except of SDK.
- */
- static final LocalSourcePredicate NOT_SDK = new LocalSourcePredicate_NOT_SDK();
+ @override
+ Source fromEncoding(UriKind kind, Uri uri) {
+ if (kind == UriKind.DART_URI) {
+ return _sdk.fromEncoding(kind, uri);
+ }
+ return null;
+ }
/**
- * Determines if the given [Source] is local.
+ * Return the [DartSdk] against which URIs are to be resolved.
*
- * @param source the [Source] to analyze
- * @return `true` if the given [Source] is local
+ * @return the [DartSdk] against which URIs are to be resolved.
*/
- bool isLocal(Source source);
-}
-
-class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
- @override
- bool isLocal(Source source) => false;
-}
-
-class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
- @override
- bool isLocal(Source source) => true;
-}
+ DartSdk get dartSdk => _sdk;
-class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
@override
- bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
+ Source resolveAbsolute(Uri uri) {
+ if (!isDartUri(uri)) {
+ return null;
+ }
+ return _sdk.mapDartUri(uri.toString());
+ }
}
/**
@@ -322,137 +212,211 @@ class LineInfo_Location {
}
/**
- * Instances of class `ContentCache` hold content used to override the default content of a
- * [Source].
+ * Instances of interface `LocalSourcePredicate` are used to determine if the given
+ * [Source] is "local" in some sense, so can be updated.
*/
-class ContentCache {
+abstract class LocalSourcePredicate {
/**
- * A table mapping sources to the contents of those sources. This is used to override the default
- * contents of a source.
+ * Instance of [LocalSourcePredicate] that always returns `false`.
*/
- Map<Source, String> _contentMap = new Map<Source, String>();
+ static final LocalSourcePredicate FALSE = new LocalSourcePredicate_FALSE();
/**
- * A table mapping sources to the modification stamps of those sources. This is used when the
- * default contents of a source has been overridden.
+ * Instance of [LocalSourcePredicate] that always returns `true`.
*/
- Map<Source, int> _stampMap = new Map<Source, int>();
+ static final LocalSourcePredicate TRUE = new LocalSourcePredicate_TRUE();
/**
- * Return the contents of the given source, or `null` if this cache does not override the
- * contents of the source.
+ * Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
+ * except of SDK.
+ */
+ static final LocalSourcePredicate NOT_SDK = new LocalSourcePredicate_NOT_SDK();
+
+ /**
+ * Determines if the given [Source] is local.
*
- * <b>Note:</b> This method is not intended to be used except by
- * [AnalysisContext#getContents].
+ * @param source the [Source] to analyze
+ * @return `true` if the given [Source] is local
+ */
+ bool isLocal(Source source);
+}
+
+class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
+ @override
+ bool isLocal(Source source) => false;
+}
+
+class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
+ @override
+ bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
+}
+
+class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
+ @override
+ bool isLocal(Source source) => true;
+}
+
+/**
+ * The interface `Source` defines the behavior of objects representing source code that can be
+ * analyzed by the analysis engine.
+ *
+ * Implementations of this interface need to be aware of some assumptions made by the analysis
+ * engine concerning sources:
+ * * Sources are not required to be unique. That is, there can be multiple instances representing
+ * the same source.
+ * * Sources are long lived. That is, the engine is allowed to hold on to a source for an extended
+ * period of time and that source must continue to report accurate and up-to-date information.
+ * Because of these assumptions, most implementations will not maintain any state but will delegate
+ * to an authoritative system of record in order to implement this API. For example, a source that
+ * represents files on disk would typically query the file system to determine the state of the
+ * file.
+ *
+ * If the instances that implement this API are the system of record, then they will typically be
+ * unique. In that case, sources that are created that represent non-existent files must also be
+ * retained so that if those files are created at a later date the long-lived sources representing
+ * those files will know that they now exist.
+ */
+abstract class Source {
+ /**
+ * An empty array of sources.
+ */
+ static final List<Source> EMPTY_ARRAY = new List<Source>(0);
+
+ /**
+ * Return `true` if the given object is a source that represents the same source code as
+ * this source.
*
- * @param source the source whose content is to be returned
- * @return the contents of the given source
+ * @param object the object to be compared with this object
+ * @return `true` if the given object is a source that represents the same source code as
+ * this source
+ * @see Object#equals(Object)
+ */
+ @override
+ bool operator ==(Object object);
+
+ /**
+ * Return `true` if this source exists.
+ *
+ * Clients should consider using the the method [AnalysisContext#exists] because
+ * contexts can have local overrides of the content of a source that the source is not aware of
+ * and a source with local content is considered to exist even if there is no file on disk.
+ *
+ * @return `true` if this source exists
+ */
+ bool exists();
+
+ /**
+ * Get the contents and timestamp of this source.
+ *
+ * Clients should consider using the the method [AnalysisContext#getContents]
+ * because contexts can have local overrides of the content of a source that the source is not
+ * aware of.
+ *
+ * @return the contents and timestamp of the source
+ * @throws Exception if the contents of this source could not be accessed
*/
- String getContents(Source source) => _contentMap[source];
+ TimestampedData<String> get contents;
/**
- * Return the modification stamp of the given source, or `null` if this cache does not
- * override the contents of the source.
- *
- * <b>Note:</b> This method is not intended to be used except by
- * [AnalysisContext#getModificationStamp].
+ * Return an encoded representation of this source that can be used to create a source that is
+ * equal to this source.
*
- * @param source the source whose modification stamp is to be returned
- * @return the modification stamp of the given source
+ * @return an encoded representation of this source
+ * @see SourceFactory#fromEncoding(String)
*/
- int getModificationStamp(Source source) => _stampMap[source];
+ String get encoding;
/**
- * Set the contents of the given source to the given contents. This has the effect of overriding
- * the default contents of the source. If the contents are `null` the override is removed so
- * that the default contents will be returned.
+ * Return the full (long) version of the name that can be displayed to the user to denote this
+ * source. For example, for a source representing a file this would typically be the absolute path
+ * of the file.
*
- * @param source the source whose contents are being overridden
- * @param contents the new contents of the source
- * @return the original cached contents or `null` if none
+ * @return a name that can be displayed to the user to denote this source
*/
- String setContents(Source source, String contents) {
- if (contents == null) {
- _stampMap.remove(source);
- return _contentMap.remove(source);
- } else {
- int newStamp = JavaSystem.currentTimeMillis();
- int oldStamp = javaMapPut(_stampMap, source, newStamp);
- // Occasionally, if this method is called in rapid succession, the timestamps are equal.
- // Guard against this by artificially incrementing the new timestamp
- if (newStamp == oldStamp) {
- _stampMap[source] = newStamp + 1;
- }
- return javaMapPut(_contentMap, source, contents);
- }
- }
-}
+ String get fullName;
-/**
- * Instances of the class `DartUriResolver` resolve `dart` URI's.
- */
-class DartUriResolver extends UriResolver {
/**
- * Return `true` if the given URI is a `dart-ext:` URI.
+ * Return the modification stamp for this source. A modification stamp is a non-negative integer
+ * with the property that if the contents of the source have not been modified since the last time
+ * the modification stamp was accessed then the same value will be returned, but if the contents
+ * of the source have been modified one or more times (even if the net change is zero) the stamps
+ * will be different.
*
- * @param uriContent the textual representation of the URI being tested
- * @return `true` if the given URI is a `dart-ext:` URI
+ * Clients should consider using the the method
+ * [AnalysisContext#getModificationStamp] because contexts can have local overrides
+ * of the content of a source that the source is not aware of.
+ *
+ * @return the modification stamp for this source
*/
- static bool isDartExtUri(String uriContent) => uriContent != null && uriContent.startsWith(_DART_EXT_SCHEME);
+ int get modificationStamp;
/**
- * The Dart SDK against which URI's are to be resolved.
+ * Return a short version of the name that can be displayed to the user to denote this source. For
+ * example, for a source representing a file this would typically be the name of the file.
+ *
+ * @return a name that can be displayed to the user to denote this source
*/
- final DartSdk _sdk;
+ String get shortName;
/**
- * The name of the `dart` scheme.
+ * Return the kind of URI from which this source was originally derived. If this source was
+ * created from an absolute URI, then the returned kind will reflect the scheme of the absolute
+ * URI. If it was created from a relative URI, then the returned kind will be the same as the kind
+ * of the source against which the relative URI was resolved.
+ *
+ * @return the kind of URI from which this source was originally derived
*/
- static String _DART_SCHEME = "dart";
+ UriKind get uriKind;
/**
- * The prefix of a URI using the dart-ext scheme to reference a native code library.
+ * Return a hash code for this source.
+ *
+ * @return a hash code for this source
+ * @see Object#hashCode()
*/
- static String _DART_EXT_SCHEME = "dart-ext:";
+ @override
+ int get hashCode;
/**
- * Return `true` if the given URI is a `dart:` URI.
+ * Return `true` if this source is in one of the system libraries.
*
- * @param uri the URI being tested
- * @return `true` if the given URI is a `dart:` URI
+ * @return `true` if this is in a system library
*/
- static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme;
+ bool get isInSystemLibrary;
/**
- * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
- * given Dart SDK.
+ * Resolve the relative URI against the URI associated with this source object. Return a
+ * [Source] representing the URI to which it was resolved, or `null` if it
+ * could not be resolved.
*
- * @param sdk the Dart SDK against which URI's are to be resolved
+ * Note: This method is not intended for public use, it is only visible out of necessity. It is
+ * only intended to be invoked by a [SourceFactory]. Source factories will
+ * only invoke this method if the URI is relative, so implementations of this method are not
+ * required to, and generally do not, verify the argument. The result of invoking this method with
+ * an absolute URI is intentionally left unspecified.
+ *
+ * @param relativeUri the relative URI to be resolved against the containing source
+ * @return a [Source] representing the URI to which given URI was resolved
*/
- DartUriResolver(this._sdk);
-
- @override
- Source fromEncoding(UriKind kind, Uri uri) {
- if (kind == UriKind.DART_URI) {
- return _sdk.fromEncoding(kind, uri);
- }
- return null;
- }
+ Source resolveRelative(Uri relativeUri);
+}
+/**
+ * The interface `SourceContainer` is used by clients to define a collection of sources
+ *
+ * Source containers are not used within analysis engine, but can be used by clients to group
+ * sources for the purposes of accessing composite dependency information. For example, the Eclipse
+ * client uses source containers to represent Eclipse projects, which allows it to easily compute
+ * project-level dependencies.
+ */
+abstract class SourceContainer {
/**
- * Return the [DartSdk] against which URIs are to be resolved.
+ * Determine if the specified source is part of the receiver's collection of sources.
*
- * @return the [DartSdk] against which URIs are to be resolved.
+ * @param source the source in question
+ * @return `true` if the receiver contains the source, else `false`
*/
- DartSdk get dartSdk => _sdk;
-
- @override
- Source resolveAbsolute(Uri uri) {
- if (!isDartUri(uri)) {
- return null;
- }
- return _sdk.mapDartUri(uri.toString());
- }
+ bool contains(Source source);
}
/**
@@ -629,21 +593,36 @@ class SourceFactory {
}
/**
- * The interface `SourceContainer` is used by clients to define a collection of sources
- *
- * Source containers are not used within analysis engine, but can be used by clients to group
- * sources for the purposes of accessing composite dependency information. For example, the Eclipse
- * client uses source containers to represent Eclipse projects, which allows it to easily compute
- * project-level dependencies.
+ * The enumeration `SourceKind` defines the different kinds of sources that are known to the
+ * analysis engine.
*/
-abstract class SourceContainer {
+class SourceKind extends Enum<SourceKind> {
/**
- * Determine if the specified source is part of the receiver's collection of sources.
- *
- * @param source the source in question
- * @return `true` if the receiver contains the source, else `false`
+ * A source containing HTML. The HTML might or might not contain Dart scripts.
*/
- bool contains(Source source);
+ static const SourceKind HTML = const SourceKind('HTML', 0);
+
+ /**
+ * A Dart compilation unit that is not a part of another library. Libraries might or might not
+ * contain any directives, including a library directive.
+ */
+ static const SourceKind LIBRARY = const SourceKind('LIBRARY', 1);
+
+ /**
+ * A Dart compilation unit that is part of another library. Parts contain a part-of directive.
+ */
+ static const SourceKind PART = const SourceKind('PART', 2);
+
+ /**
+ * An unknown kind of source. Used both when it is not possible to identify the kind of a source
+ * and also when the kind of a source is not known without performing a computation and the client
+ * does not want to spend the time to identify the kind.
+ */
+ static const SourceKind UNKNOWN = const SourceKind('UNKNOWN', 3);
+
+ static const List<SourceKind> values = const [HTML, LIBRARY, PART, UNKNOWN];
+
+ const SourceKind(String name, int ordinal) : super(name, ordinal);
}
/**
@@ -779,36 +758,17 @@ class SourceRange {
}
/**
- * The enumeration `SourceKind` defines the different kinds of sources that are known to the
- * analysis engine.
+ * The interface `ContentReceiver` defines the behavior of objects that can receive the
+ * content of a source.
*/
-class SourceKind extends Enum<SourceKind> {
- /**
- * A source containing HTML. The HTML might or might not contain Dart scripts.
- */
- static const SourceKind HTML = const SourceKind('HTML', 0);
-
- /**
- * A Dart compilation unit that is not a part of another library. Libraries might or might not
- * contain any directives, including a library directive.
- */
- static const SourceKind LIBRARY = const SourceKind('LIBRARY', 1);
-
- /**
- * A Dart compilation unit that is part of another library. Parts contain a part-of directive.
- */
- static const SourceKind PART = const SourceKind('PART', 2);
-
+abstract class Source_ContentReceiver {
/**
- * An unknown kind of source. Used both when it is not possible to identify the kind of a source
- * and also when the kind of a source is not known without performing a computation and the client
- * does not want to spend the time to identify the kind.
+ * Accept the contents of a source.
+ *
+ * @param contents the contents of the source
+ * @param modificationTime the time at which the contents were last set
*/
- static const SourceKind UNKNOWN = const SourceKind('UNKNOWN', 3);
-
- static const List<SourceKind> values = const [HTML, LIBRARY, PART, UNKNOWN];
-
- const SourceKind(String name, int ordinal) : super(name, ordinal);
+ void accept(String contents, int modificationTime);
}
/**
@@ -872,4 +832,44 @@ class UriKind extends Enum<UriKind> {
* @param encoding the single character encoding used to identify this kind of URI.
*/
const UriKind(String name, int ordinal, this.encoding) : super(name, ordinal);
+}
+
+/**
+ * The abstract class `UriResolver` defines the behavior of objects that are used to resolve
+ * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
+ * absolute URI.
+ */
+abstract class UriResolver {
+ /**
+ * If this resolver should be used for URI's of the given kind, resolve the given absolute URI.
+ * The URI does not need to have the scheme handled by this resolver if the kind matches. Return a
+ * [Source] representing the file to which it was resolved, whether or not the
+ * resulting source exists, or `null` if it could not be resolved because the URI is
+ * invalid.
+ *
+ * @param kind the kind of URI that was originally resolved in order to produce an encoding with
+ * the given URI
+ * @param uri the URI to be resolved
+ * @return a [Source] representing the file to which given URI was resolved
+ */
+ Source fromEncoding(UriKind kind, Uri uri);
+
+ /**
+ * Resolve the given absolute URI. Return a [Source] representing the file to which
+ * it was resolved, whether or not the resulting source exists, or `null` if it could not be
+ * resolved because the URI is invalid.
+ *
+ * @param uri the URI to be resolved
+ * @return a [Source] representing the file to which given URI was resolved
+ */
+ Source resolveAbsolute(Uri uri);
+
+ /**
+ * Return an absolute URI that represents the given source, or `null` if a valid URI cannot
+ * be computed.
+ *
+ * @param source the source to get URI for
+ * @return the absolute URI representing the given source
+ */
+ Uri restoreAbsolute(Source source) => null;
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/lib/src/generated/source_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698