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

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

Issue 16337007: Version 0.5.13.1 . (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 7 years, 6 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 '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 /**
11 * Instances of the class {@code SourceFactory} resolve possibly relative URI's against an existing{@link Source source}. 12 * Instances of the class {@code SourceFactory} resolve possibly relative URI's against an existing{@link Source source}.
12 * @coverage dart.engine.source 13 * @coverage dart.engine.source
13 */ 14 */
14 class SourceFactory { 15 class SourceFactory {
16
15 /** 17 /**
16 * The analysis context that this source factory is associated with. 18 * The analysis context that this source factory is associated with.
17 */ 19 */
18 AnalysisContext _context; 20 AnalysisContext _context;
21
19 /** 22 /**
20 * The resolvers used to resolve absolute URI's. 23 * The resolvers used to resolve absolute URI's.
21 */ 24 */
22 List<UriResolver> _resolvers; 25 List<UriResolver> _resolvers;
26
23 /** 27 /**
24 * A cache of content used to override the default content of a source. 28 * A cache of content used to override the default content of a source.
25 */ 29 */
26 ContentCache _contentCache; 30 ContentCache _contentCache;
31
27 /** 32 /**
28 * Initialize a newly created source factory. 33 * Initialize a newly created source factory.
29 * @param contentCache the cache holding content used to override the default content of a source 34 * @param contentCache the cache holding content used to override the default content of a source
30 * @param resolvers the resolvers used to resolve absolute URI's 35 * @param resolvers the resolvers used to resolve absolute URI's
31 */ 36 */
32 SourceFactory.con1(ContentCache contentCache2, List<UriResolver> resolvers2) { 37 SourceFactory.con1(ContentCache contentCache2, List<UriResolver> resolvers2) {
33 _jtd_constructor_333_impl(contentCache2, resolvers2); 38 _jtd_constructor_340_impl(contentCache2, resolvers2);
34 } 39 }
35 _jtd_constructor_333_impl(ContentCache contentCache2, List<UriResolver> resolv ers2) { 40 _jtd_constructor_340_impl(ContentCache contentCache2, List<UriResolver> resolv ers2) {
36 this._contentCache = contentCache2; 41 this._contentCache = contentCache2;
37 this._resolvers = resolvers2; 42 this._resolvers = resolvers2;
38 } 43 }
44
39 /** 45 /**
40 * Initialize a newly created source factory. 46 * Initialize a newly created source factory.
41 * @param resolvers the resolvers used to resolve absolute URI's 47 * @param resolvers the resolvers used to resolve absolute URI's
42 */ 48 */
43 SourceFactory.con2(List<UriResolver> resolvers) { 49 SourceFactory.con2(List<UriResolver> resolvers) {
44 _jtd_constructor_334_impl(resolvers); 50 _jtd_constructor_341_impl(resolvers);
45 } 51 }
46 _jtd_constructor_334_impl(List<UriResolver> resolvers) { 52 _jtd_constructor_341_impl(List<UriResolver> resolvers) {
47 _jtd_constructor_333_impl(new ContentCache(), resolvers); 53 _jtd_constructor_340_impl(new ContentCache(), resolvers);
48 } 54 }
55
49 /** 56 /**
50 * Return a source object representing the given absolute URI, or {@code null} if the URI is not a 57 * Return a source object representing the given absolute URI, or {@code null} if the URI is not a
51 * valid URI or if it is not an absolute URI. 58 * valid URI or if it is not an absolute URI.
52 * @param absoluteUri the absolute URI to be resolved 59 * @param absoluteUri the absolute URI to be resolved
53 * @return a source object representing the absolute URI 60 * @return a source object representing the absolute URI
54 */ 61 */
55 Source forUri(String absoluteUri) { 62 Source forUri(String absoluteUri) {
56 try { 63 try {
57 Uri uri = Uri.parse(absoluteUri); 64 Uri uri = parseUriWithException(absoluteUri);
58 if (uri.isAbsolute) { 65 if (uri.isAbsolute) {
59 return resolveUri2(null, uri); 66 return resolveUri2(null, uri);
60 } 67 }
61 } on URISyntaxException catch (exception) { 68 } on URISyntaxException catch (exception) {
62 } 69 }
63 return null; 70 return null;
64 } 71 }
72
65 /** 73 /**
66 * Return a source object that is equal to the source object used to obtain th e given encoding. 74 * Return a source object that is equal to the source object used to obtain th e given encoding.
67 * @param encoding the encoding of a source object 75 * @param encoding the encoding of a source object
68 * @return a source object that is described by the given encoding 76 * @return a source object that is described by the given encoding
69 * @throws IllegalArgumentException if the argument is not a valid encoding 77 * @throws IllegalArgumentException if the argument is not a valid encoding
70 * @see Source#getEncoding() 78 * @see Source#getEncoding()
71 */ 79 */
72 Source fromEncoding(String encoding) { 80 Source fromEncoding(String encoding) {
73 if (encoding.length < 2) { 81 if (encoding.length < 2) {
74 throw new IllegalArgumentException("Invalid encoding length"); 82 throw new IllegalArgumentException("Invalid encoding length");
75 } 83 }
76 UriKind kind = UriKind.fromEncoding(encoding.codeUnitAt(0)); 84 UriKind kind = UriKind.fromEncoding(encoding.codeUnitAt(0));
77 if (kind == null) { 85 if (kind == null) {
78 throw new IllegalArgumentException("Invalid source kind in encoding: ${kin d}"); 86 throw new IllegalArgumentException("Invalid source kind in encoding: ${kin d}");
79 } 87 }
80 try { 88 try {
81 Uri uri = Uri.parse(encoding.substring(1)); 89 Uri uri = parseUriWithException(encoding.substring(1));
82 for (UriResolver resolver in _resolvers) { 90 for (UriResolver resolver in _resolvers) {
83 Source result = resolver.fromEncoding(_contentCache, kind, uri); 91 Source result = resolver.fromEncoding(_contentCache, kind, uri);
84 if (result != null) { 92 if (result != null) {
85 return result; 93 return result;
86 } 94 }
87 } 95 }
88 throw new IllegalArgumentException("No resolver for kind: ${kind}"); 96 throw new IllegalArgumentException("No resolver for kind: ${kind}");
89 } catch (exception) { 97 } catch (exception) {
90 throw new IllegalArgumentException("Invalid URI in encoding"); 98 throw new IllegalArgumentException("Invalid URI in encoding");
91 } 99 }
92 } 100 }
101
93 /** 102 /**
94 * Return a cache of content used to override the default content of a source. 103 * Return a cache of content used to override the default content of a source.
95 * @return a cache of content used to override the default content of a source 104 * @return a cache of content used to override the default content of a source
96 */ 105 */
97 ContentCache get contentCache => _contentCache; 106 ContentCache get contentCache => _contentCache;
107
98 /** 108 /**
99 * Return the analysis context that this source factory is associated with. 109 * Return the analysis context that this source factory is associated with.
100 * @return the analysis context that this source factory is associated with 110 * @return the analysis context that this source factory is associated with
101 */ 111 */
102 AnalysisContext get context => _context; 112 AnalysisContext get context => _context;
113
103 /** 114 /**
104 * Return the {@link DartSdk} associated with this {@link SourceFactory}, or { @code null} if there 115 * Return the {@link DartSdk} associated with this {@link SourceFactory}, or { @code null} if there
105 * is no such SDK. 116 * is no such SDK.
106 * @return the {@link DartSdk} associated with this {@link SourceFactory}, or {@code null} if 117 * @return the {@link DartSdk} associated with this {@link SourceFactory}, or {@code null} if
107 * there is no such SDK 118 * there is no such SDK
108 */ 119 */
109 DartSdk get dartSdk { 120 DartSdk get dartSdk {
110 for (UriResolver resolver in _resolvers) { 121 for (UriResolver resolver in _resolvers) {
111 if (resolver is DartUriResolver) { 122 if (resolver is DartUriResolver) {
112 DartUriResolver dartUriResolver = resolver as DartUriResolver; 123 DartUriResolver dartUriResolver = resolver as DartUriResolver;
113 return dartUriResolver.dartSdk; 124 return dartUriResolver.dartSdk;
114 } 125 }
115 } 126 }
116 return null; 127 return null;
117 } 128 }
129
118 /** 130 /**
119 * Return a source object representing the URI that results from resolving the given (possibly 131 * Return a source object representing the URI that results from resolving the given (possibly
120 * 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 132 * 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
121 * source object's URI. 133 * source object's URI.
122 * @param containingSource the source containing the given URI 134 * @param containingSource the source containing the given URI
123 * @param containedUri the (possibly relative) URI to be resolved against the containing source 135 * @param containedUri the (possibly relative) URI to be resolved against the containing source
124 * @return the source representing the contained URI 136 * @return the source representing the contained URI
125 */ 137 */
126 Source resolveUri(Source containingSource, String containedUri) { 138 Source resolveUri(Source containingSource, String containedUri) {
127 try { 139 try {
128 return resolveUri2(containingSource, Uri.parse(containedUri)); 140 return resolveUri2(containingSource, parseUriWithException(containedUri));
129 } on URISyntaxException catch (exception) { 141 } on URISyntaxException catch (exception) {
130 return null; 142 return null;
131 } 143 }
132 } 144 }
145
146 /**
147 * Return an absolute URI that represents the given source.
148 * @param source the source to get URI for
149 * @return the absolute URI representing the given source, may be {@code null}
150 */
151 Uri restoreUri(Source source) {
152 for (UriResolver resolver in _resolvers) {
153 Uri uri = resolver.restoreAbsolute(source);
154 if (uri != null) {
155 return uri;
156 }
157 }
158 return null;
159 }
160
133 /** 161 /**
134 * Set the contents of the given source to the given contents. This has the ef fect of overriding 162 * Set the contents of the given source to the given contents. This has the ef fect of overriding
135 * the default contents of the source. If the contents are {@code null} the ov erride is removed so 163 * the default contents of the source. If the contents are {@code null} the ov erride is removed so
136 * that the default contents will be returned. 164 * that the default contents will be returned.
137 * @param source the source whose contents are being overridden 165 * @param source the source whose contents are being overridden
138 * @param contents the new contents of the source 166 * @param contents the new contents of the source
139 */ 167 */
140 void setContents(Source source, String contents) { 168 void setContents(Source source, String contents) {
141 _contentCache.setContents(source, contents); 169 _contentCache.setContents(source, contents);
142 } 170 }
171
143 /** 172 /**
144 * Set the analysis context that this source factory is associated with to the given context. 173 * Set the analysis context that this source factory is associated with to the given context.
145 * <p> 174 * <p>
146 * <b>Note:</b> This method should only be invoked by{@link AnalysisContextImp l#setSourceFactory(SourceFactory)} and is only public out of 175 * <b>Note:</b> This method should only be invoked by{@link AnalysisContextImp l#setSourceFactory(SourceFactory)} and is only public out of
147 * necessity. 176 * necessity.
148 * @param context the analysis context that this source factory is associated with 177 * @param context the analysis context that this source factory is associated with
149 */ 178 */
150 void set context(AnalysisContext context2) { 179 void set context(AnalysisContext context2) {
151 this._context = context2; 180 this._context = context2;
152 } 181 }
182
153 /** 183 /**
154 * Return the contents of the given source, or {@code null} if this factory do es not override the 184 * Return the contents of the given source, or {@code null} if this factory do es not override the
155 * contents of the source. 185 * contents of the source.
156 * <p> 186 * <p>
157 * <b>Note:</b> This method is not intended to be used except by{@link FileBas edSource#getContents(com.google.dart.engine.source.Source.ContentReceiver)}. 187 * <b>Note:</b> This method is not intended to be used except by{@link FileBas edSource#getContents(com.google.dart.engine.source.Source.ContentReceiver)}.
158 * @param source the source whose content is to be returned 188 * @param source the source whose content is to be returned
159 * @return the contents of the given source 189 * @return the contents of the given source
160 */ 190 */
161 String getContents(Source source) => _contentCache.getContents(source); 191 String getContents(Source source) => _contentCache.getContents(source);
192
162 /** 193 /**
163 * Return the modification stamp of the given source, or {@code null} if this factory does not 194 * Return the modification stamp of the given source, or {@code null} if this factory does not
164 * override the contents of the source. 195 * override the contents of the source.
165 * <p> 196 * <p>
166 * <b>Note:</b> This method is not intended to be used except by{@link FileBas edSource#getModificationStamp()}. 197 * <b>Note:</b> This method is not intended to be used except by{@link FileBas edSource#getModificationStamp()}.
167 * @param source the source whose modification stamp is to be returned 198 * @param source the source whose modification stamp is to be returned
168 * @return the modification stamp of the given source 199 * @return the modification stamp of the given source
169 */ 200 */
170 int getModificationStamp(Source source) => _contentCache.getModificationStamp( source); 201 int getModificationStamp(Source source) => _contentCache.getModificationStamp( source);
202
171 /** 203 /**
172 * Return a source object representing the URI that results from resolving the given (possibly 204 * Return a source object representing the URI that results from resolving the given (possibly
173 * 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 205 * 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
174 * source object's URI. 206 * source object's URI.
175 * @param containingSource the source containing the given URI 207 * @param containingSource the source containing the given URI
176 * @param containedUri the (possibly relative) URI to be resolved against the containing source 208 * @param containedUri the (possibly relative) URI to be resolved against the containing source
177 * @return the source representing the contained URI 209 * @return the source representing the contained URI
178 */ 210 */
179 Source resolveUri2(Source containingSource, Uri containedUri) { 211 Source resolveUri2(Source containingSource, Uri containedUri) {
180 if (containedUri.isAbsolute) { 212 if (containedUri.isAbsolute) {
181 for (UriResolver resolver in _resolvers) { 213 for (UriResolver resolver in _resolvers) {
182 Source result = resolver.resolveAbsolute(_contentCache, containedUri); 214 Source result = resolver.resolveAbsolute(_contentCache, containedUri);
183 if (result != null) { 215 if (result != null) {
184 return result; 216 return result;
185 } 217 }
186 } 218 }
187 return null; 219 return null;
188 } else { 220 } else {
189 return containingSource.resolveRelative(containedUri); 221 return containingSource.resolveRelative(containedUri);
190 } 222 }
191 } 223 }
192 } 224 }
225
193 /** 226 /**
194 * The abstract class {@code UriResolver} defines the behavior of objects that a re used to resolve 227 * The abstract class {@code UriResolver} defines the behavior of objects that a re used to resolve
195 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of 228 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of
196 * absolute URI. 229 * absolute URI.
197 * @coverage dart.engine.source 230 * @coverage dart.engine.source
198 */ 231 */
199 abstract class UriResolver { 232 abstract class UriResolver {
200 /** 233
201 * Initialize a newly created resolver.
202 */
203 UriResolver() : super() {
204 }
205 /** 234 /**
206 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI. 235 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI.
207 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a{@link Source source} representing the file to which it was resolved, or {@code null} if it 236 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a{@link Source source} representing the file to which it was resolved, or {@code null} if it
208 * could not be resolved. 237 * could not be resolved.
209 * @param contentCache the content cache used to access the contents of the re turned source 238 * @param contentCache the content cache used to access the contents of the re turned source
210 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with 239 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with
211 * the given URI 240 * the given URI
212 * @param uri the URI to be resolved 241 * @param uri the URI to be resolved
213 * @return a {@link Source source} representing the file to which given URI wa s resolved 242 * @return a {@link Source source} representing the file to which given URI wa s resolved
214 */ 243 */
215 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri); 244 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri);
245
216 /** 246 /**
217 * Resolve the given absolute URI. Return a {@link Source source} representing the file to which 247 * Resolve the given absolute URI. Return a {@link Source source} representing the file to which
218 * it was resolved, or {@code null} if it could not be resolved. 248 * it was resolved, or {@code null} if it could not be resolved.
219 * @param contentCache the content cache used to access the contents of the re turned source 249 * @param contentCache the content cache used to access the contents of the re turned source
220 * @param uri the URI to be resolved 250 * @param uri the URI to be resolved
221 * @return a {@link Source source} representing the file to which given URI wa s resolved 251 * @return a {@link Source source} representing the file to which given URI wa s resolved
222 */ 252 */
223 Source resolveAbsolute(ContentCache contentCache, Uri uri); 253 Source resolveAbsolute(ContentCache contentCache, Uri uri);
254
255 /**
256 * Return an absolute URI that represents the given source.
257 * @param source the source to get URI for
258 * @return the absolute URI representing the given source, may be {@code null}
259 */
260 Uri restoreAbsolute(Source source) => null;
224 } 261 }
262
225 /** 263 /**
226 * The interface {@code Source} defines the behavior of objects representing sou rce code that can be 264 * The interface {@code Source} defines the behavior of objects representing sou rce code that can be
227 * compiled. 265 * compiled.
228 * @coverage dart.engine.source 266 * @coverage dart.engine.source
229 */ 267 */
230 abstract class Source { 268 abstract class Source {
269
231 /** 270 /**
232 * An empty array of sources. 271 * An empty array of sources.
233 */ 272 */
234 static List<Source> EMPTY_ARRAY = new List<Source>(0); 273 static List<Source> EMPTY_ARRAY = new List<Source>(0);
274
235 /** 275 /**
236 * Return {@code true} if the given object is a source that represents the sam e source code as 276 * Return {@code true} if the given object is a source that represents the sam e source code as
237 * this source. 277 * this source.
238 * @param object the object to be compared with this object 278 * @param object the object to be compared with this object
239 * @return {@code true} if the given object is a source that represents the sa me source code as 279 * @return {@code true} if the given object is a source that represents the sa me source code as
240 * this source 280 * this source
241 * @see Object#equals(Object) 281 * @see Object#equals(Object)
242 */ 282 */
243 bool operator ==(Object object); 283 bool operator ==(Object object);
284
244 /** 285 /**
245 * Return {@code true} if this source exists. 286 * Return {@code true} if this source exists.
246 * @return {@code true} if this source exists 287 * @return {@code true} if this source exists
247 */ 288 */
248 bool exists(); 289 bool exists();
290
249 /** 291 /**
250 * Get the contents of this source and pass it to the given receiver. Exactly one of the methods 292 * Get the contents of this source and pass it to the given receiver. Exactly one of the methods
251 * defined on the receiver will be invoked unless an exception is thrown. The method that will be 293 * defined on the receiver will be invoked unless an exception is thrown. The method that will be
252 * invoked depends on which of the possible representations of the contents is the most efficient. 294 * invoked depends on which of the possible representations of the contents is the most efficient.
253 * Whichever method is invoked, it will be invoked before this method returns. 295 * Whichever method is invoked, it will be invoked before this method returns.
254 * @param receiver the content receiver to which the content of this source wi ll be passed 296 * @param receiver the content receiver to which the content of this source wi ll be passed
255 * @throws Exception if the contents of this source could not be accessed 297 * @throws Exception if the contents of this source could not be accessed
256 */ 298 */
257 void getContents(Source_ContentReceiver receiver); 299 void getContents(Source_ContentReceiver receiver);
300
258 /** 301 /**
259 * Return an encoded representation of this source that can be used to create a source that is 302 * Return an encoded representation of this source that can be used to create a source that is
260 * equal to this source. 303 * equal to this source.
261 * @return an encoded representation of this source 304 * @return an encoded representation of this source
262 * @see SourceFactory#fromEncoding(String) 305 * @see SourceFactory#fromEncoding(String)
263 */ 306 */
264 String get encoding; 307 String get encoding;
308
265 /** 309 /**
266 * Return the full (long) version of the name that can be displayed to the use r to denote this 310 * Return the full (long) version of the name that can be displayed to the use r to denote this
267 * source. For example, for a source representing a file this would typically be the absolute path 311 * source. For example, for a source representing a file this would typically be the absolute path
268 * of the file. 312 * of the file.
269 * @return a name that can be displayed to the user to denote this source 313 * @return a name that can be displayed to the user to denote this source
270 */ 314 */
271 String get fullName; 315 String get fullName;
316
272 /** 317 /**
273 * Return the modification stamp for this source. A modification stamp is a no n-negative integer 318 * Return the modification stamp for this source. A modification stamp is a no n-negative integer
274 * with the property that if the contents of the source have not been modified since the last time 319 * with the property that if the contents of the source have not been modified since the last time
275 * the modification stamp was accessed then the same value will be returned, b ut if the contents 320 * the modification stamp was accessed then the same value will be returned, b ut if the contents
276 * of the source have been modified one or more times (even if the net change is zero) the stamps 321 * of the source have been modified one or more times (even if the net change is zero) the stamps
277 * will be different. 322 * will be different.
278 * @return the modification stamp for this source 323 * @return the modification stamp for this source
279 */ 324 */
280 int get modificationStamp; 325 int get modificationStamp;
326
281 /** 327 /**
282 * Return a short version of the name that can be displayed to the user to den ote this source. For 328 * Return a short version of the name that can be displayed to the user to den ote this source. For
283 * example, for a source representing a file this would typically be the name of the file. 329 * example, for a source representing a file this would typically be the name of the file.
284 * @return a name that can be displayed to the user to denote this source 330 * @return a name that can be displayed to the user to denote this source
285 */ 331 */
286 String get shortName; 332 String get shortName;
333
287 /** 334 /**
288 * Return the kind of URI from which this source was originally derived. If th is source was 335 * Return the kind of URI from which this source was originally derived. If th is source was
289 * created from an absolute URI, then the returned kind will reflect the schem e of the absolute 336 * created from an absolute URI, then the returned kind will reflect the schem e of the absolute
290 * URI. If it was created from a relative URI, then the returned kind will be the same as the kind 337 * URI. If it was created from a relative URI, then the returned kind will be the same as the kind
291 * of the source against which the relative URI was resolved. 338 * of the source against which the relative URI was resolved.
292 * @return the kind of URI from which this source was originally derived 339 * @return the kind of URI from which this source was originally derived
293 */ 340 */
294 UriKind get uriKind; 341 UriKind get uriKind;
342
295 /** 343 /**
296 * Return a hash code for this source. 344 * Return a hash code for this source.
297 * @return a hash code for this source 345 * @return a hash code for this source
298 * @see Object#hashCode() 346 * @see Object#hashCode()
299 */ 347 */
300 int get hashCode; 348 int get hashCode;
349
301 /** 350 /**
302 * Return {@code true} if this source is in one of the system libraries. 351 * Return {@code true} if this source is in one of the system libraries.
303 * @return {@code true} if this is in a system library 352 * @return {@code true} if this is in a system library
304 */ 353 */
305 bool isInSystemLibrary(); 354 bool isInSystemLibrary();
355
306 /** 356 /**
307 * 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 357 * 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
308 * could not be resolved. 358 * could not be resolved.
309 * <p> 359 * <p>
310 * Note: This method is not intended for public use, it is only visible out of necessity. It is 360 * Note: This method is not intended for public use, it is only visible out of necessity. It is
311 * only intended to be invoked by a {@link SourceFactory source factory}. Sour ce factories will 361 * only intended to be invoked by a {@link SourceFactory source factory}. Sour ce factories will
312 * only invoke this method if the URI is relative, so implementations of this method are not 362 * only invoke this method if the URI is relative, so implementations of this method are not
313 * required to, and generally do not, verify the argument. The result of invok ing this method with 363 * required to, and generally do not, verify the argument. The result of invok ing this method with
314 * an absolute URI is intentionally left unspecified. 364 * an absolute URI is intentionally left unspecified.
315 * @param relativeUri the relative URI to be resolved against the containing s ource 365 * @param relativeUri the relative URI to be resolved against the containing s ource
316 * @return a {@link Source source} representing the URI to which given URI was resolved 366 * @return a {@link Source source} representing the URI to which given URI was resolved
317 */ 367 */
318 Source resolveRelative(Uri relativeUri); 368 Source resolveRelative(Uri relativeUri);
319 } 369 }
370
320 /** 371 /**
321 * The interface {@code ContentReceiver} defines the behavior of objects that ca n receive the 372 * The interface {@code ContentReceiver} defines the behavior of objects that ca n receive the
322 * content of a source. 373 * content of a source.
323 */ 374 */
324 abstract class Source_ContentReceiver { 375 abstract class Source_ContentReceiver {
376
325 /** 377 /**
326 * Accept the contents of a source represented as a character buffer. 378 * Accept the contents of a source represented as a character buffer.
327 * @param contents the contents of the source 379 * @param contents the contents of the source
328 * @param modificationTime the time at which the contents were last set 380 * @param modificationTime the time at which the contents were last set
329 */ 381 */
330 void accept(CharBuffer contents, int modificationTime); 382 void accept(CharBuffer contents, int modificationTime);
383
331 /** 384 /**
332 * Accept the contents of a source represented as a string. 385 * Accept the contents of a source represented as a string.
333 * @param contents the contents of the source 386 * @param contents the contents of the source
334 * @param modificationTime the time at which the contents were last set 387 * @param modificationTime the time at which the contents were last set
335 */ 388 */
336 void accept2(String contents, int modificationTime); 389 void accept2(String contents, int modificationTime);
337 } 390 }
391
338 /** 392 /**
339 * The enumeration {@code SourceKind} defines the different kinds of sources tha t are known to the 393 * The enumeration {@code SourceKind} defines the different kinds of sources tha t are known to the
340 * analysis engine. 394 * analysis engine.
341 * @coverage dart.engine.source 395 * @coverage dart.engine.source
342 */ 396 */
343 class SourceKind implements Comparable<SourceKind> { 397 class SourceKind implements Comparable<SourceKind> {
398
344 /** 399 /**
345 * A source containing HTML. The HTML might or might not contain Dart scripts. 400 * A source containing HTML. The HTML might or might not contain Dart scripts.
346 */ 401 */
347 static final SourceKind HTML = new SourceKind('HTML', 0); 402 static final SourceKind HTML = new SourceKind('HTML', 0);
403
348 /** 404 /**
349 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not 405 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not
350 * contain any directives, including a library directive. 406 * contain any directives, including a library directive.
351 */ 407 */
352 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1); 408 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1);
409
353 /** 410 /**
354 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive. 411 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive.
355 */ 412 */
356 static final SourceKind PART = new SourceKind('PART', 2); 413 static final SourceKind PART = new SourceKind('PART', 2);
414
357 /** 415 /**
358 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source 416 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source
359 * and also when the kind of a source is not known without performing a comput ation and the client 417 * and also when the kind of a source is not known without performing a comput ation and the client
360 * does not want to spend the time to identify the kind. 418 * does not want to spend the time to identify the kind.
361 */ 419 */
362 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3); 420 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3);
363 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN]; 421 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN];
364 final String __name; 422
365 final int __ordinal; 423 /// The name of this enum constant, as declared in the enum declaration.
366 int get ordinal => __ordinal; 424 final String name;
367 SourceKind(this.__name, this.__ordinal) { 425
426 /// The position in the enum declaration.
427 final int ordinal;
428 SourceKind(this.name, this.ordinal) {
368 } 429 }
369 int compareTo(SourceKind other) => __ordinal - other.__ordinal; 430 int compareTo(SourceKind other) => ordinal - other.ordinal;
370 String toString() => __name; 431 String toString() => name;
371 } 432 }
433
372 /** 434 /**
373 * The enumeration {@code UriKind} defines the different kinds of URI's that are known to the 435 * The enumeration {@code UriKind} defines the different kinds of URI's that are known to the
374 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source. 436 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source.
375 * @coverage dart.engine.source 437 * @coverage dart.engine.source
376 */ 438 */
377 class UriKind implements Comparable<UriKind> { 439 class UriKind implements Comparable<UriKind> {
440
378 /** 441 /**
379 * A 'dart:' URI. 442 * A 'dart:' URI.
380 */ 443 */
381 static final UriKind DART_URI = new UriKind('DART_URI', 0, 0x64); 444 static final UriKind DART_URI = new UriKind('DART_URI', 0, 0x64);
445
382 /** 446 /**
383 * A 'file:' URI. 447 * A 'file:' URI.
384 */ 448 */
385 static final UriKind FILE_URI = new UriKind('FILE_URI', 1, 0x66); 449 static final UriKind FILE_URI = new UriKind('FILE_URI', 1, 0x66);
450
386 /** 451 /**
387 * A 'package:' URI. 452 * A 'package:' URI.
388 */ 453 */
389 static final UriKind PACKAGE_URI = new UriKind('PACKAGE_URI', 2, 0x70); 454 static final UriKind PACKAGE_URI = new UriKind('PACKAGE_URI', 2, 0x70);
390 static final List<UriKind> values = [DART_URI, FILE_URI, PACKAGE_URI]; 455 static final List<UriKind> values = [DART_URI, FILE_URI, PACKAGE_URI];
391 final String __name; 456
392 final int __ordinal; 457 /// The name of this enum constant, as declared in the enum declaration.
393 int get ordinal => __ordinal; 458 final String name;
459
460 /// The position in the enum declaration.
461 final int ordinal;
462
394 /** 463 /**
395 * The single character encoding used to identify this kind of URI. 464 * The single character encoding used to identify this kind of URI.
396 */ 465 */
397 int _encoding = 0; 466 int _encoding = 0;
467
398 /** 468 /**
399 * Initialize a newly created URI kind to have the given encoding. 469 * Initialize a newly created URI kind to have the given encoding.
400 * @param encoding the single character encoding used to identify this kind of URI. 470 * @param encoding the single character encoding used to identify this kind of URI.
401 */ 471 */
402 UriKind(this.__name, this.__ordinal, int encoding) { 472 UriKind(this.name, this.ordinal, int encoding) {
403 this._encoding = encoding; 473 this._encoding = encoding;
404 } 474 }
475
405 /** 476 /**
406 * Return the URI kind represented by the given encoding, or {@code null} if t here is no kind with 477 * Return the URI kind represented by the given encoding, or {@code null} if t here is no kind with
407 * the given encoding. 478 * the given encoding.
408 * @param encoding the single character encoding used to identify the URI kind to be returned 479 * @param encoding the single character encoding used to identify the URI kind to be returned
409 * @return the URI kind represented by the given encoding 480 * @return the URI kind represented by the given encoding
410 */ 481 */
411 static UriKind fromEncoding(int encoding) { 482 static UriKind fromEncoding(int encoding) {
412 while (true) { 483 while (true) {
413 if (encoding == 0x64) { 484 if (encoding == 0x64) {
414 return DART_URI; 485 return DART_URI;
415 } else if (encoding == 0x66) { 486 } else if (encoding == 0x66) {
416 return FILE_URI; 487 return FILE_URI;
417 } else if (encoding == 0x70) { 488 } else if (encoding == 0x70) {
418 return PACKAGE_URI; 489 return PACKAGE_URI;
419 } 490 }
420 break; 491 break;
421 } 492 }
422 return null; 493 return null;
423 } 494 }
495
424 /** 496 /**
425 * Return the single character encoding used to identify this kind of URI. 497 * Return the single character encoding used to identify this kind of URI.
426 * @return the single character encoding used to identify this kind of URI 498 * @return the single character encoding used to identify this kind of URI
427 */ 499 */
428 int get encoding => _encoding; 500 int get encoding => _encoding;
429 int compareTo(UriKind other) => __ordinal - other.__ordinal; 501 int compareTo(UriKind other) => ordinal - other.ordinal;
430 String toString() => __name; 502 String toString() => name;
431 } 503 }
504
432 /** 505 /**
433 * A source range defines an {@link Element}'s source coordinates relative to it s {@link Source}. 506 * A source range defines an {@link Element}'s source coordinates relative to it s {@link Source}.
434 * @coverage dart.engine.utilities 507 * @coverage dart.engine.utilities
435 */ 508 */
436 class SourceRange { 509 class SourceRange {
510
437 /** 511 /**
438 * The 0-based index of the first character of the source code for this elemen t, relative to the 512 * The 0-based index of the first character of the source code for this elemen t, relative to the
439 * source buffer in which this element is contained. 513 * source buffer in which this element is contained.
440 */ 514 */
441 int _offset = 0; 515 int _offset = 0;
516
442 /** 517 /**
443 * The number of characters of the source code for this element, relative to t he source buffer in 518 * The number of characters of the source code for this element, relative to t he source buffer in
444 * which this element is contained. 519 * which this element is contained.
445 */ 520 */
446 int _length = 0; 521 int _length = 0;
522
447 /** 523 /**
448 * Initialize a newly created source range using the given offset and the give n length. 524 * Initialize a newly created source range using the given offset and the give n length.
449 * @param offset the given offset 525 * @param offset the given offset
450 * @param length the given length 526 * @param length the given length
451 */ 527 */
452 SourceRange(int offset, int length) { 528 SourceRange(int offset, int length) {
453 this._offset = offset; 529 this._offset = offset;
454 this._length = length; 530 this._length = length;
455 } 531 }
532
456 /** 533 /**
457 * @return {@code true} if <code>x</code> is in \[offset, offset + length) int erval. 534 * @return {@code true} if <code>x</code> is in \[offset, offset + length) int erval.
458 */ 535 */
459 bool contains(int x) => _offset <= x && x < _offset + _length; 536 bool contains(int x) => _offset <= x && x < _offset + _length;
537
460 /** 538 /**
461 * @return {@code true} if <code>x</code> is in (offset, offset + length) inte rval. 539 * @return {@code true} if <code>x</code> is in (offset, offset + length) inte rval.
462 */ 540 */
463 bool containsExclusive(int x) => _offset < x && x < _offset + _length; 541 bool containsExclusive(int x) => _offset < x && x < _offset + _length;
542
464 /** 543 /**
465 * @return {@code true} if <code>otherRange</code> covers this {@link SourceRa nge}. 544 * @return {@code true} if <code>otherRange</code> covers this {@link SourceRa nge}.
466 */ 545 */
467 bool coveredBy(SourceRange otherRange) => otherRange.covers(this); 546 bool coveredBy(SourceRange otherRange) => otherRange.covers(this);
547
468 /** 548 /**
469 * @return {@code true} if this {@link SourceRange} covers <code>otherRange</c ode>. 549 * @return {@code true} if this {@link SourceRange} covers <code>otherRange</c ode>.
470 */ 550 */
471 bool covers(SourceRange otherRange) => offset <= otherRange.offset && otherRan ge.end <= end; 551 bool covers(SourceRange otherRange) => offset <= otherRange.offset && otherRan ge.end <= end;
552
472 /** 553 /**
473 * @return {@code true} if this {@link SourceRange} ends in <code>otherRange</ code>. 554 * @return {@code true} if this {@link SourceRange} ends in <code>otherRange</ code>.
474 */ 555 */
475 bool endsIn(SourceRange otherRange) { 556 bool endsIn(SourceRange otherRange) {
476 int thisEnd = end; 557 int thisEnd = end;
477 return otherRange.contains(thisEnd); 558 return otherRange.contains(thisEnd);
478 } 559 }
479 bool operator ==(Object obj) { 560 bool operator ==(Object obj) {
480 if (obj is! SourceRange) { 561 if (obj is! SourceRange) {
481 return false; 562 return false;
482 } 563 }
483 SourceRange sourceRange = obj as SourceRange; 564 SourceRange sourceRange = obj as SourceRange;
484 return sourceRange.offset == _offset && sourceRange.length == _length; 565 return sourceRange.offset == _offset && sourceRange.length == _length;
485 } 566 }
567
486 /** 568 /**
487 * @return the 0-based index of the after-last character of the source code fo r this element, 569 * @return the 0-based index of the after-last character of the source code fo r this element,
488 * relative to the source buffer in which this element is contained. 570 * relative to the source buffer in which this element is contained.
489 */ 571 */
490 int get end => _offset + _length; 572 int get end => _offset + _length;
573
491 /** 574 /**
492 * @return the expanded instance of {@link SourceRange}, which has the same ce nter. 575 * @return the expanded instance of {@link SourceRange}, which has the same ce nter.
493 */ 576 */
494 SourceRange getExpanded(int delta) => new SourceRange(_offset - delta, delta + _length + delta); 577 SourceRange getExpanded(int delta) => new SourceRange(_offset - delta, delta + _length + delta);
578
495 /** 579 /**
496 * Returns the number of characters of the source code for this element, relat ive to the source 580 * Returns the number of characters of the source code for this element, relat ive to the source
497 * buffer in which this element is contained. 581 * buffer in which this element is contained.
498 * @return the number of characters of the source code for this element, relat ive to the source 582 * @return the number of characters of the source code for this element, relat ive to the source
499 * buffer in which this element is contained 583 * buffer in which this element is contained
500 */ 584 */
501 int get length => _length; 585 int get length => _length;
586
502 /** 587 /**
503 * @return the instance of {@link SourceRange} with end moved on "delta". 588 * @return the instance of {@link SourceRange} with end moved on "delta".
504 */ 589 */
505 SourceRange getMoveEnd(int delta) => new SourceRange(_offset, _length + delta) ; 590 SourceRange getMoveEnd(int delta) => new SourceRange(_offset, _length + delta) ;
591
506 /** 592 /**
507 * Returns the 0-based index of the first character of the source code for thi s element, relative 593 * Returns the 0-based index of the first character of the source code for thi s element, relative
508 * to the source buffer in which this element is contained. 594 * to the source buffer in which this element is contained.
509 * @return the 0-based index of the first character of the source code for thi s element, relative 595 * @return the 0-based index of the first character of the source code for thi s element, relative
510 * to the source buffer in which this element is contained 596 * to the source buffer in which this element is contained
511 */ 597 */
512 int get offset => _offset; 598 int get offset => _offset;
599
600 /**
601 * @return the expanded translated of {@link SourceRange}, with moved start an d the same length.
602 */
603 SourceRange getTranslated(int delta) => new SourceRange(_offset + delta, _leng th);
513 int get hashCode => 31 * _offset + _length; 604 int get hashCode => 31 * _offset + _length;
605
514 /** 606 /**
515 * @return {@code true} if this {@link SourceRange} intersects with given. 607 * @return {@code true} if this {@link SourceRange} intersects with given.
516 */ 608 */
517 bool intersects(SourceRange other) { 609 bool intersects(SourceRange other) {
518 if (other == null) { 610 if (other == null) {
519 return false; 611 return false;
520 } 612 }
521 if (end <= other.offset) { 613 if (end <= other.offset) {
522 return false; 614 return false;
523 } 615 }
524 if (offset >= other.end) { 616 if (offset >= other.end) {
525 return false; 617 return false;
526 } 618 }
527 return true; 619 return true;
528 } 620 }
621
529 /** 622 /**
530 * @return {@code true} if this {@link SourceRange} starts in <code>otherRange </code>. 623 * @return {@code true} if this {@link SourceRange} starts in <code>otherRange </code>.
531 */ 624 */
532 bool startsIn(SourceRange otherRange) => otherRange.contains(_offset); 625 bool startsIn(SourceRange otherRange) => otherRange.contains(_offset);
533 String toString() { 626 String toString() {
534 JavaStringBuilder builder = new JavaStringBuilder(); 627 JavaStringBuilder builder = new JavaStringBuilder();
535 builder.append("[offset="); 628 builder.append("[offset=");
536 builder.append(_offset); 629 builder.append(_offset);
537 builder.append(", length="); 630 builder.append(", length=");
538 builder.append(_length); 631 builder.append(_length);
539 builder.append("]"); 632 builder.append("]");
540 return builder.toString(); 633 return builder.toString();
541 } 634 }
542 } 635 }
636
543 /** 637 /**
544 * The interface {@code SourceContainer} is used by clients to define a collecti on of sources 638 * The interface {@code SourceContainer} is used by clients to define a collecti on of sources
545 * <p> 639 * <p>
546 * Source containers are not used within analysis engine, but can be used by cli ents to group 640 * Source containers are not used within analysis engine, but can be used by cli ents to group
547 * sources for the purposes of accessing composite dependency information. For e xample, the Eclipse 641 * sources for the purposes of accessing composite dependency information. For e xample, the Eclipse
548 * client uses source containers to represent Eclipse projects, which allows it to easily compute 642 * client uses source containers to represent Eclipse projects, which allows it to easily compute
549 * project-level dependencies. 643 * project-level dependencies.
550 * @coverage dart.engine.source 644 * @coverage dart.engine.source
551 */ 645 */
552 abstract class SourceContainer { 646 abstract class SourceContainer {
647
553 /** 648 /**
554 * Determine if the specified source is part of the receiver's collection of s ources. 649 * Determine if the specified source is part of the receiver's collection of s ources.
555 * @param source the source in question 650 * @param source the source in question
556 * @return {@code true} if the receiver contains the source, else {@code false } 651 * @return {@code true} if the receiver contains the source, else {@code false }
557 */ 652 */
558 bool contains(Source source); 653 bool contains(Source source);
559 } 654 }
655
560 /** 656 /**
561 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's. 657 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's.
562 * @coverage dart.engine.source 658 * @coverage dart.engine.source
563 */ 659 */
564 class DartUriResolver extends UriResolver { 660 class DartUriResolver extends UriResolver {
661
565 /** 662 /**
566 * The Dart SDK against which URI's are to be resolved. 663 * The Dart SDK against which URI's are to be resolved.
567 */ 664 */
568 DartSdk _sdk; 665 DartSdk _sdk;
666
569 /** 667 /**
570 * The name of the {@code dart} scheme. 668 * The name of the {@code dart} scheme.
571 */ 669 */
572 static String _DART_SCHEME = "dart"; 670 static String _DART_SCHEME = "dart";
671
573 /** 672 /**
574 * Return {@code true} if the given URI is a {@code dart:} URI. 673 * Return {@code true} if the given URI is a {@code dart:} URI.
575 * @param uri the URI being tested 674 * @param uri the URI being tested
576 * @return {@code true} if the given URI is a {@code dart:} URI 675 * @return {@code true} if the given URI is a {@code dart:} URI
577 */ 676 */
578 static bool isDartUri(Uri uri) => uri.scheme == _DART_SCHEME; 677 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme;
678
579 /** 679 /**
580 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the 680 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
581 * given Dart SDK. 681 * given Dart SDK.
582 * @param sdk the Dart SDK against which URI's are to be resolved 682 * @param sdk the Dart SDK against which URI's are to be resolved
583 */ 683 */
584 DartUriResolver(DartSdk sdk) { 684 DartUriResolver(DartSdk sdk) {
585 this._sdk = sdk; 685 this._sdk = sdk;
586 } 686 }
587 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { 687 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) {
588 if (identical(kind, UriKind.DART_URI)) { 688 if (identical(kind, UriKind.DART_URI)) {
589 return _sdk.fromEncoding(contentCache, kind, uri); 689 return _sdk.fromEncoding(contentCache, kind, uri);
590 } 690 }
591 return null; 691 return null;
592 } 692 }
693
593 /** 694 /**
594 * Return the {@link DartSdk} against which URIs are to be resolved. 695 * Return the {@link DartSdk} against which URIs are to be resolved.
595 * @return the {@link DartSdk} against which URIs are to be resolved. 696 * @return the {@link DartSdk} against which URIs are to be resolved.
596 */ 697 */
597 DartSdk get dartSdk => _sdk; 698 DartSdk get dartSdk => _sdk;
598 Source resolveAbsolute(ContentCache contentCache, Uri uri) { 699 Source resolveAbsolute(ContentCache contentCache, Uri uri) {
599 if (!isDartUri(uri)) { 700 if (!isDartUri(uri)) {
600 return null; 701 return null;
601 } 702 }
602 return _sdk.mapDartUri(contentCache, uri.toString()); 703 return _sdk.mapDartUri(contentCache, uri.toString());
603 } 704 }
604 } 705 }
706
605 /** 707 /**
606 * Instances of the class {@code LineInfo} encapsulate information about line an d column information 708 * Instances of the class {@code LineInfo} encapsulate information about line an d column information
607 * within a source file. 709 * within a source file.
608 * @coverage dart.engine.utilities 710 * @coverage dart.engine.utilities
609 */ 711 */
610 class LineInfo { 712 class LineInfo {
713
611 /** 714 /**
612 * An array containing the offsets of the first character of each line in the source code. 715 * An array containing the offsets of the first character of each line in the source code.
613 */ 716 */
614 List<int> _lineStarts; 717 List<int> _lineStarts;
718
615 /** 719 /**
616 * Initialize a newly created set of line information to represent the data en coded in the given 720 * Initialize a newly created set of line information to represent the data en coded in the given
617 * array. 721 * array.
618 * @param lineStarts the offsets of the first character of each line in the so urce code 722 * @param lineStarts the offsets of the first character of each line in the so urce code
619 */ 723 */
620 LineInfo(List<int> lineStarts) { 724 LineInfo(List<int> lineStarts) {
621 if (lineStarts == null) { 725 if (lineStarts == null) {
622 throw new IllegalArgumentException("lineStarts must be non-null"); 726 throw new IllegalArgumentException("lineStarts must be non-null");
623 } else if (lineStarts.length < 1) { 727 } else if (lineStarts.length < 1) {
624 throw new IllegalArgumentException("lineStarts must be non-empty"); 728 throw new IllegalArgumentException("lineStarts must be non-empty");
625 } 729 }
626 this._lineStarts = lineStarts; 730 this._lineStarts = lineStarts;
627 } 731 }
732
628 /** 733 /**
629 * Return the location information for the character at the given offset. 734 * Return the location information for the character at the given offset.
630 * @param offset the offset of the character for which location information is to be returned 735 * @param offset the offset of the character for which location information is to be returned
631 * @return the location information for the character at the given offset 736 * @return the location information for the character at the given offset
632 */ 737 */
633 LineInfo_Location getLocation(int offset) { 738 LineInfo_Location getLocation(int offset) {
634 int lineCount = _lineStarts.length; 739 int lineCount = _lineStarts.length;
635 for (int i = 1; i < lineCount; i++) { 740 for (int i = 1; i < lineCount; i++) {
636 if (offset < _lineStarts[i]) { 741 if (offset < _lineStarts[i]) {
637 return new LineInfo_Location(i, offset - _lineStarts[i - 1] + 1); 742 return new LineInfo_Location(i, offset - _lineStarts[i - 1] + 1);
638 } 743 }
639 } 744 }
640 return new LineInfo_Location(lineCount, offset - _lineStarts[lineCount - 1] + 1); 745 return new LineInfo_Location(lineCount, offset - _lineStarts[lineCount - 1] + 1);
641 } 746 }
642 } 747 }
748
643 /** 749 /**
644 * Instances of the class {@code Location} represent the location of a character as a line and 750 * Instances of the class {@code Location} represent the location of a character as a line and
645 * column pair. 751 * column pair.
646 */ 752 */
647 class LineInfo_Location { 753 class LineInfo_Location {
754
648 /** 755 /**
649 * The one-based index of the line containing the character. 756 * The one-based index of the line containing the character.
650 */ 757 */
651 int _lineNumber = 0; 758 int _lineNumber = 0;
759
652 /** 760 /**
653 * The one-based index of the column containing the character. 761 * The one-based index of the column containing the character.
654 */ 762 */
655 int _columnNumber = 0; 763 int _columnNumber = 0;
764
656 /** 765 /**
657 * Initialize a newly created location to represent the location of the charac ter at the given 766 * Initialize a newly created location to represent the location of the charac ter at the given
658 * line and column position. 767 * line and column position.
659 * @param lineNumber the one-based index of the line containing the character 768 * @param lineNumber the one-based index of the line containing the character
660 * @param columnNumber the one-based index of the column containing the charac ter 769 * @param columnNumber the one-based index of the column containing the charac ter
661 */ 770 */
662 LineInfo_Location(int lineNumber, int columnNumber) { 771 LineInfo_Location(int lineNumber, int columnNumber) {
663 this._lineNumber = lineNumber; 772 this._lineNumber = lineNumber;
664 this._columnNumber = columnNumber; 773 this._columnNumber = columnNumber;
665 } 774 }
775
666 /** 776 /**
667 * Return the one-based index of the column containing the character. 777 * Return the one-based index of the column containing the character.
668 * @return the one-based index of the column containing the character 778 * @return the one-based index of the column containing the character
669 */ 779 */
670 int get columnNumber => _columnNumber; 780 int get columnNumber => _columnNumber;
781
671 /** 782 /**
672 * Return the one-based index of the line containing the character. 783 * Return the one-based index of the line containing the character.
673 * @return the one-based index of the line containing the character 784 * @return the one-based index of the line containing the character
674 */ 785 */
675 int get lineNumber => _lineNumber; 786 int get lineNumber => _lineNumber;
676 } 787 }
788
677 /** 789 /**
678 * Instances of class {@code ContentCache} hold content used to override the def ault content of a{@link Source}. 790 * Instances of class {@code ContentCache} hold content used to override the def ault content of a{@link Source}.
679 * @coverage dart.engine.source 791 * @coverage dart.engine.source
680 */ 792 */
681 class ContentCache { 793 class ContentCache {
794
682 /** 795 /**
683 * A table mapping sources to the contents of those sources. This is used to o verride the default 796 * A table mapping sources to the contents of those sources. This is used to o verride the default
684 * contents of a source. 797 * contents of a source.
685 */ 798 */
686 Map<Source, String> _contentMap = new Map<Source, String>(); 799 Map<Source, String> _contentMap = new Map<Source, String>();
800
687 /** 801 /**
688 * A table mapping sources to the modification stamps of those sources. This i s used when the 802 * A table mapping sources to the modification stamps of those sources. This i s used when the
689 * default contents of a source has been overridden. 803 * default contents of a source has been overridden.
690 */ 804 */
691 Map<Source, int> _stampMap = new Map<Source, int>(); 805 Map<Source, int> _stampMap = new Map<Source, int>();
692 /** 806
693 * Initialize a newly created cache to be empty.
694 */
695 ContentCache() : super() {
696 }
697 /** 807 /**
698 * Return the contents of the given source, or {@code null} if this cache does not override the 808 * Return the contents of the given source, or {@code null} if this cache does not override the
699 * contents of the source. 809 * contents of the source.
700 * <p> 810 * <p>
701 * <b>Note:</b> This method is not intended to be used except by{@link SourceF actory#getContents(com.google.dart.engine.source.Source.ContentReceiver)}. 811 * <b>Note:</b> This method is not intended to be used except by{@link SourceF actory#getContents(com.google.dart.engine.source.Source.ContentReceiver)}.
702 * @param source the source whose content is to be returned 812 * @param source the source whose content is to be returned
703 * @return the contents of the given source 813 * @return the contents of the given source
704 */ 814 */
705 String getContents(Source source) => _contentMap[source]; 815 String getContents(Source source) => _contentMap[source];
816
706 /** 817 /**
707 * Return the modification stamp of the given source, or {@code null} if this cache does not 818 * Return the modification stamp of the given source, or {@code null} if this cache does not
708 * override the contents of the source. 819 * override the contents of the source.
709 * <p> 820 * <p>
710 * <b>Note:</b> This method is not intended to be used except by{@link SourceF actory#getModificationStamp(com.google.dart.engine.source.Source)}. 821 * <b>Note:</b> This method is not intended to be used except by{@link SourceF actory#getModificationStamp(com.google.dart.engine.source.Source)}.
711 * @param source the source whose modification stamp is to be returned 822 * @param source the source whose modification stamp is to be returned
712 * @return the modification stamp of the given source 823 * @return the modification stamp of the given source
713 */ 824 */
714 int getModificationStamp(Source source) => _stampMap[source]; 825 int getModificationStamp(Source source) => _stampMap[source];
826
715 /** 827 /**
716 * Set the contents of the given source to the given contents. This has the ef fect of overriding 828 * Set the contents of the given source to the given contents. This has the ef fect of overriding
717 * the default contents of the source. If the contents are {@code null} the ov erride is removed so 829 * the default contents of the source. If the contents are {@code null} the ov erride is removed so
718 * that the default contents will be returned. 830 * that the default contents will be returned.
719 * @param source the source whose contents are being overridden 831 * @param source the source whose contents are being overridden
720 * @param contents the new contents of the source 832 * @param contents the new contents of the source
721 */ 833 */
722 void setContents(Source source, String contents) { 834 void setContents(Source source, String contents) {
723 if (contents == null) { 835 if (contents == null) {
724 _contentMap.remove(source); 836 _contentMap.remove(source);
725 _stampMap.remove(source); 837 _stampMap.remove(source);
726 } else { 838 } else {
727 _contentMap[source] = contents; 839 _contentMap[source] = contents;
728 _stampMap[source] = JavaSystem.currentTimeMillis(); 840 _stampMap[source] = JavaSystem.currentTimeMillis();
729 } 841 }
730 } 842 }
731 } 843 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/sdk_io.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