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

Side by Side 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, 7 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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.source; 8 library engine.source;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
11 import 'sdk.dart' show DartSdk; 11 import 'sdk.dart' show DartSdk;
12 import 'engine.dart' show AnalysisContext, TimestampedData; 12 import 'engine.dart' show AnalysisContext, TimestampedData;
13 13
14 /** 14 /**
15 * The abstract class `UriResolver` defines the behavior of objects that are use d to resolve 15 * Instances of class `ContentCache` hold content used to override the default c ontent of a
16 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of 16 * [Source].
17 * absolute URI.
18 */ 17 */
19 abstract class UriResolver { 18 class ContentCache {
20 /** 19 /**
21 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI. 20 * A table mapping sources to the contents of those sources. This is used to o verride the default
22 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a 21 * contents of a source.
23 * [Source] representing the file to which it was resolved, whether or not the
24 * resulting source exists, or `null` if it could not be resolved because the URI is
25 * invalid.
26 *
27 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with
28 * the given URI
29 * @param uri the URI to be resolved
30 * @return a [Source] representing the file to which given URI was resolved
31 */ 22 */
32 Source fromEncoding(UriKind kind, Uri uri); 23 Map<Source, String> _contentMap = new Map<Source, String>();
33 24
34 /** 25 /**
35 * Resolve the given absolute URI. Return a [Source] representing the file to which 26 * A table mapping sources to the modification stamps of those sources. This i s used when the
36 * it was resolved, whether or not the resulting source exists, or `null` if i t could not be 27 * default contents of a source has been overridden.
37 * resolved because the URI is invalid.
38 *
39 * @param uri the URI to be resolved
40 * @return a [Source] representing the file to which given URI was resolved
41 */ 28 */
42 Source resolveAbsolute(Uri uri); 29 Map<Source, int> _stampMap = new Map<Source, int>();
43 30
44 /** 31 /**
45 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot 32 * Return the contents of the given source, or `null` if this cache does not o verride the
46 * be computed. 33 * contents of the source.
47 * 34 *
48 * @param source the source to get URI for 35 * <b>Note:</b> This method is not intended to be used except by
49 * @return the absolute URI representing the given source 36 * [AnalysisContext#getContents].
37 *
38 * @param source the source whose content is to be returned
39 * @return the contents of the given source
50 */ 40 */
51 Uri restoreAbsolute(Source source) => null; 41 String getContents(Source source) => _contentMap[source];
42
43 /**
44 * Return the modification stamp of the given source, or `null` if this cache does not
45 * override the contents of the source.
46 *
47 * <b>Note:</b> This method is not intended to be used except by
48 * [AnalysisContext#getModificationStamp].
49 *
50 * @param source the source whose modification stamp is to be returned
51 * @return the modification stamp of the given source
52 */
53 int getModificationStamp(Source source) => _stampMap[source];
54
55 /**
56 * Set the contents of the given source to the given contents. This has the ef fect of overriding
57 * the default contents of the source. If the contents are `null` the override is removed so
58 * that the default contents will be returned.
59 *
60 * @param source the source whose contents are being overridden
61 * @param contents the new contents of the source
62 * @return the original cached contents or `null` if none
63 */
64 String setContents(Source source, String contents) {
65 if (contents == null) {
66 _stampMap.remove(source);
67 return _contentMap.remove(source);
68 } else {
69 int newStamp = JavaSystem.currentTimeMillis();
70 int oldStamp = javaMapPut(_stampMap, source, newStamp);
71 // Occasionally, if this method is called in rapid succession, the timesta mps are equal.
72 // Guard against this by artificially incrementing the new timestamp
73 if (newStamp == oldStamp) {
74 _stampMap[source] = newStamp + 1;
75 }
76 return javaMapPut(_contentMap, source, contents);
77 }
78 }
52 } 79 }
53 80
54 /** 81 /**
55 * The interface `Source` defines the behavior of objects representing source co de that can be 82 * Instances of the class `DartUriResolver` resolve `dart` URI's.
56 * analyzed by the analysis engine.
57 *
58 * Implementations of this interface need to be aware of some assumptions made b y the analysis
59 * engine concerning sources:
60 * * Sources are not required to be unique. That is, there can be multiple insta nces representing
61 * the same source.
62 * * Sources are long lived. That is, the engine is allowed to hold on to a sour ce for an extended
63 * period of time and that source must continue to report accurate and up-to-dat e information.
64 * Because of these assumptions, most implementations will not maintain any stat e but will delegate
65 * to an authoritative system of record in order to implement this API. For exam ple, a source that
66 * represents files on disk would typically query the file system to determine t he state of the
67 * file.
68 *
69 * If the instances that implement this API are the system of record, then they will typically be
70 * unique. In that case, sources that are created that represent non-existent fi les must also be
71 * retained so that if those files are created at a later date the long-lived so urces representing
72 * those files will know that they now exist.
73 */ 83 */
74 abstract class Source { 84 class DartUriResolver extends UriResolver {
75 /** 85 /**
76 * An empty array of sources. 86 * Return `true` if the given URI is a `dart-ext:` URI.
87 *
88 * @param uriContent the textual representation of the URI being tested
89 * @return `true` if the given URI is a `dart-ext:` URI
77 */ 90 */
78 static final List<Source> EMPTY_ARRAY = new List<Source>(0); 91 static bool isDartExtUri(String uriContent) => uriContent != null && uriConten t.startsWith(_DART_EXT_SCHEME);
79 92
80 /** 93 /**
81 * Return `true` if the given object is a source that represents the same sour ce code as 94 * The Dart SDK against which URI's are to be resolved.
82 * this source.
83 *
84 * @param object the object to be compared with this object
85 * @return `true` if the given object is a source that represents the same sou rce code as
86 * this source
87 * @see Object#equals(Object)
88 */ 95 */
89 @override 96 final DartSdk _sdk;
90 bool operator ==(Object object);
91 97
92 /** 98 /**
93 * Return `true` if this source exists. 99 * The name of the `dart` scheme.
94 *
95 * Clients should consider using the the method [AnalysisContext#exists] becau se
96 * contexts can have local overrides of the content of a source that the sourc e is not aware of
97 * and a source with local content is considered to exist even if there is no file on disk.
98 *
99 * @return `true` if this source exists
100 */ 100 */
101 bool exists(); 101 static String _DART_SCHEME = "dart";
102 102
103 /** 103 /**
104 * Get the contents and timestamp of this source. 104 * The prefix of a URI using the dart-ext scheme to reference a native code li brary.
105 *
106 * Clients should consider using the the method [AnalysisContext#getContents]
107 * because contexts can have local overrides of the content of a source that t he source is not
108 * aware of.
109 *
110 * @return the contents and timestamp of the source
111 * @throws Exception if the contents of this source could not be accessed
112 */ 105 */
113 TimestampedData<String> get contents; 106 static String _DART_EXT_SCHEME = "dart-ext:";
114 107
115 /** 108 /**
116 * Return an encoded representation of this source that can be used to create a source that is 109 * Return `true` if the given URI is a `dart:` URI.
117 * equal to this source.
118 * 110 *
119 * @return an encoded representation of this source 111 * @param uri the URI being tested
120 * @see SourceFactory#fromEncoding(String) 112 * @return `true` if the given URI is a `dart:` URI
121 */ 113 */
122 String get encoding; 114 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme;
123 115
124 /** 116 /**
125 * Return the full (long) version of the name that can be displayed to the use r to denote this 117 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
126 * source. For example, for a source representing a file this would typically be the absolute path 118 * given Dart SDK.
127 * of the file.
128 * 119 *
129 * @return a name that can be displayed to the user to denote this source 120 * @param sdk the Dart SDK against which URI's are to be resolved
130 */ 121 */
131 String get fullName; 122 DartUriResolver(this._sdk);
123
124 @override
125 Source fromEncoding(UriKind kind, Uri uri) {
126 if (kind == UriKind.DART_URI) {
127 return _sdk.fromEncoding(kind, uri);
128 }
129 return null;
130 }
132 131
133 /** 132 /**
134 * Return the modification stamp for this source. A modification stamp is a no n-negative integer 133 * Return the [DartSdk] against which URIs are to be resolved.
135 * with the property that if the contents of the source have not been modified since the last time
136 * the modification stamp was accessed then the same value will be returned, b ut if the contents
137 * of the source have been modified one or more times (even if the net change is zero) the stamps
138 * will be different.
139 * 134 *
140 * Clients should consider using the the method 135 * @return the [DartSdk] against which URIs are to be resolved.
141 * [AnalysisContext#getModificationStamp] because contexts can have local over rides
142 * of the content of a source that the source is not aware of.
143 *
144 * @return the modification stamp for this source
145 */ 136 */
146 int get modificationStamp; 137 DartSdk get dartSdk => _sdk;
147 138
148 /**
149 * Return a short version of the name that can be displayed to the user to den ote this source. For
150 * example, for a source representing a file this would typically be the name of the file.
151 *
152 * @return a name that can be displayed to the user to denote this source
153 */
154 String get shortName;
155
156 /**
157 * Return the kind of URI from which this source was originally derived. If th is source was
158 * created from an absolute URI, then the returned kind will reflect the schem e of the absolute
159 * URI. If it was created from a relative URI, then the returned kind will be the same as the kind
160 * of the source against which the relative URI was resolved.
161 *
162 * @return the kind of URI from which this source was originally derived
163 */
164 UriKind get uriKind;
165
166 /**
167 * Return a hash code for this source.
168 *
169 * @return a hash code for this source
170 * @see Object#hashCode()
171 */
172 @override 139 @override
173 int get hashCode; 140 Source resolveAbsolute(Uri uri) {
174 141 if (!isDartUri(uri)) {
175 /** 142 return null;
176 * Return `true` if this source is in one of the system libraries. 143 }
177 * 144 return _sdk.mapDartUri(uri.toString());
178 * @return `true` if this is in a system library 145 }
179 */
180 bool get isInSystemLibrary;
181
182 /**
183 * Resolve the relative URI against the URI associated with this source object . Return a
184 * [Source] representing the URI to which it was resolved, or `null` if it
185 * could not be resolved.
186 *
187 * Note: This method is not intended for public use, it is only visible out of necessity. It is
188 * only intended to be invoked by a [SourceFactory]. Source factories will
189 * only invoke this method if the URI is relative, so implementations of this method are not
190 * required to, and generally do not, verify the argument. The result of invok ing this method with
191 * an absolute URI is intentionally left unspecified.
192 *
193 * @param relativeUri the relative URI to be resolved against the containing s ource
194 * @return a [Source] representing the URI to which given URI was resolved
195 */
196 Source resolveRelative(Uri relativeUri);
197 } 146 }
198 147
199 /** 148 /**
200 * The interface `ContentReceiver` defines the behavior of objects that can rece ive the
201 * content of a source.
202 */
203 abstract class Source_ContentReceiver {
204 /**
205 * Accept the contents of a source.
206 *
207 * @param contents the contents of the source
208 * @param modificationTime the time at which the contents were last set
209 */
210 void accept(String contents, int modificationTime);
211 }
212
213 /**
214 * Instances of interface `LocalSourcePredicate` are used to determine if the gi ven
215 * [Source] is "local" in some sense, so can be updated.
216 */
217 abstract class LocalSourcePredicate {
218 /**
219 * Instance of [LocalSourcePredicate] that always returns `false`.
220 */
221 static final LocalSourcePredicate FALSE = new LocalSourcePredicate_FALSE();
222
223 /**
224 * Instance of [LocalSourcePredicate] that always returns `true`.
225 */
226 static final LocalSourcePredicate TRUE = new LocalSourcePredicate_TRUE();
227
228 /**
229 * Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
230 * except of SDK.
231 */
232 static final LocalSourcePredicate NOT_SDK = new LocalSourcePredicate_NOT_SDK() ;
233
234 /**
235 * Determines if the given [Source] is local.
236 *
237 * @param source the [Source] to analyze
238 * @return `true` if the given [Source] is local
239 */
240 bool isLocal(Source source);
241 }
242
243 class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
244 @override
245 bool isLocal(Source source) => false;
246 }
247
248 class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
249 @override
250 bool isLocal(Source source) => true;
251 }
252
253 class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
254 @override
255 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
256 }
257
258 /**
259 * Instances of the class `LineInfo` encapsulate information about line and colu mn information 149 * Instances of the class `LineInfo` encapsulate information about line and colu mn information
260 * within a source file. 150 * within a source file.
261 */ 151 */
262 class LineInfo { 152 class LineInfo {
263 /** 153 /**
264 * An array containing the offsets of the first character of each line in the source code. 154 * An array containing the offsets of the first character of each line in the source code.
265 */ 155 */
266 final List<int> _lineStarts; 156 final List<int> _lineStarts;
267 157
268 /** 158 /**
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 * Initialize a newly created location to represent the location of the charac ter at the given 205 * Initialize a newly created location to represent the location of the charac ter at the given
316 * line and column position. 206 * line and column position.
317 * 207 *
318 * @param lineNumber the one-based index of the line containing the character 208 * @param lineNumber the one-based index of the line containing the character
319 * @param columnNumber the one-based index of the column containing the charac ter 209 * @param columnNumber the one-based index of the column containing the charac ter
320 */ 210 */
321 LineInfo_Location(this.lineNumber, this.columnNumber); 211 LineInfo_Location(this.lineNumber, this.columnNumber);
322 } 212 }
323 213
324 /** 214 /**
325 * Instances of class `ContentCache` hold content used to override the default c ontent of a 215 * Instances of interface `LocalSourcePredicate` are used to determine if the gi ven
326 * [Source]. 216 * [Source] is "local" in some sense, so can be updated.
327 */ 217 */
328 class ContentCache { 218 abstract class LocalSourcePredicate {
329 /** 219 /**
330 * A table mapping sources to the contents of those sources. This is used to o verride the default 220 * Instance of [LocalSourcePredicate] that always returns `false`.
331 * contents of a source. 221 */
332 */ 222 static final LocalSourcePredicate FALSE = new LocalSourcePredicate_FALSE();
333 Map<Source, String> _contentMap = new Map<Source, String>(); 223
334 224 /**
335 /** 225 * Instance of [LocalSourcePredicate] that always returns `true`.
336 * A table mapping sources to the modification stamps of those sources. This i s used when the 226 */
337 * default contents of a source has been overridden. 227 static final LocalSourcePredicate TRUE = new LocalSourcePredicate_TRUE();
338 */ 228
339 Map<Source, int> _stampMap = new Map<Source, int>(); 229 /**
340 230 * Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
341 /** 231 * except of SDK.
342 * Return the contents of the given source, or `null` if this cache does not o verride the 232 */
343 * contents of the source. 233 static final LocalSourcePredicate NOT_SDK = new LocalSourcePredicate_NOT_SDK() ;
344 * 234
345 * <b>Note:</b> This method is not intended to be used except by 235 /**
346 * [AnalysisContext#getContents]. 236 * Determines if the given [Source] is local.
347 * 237 *
348 * @param source the source whose content is to be returned 238 * @param source the [Source] to analyze
349 * @return the contents of the given source 239 * @return `true` if the given [Source] is local
350 */ 240 */
351 String getContents(Source source) => _contentMap[source]; 241 bool isLocal(Source source);
352 242 }
353 /** 243
354 * Return the modification stamp of the given source, or `null` if this cache does not 244 class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
355 * override the contents of the source. 245 @override
356 * 246 bool isLocal(Source source) => false;
357 * <b>Note:</b> This method is not intended to be used except by 247 }
358 * [AnalysisContext#getModificationStamp]. 248
359 * 249 class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
360 * @param source the source whose modification stamp is to be returned 250 @override
361 * @return the modification stamp of the given source 251 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
362 */ 252 }
363 int getModificationStamp(Source source) => _stampMap[source]; 253
364 254 class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
365 /** 255 @override
366 * Set the contents of the given source to the given contents. This has the ef fect of overriding 256 bool isLocal(Source source) => true;
367 * the default contents of the source. If the contents are `null` the override is removed so 257 }
368 * that the default contents will be returned. 258
369 * 259 /**
370 * @param source the source whose contents are being overridden 260 * The interface `Source` defines the behavior of objects representing source co de that can be
371 * @param contents the new contents of the source 261 * analyzed by the analysis engine.
372 * @return the original cached contents or `null` if none 262 *
373 */ 263 * Implementations of this interface need to be aware of some assumptions made b y the analysis
374 String setContents(Source source, String contents) { 264 * engine concerning sources:
375 if (contents == null) { 265 * * Sources are not required to be unique. That is, there can be multiple insta nces representing
376 _stampMap.remove(source); 266 * the same source.
377 return _contentMap.remove(source); 267 * * Sources are long lived. That is, the engine is allowed to hold on to a sour ce for an extended
378 } else { 268 * period of time and that source must continue to report accurate and up-to-dat e information.
379 int newStamp = JavaSystem.currentTimeMillis(); 269 * Because of these assumptions, most implementations will not maintain any stat e but will delegate
380 int oldStamp = javaMapPut(_stampMap, source, newStamp); 270 * to an authoritative system of record in order to implement this API. For exam ple, a source that
381 // Occasionally, if this method is called in rapid succession, the timesta mps are equal. 271 * represents files on disk would typically query the file system to determine t he state of the
382 // Guard against this by artificially incrementing the new timestamp 272 * file.
383 if (newStamp == oldStamp) { 273 *
384 _stampMap[source] = newStamp + 1; 274 * If the instances that implement this API are the system of record, then they will typically be
385 } 275 * unique. In that case, sources that are created that represent non-existent fi les must also be
386 return javaMapPut(_contentMap, source, contents); 276 * retained so that if those files are created at a later date the long-lived so urces representing
387 } 277 * those files will know that they now exist.
388 }
389 }
390
391 /**
392 * Instances of the class `DartUriResolver` resolve `dart` URI's.
393 */ 278 */
394 class DartUriResolver extends UriResolver { 279 abstract class Source {
395 /** 280 /**
396 * Return `true` if the given URI is a `dart-ext:` URI. 281 * An empty array of sources.
397 * 282 */
398 * @param uriContent the textual representation of the URI being tested 283 static final List<Source> EMPTY_ARRAY = new List<Source>(0);
399 * @return `true` if the given URI is a `dart-ext:` URI 284
400 */ 285 /**
401 static bool isDartExtUri(String uriContent) => uriContent != null && uriConten t.startsWith(_DART_EXT_SCHEME); 286 * Return `true` if the given object is a source that represents the same sour ce code as
402 287 * this source.
403 /** 288 *
404 * The Dart SDK against which URI's are to be resolved. 289 * @param object the object to be compared with this object
405 */ 290 * @return `true` if the given object is a source that represents the same sou rce code as
406 final DartSdk _sdk; 291 * this source
407 292 * @see Object#equals(Object)
408 /** 293 */
409 * The name of the `dart` scheme. 294 @override
410 */ 295 bool operator ==(Object object);
411 static String _DART_SCHEME = "dart"; 296
412 297 /**
413 /** 298 * Return `true` if this source exists.
414 * The prefix of a URI using the dart-ext scheme to reference a native code li brary. 299 *
415 */ 300 * Clients should consider using the the method [AnalysisContext#exists] becau se
416 static String _DART_EXT_SCHEME = "dart-ext:"; 301 * contexts can have local overrides of the content of a source that the sourc e is not aware of
417 302 * and a source with local content is considered to exist even if there is no file on disk.
418 /** 303 *
419 * Return `true` if the given URI is a `dart:` URI. 304 * @return `true` if this source exists
420 * 305 */
421 * @param uri the URI being tested 306 bool exists();
422 * @return `true` if the given URI is a `dart:` URI 307
423 */ 308 /**
424 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme; 309 * Get the contents and timestamp of this source.
425 310 *
426 /** 311 * Clients should consider using the the method [AnalysisContext#getContents]
427 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the 312 * because contexts can have local overrides of the content of a source that t he source is not
428 * given Dart SDK. 313 * aware of.
429 * 314 *
430 * @param sdk the Dart SDK against which URI's are to be resolved 315 * @return the contents and timestamp of the source
431 */ 316 * @throws Exception if the contents of this source could not be accessed
432 DartUriResolver(this._sdk); 317 */
433 318 TimestampedData<String> get contents;
434 @override 319
435 Source fromEncoding(UriKind kind, Uri uri) { 320 /**
436 if (kind == UriKind.DART_URI) { 321 * Return an encoded representation of this source that can be used to create a source that is
437 return _sdk.fromEncoding(kind, uri); 322 * equal to this source.
438 } 323 *
439 return null; 324 * @return an encoded representation of this source
440 } 325 * @see SourceFactory#fromEncoding(String)
441 326 */
442 /** 327 String get encoding;
443 * Return the [DartSdk] against which URIs are to be resolved. 328
444 * 329 /**
445 * @return the [DartSdk] against which URIs are to be resolved. 330 * Return the full (long) version of the name that can be displayed to the use r to denote this
446 */ 331 * source. For example, for a source representing a file this would typically be the absolute path
447 DartSdk get dartSdk => _sdk; 332 * of the file.
448 333 *
449 @override 334 * @return a name that can be displayed to the user to denote this source
450 Source resolveAbsolute(Uri uri) { 335 */
451 if (!isDartUri(uri)) { 336 String get fullName;
452 return null; 337
453 } 338 /**
454 return _sdk.mapDartUri(uri.toString()); 339 * Return the modification stamp for this source. A modification stamp is a no n-negative integer
455 } 340 * with the property that if the contents of the source have not been modified since the last time
456 } 341 * the modification stamp was accessed then the same value will be returned, b ut if the contents
457 342 * of the source have been modified one or more times (even if the net change is zero) the stamps
458 /** 343 * will be different.
344 *
345 * Clients should consider using the the method
346 * [AnalysisContext#getModificationStamp] because contexts can have local over rides
347 * of the content of a source that the source is not aware of.
348 *
349 * @return the modification stamp for this source
350 */
351 int get modificationStamp;
352
353 /**
354 * Return a short version of the name that can be displayed to the user to den ote this source. For
355 * example, for a source representing a file this would typically be the name of the file.
356 *
357 * @return a name that can be displayed to the user to denote this source
358 */
359 String get shortName;
360
361 /**
362 * Return the kind of URI from which this source was originally derived. If th is source was
363 * created from an absolute URI, then the returned kind will reflect the schem e of the absolute
364 * URI. If it was created from a relative URI, then the returned kind will be the same as the kind
365 * of the source against which the relative URI was resolved.
366 *
367 * @return the kind of URI from which this source was originally derived
368 */
369 UriKind get uriKind;
370
371 /**
372 * Return a hash code for this source.
373 *
374 * @return a hash code for this source
375 * @see Object#hashCode()
376 */
377 @override
378 int get hashCode;
379
380 /**
381 * Return `true` if this source is in one of the system libraries.
382 *
383 * @return `true` if this is in a system library
384 */
385 bool get isInSystemLibrary;
386
387 /**
388 * Resolve the relative URI against the URI associated with this source object . Return a
389 * [Source] representing the URI to which it was resolved, or `null` if it
390 * could not be resolved.
391 *
392 * Note: This method is not intended for public use, it is only visible out of necessity. It is
393 * only intended to be invoked by a [SourceFactory]. Source factories will
394 * only invoke this method if the URI is relative, so implementations of this method are not
395 * required to, and generally do not, verify the argument. The result of invok ing this method with
396 * an absolute URI is intentionally left unspecified.
397 *
398 * @param relativeUri the relative URI to be resolved against the containing s ource
399 * @return a [Source] representing the URI to which given URI was resolved
400 */
401 Source resolveRelative(Uri relativeUri);
402 }
403
404 /**
405 * The interface `SourceContainer` is used by clients to define a collection of sources
406 *
407 * Source containers are not used within analysis engine, but can be used by cli ents to group
408 * sources for the purposes of accessing composite dependency information. For e xample, the Eclipse
409 * client uses source containers to represent Eclipse projects, which allows it to easily compute
410 * project-level dependencies.
411 */
412 abstract class SourceContainer {
413 /**
414 * Determine if the specified source is part of the receiver's collection of s ources.
415 *
416 * @param source the source in question
417 * @return `true` if the receiver contains the source, else `false`
418 */
419 bool contains(Source source);
420 }
421
422 /**
459 * Instances of the class `SourceFactory` resolve possibly relative URI's agains t an existing 423 * Instances of the class `SourceFactory` resolve possibly relative URI's agains t an existing
460 * [Source]. 424 * [Source].
461 */ 425 */
462 class SourceFactory { 426 class SourceFactory {
463 /** 427 /**
464 * The analysis context that this source factory is associated with. 428 * The analysis context that this source factory is associated with.
465 */ 429 */
466 AnalysisContext context; 430 AnalysisContext context;
467 431
468 /** 432 /**
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 } 586 }
623 } 587 }
624 return null; 588 return null;
625 } else { 589 } else {
626 return containingSource.resolveRelative(containedUri); 590 return containingSource.resolveRelative(containedUri);
627 } 591 }
628 } 592 }
629 } 593 }
630 594
631 /** 595 /**
632 * The interface `SourceContainer` is used by clients to define a collection of sources 596 * The enumeration `SourceKind` defines the different kinds of sources that are known to the
633 * 597 * analysis engine.
634 * Source containers are not used within analysis engine, but can be used by cli ents to group
635 * sources for the purposes of accessing composite dependency information. For e xample, the Eclipse
636 * client uses source containers to represent Eclipse projects, which allows it to easily compute
637 * project-level dependencies.
638 */ 598 */
639 abstract class SourceContainer { 599 class SourceKind extends Enum<SourceKind> {
640 /** 600 /**
641 * Determine if the specified source is part of the receiver's collection of s ources. 601 * A source containing HTML. The HTML might or might not contain Dart scripts.
642 *
643 * @param source the source in question
644 * @return `true` if the receiver contains the source, else `false`
645 */ 602 */
646 bool contains(Source source); 603 static const SourceKind HTML = const SourceKind('HTML', 0);
604
605 /**
606 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not
607 * contain any directives, including a library directive.
608 */
609 static const SourceKind LIBRARY = const SourceKind('LIBRARY', 1);
610
611 /**
612 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive.
613 */
614 static const SourceKind PART = const SourceKind('PART', 2);
615
616 /**
617 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source
618 * and also when the kind of a source is not known without performing a comput ation and the client
619 * does not want to spend the time to identify the kind.
620 */
621 static const SourceKind UNKNOWN = const SourceKind('UNKNOWN', 3);
622
623 static const List<SourceKind> values = const [HTML, LIBRARY, PART, UNKNOWN];
624
625 const SourceKind(String name, int ordinal) : super(name, ordinal);
647 } 626 }
648 627
649 /** 628 /**
650 * A source range defines an [Element]'s source coordinates relative to its [Sou rce]. 629 * A source range defines an [Element]'s source coordinates relative to its [Sou rce].
651 */ 630 */
652 class SourceRange { 631 class SourceRange {
653 /** 632 /**
654 * An empty [SourceRange] with offset `0` and length `0`. 633 * An empty [SourceRange] with offset `0` and length `0`.
655 */ 634 */
656 static SourceRange EMPTY = new SourceRange(0, 0); 635 static SourceRange EMPTY = new SourceRange(0, 0);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 builder.append("[offset="); 751 builder.append("[offset=");
773 builder.append(offset); 752 builder.append(offset);
774 builder.append(", length="); 753 builder.append(", length=");
775 builder.append(length); 754 builder.append(length);
776 builder.append("]"); 755 builder.append("]");
777 return builder.toString(); 756 return builder.toString();
778 } 757 }
779 } 758 }
780 759
781 /** 760 /**
782 * The enumeration `SourceKind` defines the different kinds of sources that are known to the 761 * The interface `ContentReceiver` defines the behavior of objects that can rece ive the
783 * analysis engine. 762 * content of a source.
784 */ 763 */
785 class SourceKind extends Enum<SourceKind> { 764 abstract class Source_ContentReceiver {
786 /** 765 /**
787 * A source containing HTML. The HTML might or might not contain Dart scripts. 766 * Accept the contents of a source.
767 *
768 * @param contents the contents of the source
769 * @param modificationTime the time at which the contents were last set
788 */ 770 */
789 static const SourceKind HTML = const SourceKind('HTML', 0); 771 void accept(String contents, int modificationTime);
790
791 /**
792 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not
793 * contain any directives, including a library directive.
794 */
795 static const SourceKind LIBRARY = const SourceKind('LIBRARY', 1);
796
797 /**
798 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive.
799 */
800 static const SourceKind PART = const SourceKind('PART', 2);
801
802 /**
803 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source
804 * and also when the kind of a source is not known without performing a comput ation and the client
805 * does not want to spend the time to identify the kind.
806 */
807 static const SourceKind UNKNOWN = const SourceKind('UNKNOWN', 3);
808
809 static const List<SourceKind> values = const [HTML, LIBRARY, PART, UNKNOWN];
810
811 const SourceKind(String name, int ordinal) : super(name, ordinal);
812 } 772 }
813 773
814 /** 774 /**
815 * The enumeration `UriKind` defines the different kinds of URI's that are known to the 775 * The enumeration `UriKind` defines the different kinds of URI's that are known to the
816 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source. 776 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source.
817 */ 777 */
818 class UriKind extends Enum<UriKind> { 778 class UriKind extends Enum<UriKind> {
819 /** 779 /**
820 * A 'dart:' URI. 780 * A 'dart:' URI.
821 */ 781 */
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 * The single character encoding used to identify this kind of URI. 825 * The single character encoding used to identify this kind of URI.
866 */ 826 */
867 final int encoding; 827 final int encoding;
868 828
869 /** 829 /**
870 * Initialize a newly created URI kind to have the given encoding. 830 * Initialize a newly created URI kind to have the given encoding.
871 * 831 *
872 * @param encoding the single character encoding used to identify this kind of URI. 832 * @param encoding the single character encoding used to identify this kind of URI.
873 */ 833 */
874 const UriKind(String name, int ordinal, this.encoding) : super(name, ordinal); 834 const UriKind(String name, int ordinal, this.encoding) : super(name, ordinal);
835 }
836
837 /**
838 * The abstract class `UriResolver` defines the behavior of objects that are use d to resolve
839 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
840 * absolute URI.
841 */
842 abstract class UriResolver {
843 /**
844 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI.
845 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a
846 * [Source] representing the file to which it was resolved, whether or not the
847 * resulting source exists, or `null` if it could not be resolved because the URI is
848 * invalid.
849 *
850 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with
851 * the given URI
852 * @param uri the URI to be resolved
853 * @return a [Source] representing the file to which given URI was resolved
854 */
855 Source fromEncoding(UriKind kind, Uri uri);
856
857 /**
858 * Resolve the given absolute URI. Return a [Source] representing the file to which
859 * it was resolved, whether or not the resulting source exists, or `null` if i t could not be
860 * resolved because the URI is invalid.
861 *
862 * @param uri the URI to be resolved
863 * @return a [Source] representing the file to which given URI was resolved
864 */
865 Source resolveAbsolute(Uri uri);
866
867 /**
868 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot
869 * be computed.
870 *
871 * @param source the source to get URI for
872 * @return the absolute URI representing the given source
873 */
874 Uri restoreAbsolute(Source source) => null;
875 } 875 }
OLDNEW
« 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