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

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

Issue 103233003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 'java_core.dart'; 6 import 'java_core.dart';
7 import 'sdk.dart' show DartSdk; 7 import 'sdk.dart' show DartSdk;
8 import 'engine.dart' show AnalysisContext; 8 import 'engine.dart' show AnalysisContext;
9 9
10 /** 10 /**
11 * Instances of interface `LocalSourcePredicate` are used to determine if the gi ven
12 * [Source] is "local" in some sense, so can be updated.
13 *
14 * @coverage dart.engine.source
15 */
16 abstract class LocalSourcePredicate {
17 /**
18 * Instance of [LocalSourcePredicate] that always returns `false`.
19 */
20 static final LocalSourcePredicate _FALSE = new LocalSourcePredicate_15();
21
22 /**
23 * Instance of [LocalSourcePredicate] that always returns `true`.
24 */
25 static final LocalSourcePredicate _TRUE = new LocalSourcePredicate_16();
26
27 /**
28 * Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
29 * except of SDK.
30 */
31 static final LocalSourcePredicate _NOT_SDK = new LocalSourcePredicate_17();
32
33 /**
34 * Determines if the given [Source] is local.
35 *
36 * @param source the [Source] to analyze
37 * @return `true` if the given [Source] is local
38 */
39 bool isLocal(Source source);
40 }
41
42 class LocalSourcePredicate_15 implements LocalSourcePredicate {
43 bool isLocal(Source source) => false;
44 }
45
46 class LocalSourcePredicate_16 implements LocalSourcePredicate {
47 bool isLocal(Source source) => true;
48 }
49
50 class LocalSourcePredicate_17 implements LocalSourcePredicate {
51 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
52 }
53
54 /**
11 * Instances of the class `SourceFactory` resolve possibly relative URI's agains t an existing 55 * Instances of the class `SourceFactory` resolve possibly relative URI's agains t an existing
12 * [Source]. 56 * [Source].
13 * 57 *
14 * @coverage dart.engine.source 58 * @coverage dart.engine.source
15 */ 59 */
16 class SourceFactory { 60 class SourceFactory {
17 /** 61 /**
18 * The analysis context that this source factory is associated with. 62 * The analysis context that this source factory is associated with.
19 */ 63 */
20 AnalysisContext context; 64 AnalysisContext context;
21 65
22 /** 66 /**
67 * A cache of content used to override the default content of a source.
68 */
69 ContentCache contentCache;
70
71 /**
23 * The resolvers used to resolve absolute URI's. 72 * The resolvers used to resolve absolute URI's.
24 */ 73 */
25 List<UriResolver> _resolvers; 74 List<UriResolver> _resolvers;
26 75
27 /** 76 /**
28 * A cache of content used to override the default content of a source. 77 * The predicate to determine is [Source] is local.
29 */ 78 */
30 ContentCache contentCache; 79 LocalSourcePredicate _localSourcePredicate;
31 80
32 /** 81 /**
33 * Initialize a newly created source factory. 82 * Initialize a newly created source factory.
34 * 83 *
35 * @param contentCache the cache holding content used to override the default content of a source 84 * @param contentCache the cache holding content used to override the default content of a source
36 * @param resolvers the resolvers used to resolve absolute URI's 85 * @param resolvers the resolvers used to resolve absolute URI's
37 */ 86 */
38 SourceFactory.con1(ContentCache contentCache, List<UriResolver> resolvers) { 87 SourceFactory.con1(ContentCache contentCache, List<UriResolver> resolvers) {
39 this.contentCache = contentCache; 88 this.contentCache = contentCache;
40 this._resolvers = resolvers; 89 this._resolvers = resolvers;
90 this._localSourcePredicate = LocalSourcePredicate._NOT_SDK;
41 } 91 }
42 92
43 /** 93 /**
44 * Initialize a newly created source factory. 94 * Initialize a newly created source factory.
45 * 95 *
46 * @param resolvers the resolvers used to resolve absolute URI's 96 * @param resolvers the resolvers used to resolve absolute URI's
47 */ 97 */
48 SourceFactory.con2(List<UriResolver> resolvers) : this.con1(new ContentCache() , resolvers); 98 SourceFactory.con2(List<UriResolver> resolvers) : this.con1(new ContentCache() , resolvers);
49 99
50 /** 100 /**
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 for (UriResolver resolver in _resolvers) { 156 for (UriResolver resolver in _resolvers) {
107 if (resolver is DartUriResolver) { 157 if (resolver is DartUriResolver) {
108 DartUriResolver dartUriResolver = resolver as DartUriResolver; 158 DartUriResolver dartUriResolver = resolver as DartUriResolver;
109 return dartUriResolver.dartSdk; 159 return dartUriResolver.dartSdk;
110 } 160 }
111 } 161 }
112 return null; 162 return null;
113 } 163 }
114 164
115 /** 165 /**
166 * Determines if the given [Source] is local.
167 *
168 * @param source the [Source] to analyze
169 * @return `true` if the given [Source] is local
170 */
171 bool isLocalSource(Source source) => _localSourcePredicate.isLocal(source);
172
173 /**
116 * Return a source object representing the URI that results from resolving the given (possibly 174 * Return a source object representing the URI that results from resolving the given (possibly
117 * relative) contained URI against the URI associated with an existing source object, or 175 * relative) contained URI against the URI associated with an existing source object, or
118 * `null` if either the contained URI is invalid or if it cannot be resolved a gainst the 176 * `null` if either the contained URI is invalid or if it cannot be resolved a gainst the
119 * source object's URI. 177 * source object's URI.
120 * 178 *
121 * @param containingSource the source containing the given URI 179 * @param containingSource the source containing the given URI
122 * @param containedUri the (possibly relative) URI to be resolved against the containing source 180 * @param containedUri the (possibly relative) URI to be resolved against the containing source
123 * @return the source representing the contained URI 181 * @return the source representing the contained URI
124 */ 182 */
125 Source resolveUri(Source containingSource, String containedUri) { 183 Source resolveUri(Source containingSource, String containedUri) {
(...skipping 28 matching lines...) Expand all
154 * the default contents of the source. If the contents are `null` the override is removed so 212 * the default contents of the source. If the contents are `null` the override is removed so
155 * that the default contents will be returned. 213 * that the default contents will be returned.
156 * 214 *
157 * @param source the source whose contents are being overridden 215 * @param source the source whose contents are being overridden
158 * @param contents the new contents of the source 216 * @param contents the new contents of the source
159 * @return the original cached contents or `null` if none 217 * @return the original cached contents or `null` if none
160 */ 218 */
161 String setContents(Source source, String contents) => contentCache.setContents (source, contents); 219 String setContents(Source source, String contents) => contentCache.setContents (source, contents);
162 220
163 /** 221 /**
222 * Sets the [LocalSourcePredicate].
223 *
224 * @param localSourcePredicate the predicate to determine is [Source] is local
225 */
226 void set localSourcePredicate(LocalSourcePredicate localSourcePredicate) {
227 this._localSourcePredicate = localSourcePredicate;
228 }
229
230 /**
164 * Return the contents of the given source, or `null` if this factory does not override the 231 * Return the contents of the given source, or `null` if this factory does not override the
165 * contents of the source. 232 * contents of the source.
166 * 233 *
167 * <b>Note:</b> This method is not intended to be used except by 234 * <b>Note:</b> This method is not intended to be used except by
168 * [FileBasedSource#getContents]. 235 * [FileBasedSource#getContents].
169 * 236 *
170 * @param source the source whose content is to be returned 237 * @param source the source whose content is to be returned
171 * @return the contents of the given source 238 * @return the contents of the given source
172 */ 239 */
173 String getContents(Source source) => contentCache.getContents(source); 240 String getContents(Source source) => contentCache.getContents(source);
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 561 }
495 } 562 }
496 563
497 /** 564 /**
498 * A source range defines an [Element]'s source coordinates relative to its [Sou rce]. 565 * A source range defines an [Element]'s source coordinates relative to its [Sou rce].
499 * 566 *
500 * @coverage dart.engine.utilities 567 * @coverage dart.engine.utilities
501 */ 568 */
502 class SourceRange { 569 class SourceRange {
503 /** 570 /**
571 * An empty [SourceRange] with offset `0` and length `0`.
572 */
573 static SourceRange EMPTY = new SourceRange(0, 0);
574
575 /**
504 * The 0-based index of the first character of the source code for this elemen t, relative to the 576 * The 0-based index of the first character of the source code for this elemen t, relative to the
505 * source buffer in which this element is contained. 577 * source buffer in which this element is contained.
506 */ 578 */
507 int offset = 0; 579 int offset = 0;
508 580
509 /** 581 /**
510 * The number of characters of the source code for this element, relative to t he source buffer in 582 * The number of characters of the source code for this element, relative to t he source buffer in
511 * which this element is contained. 583 * which this element is contained.
512 */ 584 */
513 int length = 0; 585 int length = 0;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 String setContents(Source source, String contents) { 882 String setContents(Source source, String contents) {
811 if (contents == null) { 883 if (contents == null) {
812 _stampMap.remove(source); 884 _stampMap.remove(source);
813 return _contentMap.remove(source); 885 return _contentMap.remove(source);
814 } else { 886 } else {
815 _stampMap[source] = JavaSystem.currentTimeMillis(); 887 _stampMap[source] = JavaSystem.currentTimeMillis();
816 return javaMapPut(_contentMap, source, contents); 888 return javaMapPut(_contentMap, source, contents);
817 } 889 }
818 } 890 }
819 } 891 }
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