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

Side by Side Diff: pkg/analyzer-experimental/lib/src/generated/source.dart

Issue 12502002: Update analyzer-experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.source; 4 library engine.source;
5 5
6 import 'dart:io';
7 import 'dart:uri'; 6 import 'dart:uri';
8 import 'java_core.dart'; 7 import 'java_core.dart';
9 import 'package:analyzer-experimental/src/generated/sdk.dart' show DartSdk;
10 8
11 /** 9 /**
12 * Instances of the class {@code FileUriResolver} resolve {@code file} URI's.
13 */
14 class FileUriResolver extends UriResolver {
15 /**
16 * The name of the {@code file} scheme.
17 */
18 static String _FILE_SCHEME = "file";
19 /**
20 * Return {@code true} if the given URI is a {@code file} URI.
21 * @param uri the URI being tested
22 * @return {@code true} if the given URI is a {@code file} URI
23 */
24 static bool isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
25 /**
26 * Initialize a newly created resolver to resolve {@code file} URI's relative to the given root
27 * directory.
28 */
29 FileUriResolver() : super() {
30 }
31 Source resolveAbsolute(SourceFactory factory, Uri uri) {
32 if (!isFileUri(uri)) {
33 return null;
34 }
35 return new FileBasedSource.con1(factory, newFileFromUri(uri));
36 }
37 }
38 /**
39 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's.
40 */
41 class DartUriResolver extends UriResolver {
42 /**
43 * The Dart SDK against which URI's are to be resolved.
44 */
45 DartSdk _sdk;
46 /**
47 * The name of the {@code dart} scheme.
48 */
49 static String _DART_SCHEME = "dart";
50 /**
51 * Return {@code true} if the given URI is a {@code dart:} URI.
52 * @param uri the URI being tested
53 * @return {@code true} if the given URI is a {@code dart:} URI
54 */
55 static bool isDartUri(Uri uri) => uri.scheme == _DART_SCHEME;
56 /**
57 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
58 * given Dart SDK.
59 * @param sdk the Dart SDK against which URI's are to be resolved
60 */
61 DartUriResolver(DartSdk sdk) {
62 this._sdk = sdk;
63 }
64 Source resolveAbsolute(SourceFactory factory, Uri uri) {
65 if (!isDartUri(uri)) {
66 return null;
67 }
68 File resolvedFile = _sdk.mapDartUri(uri.toString());
69 return new FileBasedSource.con2(factory, resolvedFile, true);
70 }
71 }
72 /**
73 * Instances of the class {@code FileBasedSource} implement a source that repres ents a file.
74 */
75 class FileBasedSource implements Source {
76 /**
77 * The source factory that created this source and that should be used to reso lve URI's against
78 * this source.
79 */
80 SourceFactory _factory;
81 /**
82 * The file represented by this source.
83 */
84 File _file;
85 /**
86 * A flag indicating whether this source is in one of the system libraries.
87 */
88 bool _inSystemLibrary = false;
89 /**
90 * Initialize a newly created source object. The source object is assumed to n ot be in a system
91 * library.
92 * @param factory the source factory that created this source
93 * @param file the file represented by this source
94 */
95 FileBasedSource.con1(SourceFactory factory, File file) {
96 _jtd_constructor_243_impl(factory, file);
97 }
98 _jtd_constructor_243_impl(SourceFactory factory, File file) {
99 _jtd_constructor_244_impl(factory, file, false);
100 }
101 /**
102 * Initialize a newly created source object.
103 * @param factory the source factory that created this source
104 * @param file the file represented by this source
105 * @param inSystemLibrary {@code true} if this source is in one of the system libraries
106 */
107 FileBasedSource.con2(SourceFactory factory2, File file3, bool inSystemLibrary2 ) {
108 _jtd_constructor_244_impl(factory2, file3, inSystemLibrary2);
109 }
110 _jtd_constructor_244_impl(SourceFactory factory2, File file3, bool inSystemLib rary2) {
111 this._factory = factory2;
112 this._file = file3;
113 this._inSystemLibrary = inSystemLibrary2;
114 }
115 bool operator ==(Object object) => object != null && identical(this.runtimeTyp e, object.runtimeType) && _file == ((object as FileBasedSource))._file;
116 void getContents(Source_ContentReceiver receiver) {
117 receiver.accept2(_file.readAsStringSync());
118 }
119 String get fullName => _file.fullPathSync();
120 String get shortName => _file.name;
121 int get hashCode => _file.hashCode;
122 bool isInSystemLibrary() => _inSystemLibrary;
123 Source resolve(String uri) => _factory.resolveUri(this, uri);
124 String toString() {
125 if (_file == null) {
126 return "<unknown source>";
127 }
128 return _file.fullPathSync();
129 }
130 /**
131 * Return the file represented by this source. This is an internal method that is only intended to
132 * be used by {@link UriResolver}.
133 * @return the file represented by this source
134 */
135 File get file => _file;
136 }
137 /**
138 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour ce container that
139 * contains all sources within a given directory.
140 */
141 class DirectoryBasedSourceContainer implements SourceContainer {
142 /**
143 * Append the system file separator to the given path unless the path already ends with a
144 * separator.
145 * @param path the path to which the file separator is to be added
146 * @return a path that ends with the system file separator
147 */
148 static String appendFileSeparator(String path) {
149 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == System.pathSeparatorChar) {
150 return path;
151 }
152 return "${path}${System.pathSeparator}";
153 }
154 /**
155 * The container's path (not {@code null}).
156 */
157 String _path;
158 /**
159 * Construct a container representing the specified directory and containing a ny sources whose{@link Source#getFullName()} starts with the directory's path. T his is a convenience method,
160 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour ceContainer(String)}.
161 * @param directory the directory (not {@code null})
162 */
163 DirectoryBasedSourceContainer.con1(File directory) {
164 _jtd_constructor_241_impl(directory);
165 }
166 _jtd_constructor_241_impl(File directory) {
167 _jtd_constructor_242_impl(directory.fullPathSync());
168 }
169 /**
170 * Construct a container representing the specified path and containing any so urces whose{@link Source#getFullName()} starts with the specified path.
171 * @param path the path (not {@code null} and not empty)
172 */
173 DirectoryBasedSourceContainer.con2(String path3) {
174 _jtd_constructor_242_impl(path3);
175 }
176 _jtd_constructor_242_impl(String path3) {
177 this._path = appendFileSeparator(path3);
178 }
179 bool contains(Source source) => source.fullName.startsWith(_path);
180 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && ((ob j as DirectoryBasedSourceContainer)).path == path;
181 /**
182 * Answer the receiver's path, used to determine if a source is contained in t he receiver.
183 * @return the path (not {@code null}, not empty)
184 */
185 String get path => _path;
186 int get hashCode => _path.hashCode;
187 }
188 /**
189 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI 's in the context of
190 * an application.
191 */
192 class PackageUriResolver extends UriResolver {
193 /**
194 * The package directories that {@code package} URI's are assumed to be relati ve to.
195 */
196 List<File> _packagesDirectories;
197 /**
198 * The name of the {@code package} scheme.
199 */
200 static String _PACKAGE_SCHEME = "package";
201 /**
202 * Return {@code true} if the given URI is a {@code package} URI.
203 * @param uri the URI being tested
204 * @return {@code true} if the given URI is a {@code package} URI
205 */
206 static bool isPackageUri(Uri uri) => uri.scheme == _PACKAGE_SCHEME;
207 /**
208 * Initialize a newly created resolver to resolve {@code package} URI's relati ve to the given
209 * package directories.
210 * @param packagesDirectories the package directories that {@code package} URI 's are assumed to be
211 * relative to
212 */
213 PackageUriResolver(List<File> packagesDirectories) {
214 if (packagesDirectories.length < 1) {
215 throw new IllegalArgumentException("At least one package directory must be provided");
216 }
217 this._packagesDirectories = packagesDirectories;
218 }
219 Source resolveAbsolute(SourceFactory factory, Uri uri) {
220 if (!isPackageUri(uri)) {
221 return null;
222 }
223 String path4 = uri.path;
224 if (path4 == null) {
225 path4 = uri.path;
226 if (path4 == null) {
227 return null;
228 }
229 }
230 for (File packagesDirectory in _packagesDirectories) {
231 File resolvedFile = newRelativeFile(packagesDirectory, path4);
232 if (resolvedFile.existsSync()) {
233 return new FileBasedSource.con1(factory, resolvedFile);
234 }
235 }
236 return new FileBasedSource.con1(factory, newRelativeFile(_packagesDirectorie s[0], path4));
237 }
238 }
239 /**
240 * The abstract class {@code UriResolver} defines the behavior of objects that a re used to resolve
241 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
242 * absolute URI.
243 */
244 abstract class UriResolver {
245 /**
246 * Initialize a newly created resolver.
247 */
248 UriResolver() : super() {
249 }
250 /**
251 * Working on behalf of the given source factory, resolve the (possibly relati ve) contained URI
252 * against the URI associated with the containing source object. Return a {@li nk Source source}representing the file to which it was resolved, or {@code null} if it could not be resolved.
253 * @param factory the source factory requesting the resolution of the URI
254 * @param containingSource the source containing the given URI
255 * @param containedUri the (possibly relative) URI to be resolved against the containing source
256 * @return a {@link Source source} representing the URI to which given URI was resolved
257 */
258 Source resolve(SourceFactory factory, Source containingSource, Uri containedUr i) {
259 if (containedUri.isAbsolute()) {
260 return resolveAbsolute(factory, containedUri);
261 } else {
262 return resolveRelative(factory, containingSource, containedUri);
263 }
264 }
265 /**
266 * Resolve the given absolute URI. Return a {@link Source source} representing the file to which
267 * it was resolved, or {@code null} if it could not be resolved.
268 * @param uri the URI to be resolved
269 * @return a {@link Source source} representing the URI to which given URI was resolved
270 */
271 Source resolveAbsolute(SourceFactory factory, Uri uri);
272 /**
273 * Resolve the relative (contained) URI against the URI associated with the co ntaining source
274 * object. Return a {@link Source source} representing the file to which it wa s resolved, or{@code null} if it could not be resolved.
275 * @param containingSource the source containing the given URI
276 * @param containedUri the (possibly relative) URI to be resolved against the containing source
277 * @return a {@link Source source} representing the URI to which given URI was resolved
278 */
279 Source resolveRelative(SourceFactory factory, Source containingSource, Uri con tainedUri) {
280 if (containingSource is FileBasedSource) {
281 try {
282 Uri resolvedUri = newUriFromFile(((containingSource as FileBasedSource)) .file).resolveUri(containedUri);
283 return new FileBasedSource.con1(factory, newFileFromUri(resolvedUri));
284 } on JavaException catch (exception) {
285 }
286 }
287 return null;
288 }
289 }
290 /**
291 * Instances of the class {@code SourceFactory} resolve possibly relative URI's against an existing{@link Source source}. 10 * Instances of the class {@code SourceFactory} resolve possibly relative URI's against an existing{@link Source source}.
292 */ 11 */
293 class SourceFactory { 12 class SourceFactory {
294 /** 13 /**
295 * The resolvers used to resolve absolute URI's. 14 * The resolvers used to resolve absolute URI's.
296 */ 15 */
297 List<UriResolver> _resolvers; 16 List<UriResolver> _resolvers;
298 /** 17 /**
299 * A cache of content used to override the default content of a source. 18 * A cache of content used to override the default content of a source.
300 */ 19 */
301 ContentCache _contentCache; 20 ContentCache _contentCache;
302 /** 21 /**
303 * Initialize a newly created source factory. 22 * Initialize a newly created source factory.
304 * @param contentCache the cache holding content used to override the default content of a source. 23 * @param contentCache the cache holding content used to override the default content of a source.
305 * @param resolvers the resolvers used to resolve absolute URI's 24 * @param resolvers the resolvers used to resolve absolute URI's
306 */ 25 */
307 SourceFactory.con1(ContentCache contentCache2, List<UriResolver> resolvers2) { 26 SourceFactory.con1(ContentCache contentCache2, List<UriResolver> resolvers2) {
308 _jtd_constructor_247_impl(contentCache2, resolvers2); 27 _jtd_constructor_282_impl(contentCache2, resolvers2);
309 } 28 }
310 _jtd_constructor_247_impl(ContentCache contentCache2, List<UriResolver> resolv ers2) { 29 _jtd_constructor_282_impl(ContentCache contentCache2, List<UriResolver> resolv ers2) {
311 this._contentCache = contentCache2; 30 this._contentCache = contentCache2;
312 this._resolvers = resolvers2; 31 this._resolvers = resolvers2;
313 } 32 }
314 /** 33 /**
315 * Initialize a newly created source factory. 34 * Initialize a newly created source factory.
316 * @param resolvers the resolvers used to resolve absolute URI's 35 * @param resolvers the resolvers used to resolve absolute URI's
317 */ 36 */
318 SourceFactory.con2(List<UriResolver> resolvers) { 37 SourceFactory.con2(List<UriResolver> resolvers) {
319 _jtd_constructor_248_impl(resolvers); 38 _jtd_constructor_283_impl(resolvers);
320 } 39 }
321 _jtd_constructor_248_impl(List<UriResolver> resolvers) { 40 _jtd_constructor_283_impl(List<UriResolver> resolvers) {
322 _jtd_constructor_247_impl(new ContentCache(), [resolvers]); 41 _jtd_constructor_282_impl(new ContentCache(), [resolvers]);
323 } 42 }
324 /** 43 /**
325 * Return a source container representing the given directory
326 * @param directory the directory (not {@code null})
327 * @return the source container representing the directory (not {@code null})
328 */
329 SourceContainer forDirectory(File directory) => new DirectoryBasedSourceContai ner.con1(directory);
330 /**
331 * Return a source object representing the given file.
332 * @param file the file to be represented by the returned source object
333 * @return a source object representing the given file
334 */
335 Source forFile(File file) => new FileBasedSource.con1(this, file);
336 /**
337 * Return a source object representing the given absolute URI, or {@code null} if the URI is not a 44 * Return a source object representing the given absolute URI, or {@code null} if the URI is not a
338 * valid URI or if it is not an absolute URI. 45 * valid URI or if it is not an absolute URI.
339 * @param absoluteUri the absolute URI to be resolved 46 * @param absoluteUri the absolute URI to be resolved
340 * @return a source object representing the absolute URI 47 * @return a source object representing the absolute URI
341 */ 48 */
342 Source forUri(String absoluteUri) { 49 Source forUri(String absoluteUri) {
343 try { 50 try {
344 Uri uri = new Uri.fromComponents(path: absoluteUri); 51 Uri uri = new Uri.fromComponents(path: absoluteUri);
345 if (uri.isAbsolute()) { 52 if (uri.isAbsolute) {
346 return resolveUri2(null, uri); 53 return resolveUri2(null, uri);
347 } 54 }
348 } on URISyntaxException catch (exception) { 55 } on URISyntaxException catch (exception) {
349 } 56 }
350 return null; 57 return null;
351 } 58 }
352 /** 59 /**
60 * Return a source object that is equal to the source object used to obtain th e given encoding, or{@code null} if the argument is not a valid encoding.
61 * @param encoding the encoding of a source object
62 * @return a source object that is described by the given encoding
63 * @see Source#getEncoding()
64 */
65 Source fromEncoding(String encoding) => forUri(encoding);
66 /**
353 * Return a source object representing the URI that results from resolving the given (possibly 67 * Return a source object representing the URI that results from resolving the given (possibly
354 * relative) contained URI against the URI associated with an existing source object, or{@code null} if either the contained URI is invalid or if it cannot be resolved against the 68 * relative) contained URI against the URI associated with an existing source object, or{@code null} if either the contained URI is invalid or if it cannot be resolved against the
355 * source object's URI. 69 * source object's URI.
356 * @param containingSource the source containing the given URI 70 * @param containingSource the source containing the given URI
357 * @param containedUri the (possibly relative) URI to be resolved against the containing source 71 * @param containedUri the (possibly relative) URI to be resolved against the containing source
358 * @return the source representing the contained URI 72 * @return the source representing the contained URI
359 */ 73 */
360 Source resolveUri(Source containingSource, String containedUri) { 74 Source resolveUri(Source containingSource, String containedUri) {
361 try { 75 try {
362 return resolveUri2(containingSource, new Uri.fromComponents(path: containe dUri)); 76 return resolveUri2(containingSource, new Uri.fromComponents(path: containe dUri));
(...skipping 22 matching lines...) Expand all
385 String getContents(Source source) => _contentCache.getContents(source); 99 String getContents(Source source) => _contentCache.getContents(source);
386 /** 100 /**
387 * Return a source object representing the URI that results from resolving the given (possibly 101 * Return a source object representing the URI that results from resolving the given (possibly
388 * relative) contained URI against the URI associated with an existing source object, or{@code null} if either the contained URI is invalid or if it cannot be resolved against the 102 * relative) contained URI against the URI associated with an existing source object, or{@code null} if either the contained URI is invalid or if it cannot be resolved against the
389 * source object's URI. 103 * source object's URI.
390 * @param containingSource the source containing the given URI 104 * @param containingSource the source containing the given URI
391 * @param containedUri the (possibly relative) URI to be resolved against the containing source 105 * @param containedUri the (possibly relative) URI to be resolved against the containing source
392 * @return the source representing the contained URI 106 * @return the source representing the contained URI
393 */ 107 */
394 Source resolveUri2(Source containingSource, Uri containedUri) { 108 Source resolveUri2(Source containingSource, Uri containedUri) {
395 for (UriResolver resolver in _resolvers) { 109 if (containedUri.isAbsolute) {
396 Source result = resolver.resolve(this, containingSource, containedUri); 110 for (UriResolver resolver in _resolvers) {
397 if (result != null) { 111 Source result = resolver.resolveAbsolute(this, containedUri);
398 return result; 112 if (result != null) {
113 return result;
114 }
399 } 115 }
116 return null;
117 } else {
118 return containingSource.resolveRelative(containedUri);
400 } 119 }
401 return null;
402 } 120 }
403 } 121 }
404 /** 122 /**
123 * The abstract class {@code UriResolver} defines the behavior of objects that a re used to resolve
124 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
125 * absolute URI.
126 */
127 abstract class UriResolver {
128 /**
129 * Initialize a newly created resolver.
130 */
131 UriResolver() : super() {
132 }
133 /**
134 * Resolve the given absolute URI. Return a {@link Source source} representing the file to which
135 * it was resolved, or {@code null} if it could not be resolved.
136 * @param uri the URI to be resolved
137 * @return a {@link Source source} representing the URI to which given URI was resolved
138 */
139 Source resolveAbsolute(SourceFactory factory, Uri uri);
140 }
141 /**
405 * The interface {@code Source} defines the behavior of objects representing sou rce code that can be 142 * The interface {@code Source} defines the behavior of objects representing sou rce code that can be
406 * compiled. 143 * compiled.
407 */ 144 */
408 abstract class Source { 145 abstract class Source {
409 /** 146 /**
147 * An empty array of sources.
148 */
149 static List<Source> EMPTY_ARRAY = new List<Source>(0);
150 /**
410 * Return {@code true} if the given object is a source that represents the sam e source code as 151 * Return {@code true} if the given object is a source that represents the sam e source code as
411 * this source. 152 * this source.
412 * @param object the object to be compared with this object 153 * @param object the object to be compared with this object
413 * @return {@code true} if the given object is a source that represents the sa me source code as 154 * @return {@code true} if the given object is a source that represents the sa me source code as
414 * this source 155 * this source
415 * @see Object#equals(Object) 156 * @see Object#equals(Object)
416 */ 157 */
417 bool operator ==(Object object); 158 bool operator ==(Object object);
418 /** 159 /**
160 * Return {@code true} if this source exists.
161 * @return {@code true} if this source exists
162 */
163 bool exists();
164 /**
419 * Get the contents of this source and pass it to the given receiver. Exactly one of the methods 165 * Get the contents of this source and pass it to the given receiver. Exactly one of the methods
420 * defined on the receiver will be invoked unless an exception is thrown. The method that will be 166 * defined on the receiver will be invoked unless an exception is thrown. The method that will be
421 * invoked depends on which of the possible representations of the contents is the most efficient. 167 * invoked depends on which of the possible representations of the contents is the most efficient.
422 * Whichever method is invoked, it will be invoked before this method returns. 168 * Whichever method is invoked, it will be invoked before this method returns.
423 * @param receiver the content receiver to which the content of this source wi ll be passed 169 * @param receiver the content receiver to which the content of this source wi ll be passed
424 * @throws Exception if the contents of this source could not be accessed 170 * @throws Exception if the contents of this source could not be accessed
425 */ 171 */
426 void getContents(Source_ContentReceiver receiver); 172 void getContents(Source_ContentReceiver receiver);
427 /** 173 /**
174 * Return an encoded representation of this source that can be used to create a source that is
175 * equal to this source.
176 * @return an encoded representation of this source
177 * @see SourceFactory#fromEncoding(String)
178 */
179 String get encoding;
180 /**
428 * Return the full (long) version of the name that can be displayed to the use r to denote this 181 * Return the full (long) version of the name that can be displayed to the use r to denote this
429 * source. For example, for a source representing a file this would typically be the absolute path 182 * source. For example, for a source representing a file this would typically be the absolute path
430 * of the file. 183 * of the file.
431 * @return a name that can be displayed to the user to denote this source 184 * @return a name that can be displayed to the user to denote this source
432 */ 185 */
433 String get fullName; 186 String get fullName;
434 /** 187 /**
435 * Return a short version of the name that can be displayed to the user to den ote this source. For 188 * Return a short version of the name that can be displayed to the user to den ote this source. For
436 * example, for a source representing a file this would typically be the name of the file. 189 * example, for a source representing a file this would typically be the name of the file.
437 * @return a name that can be displayed to the user to denote this source 190 * @return a name that can be displayed to the user to denote this source
438 */ 191 */
439 String get shortName; 192 String get shortName;
440 /** 193 /**
441 * Return a hash code for this source. 194 * Return a hash code for this source.
442 * @return a hash code for this source 195 * @return a hash code for this source
443 * @see Object#hashCode() 196 * @see Object#hashCode()
444 */ 197 */
445 int get hashCode; 198 int get hashCode;
446 /** 199 /**
447 * Return {@code true} if this source is in one of the system libraries. 200 * Return {@code true} if this source is in one of the system libraries.
448 * @return {@code true} if this is in a system library 201 * @return {@code true} if this is in a system library
449 */ 202 */
450 bool isInSystemLibrary(); 203 bool isInSystemLibrary();
451 /** 204 /**
452 * Resolve the given URI relative to the location of this source. 205 * Resolve the given URI relative to the location of this source.
453 * @param uri the URI to be resolved against this source 206 * @param uri the URI to be resolved against this source
454 * @return a source representing the resolved URI 207 * @return a source representing the resolved URI
455 */ 208 */
456 Source resolve(String uri); 209 Source resolve(String uri);
210 /**
211 * Resolve the relative URI against the URI associated with this source object . Return a{@link Source source} representing the URI to which it was resolved, o r {@code null} if it
212 * could not be resolved.
213 * <p>
214 * Note: This method is not intended for public use, it is only visible out of necessity. It is
215 * only intended to be invoked by a {@link SourceFactory source factory}. Sour ce factories will
216 * only invoke this method if the URI is relative, so implementations of this method are not
217 * required to, and generally do not, verify the argument. The result of invok ing this method with
218 * an absolute URI is intentionally left unspecified.
219 * @param relativeUri the relative URI to be resolved against the containing s ource
220 * @return a {@link Source source} representing the URI to which given URI was resolved
221 */
222 Source resolveRelative(Uri relativeUri);
457 } 223 }
458 /** 224 /**
459 * The interface {@code ContentReceiver} defines the behavior of objects that ca n receive the 225 * The interface {@code ContentReceiver} defines the behavior of objects that ca n receive the
460 * content of a source. 226 * content of a source.
461 */ 227 */
462 abstract class Source_ContentReceiver { 228 abstract class Source_ContentReceiver {
463 /** 229 /**
464 * Accept the contents of a source represented as a character buffer. 230 * Accept the contents of a source represented as a character buffer.
465 * @param contents the contents of the source 231 * @param contents the contents of the source
466 */ 232 */
467 accept(CharBuffer contents); 233 accept(CharBuffer contents);
468 /** 234 /**
469 * Accept the contents of a source represented as a string. 235 * Accept the contents of a source represented as a string.
470 * @param contents the contents of the source 236 * @param contents the contents of the source
471 */ 237 */
472 void accept2(String contents); 238 void accept2(String contents);
473 } 239 }
474 /** 240 /**
475 * Instances of class {@code ContentCache} hold content used to override the def ault content of a{@link Source}. 241 * The enumeration {@code SourceKind} defines the different kinds of sources tha t are known to the
242 * analysis engine.
476 */ 243 */
477 class ContentCache { 244 class SourceKind {
478 /** 245 /**
479 * A table mapping sources to the contents of those sources. This is used to o verride the default 246 * A source containing HTML. The HTML might or might not contain Dart scripts.
480 * contents of a source.
481 */ 247 */
482 Map<Source, String> _contentMap = new Map<Source, String>(); 248 static final SourceKind HTML = new SourceKind('HTML', 0);
483 /** 249 /**
484 * Return the contents of the given source, or {@code null} if this cache does not override the 250 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not
485 * contents of the source. 251 * contain any directives, including a library directive.
486 * <p>
487 * <b>Note:</b> This method is not intended to be used except by{@link SourceF actory#getContents(com.google.dart.engine.source.Source.ContentReceiver)}.
488 * @param source the source whose content is to be returned
489 * @return the contents of the given source
490 */ 252 */
491 String getContents(Source source) => _contentMap[source]; 253 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1);
492 /** 254 /**
493 * Set the contents of the given source to the given contents. This has the ef fect of overriding 255 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive.
494 * the default contents of the source. If the contents are {@code null} the ov erride is removed so
495 * that the default contents will be returned.
496 * @param source the source whose contents are being overridden
497 * @param contents the new contents of the source
498 */ 256 */
499 void setContents(Source source, String contents) { 257 static final SourceKind PART = new SourceKind('PART', 2);
500 if (contents == null) { 258 /**
501 _contentMap.remove(source); 259 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source
502 } else { 260 * and also when the kind of a source is not known without performing a comput ation and the client
503 _contentMap[source] = contents; 261 * does not want to spend the time to identify the kind.
262 */
263 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3);
264 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN];
265 final String __name;
266 final int __ordinal;
267 SourceKind(this.__name, this.__ordinal) {
268 }
269 String toString() => __name;
270 }
271 /**
272 * A source range defines an {@link Element}'s source coordinates relative to it s {@link Source}.
273 */
274 class SourceRange {
275 /**
276 * The 0-based index of the first character of the source code for this elemen t, relative to the
277 * source buffer in which this element is contained.
278 */
279 int _offset = 0;
280 /**
281 * The number of characters of the source code for this element, relative to t he source buffer in
282 * which this element is contained.
283 */
284 int _length = 0;
285 /**
286 * Initialize a newly created source range using the given offset and the give n length.
287 * @param offset the given offset
288 * @param length the given length
289 */
290 SourceRange(int offset, int length) {
291 this._offset = offset;
292 this._length = length;
293 }
294 /**
295 * @return <code>true</code> if <code>x</code> is in [offset, offset + length) interval.
296 */
297 bool contains(int x) => _offset <= x && x < _offset + _length;
298 /**
299 * @return <code>true</code> if <code>otherRange</code> covers this {@link Sou rceRange}.
300 */
301 bool coveredBy(SourceRange otherRange) => otherRange.covers(this);
302 /**
303 * @return <code>true</code> if this {@link SourceRange} covers <code>otherRan ge</code>.
304 */
305 bool covers(SourceRange otherRange) => offset <= otherRange.offset && otherRan ge.end <= end;
306 /**
307 * @return <code>true</code> if this {@link SourceRange} ends in <code>otherRa nge</code>.
308 */
309 bool endsIn(SourceRange otherRange) {
310 int thisEnd = end;
311 return otherRange.contains(thisEnd);
312 }
313 bool operator ==(Object obj) {
314 if (obj is! SourceRange) {
315 return false;
504 } 316 }
317 SourceRange sourceRange = obj as SourceRange;
318 return sourceRange.offset == _offset && sourceRange.length == _length;
319 }
320 /**
321 * @return the 0-based index of the after-last character of the source code fo r this element,
322 * relative to the source buffer in which this element is contained.
323 */
324 int get end => _offset + _length;
325 /**
326 * @return the expanded instance of {@link SourceRange}, which has the same ce nter.
327 */
328 SourceRange getExpanded(int delta) => new SourceRange(_offset - delta, delta + _length + delta);
329 /**
330 * Returns the number of characters of the source code for this element, relat ive to the source
331 * buffer in which this element is contained.
332 * @return the number of characters of the source code for this element, relat ive to the source
333 * buffer in which this element is contained
334 */
335 int get length => _length;
336 /**
337 * @return the instance of {@link SourceRange} with end moved on "delta".
338 */
339 SourceRange getMoveEnd(int delta) => new SourceRange(_offset, _length + delta) ;
340 /**
341 * Returns the 0-based index of the first character of the source code for thi s element, relative
342 * to the source buffer in which this element is contained.
343 * @return the 0-based index of the first character of the source code for thi s element, relative
344 * to the source buffer in which this element is contained
345 */
346 int get offset => _offset;
347 int get hashCode => 31 * _offset + _length;
348 /**
349 * @return <code>true</code> if this {@link SourceRange} intersects with given .
350 */
351 bool intersects(SourceRange other) {
352 if (other == null) {
353 return false;
354 }
355 if (end <= other.offset) {
356 return false;
357 }
358 if (offset >= other.end) {
359 return false;
360 }
361 return true;
362 }
363 /**
364 * @return <code>true</code> if this {@link SourceRange} starts in <code>other Range</code>.
365 */
366 bool startsIn(SourceRange otherRange) => otherRange.contains(_offset);
367 String toString() {
368 StringBuffer builder = new StringBuffer();
369 builder.write("[offset=");
370 builder.write(_offset);
371 builder.write(", length=");
372 builder.write(_length);
373 builder.write("]");
374 return builder.toString();
505 } 375 }
506 } 376 }
507 /** 377 /**
508 * The interface {@code SourceContainer} is used by clients to define a collecti on of sources 378 * The interface {@code SourceContainer} is used by clients to define a collecti on of sources
509 * <p> 379 * <p>
510 * Source containers are not used within analysis engine, but can be used by cli ents to group 380 * Source containers are not used within analysis engine, but can be used by cli ents to group
511 * sources for the purposes of accessing composite dependency information. For e xample, the Eclipse 381 * sources for the purposes of accessing composite dependency information. For e xample, the Eclipse
512 * client uses source containers to represent Eclipse projects, which allows it to easily compute 382 * client uses source containers to represent Eclipse projects, which allows it to easily compute
513 * project-level dependencies. 383 * project-level dependencies.
514 */ 384 */
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 * @return the one-based index of the column containing the character 455 * @return the one-based index of the column containing the character
586 */ 456 */
587 int get columnNumber => _columnNumber; 457 int get columnNumber => _columnNumber;
588 /** 458 /**
589 * Return the one-based index of the line containing the character. 459 * Return the one-based index of the line containing the character.
590 * @return the one-based index of the line containing the character 460 * @return the one-based index of the line containing the character
591 */ 461 */
592 int get lineNumber => _lineNumber; 462 int get lineNumber => _lineNumber;
593 } 463 }
594 /** 464 /**
595 * The enumeration {@code SourceKind} defines the different kinds of sources tha t are known to the 465 * Instances of class {@code ContentCache} hold content used to override the def ault content of a{@link Source}.
596 * analysis engine.
597 */ 466 */
598 class SourceKind { 467 class ContentCache {
599 /** 468 /**
600 * A source containing HTML. The HTML might or might not contain Dart scripts. 469 * A table mapping sources to the contents of those sources. This is used to o verride the default
470 * contents of a source.
601 */ 471 */
602 static final SourceKind HTML = new SourceKind('HTML', 0); 472 Map<Source, String> _contentMap = new Map<Source, String>();
603 /** 473 /**
604 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not 474 * Return the contents of the given source, or {@code null} if this cache does not override the
605 * contain any directives, including a library directive. 475 * contents of the source.
476 * <p>
477 * <b>Note:</b> This method is not intended to be used except by{@link SourceF actory#getContents(com.google.dart.engine.source.Source.ContentReceiver)}.
478 * @param source the source whose content is to be returned
479 * @return the contents of the given source
606 */ 480 */
607 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1); 481 String getContents(Source source) => _contentMap[source];
608 /** 482 /**
609 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive. 483 * Set the contents of the given source to the given contents. This has the ef fect of overriding
484 * the default contents of the source. If the contents are {@code null} the ov erride is removed so
485 * that the default contents will be returned.
486 * @param source the source whose contents are being overridden
487 * @param contents the new contents of the source
610 */ 488 */
611 static final SourceKind PART = new SourceKind('PART', 2); 489 void setContents(Source source, String contents) {
612 /** 490 if (contents == null) {
613 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source 491 _contentMap.remove(source);
614 * and also when the kind of a source is not known without performing a comput ation and the client 492 } else {
615 * does not want to spend the time to identify the kind. 493 _contentMap[source] = contents;
616 */ 494 }
617 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3);
618 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN];
619 final String __name;
620 final int __ordinal;
621 SourceKind(this.__name, this.__ordinal) {
622 } 495 }
623 String toString() => __name;
624 } 496 }
OLDNEW
« no previous file with comments | « pkg/analyzer-experimental/lib/src/generated/sdk.dart ('k') | pkg/analyzer-experimental/lib/src/generated/source_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698