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

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

Issue 184893003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 // 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; 12 import 'engine.dart' show AnalysisContext, TimestampedData;
13 13
14 /** 14 /**
15 * Instances of interface `LocalSourcePredicate` are used to determine if the gi ven 15 * Instances of interface `LocalSourcePredicate` are used to determine if the gi ven
16 * [Source] is "local" in some sense, so can be updated. 16 * [Source] is "local" in some sense, so can be updated.
17 * 17 *
18 * @coverage dart.engine.source 18 * @coverage dart.engine.source
19 */ 19 */
20 abstract class LocalSourcePredicate { 20 abstract class LocalSourcePredicate {
21 /** 21 /**
22 * Instance of [LocalSourcePredicate] that always returns `false`. 22 * Instance of [LocalSourcePredicate] that always returns `false`.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 * 61 *
62 * @coverage dart.engine.source 62 * @coverage dart.engine.source
63 */ 63 */
64 class SourceFactory { 64 class SourceFactory {
65 /** 65 /**
66 * The analysis context that this source factory is associated with. 66 * The analysis context that this source factory is associated with.
67 */ 67 */
68 AnalysisContext context; 68 AnalysisContext context;
69 69
70 /** 70 /**
71 * A cache of content used to override the default content of a source.
72 */
73 ContentCache _contentCache;
74
75 /**
76 * The resolvers used to resolve absolute URI's. 71 * The resolvers used to resolve absolute URI's.
77 */ 72 */
78 List<UriResolver> _resolvers; 73 List<UriResolver> _resolvers;
79 74
80 /** 75 /**
81 * The predicate to determine is [Source] is local. 76 * The predicate to determine is [Source] is local.
82 */ 77 */
83 LocalSourcePredicate _localSourcePredicate; 78 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK;
84
85 /**
86 * Initialize a newly created source factory.
87 *
88 * @param contentCache the cache holding content used to override the default content of a source
89 * @param resolvers the resolvers used to resolve absolute URI's
90 */
91 SourceFactory.con1(ContentCache contentCache, List<UriResolver> resolvers) {
92 this._contentCache = contentCache;
93 this._resolvers = resolvers;
94 this._localSourcePredicate = LocalSourcePredicate.NOT_SDK;
95 }
96 79
97 /** 80 /**
98 * Initialize a newly created source factory. 81 * Initialize a newly created source factory.
99 * 82 *
100 * @param resolvers the resolvers used to resolve absolute URI's 83 * @param resolvers the resolvers used to resolve absolute URI's
101 */ 84 */
102 SourceFactory.con2(List<UriResolver> resolvers) : this.con1(new ContentCache() , resolvers); 85 SourceFactory(List<UriResolver> resolvers) {
86 this._resolvers = resolvers;
87 }
103 88
104 /** 89 /**
105 * Return a source object representing the given absolute URI, or `null` if th e URI is not a 90 * Return a source object representing the given absolute URI, or `null` if th e URI is not a
106 * valid URI or if it is not an absolute URI. 91 * valid URI or if it is not an absolute URI.
107 * 92 *
108 * @param absoluteUri the absolute URI to be resolved 93 * @param absoluteUri the absolute URI to be resolved
109 * @return a source object representing the absolute URI 94 * @return a source object representing the absolute URI
110 */ 95 */
111 Source forUri(String absoluteUri) { 96 Source forUri(String absoluteUri) {
112 try { 97 try {
(...skipping 18 matching lines...) Expand all
131 if (encoding.length < 2) { 116 if (encoding.length < 2) {
132 throw new IllegalArgumentException("Invalid encoding length"); 117 throw new IllegalArgumentException("Invalid encoding length");
133 } 118 }
134 UriKind kind = UriKind.fromEncoding(encoding.codeUnitAt(0)); 119 UriKind kind = UriKind.fromEncoding(encoding.codeUnitAt(0));
135 if (kind == null) { 120 if (kind == null) {
136 throw new IllegalArgumentException("Invalid source kind in encoding: ${kin d}"); 121 throw new IllegalArgumentException("Invalid source kind in encoding: ${kin d}");
137 } 122 }
138 try { 123 try {
139 Uri uri = parseUriWithException(encoding.substring(1)); 124 Uri uri = parseUriWithException(encoding.substring(1));
140 for (UriResolver resolver in _resolvers) { 125 for (UriResolver resolver in _resolvers) {
141 Source result = resolver.fromEncoding(_contentCache, kind, uri); 126 Source result = resolver.fromEncoding(kind, uri);
142 if (result != null) { 127 if (result != null) {
143 return result; 128 return result;
144 } 129 }
145 } 130 }
146 throw new IllegalArgumentException("No resolver for kind: ${kind}"); 131 throw new IllegalArgumentException("No resolver for kind: ${kind}");
147 } on JavaException catch (exception) { 132 } on JavaException catch (exception) {
148 throw new IllegalArgumentException("Invalid URI in encoding"); 133 throw new IllegalArgumentException("Invalid URI in encoding");
149 } 134 }
150 } 135 }
151 136
152 /** 137 /**
153 * Return a cache of content used to override the default content of a source.
154 *
155 * @return a cache of content used to override the default content of a source
156 */
157 ContentCache get contentCache => _contentCache;
158
159 /**
160 * Return the [DartSdk] associated with this [SourceFactory], or `null` if the re 138 * Return the [DartSdk] associated with this [SourceFactory], or `null` if the re
161 * is no such SDK. 139 * is no such SDK.
162 * 140 *
163 * @return the [DartSdk] associated with this [SourceFactory], or `null` if 141 * @return the [DartSdk] associated with this [SourceFactory], or `null` if
164 * there is no such SDK 142 * there is no such SDK
165 */ 143 */
166 DartSdk get dartSdk { 144 DartSdk get dartSdk {
167 for (UriResolver resolver in _resolvers) { 145 for (UriResolver resolver in _resolvers) {
168 if (resolver is DartUriResolver) { 146 if (resolver is DartUriResolver) {
169 DartUriResolver dartUriResolver = resolver; 147 DartUriResolver dartUriResolver = resolver;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 for (UriResolver resolver in _resolvers) { 191 for (UriResolver resolver in _resolvers) {
214 Uri uri = resolver.restoreAbsolute(source); 192 Uri uri = resolver.restoreAbsolute(source);
215 if (uri != null) { 193 if (uri != null) {
216 return uri; 194 return uri;
217 } 195 }
218 } 196 }
219 return null; 197 return null;
220 } 198 }
221 199
222 /** 200 /**
223 * Set the contents of the given source to the given contents. This has the ef fect of overriding
224 * the default contents of the source. If the contents are `null` the override is removed so
225 * that the default contents will be returned.
226 *
227 * @param source the source whose contents are being overridden
228 * @param contents the new contents of the source
229 * @return the original cached contents or `null` if none
230 */
231 String setContents(Source source, String contents) => _contentCache.setContent s(source, contents);
232
233 /**
234 * Sets the [LocalSourcePredicate]. 201 * Sets the [LocalSourcePredicate].
235 * 202 *
236 * @param localSourcePredicate the predicate to determine is [Source] is local 203 * @param localSourcePredicate the predicate to determine is [Source] is local
237 */ 204 */
238 void set localSourcePredicate(LocalSourcePredicate localSourcePredicate) { 205 void set localSourcePredicate(LocalSourcePredicate localSourcePredicate) {
239 this._localSourcePredicate = localSourcePredicate; 206 this._localSourcePredicate = localSourcePredicate;
240 } 207 }
241 208
242 /** 209 /**
243 * Return the contents of the given source, or `null` if this factory does not override the
244 * contents of the source.
245 *
246 * <b>Note:</b> This method is not intended to be used except by
247 * [FileBasedSource#getContents].
248 *
249 * @param source the source whose content is to be returned
250 * @return the contents of the given source
251 */
252 String getContents(Source source) => _contentCache.getContents(source);
253
254 /**
255 * Return the modification stamp of the given source, or `null` if this factor y does not
256 * override the contents of the source.
257 *
258 * <b>Note:</b> This method is not intended to be used except by
259 * [FileBasedSource#getModificationStamp].
260 *
261 * @param source the source whose modification stamp is to be returned
262 * @return the modification stamp of the given source
263 */
264 int getModificationStamp(Source source) => _contentCache.getModificationStamp( source);
265
266 /**
267 * Return a source object representing the URI that results from resolving the given (possibly 210 * Return a source object representing the URI that results from resolving the given (possibly
268 * relative) contained URI against the URI associated with an existing source object, or 211 * relative) contained URI against the URI associated with an existing source object, or
269 * `null` if either the contained URI is invalid or if it cannot be resolved a gainst the 212 * `null` if either the contained URI is invalid or if it cannot be resolved a gainst the
270 * source object's URI. 213 * source object's URI.
271 * 214 *
272 * @param containingSource the source containing the given URI 215 * @param containingSource the source containing the given URI
273 * @param containedUri the (possibly relative) URI to be resolved against the containing source 216 * @param containedUri the (possibly relative) URI to be resolved against the containing source
274 * @return the source representing the contained URI 217 * @return the source representing the contained URI
275 */ 218 */
276 Source resolveUri2(Source containingSource, Uri containedUri) { 219 Source resolveUri2(Source containingSource, Uri containedUri) {
277 if (containedUri.isAbsolute) { 220 if (containedUri.isAbsolute) {
278 for (UriResolver resolver in _resolvers) { 221 for (UriResolver resolver in _resolvers) {
279 Source result = resolver.resolveAbsolute(_contentCache, containedUri); 222 Source result = resolver.resolveAbsolute(containedUri);
280 if (result != null) { 223 if (result != null) {
281 return result; 224 return result;
282 } 225 }
283 } 226 }
284 return null; 227 return null;
285 } else { 228 } else {
286 return containingSource.resolveRelative(containedUri); 229 return containingSource.resolveRelative(containedUri);
287 } 230 }
288 } 231 }
289 } 232 }
290 233
291 /** 234 /**
292 * The abstract class `UriResolver` defines the behavior of objects that are use d to resolve 235 * The abstract class `UriResolver` defines the behavior of objects that are use d to resolve
293 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of 236 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
294 * absolute URI. 237 * absolute URI.
295 * 238 *
296 * @coverage dart.engine.source 239 * @coverage dart.engine.source
297 */ 240 */
298 abstract class UriResolver { 241 abstract class UriResolver {
299 /** 242 /**
300 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI. 243 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI.
301 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a 244 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a
302 * [Source] representing the file to which it was resolved, or `null` if it 245 * [Source] representing the file to which it was resolved, or `null` if it
303 * could not be resolved. 246 * could not be resolved.
304 * 247 *
305 * @param contentCache the content cache used to access the contents of the re turned source
306 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with 248 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with
307 * the given URI 249 * the given URI
308 * @param uri the URI to be resolved 250 * @param uri the URI to be resolved
309 * @return a [Source] representing the file to which given URI was resolved 251 * @return a [Source] representing the file to which given URI was resolved
310 */ 252 */
311 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri); 253 Source fromEncoding(UriKind kind, Uri uri);
312 254
313 /** 255 /**
314 * Resolve the given absolute URI. Return a [Source] representing the file to which 256 * Resolve the given absolute URI. Return a [Source] representing the file to which
315 * it was resolved, or `null` if it could not be resolved. 257 * it was resolved, or `null` if it could not be resolved.
316 * 258 *
317 * @param contentCache the content cache used to access the contents of the re turned source
318 * @param uri the URI to be resolved 259 * @param uri the URI to be resolved
319 * @return a [Source] representing the file to which given URI was resolved 260 * @return a [Source] representing the file to which given URI was resolved
320 */ 261 */
321 Source resolveAbsolute(ContentCache contentCache, Uri uri); 262 Source resolveAbsolute(Uri uri);
322 263
323 /** 264 /**
324 * Return an absolute URI that represents the given source. 265 * Return an absolute URI that represents the given source.
325 * 266 *
326 * @param source the source to get URI for 267 * @param source the source to get URI for
327 * @return the absolute URI representing the given source, may be `null` 268 * @return the absolute URI representing the given source, may be `null`
328 */ 269 */
329 Uri restoreAbsolute(Source source) => null; 270 Uri restoreAbsolute(Source source) => null;
330 } 271 }
331 272
(...skipping 16 matching lines...) Expand all
348 * @param object the object to be compared with this object 289 * @param object the object to be compared with this object
349 * @return `true` if the given object is a source that represents the same sou rce code as 290 * @return `true` if the given object is a source that represents the same sou rce code as
350 * this source 291 * this source
351 * @see Object#equals(Object) 292 * @see Object#equals(Object)
352 */ 293 */
353 bool operator ==(Object object); 294 bool operator ==(Object object);
354 295
355 /** 296 /**
356 * Return `true` if this source exists. 297 * Return `true` if this source exists.
357 * 298 *
299 * Clients should consider using the the method [AnalysisContext#exists] becau se
300 * contexts can have local overrides of the content of a source that the sourc e is not aware of
301 * and a source with local content is considered to exist even if there is no file on disk.
302 *
358 * @return `true` if this source exists 303 * @return `true` if this source exists
359 */ 304 */
360 bool exists(); 305 bool exists();
361 306
362 /** 307 /**
363 * Get the contents of this source and pass it to the given receiver. Exactly one of the methods 308 * Get the contents and timestamp of this source.
364 * defined on the receiver will be invoked unless an exception is thrown. The method that will be 309 *
365 * invoked depends on which of the possible representations of the contents is the most efficient. 310 * Clients should consider using the the method [AnalysisContext#getContents]
366 * Whichever method is invoked, it will be invoked before this method returns. 311 * because contexts can have local overrides of the content of a source that t he source is not
312 * aware of.
313 *
314 * @return the contents and timestamp of the source
315 * @throws Exception if the contents of this source could not be accessed
316 */
317 TimestampedData<String> get contents;
318
319 /**
320 * Get the contents of this source and pass it to the given content receiver.
321 *
322 * Clients should consider using the the method
323 * [AnalysisContext#getContents] because contexts can have local
324 * overrides of the content of a source that the source is not aware of.
367 * 325 *
368 * @param receiver the content receiver to which the content of this source wi ll be passed 326 * @param receiver the content receiver to which the content of this source wi ll be passed
369 * @throws Exception if the contents of this source could not be accessed 327 * @throws Exception if the contents of this source could not be accessed
370 */ 328 */
371 void getContents(Source_ContentReceiver receiver); 329 void getContentsToReceiver(Source_ContentReceiver receiver);
372 330
373 /** 331 /**
374 * Return an encoded representation of this source that can be used to create a source that is 332 * Return an encoded representation of this source that can be used to create a source that is
375 * equal to this source. 333 * equal to this source.
376 * 334 *
377 * @return an encoded representation of this source 335 * @return an encoded representation of this source
378 * @see SourceFactory#fromEncoding(String) 336 * @see SourceFactory#fromEncoding(String)
379 */ 337 */
380 String get encoding; 338 String get encoding;
381 339
382 /** 340 /**
383 * Return the full (long) version of the name that can be displayed to the use r to denote this 341 * Return the full (long) version of the name that can be displayed to the use r to denote this
384 * source. For example, for a source representing a file this would typically be the absolute path 342 * source. For example, for a source representing a file this would typically be the absolute path
385 * of the file. 343 * of the file.
386 * 344 *
387 * @return a name that can be displayed to the user to denote this source 345 * @return a name that can be displayed to the user to denote this source
388 */ 346 */
389 String get fullName; 347 String get fullName;
390 348
391 /** 349 /**
392 * Return the modification stamp for this source. A modification stamp is a no n-negative integer 350 * Return the modification stamp for this source. A modification stamp is a no n-negative integer
393 * with the property that if the contents of the source have not been modified since the last time 351 * with the property that if the contents of the source have not been modified since the last time
394 * the modification stamp was accessed then the same value will be returned, b ut if the contents 352 * the modification stamp was accessed then the same value will be returned, b ut if the contents
395 * of the source have been modified one or more times (even if the net change is zero) the stamps 353 * of the source have been modified one or more times (even if the net change is zero) the stamps
396 * will be different. 354 * will be different.
397 * 355 *
356 * Clients should consider using the the method
357 * [AnalysisContext#getModificationStamp] because contexts can have local over rides
358 * of the content of a source that the source is not aware of.
359 *
398 * @return the modification stamp for this source 360 * @return the modification stamp for this source
399 */ 361 */
400 int get modificationStamp; 362 int get modificationStamp;
401 363
402 /** 364 /**
403 * Return a short version of the name that can be displayed to the user to den ote this source. For 365 * Return a short version of the name that can be displayed to the user to den ote this source. For
404 * example, for a source representing a file this would typically be the name of the file. 366 * example, for a source representing a file this would typically be the name of the file.
405 * 367 *
406 * @return a name that can be displayed to the user to denote this source 368 * @return a name that can be displayed to the user to denote this source
407 */ 369 */
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 /** 694 /**
733 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the 695 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
734 * given Dart SDK. 696 * given Dart SDK.
735 * 697 *
736 * @param sdk the Dart SDK against which URI's are to be resolved 698 * @param sdk the Dart SDK against which URI's are to be resolved
737 */ 699 */
738 DartUriResolver(DartSdk sdk) { 700 DartUriResolver(DartSdk sdk) {
739 this._sdk = sdk; 701 this._sdk = sdk;
740 } 702 }
741 703
742 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { 704 Source fromEncoding(UriKind kind, Uri uri) {
743 if (identical(kind, UriKind.DART_URI)) { 705 if (identical(kind, UriKind.DART_URI)) {
744 return _sdk.fromEncoding(contentCache, kind, uri); 706 return _sdk.fromEncoding(kind, uri);
745 } 707 }
746 return null; 708 return null;
747 } 709 }
748 710
749 /** 711 /**
750 * Return the [DartSdk] against which URIs are to be resolved. 712 * Return the [DartSdk] against which URIs are to be resolved.
751 * 713 *
752 * @return the [DartSdk] against which URIs are to be resolved. 714 * @return the [DartSdk] against which URIs are to be resolved.
753 */ 715 */
754 DartSdk get dartSdk => _sdk; 716 DartSdk get dartSdk => _sdk;
755 717
756 Source resolveAbsolute(ContentCache contentCache, Uri uri) { 718 Source resolveAbsolute(Uri uri) {
757 if (!isDartUri(uri)) { 719 if (!isDartUri(uri)) {
758 return null; 720 return null;
759 } 721 }
760 return _sdk.mapDartUri(uri.toString()); 722 return _sdk.mapDartUri(uri.toString());
761 } 723 }
762 } 724 }
763 725
764 /** 726 /**
765 * Instances of the class `LineInfo` encapsulate information about line and colu mn information 727 * Instances of the class `LineInfo` encapsulate information about line and colu mn information
766 * within a source file. 728 * within a source file.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 * A table mapping sources to the modification stamps of those sources. This i s used when the 809 * A table mapping sources to the modification stamps of those sources. This i s used when the
848 * default contents of a source has been overridden. 810 * default contents of a source has been overridden.
849 */ 811 */
850 Map<Source, int> _stampMap = new Map<Source, int>(); 812 Map<Source, int> _stampMap = new Map<Source, int>();
851 813
852 /** 814 /**
853 * Return the contents of the given source, or `null` if this cache does not o verride the 815 * Return the contents of the given source, or `null` if this cache does not o verride the
854 * contents of the source. 816 * contents of the source.
855 * 817 *
856 * <b>Note:</b> This method is not intended to be used except by 818 * <b>Note:</b> This method is not intended to be used except by
857 * [SourceFactory#getContents]. 819 * [AnalysisContext#getContents].
858 * 820 *
859 * @param source the source whose content is to be returned 821 * @param source the source whose content is to be returned
860 * @return the contents of the given source 822 * @return the contents of the given source
861 */ 823 */
862 String getContents(Source source) => _contentMap[source]; 824 String getContents(Source source) => _contentMap[source];
863 825
864 /** 826 /**
865 * Return the modification stamp of the given source, or `null` if this cache does not 827 * Return the modification stamp of the given source, or `null` if this cache does not
866 * override the contents of the source. 828 * override the contents of the source.
867 * 829 *
868 * <b>Note:</b> This method is not intended to be used except by 830 * <b>Note:</b> This method is not intended to be used except by
869 * [SourceFactory#getModificationStamp]. 831 * [AnalysisContext#getModificationStamp].
870 * 832 *
871 * @param source the source whose modification stamp is to be returned 833 * @param source the source whose modification stamp is to be returned
872 * @return the modification stamp of the given source 834 * @return the modification stamp of the given source
873 */ 835 */
874 int getModificationStamp(Source source) => _stampMap[source]; 836 int getModificationStamp(Source source) => _stampMap[source];
875 837
876 /** 838 /**
877 * Set the contents of the given source to the given contents. This has the ef fect of overriding 839 * Set the contents of the given source to the given contents. This has the ef fect of overriding
878 * the default contents of the source. If the contents are `null` the override is removed so 840 * the default contents of the source. If the contents are `null` the override is removed so
879 * that the default contents will be returned. 841 * that the default contents will be returned.
(...skipping 11 matching lines...) Expand all
891 int oldStamp = javaMapPut(_stampMap, source, newStamp); 853 int oldStamp = javaMapPut(_stampMap, source, newStamp);
892 // Occasionally, if this method is called in rapid succession, the timesta mps are equal. 854 // Occasionally, if this method is called in rapid succession, the timesta mps are equal.
893 // Guard against this by artificially incrementing the new timestamp 855 // Guard against this by artificially incrementing the new timestamp
894 if (newStamp == oldStamp) { 856 if (newStamp == oldStamp) {
895 _stampMap[source] = newStamp + 1; 857 _stampMap[source] = newStamp + 1;
896 } 858 }
897 return javaMapPut(_contentMap, source, contents); 859 return javaMapPut(_contentMap, source, contents);
898 } 860 }
899 } 861 }
900 } 862 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698