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

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

Issue 12502002: Update analyzer-experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine; 4 library engine;
5 5
6 import 'java_core.dart'; 6 import 'java_core.dart';
7 import 'java_engine.dart';
7 import 'dart:collection' show HasNextIterator; 8 import 'dart:collection' show HasNextIterator;
8 import 'error.dart'; 9 import 'error.dart';
9 import 'source.dart'; 10 import 'source.dart';
10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; 11 import 'scanner.dart' show Token, CharBufferScanner, StringScanner;
11 import 'ast.dart' show CompilationUnit; 12 import 'ast.dart' show CompilationUnit, Directive, PartOfDirective;
12 import 'parser.dart' show Parser; 13 import 'parser.dart' show Parser;
13 import 'element.dart'; 14 import 'element.dart';
14 import 'resolver.dart' show Namespace, NamespaceBuilder, LibraryResolver; 15 import 'resolver.dart' show Namespace, NamespaceBuilder, LibraryResolver;
16 import 'html_scanner.dart' show HtmlScanner, HtmlScanResult, HtmlParser, HtmlPar seResult;
15 17
16 /** 18 /**
17 * The unique instance of the class {@code AnalysisEngine} serves as the entry p oint for the 19 * The unique instance of the class {@code AnalysisEngine} serves as the entry p oint for the
18 * functionality provided by the analysis engine. 20 * functionality provided by the analysis engine.
19 */ 21 */
20 class AnalysisEngine { 22 class AnalysisEngine {
21 /** 23 /**
24 * The suffix used for Dart source files.
25 */
26 static String SUFFIX_DART = "dart";
27 /**
28 * The short suffix used for HTML files.
29 */
30 static String SUFFIX_HTM = "htm";
31 /**
32 * The long suffix used for HTML files.
33 */
34 static String SUFFIX_HTML = "html";
35 /**
22 * The unique instance of this class. 36 * The unique instance of this class.
23 */ 37 */
24 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); 38 static AnalysisEngine _UniqueInstance = new AnalysisEngine();
25 /** 39 /**
26 * Return the unique instance of this class. 40 * Return the unique instance of this class.
27 * @return the unique instance of this class 41 * @return the unique instance of this class
28 */ 42 */
29 static AnalysisEngine get instance => _UniqueInstance; 43 static AnalysisEngine get instance => _UniqueInstance;
30 /** 44 /**
45 * Return {@code true} if the given file name is assumed to contain Dart sourc e code.
46 * @param fileName the name of the file being tested
47 * @return {@code true} if the given file name is assumed to contain Dart sour ce code
48 */
49 static bool isDartFileName(String fileName) {
50 if (fileName == null) {
51 return false;
52 }
53 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName), SUFFIX_DART);
54 }
55 /**
56 * Return {@code true} if the given file name is assumed to contain HTML.
57 * @param fileName the name of the file being tested
58 * @return {@code true} if the given file name is assumed to contain HTML
59 */
60 static bool isHtmlFileName(String fileName) {
61 if (fileName == null) {
62 return false;
63 }
64 String extension = FileNameUtilities.getExtension(fileName);
65 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual sIgnoreCase(extension, SUFFIX_HTM);
66 }
67 /**
31 * The logger that should receive information about errors within the analysis engine. 68 * The logger that should receive information about errors within the analysis engine.
32 */ 69 */
33 Logger _logger = Logger.NULL; 70 Logger _logger = Logger.NULL;
34 /** 71 /**
35 * Prevent the creation of instances of this class. 72 * Prevent the creation of instances of this class.
36 */ 73 */
37 AnalysisEngine() : super() { 74 AnalysisEngine() : super() {
38 } 75 }
39 /** 76 /**
40 * Create a new context in which analysis can be performed. 77 * Create a new context in which analysis can be performed.
(...skipping 11 matching lines...) Expand all
52 * @param logger the logger that should receive information about errors withi n the analysis 89 * @param logger the logger that should receive information about errors withi n the analysis
53 * engine 90 * engine
54 */ 91 */
55 void set logger(Logger logger2) { 92 void set logger(Logger logger2) {
56 this._logger = logger2 == null ? Logger.NULL : logger2; 93 this._logger = logger2 == null ? Logger.NULL : logger2;
57 } 94 }
58 } 95 }
59 /** 96 /**
60 * The interface {@code AnalysisContext} defines the behavior of objects that re present a context in 97 * The interface {@code AnalysisContext} defines the behavior of objects that re present a context in
61 * which analysis can be performed. The context includes such information as the version of the SDK 98 * which analysis can be performed. The context includes such information as the version of the SDK
62 * being analyzed against as well as the package-root used to resolve 'package:' URI's. This 99 * being analyzed against as well as the package-root used to resolve 'package:' URI's. (The latter
63 * information is included indirectly through the {@link SourceFactory source fa ctory}. 100 * is included indirectly through the {@link SourceFactory source factory}.)
64 * <p> 101 * <p>
65 * Analysis engine allows for having more than one context. This can be used, fo r example, to 102 * Analysis engine allows for having more than one context. This can be used, fo r example, to
66 * perform one analysis based on the state of files on disk and a separate analy sis based on the 103 * perform one analysis based on the state of files on disk and a separate analy sis based on the
67 * state of those files in open editors. It can also be used to perform an analy sis based on a 104 * state of those files in open editors. It can also be used to perform an analy sis based on a
68 * proposed future state, such as after a refactoring. 105 * proposed future state, such as the state after a refactoring.
69 */ 106 */
70 abstract class AnalysisContext { 107 abstract class AnalysisContext {
71 /** 108 /**
109 * Respond to the given set of changes by removing any cached information that might now be
110 * out-of-date. The result indicates what operations need to be performed as a result of this
111 * change without actually performing those operations.
112 * @param changeSet a description of the changes that have occurred
113 * @return a result (not {@code null}) indicating operations to be performed
114 */
115 ChangeResult changed(ChangeSet changeSet);
116 /**
72 * Clear any cached information that is dependent on resolution. This method s hould be invoked if 117 * Clear any cached information that is dependent on resolution. This method s hould be invoked if
73 * the assumptions used by resolution have changed but the contents of the fil e have not changed. 118 * the assumptions used by resolution have changed but the contents of the fil e have not changed.
74 * Use {@link #sourceChanged(Source)} and {@link #sourcesDeleted(SourceContain er)} to indicate 119 * Use {@link #sourceChanged(Source)} and {@link #sourcesDeleted(SourceContain er)} to indicate
75 * when the contents of a file or files have changed. 120 * when the contents of a file or files have changed.
76 */ 121 */
77 void clearResolution(); 122 void clearResolution();
78 /** 123 /**
79 * Call this method when this context is no longer going to be used. At this p oint, the receiver 124 * Call this method when this context is no longer going to be used. At this p oint, the receiver
80 * may choose to push some of its information back into the global cache for c onsumption by 125 * may choose to push some of its information back into the global cache for c onsumption by
81 * another context for performance. 126 * another context for performance.
82 */ 127 */
83 void discard(); 128 void discard();
84 /** 129 /**
85 * Create a new context in which analysis can be performed. Any sources in the specified directory 130 * Create a new context in which analysis can be performed. Any sources in the specified directory
86 * in the receiver will be removed from the receiver and added to the newly cr eated context. 131 * in the receiver will be removed from the receiver and added to the newly cr eated context.
87 * @param directory the directory (not {@code null}) containing sources that s hould be removed 132 * @param directory the directory (not {@code null}) containing sources that s hould be removed
88 * from the receiver and added to the returned context 133 * from the receiver and added to the returned context
89 * @return the analysis context that was created (not {@code null}) 134 * @return the analysis context that was created (not {@code null})
90 */ 135 */
91 AnalysisContext extractAnalysisContext(SourceContainer container); 136 AnalysisContext extractAnalysisContext(SourceContainer container);
92 /** 137 /**
93 * Answer the collection of sources that have been added to the receiver via{@ link #sourceAvailable(Source)} and not removed from the receiver via{@link #sour ceDeleted(Source)} or {@link #sourcesDeleted(SourceContainer)}.
94 * @return a collection of sources (not {@code null}, contains no {@code null} s)
95 */
96 Collection<Source> get availableSources;
97 /**
98 * Return the element referenced by the given location. 138 * Return the element referenced by the given location.
99 * @param location the reference describing the element to be returned 139 * @param location the reference describing the element to be returned
100 * @return the element referenced by the given location 140 * @return the element referenced by the given location
101 */ 141 */
102 Element getElement(ElementLocation location); 142 Element getElement(ElementLocation location);
103 /** 143 /**
104 * Return an array containing all of the errors associated with the given sour ce. 144 * Return an array containing all of the errors associated with the given sour ce.
105 * @param source the source whose errors are to be returned 145 * @param source the source whose errors are to be returned
106 * @return all of the errors associated with the given source 146 * @return all of the errors associated with the given source
107 * @throws AnalysisException if the errors could not be determined because the analysis could not 147 * @throws AnalysisException if the errors could not be determined because the analysis could not
108 * be performed 148 * be performed
109 */ 149 */
110 List<AnalysisError> getErrors(Source source); 150 List<AnalysisError> getErrors(Source source);
111 /** 151 /**
112 * Parse and build an element model for the HTML file defined by the given sou rce. 152 * Parse and build an element model for the HTML file defined by the given sou rce.
113 * @param source the source defining the HTML file whose element model is to b e returned 153 * @param source the source defining the HTML file whose element model is to b e returned
114 * @return the element model corresponding to the HTML file defined by the giv en source 154 * @return the element model corresponding to the HTML file defined by the giv en source
115 */ 155 */
116 HtmlElement getHtmlElement(Source source); 156 HtmlElement getHtmlElement(Source source);
117 /** 157 /**
118 * Return the kind of the given source if it is already known, or {@code null} if the kind is not 158 * Return the kind of the given source if it is already known, or {@code null} if the kind is not
119 * already known. 159 * already known.
120 * @param source the source whose kind is to be returned 160 * @param source the source whose kind is to be returned
121 * @return the kind of the given source 161 * @return the kind of the given source
122 * @see #getOrComputeKindOf(Source) 162 * @see #getOrComputeKindOf(Source)
123 */ 163 */
124 SourceKind getKnownKindOf(Source source); 164 SourceKind getKnownKindOf(Source source);
125 /** 165 /**
166 * Return the sources for the defining compilation units of any libraries of w hich the given
167 * source is a part. The array will normally contain a single library because most Dart sources
168 * are only included in a single library, but it is possible to have a part th at is contained in
169 * multiple identically named libraries. If the source represents the defining compilation unit of
170 * a library, then the returned array will contain the given source as its onl y element. If the
171 * source does not represent a Dart source or is not known to this context, th e returned array
172 * will be empty.
173 * @param source the source contained in the returned libraries
174 * @return the sources for the libraries containing the given source
175 */
176 List<Source> getLibrariesContaining(Source source);
177 /**
126 * Return the element model corresponding to the library defined by the given source. If the 178 * Return the element model corresponding to the library defined by the given source. If the
127 * element model does not yet exist it will be created. The process of creatin g an element model 179 * element model does not yet exist it will be created. The process of creatin g an element model
128 * for a library can long-running, depending on the size of the library and th e number of 180 * for a library can long-running, depending on the size of the library and th e number of
129 * libraries that are imported into it that also need to have a model built fo r them. 181 * libraries that are imported into it that also need to have a model built fo r them.
130 * @param source the source defining the library whose element model is to be returned 182 * @param source the source defining the library whose element model is to be returned
131 * @return the element model corresponding to the library defined by the given source or{@code null} if the element model could not be determined because the analysis could 183 * @return the element model corresponding to the library defined by the given source or{@code null} if the element model could not be determined because the analysis could
132 * not be performed 184 * not be performed
133 */ 185 */
134 LibraryElement getLibraryElement(Source source); 186 LibraryElement getLibraryElement(Source source);
135 /** 187 /**
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void mergeAnalysisContext(AnalysisContext context); 227 void mergeAnalysisContext(AnalysisContext context);
176 /** 228 /**
177 * Parse a single source to produce an AST structure. The resulting AST struct ure may or may not 229 * Parse a single source to produce an AST structure. The resulting AST struct ure may or may not
178 * be resolved, and may have a slightly different structure depending upon whe ther it is resolved. 230 * be resolved, and may have a slightly different structure depending upon whe ther it is resolved.
179 * @param source the source to be parsed 231 * @param source the source to be parsed
180 * @return the AST structure representing the content of the source 232 * @return the AST structure representing the content of the source
181 * @throws AnalysisException if the analysis could not be performed 233 * @throws AnalysisException if the analysis could not be performed
182 */ 234 */
183 CompilationUnit parse(Source source); 235 CompilationUnit parse(Source source);
184 /** 236 /**
237 * Parse a single HTML source to produce an AST structure. The resulting HTML AST structure may or
238 * may not be resolved, and may have a slightly different structure depending upon whether it is
239 * resolved.
240 * @param source the HTML source to be parsed
241 * @return the parse result (not {@code null})
242 * @throws AnalysisException if the analysis could not be performed
243 */
244 HtmlParseResult parseHtml(Source source);
245 /**
185 * Parse and resolve a single source within the given context to produce a ful ly resolved AST. 246 * Parse and resolve a single source within the given context to produce a ful ly resolved AST.
186 * @param source the source to be parsed and resolved 247 * @param source the source to be parsed and resolved
187 * @param library the library defining the context in which the source file is to be resolved 248 * @param library the library defining the context in which the source file is to be resolved
188 * @return the result of resolving the AST structure representing the content of the source 249 * @return the result of resolving the AST structure representing the content of the source
189 * @throws AnalysisException if the analysis could not be performed 250 * @throws AnalysisException if the analysis could not be performed
190 */ 251 */
191 CompilationUnit resolve(Source source, LibraryElement library); 252 CompilationUnit resolve(Source source, LibraryElement library);
192 /** 253 /**
193 * Scan a single source to produce a token stream. 254 * Scan a single source to produce a token stream.
194 * @param source the source to be scanned 255 * @param source the source to be scanned
195 * @param errorListener the listener to which errors should be reported 256 * @param errorListener the listener to which errors should be reported
196 * @return the head of the token stream representing the content of the source 257 * @return the head of the token stream representing the content of the source
197 * @throws AnalysisException if the analysis could not be performed 258 * @throws AnalysisException if the analysis could not be performed
198 */ 259 */
199 Token scan(Source source, AnalysisErrorListener errorListener); 260 Token scan(Source source, AnalysisErrorListener errorListener);
200 /** 261 /**
262 * Scan a single source to produce an HTML token stream.
263 * @param source the source to be scanned
264 * @return the scan result (not {@code null})
265 * @throws AnalysisException if the analysis could not be performed
266 */
267 HtmlScanResult scanHtml(Source source);
268 /**
201 * Set the source factory used to create the sources that can be analyzed in t his context to the 269 * Set the source factory used to create the sources that can be analyzed in t his context to the
202 * given source factory. 270 * given source factory.
203 * @param sourceFactory the source factory used to create the sources that can be analyzed in this 271 * @param sourceFactory the source factory used to create the sources that can be analyzed in this
204 * context 272 * context
205 */ 273 */
206 void set sourceFactory(SourceFactory sourceFactory4); 274 void set sourceFactory(SourceFactory sourceFactory4);
207 /** 275 /**
208 * Cache the fact that content for the given source is now available, is of in terest to the
209 * client, and should be analyzed. Do not modify or discard any information ab out this source that
210 * is already cached.
211 * @param source the source that is now available
212 */
213 void sourceAvailable(Source source);
214 /**
215 * Respond to the fact that the content of the given source has changed by rem oving any cached
216 * information that might now be out-of-date.
217 * @param source the source whose content has changed
218 */
219 void sourceChanged(Source source);
220 /**
221 * Respond to the fact that the given source has been deleted and should no lo nger be analyzed by
222 * removing any cached information that might now be out-of-date.
223 * @param source the source that was deleted
224 */
225 void sourceDeleted(Source source);
226 /**
227 * Discard cached information for all files in the specified source container.
228 * @param container the source container that was deleted (not {@code null})
229 */
230 void sourcesDeleted(SourceContainer container);
231 /**
232 * Given a collection of sources with content that has changed, return an {@li nk Iterable}identifying the sources that need to be resolved. 276 * Given a collection of sources with content that has changed, return an {@li nk Iterable}identifying the sources that need to be resolved.
233 * @param changedSources an array of sources (not {@code null}, contains no {@ code null}s) 277 * @param changedSources an array of sources (not {@code null}, contains no {@ code null}s)
234 * @return An iterable returning the sources to be resolved 278 * @return An iterable returning the sources to be resolved
235 */ 279 */
236 Iterable<Source> sourcesToResolve(List<Source> changedSources); 280 Iterable<Source> sourcesToResolve(List<Source> changedSources);
237 } 281 }
238 /** 282 /**
239 * Instances of the class {@code AnalysisException} represent an exception that occurred during the 283 * Instances of the class {@code AnalysisException} represent an exception that occurred during the
240 * analysis of one or more sources. 284 * analysis of one or more sources.
241 */ 285 */
242 class AnalysisException extends JavaException { 286 class AnalysisException extends JavaException {
243 /** 287 /**
244 * Initialize a newly created exception. 288 * Initialize a newly created exception.
245 */ 289 */
246 AnalysisException() : super() { 290 AnalysisException() : super() {
247 _jtd_constructor_117_impl(); 291 _jtd_constructor_119_impl();
248 } 292 }
249 _jtd_constructor_117_impl() { 293 _jtd_constructor_119_impl() {
250 } 294 }
251 /** 295 /**
252 * Initialize a newly created exception to have the given message. 296 * Initialize a newly created exception to have the given message.
253 * @param message the message associated with the exception 297 * @param message the message associated with the exception
254 */ 298 */
255 AnalysisException.con1(String message) : super(message) { 299 AnalysisException.con1(String message) : super(message) {
256 _jtd_constructor_118_impl(message); 300 _jtd_constructor_120_impl(message);
257 } 301 }
258 _jtd_constructor_118_impl(String message) { 302 _jtd_constructor_120_impl(String message) {
259 } 303 }
260 /** 304 /**
261 * Initialize a newly created exception to have the given message and cause. 305 * Initialize a newly created exception to have the given message and cause.
262 * @param message the message associated with the exception 306 * @param message the message associated with the exception
263 * @param cause the underlying exception that caused this exception 307 * @param cause the underlying exception that caused this exception
264 */ 308 */
265 AnalysisException.con2(String message, Exception cause) : super(message, cause ) { 309 AnalysisException.con2(String message, Exception cause) : super(message, cause ) {
266 _jtd_constructor_119_impl(message, cause); 310 _jtd_constructor_121_impl(message, cause);
267 } 311 }
268 _jtd_constructor_119_impl(String message, Exception cause) { 312 _jtd_constructor_121_impl(String message, Exception cause) {
269 } 313 }
270 /** 314 /**
271 * Initialize a newly created exception to have the given cause. 315 * Initialize a newly created exception to have the given cause.
272 * @param cause the underlying exception that caused this exception 316 * @param cause the underlying exception that caused this exception
273 */ 317 */
274 AnalysisException.con3(Exception cause) : super.withCause(cause) { 318 AnalysisException.con3(Exception cause) : super.withCause(cause) {
275 _jtd_constructor_120_impl(cause); 319 _jtd_constructor_122_impl(cause);
276 } 320 }
277 _jtd_constructor_120_impl(Exception cause) { 321 _jtd_constructor_122_impl(Exception cause) {
278 } 322 }
279 } 323 }
280 /** 324 /**
325 * Instances of {@code ChangeResult} are returned by {@link AnalysisContext#chan ged(ChangeSet)} to
326 * indicate what operations need to be performed as a result of the change.
327 */
328 class ChangeResult {
329 }
330 /**
331 * Instances of the class {@code ChangeSet} indicate what sources have been adde d, changed, or
332 * removed.
333 */
334 class ChangeSet {
335 /**
336 * A table mapping the sources that have been added to their contents.
337 */
338 Map<Source, String> _added3 = new Map<Source, String>();
339 /**
340 * A table mapping the sources that have been changed to their contents.
341 */
342 Map<Source, String> _changed3 = new Map<Source, String>();
343 /**
344 * A list containing the sources that have been removed..
345 */
346 List<Source> _removed2 = new List<Source>();
347 /**
348 * A list containing the source containers specifying additional sources that have been removed.
349 */
350 List<SourceContainer> _removedContainers = new List<SourceContainer>();
351 /**
352 * Initialize a newly created change set to be empty.
353 */
354 ChangeSet() : super() {
355 }
356 /**
357 * Record that the specified source has been added and that it's content is th e default contents
358 * of the source.
359 * @param source the source that was added
360 */
361 void added(Source source) {
362 added2(source, null);
363 }
364 /**
365 * Record that the specified source has been added and that it has the given c ontent. If the
366 * content is non-{@code null}, this has the effect of overriding the default contents of the
367 * source. If the contents are {@code null}, any previous the override is remo ved so that the
368 * default contents will be used.
369 * @param source the source that was added
370 * @param content the content of the new source
371 */
372 void added2(Source source, String content) {
373 if (source != null) {
374 _added3[source] = content;
375 }
376 }
377 /**
378 * Record that the specified source has been changed and that it's content is the default contents
379 * of the source.
380 * @param source the source that was changed
381 */
382 void changed(Source source) {
383 changed2(source, null);
384 }
385 /**
386 * Record that the specified source has been changed and that it now has the g iven content. If the
387 * content is non-{@code null}, this has the effect of overriding the default contents of the
388 * source. If the contents are {@code null}, any previous the override is remo ved so that the
389 * default contents will be used.
390 * @param source the source that was changed
391 * @param content the new content of the source
392 */
393 void changed2(Source source, String content) {
394 if (source != null) {
395 _changed3[source] = content;
396 }
397 }
398 /**
399 * Return a table mapping the sources that have been added to their contents.
400 * @return a table mapping the sources that have been added to their contents
401 */
402 Map<Source, String> get addedWithContent => _added3;
403 /**
404 * Return a table mapping the sources that have been changed to their contents .
405 * @return a table mapping the sources that have been changed to their content s
406 */
407 Map<Source, String> get changedWithContent => _changed3;
408 /**
409 * Return a list containing the sources that were removed.
410 * @return a list containing the sources that were removed
411 */
412 List<Source> get removed => _removed2;
413 /**
414 * Return a list containing the source containers that were removed.
415 * @return a list containing the source containers that were removed
416 */
417 List<SourceContainer> get removedContainers => _removedContainers;
418 /**
419 * Return {@code true} if this change set does not contain any changes.
420 * @return {@code true} if this change set does not contain any changes
421 */
422 bool isEmpty() => _added3.isEmpty && _changed3.isEmpty && _removed2.isEmpty && _removedContainers.isEmpty;
423 /**
424 * Record that the specified source has been removed.
425 * @param source the source that was removed
426 */
427 void removed3(Source source) {
428 if (source != null) {
429 _removed2.add(source);
430 }
431 }
432 /**
433 * Record that the specified source container has been removed.
434 * @param container the source container that was removed
435 */
436 void removedContainer(SourceContainer container) {
437 if (container != null) {
438 _removedContainers.add(container);
439 }
440 }
441 }
442 /**
281 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys isContext analysis 443 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys isContext analysis
282 * context}. 444 * context}.
283 */ 445 */
284 class AnalysisContextImpl implements AnalysisContext { 446 class AnalysisContextImpl implements AnalysisContext {
285 /** 447 /**
286 * The source factory used to create the sources that can be analyzed in this context. 448 * The source factory used to create the sources that can be analyzed in this context.
287 */ 449 */
288 SourceFactory _sourceFactory; 450 SourceFactory _sourceFactory;
289 /** 451 /**
452 * A table mapping sources known to the context to the information known about the source.
453 */
454 Map<Source, SourceInfo> _sourceMap = new Map<Source, SourceInfo>();
455 /**
290 * A cache mapping sources to the compilation units that were produced for the contents of the 456 * A cache mapping sources to the compilation units that were produced for the contents of the
291 * source. 457 * source.
292 */ 458 */
293 Map<Source, CompilationUnit> _parseCache = new Map<Source, CompilationUnit>(); 459 Map<Source, CompilationUnit> _parseCache = new Map<Source, CompilationUnit>();
294 /** 460 /**
461 * A cache mapping sources to the html parse results that were produced for th e contents of the
462 * source.
463 */
464 Map<Source, HtmlParseResult> _htmlParseCache = new Map<Source, HtmlParseResult >();
465 /**
295 * A cache mapping sources (of the defining compilation units of libraries) to the library 466 * A cache mapping sources (of the defining compilation units of libraries) to the library
296 * elements for those libraries. 467 * elements for those libraries.
297 */ 468 */
298 Map<Source, LibraryElement> _libraryElementCache = new Map<Source, LibraryElem ent>(); 469 Map<Source, LibraryElement> _libraryElementCache = new Map<Source, LibraryElem ent>();
299 /** 470 /**
300 * A cache mapping sources (of the defining compilation units of libraries) to the public 471 * A cache mapping sources (of the defining compilation units of libraries) to the public
301 * namespace for that library. 472 * namespace for that library.
302 */ 473 */
303 Map<Source, Namespace> _publicNamespaceCache = new Map<Source, Namespace>(); 474 Map<Source, Namespace> _publicNamespaceCache = new Map<Source, Namespace>();
304 /** 475 /**
305 * A cache of the available sources of interest to the client. Sources are add ed to this
306 * collection via {@link #sourceAvailable(Source)} and removed from this colle ction via{@link #sourceDeleted(Source)} and {@link #directoryDeleted(File)}
307 */
308 Set<Source> _availableSources = new Set<Source>();
309 /**
310 * The object used to synchronize access to all of the caches. 476 * The object used to synchronize access to all of the caches.
311 */ 477 */
312 Object _cacheLock = new Object(); 478 Object _cacheLock = new Object();
313 /** 479 /**
314 * The suffix used by sources that contain Dart. 480 * The suffix used by sources that contain Dart.
315 */ 481 */
316 static String _DART_SUFFIX = ".dart"; 482 static String _DART_SUFFIX = ".dart";
317 /** 483 /**
318 * The suffix used by sources that contain HTML. 484 * The suffix used by sources that contain HTML.
319 */ 485 */
320 static String _HTML_SUFFIX = ".html"; 486 static String _HTML_SUFFIX = ".html";
321 /** 487 /**
322 * Initialize a newly created analysis context. 488 * Initialize a newly created analysis context.
323 */ 489 */
324 AnalysisContextImpl() : super() { 490 AnalysisContextImpl() : super() {
325 } 491 }
492 ChangeResult changed(ChangeSet changeSet) {
493 if (changeSet.isEmpty()) {
494 return new ChangeResult();
495 }
496 {
497 for (MapEntry<Source, String> entry in getMapEntrySet(changeSet.addedWithC ontent)) {
498 _sourceFactory.setContents(entry.getKey(), entry.getValue());
499 }
500 for (MapEntry<Source, String> entry in getMapEntrySet(changeSet.changedWit hContent)) {
501 _sourceFactory.setContents(entry.getKey(), entry.getValue());
502 }
503 for (Source source in changeSet.addedWithContent.keys.toSet()) {
504 sourceAvailable(source);
505 }
506 for (Source source in changeSet.changedWithContent.keys.toSet()) {
507 sourceChanged(source);
508 }
509 for (Source source in changeSet.removed) {
510 sourceDeleted(source);
511 }
512 for (SourceContainer container in changeSet.removedContainers) {
513 sourcesDeleted(container);
514 }
515 }
516 return new ChangeResult();
517 }
326 void clearResolution() { 518 void clearResolution() {
327 { 519 {
328 _parseCache.clear(); 520 _parseCache.clear();
521 _htmlParseCache.clear();
329 _libraryElementCache.clear(); 522 _libraryElementCache.clear();
330 _publicNamespaceCache.clear(); 523 _publicNamespaceCache.clear();
331 } 524 }
332 } 525 }
333 void discard() { 526 void discard() {
334 { 527 {
528 _sourceMap.clear();
335 _parseCache.clear(); 529 _parseCache.clear();
530 _htmlParseCache.clear();
336 _libraryElementCache.clear(); 531 _libraryElementCache.clear();
337 _publicNamespaceCache.clear(); 532 _publicNamespaceCache.clear();
338 _availableSources.clear();
339 } 533 }
340 } 534 }
341 AnalysisContext extractAnalysisContext(SourceContainer container) { 535 AnalysisContext extractAnalysisContext(SourceContainer container) {
342 AnalysisContext newContext = AnalysisEngine.instance.createAnalysisContext() ; 536 AnalysisContextImpl newContext = AnalysisEngine.instance.createAnalysisConte xt() as AnalysisContextImpl;
537 List<Source> sourcesToRemove = new List<Source>();
343 { 538 {
344 JavaIterator<Source> iter = new JavaIterator(_availableSources); 539 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) {
345 while (iter.hasNext) { 540 Source source = entry.getKey();
346 Source source = iter.next();
347 if (container.contains(source)) { 541 if (container.contains(source)) {
348 iter.remove(); 542 sourcesToRemove.add(source);
349 newContext.sourceAvailable(source); 543 newContext._sourceMap[source] = new SourceInfo.con2(entry.getValue());
350 } 544 }
351 } 545 }
352 } 546 }
353 return newContext; 547 return newContext;
354 } 548 }
355 Collection<Source> get availableSources {
356 {
357 return new List<Source>.from(_availableSources);
358 }
359 }
360 Element getElement(ElementLocation location) { 549 Element getElement(ElementLocation location) {
361 throw new UnsupportedOperationException(); 550 throw new UnsupportedOperationException();
362 } 551 }
363 List<AnalysisError> getErrors(Source source) { 552 List<AnalysisError> getErrors(Source source) {
364 throw new UnsupportedOperationException(); 553 throw new UnsupportedOperationException();
365 } 554 }
366 HtmlElement getHtmlElement(Source source) { 555 HtmlElement getHtmlElement(Source source) {
367 throw new UnsupportedOperationException(); 556 throw new UnsupportedOperationException();
368 } 557 }
369 SourceKind getKnownKindOf(Source source) { 558 SourceKind getKnownKindOf(Source source) {
370 if (source.fullName.endsWith(_HTML_SUFFIX)) { 559 if (source.fullName.endsWith(_HTML_SUFFIX)) {
371 return SourceKind.HTML; 560 return SourceKind.HTML;
372 } 561 }
373 if (!source.fullName.endsWith(_DART_SUFFIX)) { 562 if (!source.fullName.endsWith(_DART_SUFFIX)) {
374 return SourceKind.UNKNOWN; 563 return SourceKind.UNKNOWN;
375 } 564 }
376 { 565 {
377 if (_libraryElementCache.containsKey(source)) { 566 if (_libraryElementCache.containsKey(source)) {
378 return SourceKind.LIBRARY; 567 return SourceKind.LIBRARY;
379 } 568 }
380 CompilationUnit unit = _parseCache[source]; 569 CompilationUnit unit = _parseCache[source];
381 if (unit != null && hasPartOfDirective(unit)) { 570 if (unit != null && hasPartOfDirective(unit)) {
382 return SourceKind.PART; 571 return SourceKind.PART;
383 } 572 }
384 } 573 }
385 return null; 574 return null;
386 } 575 }
576 List<Source> getLibrariesContaining(Source source) {
577 {
578 SourceInfo info = _sourceMap[source];
579 if (info == null) {
580 return Source.EMPTY_ARRAY;
581 }
582 return info.librarySources;
583 }
584 }
387 LibraryElement getLibraryElement(Source source) { 585 LibraryElement getLibraryElement(Source source) {
388 { 586 {
389 LibraryElement element = _libraryElementCache[source]; 587 LibraryElement element = _libraryElementCache[source];
390 if (element == null) { 588 if (element == null) {
391 RecordingErrorListener listener = new RecordingErrorListener(); 589 if (getOrComputeKindOf(source) != SourceKind.LIBRARY) {
392 LibraryResolver resolver = new LibraryResolver(this, listener); 590 return null;
591 }
592 LibraryResolver resolver = new LibraryResolver.con1(this);
393 try { 593 try {
394 element = resolver.resolveLibrary(source, true); 594 element = resolver.resolveLibrary(source, true);
595 if (element != null) {
596 _libraryElementCache[source] = element;
597 }
395 } on AnalysisException catch (exception) { 598 } on AnalysisException catch (exception) {
396 AnalysisEngine.instance.logger.logError2("Could not resolve the librar y ${source.fullName}", exception); 599 AnalysisEngine.instance.logger.logError2("Could not resolve the librar y ${source.fullName}", exception);
397 } 600 }
398 } 601 }
399 return element; 602 return element;
400 } 603 }
401 } 604 }
402 /** 605 /**
403 * Return the element model corresponding to the library defined by the given source, or{@code null} if the element model does not yet exist. 606 * Return the element model corresponding to the library defined by the given source, or{@code null} if the element model does not yet exist.
404 * @param source the source defining the library whose element model is to be returned 607 * @param source the source defining the library whose element model is to be returned
(...skipping 21 matching lines...) Expand all
426 List<AnalysisError> getParsingErrors(Source source) { 629 List<AnalysisError> getParsingErrors(Source source) {
427 throw new UnsupportedOperationException(); 630 throw new UnsupportedOperationException();
428 } 631 }
429 /** 632 /**
430 * Return a namespace containing mappings for all of the public names defined by the given 633 * Return a namespace containing mappings for all of the public names defined by the given
431 * library. 634 * library.
432 * @param library the library whose public namespace is to be returned 635 * @param library the library whose public namespace is to be returned
433 * @return the public namespace of the given library 636 * @return the public namespace of the given library
434 */ 637 */
435 Namespace getPublicNamespace(LibraryElement library) { 638 Namespace getPublicNamespace(LibraryElement library) {
436 Source source7 = library.definingCompilationUnit.source; 639 Source source8 = library.definingCompilationUnit.source;
437 { 640 {
438 Namespace namespace = _publicNamespaceCache[source7]; 641 Namespace namespace = _publicNamespaceCache[source8];
439 if (namespace == null) { 642 if (namespace == null) {
440 NamespaceBuilder builder = new NamespaceBuilder(); 643 NamespaceBuilder builder = new NamespaceBuilder();
441 namespace = builder.createPublicNamespace(library); 644 namespace = builder.createPublicNamespace(library);
442 _publicNamespaceCache[source7] = namespace; 645 _publicNamespaceCache[source8] = namespace;
443 } 646 }
444 return namespace; 647 return namespace;
445 } 648 }
446 } 649 }
447 /** 650 /**
448 * Return a namespace containing mappings for all of the public names defined by the library 651 * Return a namespace containing mappings for all of the public names defined by the library
449 * defined by the given source. 652 * defined by the given source.
450 * @param source the source defining the library whose public namespace is to be returned 653 * @param source the source defining the library whose public namespace is to be returned
451 * @return the public namespace corresponding to the library defined by the gi ven source 654 * @return the public namespace corresponding to the library defined by the gi ven source
452 */ 655 */
(...skipping 11 matching lines...) Expand all
464 } 667 }
465 return namespace; 668 return namespace;
466 } 669 }
467 } 670 }
468 List<AnalysisError> getResolutionErrors(Source source) { 671 List<AnalysisError> getResolutionErrors(Source source) {
469 throw new UnsupportedOperationException(); 672 throw new UnsupportedOperationException();
470 } 673 }
471 SourceFactory get sourceFactory => _sourceFactory; 674 SourceFactory get sourceFactory => _sourceFactory;
472 void mergeAnalysisContext(AnalysisContext context) { 675 void mergeAnalysisContext(AnalysisContext context) {
473 { 676 {
474 _availableSources.addAll(context.availableSources); 677 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(((context as Ana lysisContextImpl))._sourceMap)) {
678 Source newSource = entry.getKey();
679 SourceInfo existingInfo = _sourceMap[newSource];
680 if (existingInfo == null) {
681 _sourceMap[newSource] = new SourceInfo.con2(entry.getValue());
682 } else {
683 }
684 }
475 } 685 }
476 } 686 }
477 CompilationUnit parse(Source source) { 687 CompilationUnit parse(Source source) {
478 { 688 {
479 CompilationUnit unit = _parseCache[source]; 689 CompilationUnit unit = _parseCache[source];
480 if (unit == null) { 690 if (unit == null) {
481 RecordingErrorListener errorListener = new RecordingErrorListener(); 691 RecordingErrorListener errorListener = new RecordingErrorListener();
482 Token token = scan(source, errorListener); 692 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorLi stener);
483 Parser parser = new Parser(source, errorListener); 693 Parser parser = new Parser(source, errorListener);
484 unit = parser.parseCompilationUnit(token); 694 unit = parser.parseCompilationUnit(scanResult._token);
485 unit.parsingErrors = errorListener.errors; 695 unit.parsingErrors = errorListener.getErrors2(source);
696 unit.lineInfo = new LineInfo(scanResult._lineStarts);
486 _parseCache[source] = unit; 697 _parseCache[source] = unit;
487 } 698 }
488 return unit; 699 return unit;
489 } 700 }
490 } 701 }
491 CompilationUnit parse2(Source source, AnalysisErrorListener errorListener) { 702 CompilationUnit parse3(Source source, AnalysisErrorListener errorListener) {
492 { 703 {
493 CompilationUnit unit = _parseCache[source]; 704 CompilationUnit unit = _parseCache[source];
494 if (unit == null) { 705 if (unit == null) {
495 Token token = scan(source, errorListener); 706 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorLi stener);
496 Parser parser = new Parser(source, errorListener); 707 Parser parser = new Parser(source, errorListener);
497 unit = parser.parseCompilationUnit(token); 708 unit = parser.parseCompilationUnit(scanResult._token);
709 unit.lineInfo = new LineInfo(scanResult._lineStarts);
498 _parseCache[source] = unit; 710 _parseCache[source] = unit;
499 } 711 }
500 return unit; 712 return unit;
501 } 713 }
502 } 714 }
715 HtmlParseResult parseHtml(Source source) {
716 {
717 HtmlParseResult result = _htmlParseCache[source];
718 if (result == null) {
719 result = new HtmlParser(source).parse(scanHtml(source));
720 _htmlParseCache[source] = result;
721 }
722 return result;
723 }
724 }
503 /** 725 /**
504 * Given a table mapping the source for the libraries represented by the corre sponding elements to 726 * Given a table mapping the source for the libraries represented by the corre sponding elements to
505 * the elements representing the libraries, record those mappings. 727 * the elements representing the libraries, record those mappings.
506 * @param elementMap a table mapping the source for the libraries represented by the elements to 728 * @param elementMap a table mapping the source for the libraries represented by the elements to
507 * the elements representing the libraries 729 * the elements representing the libraries
508 */ 730 */
509 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 731 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
510 { 732 {
511 javaMapPutAll(_libraryElementCache, elementMap); 733 javaMapPutAll(_libraryElementCache, elementMap);
512 } 734 }
513 } 735 }
514 CompilationUnit resolve(Source source, LibraryElement library) => parse(source ); 736 CompilationUnit resolve(Source source, LibraryElement library) => parse(source );
515 Token scan(Source source, AnalysisErrorListener errorListener) { 737 Token scan(Source source, AnalysisErrorListener errorListener) {
516 List<Token> tokens = new List<Token>(1); 738 AnalysisContextImpl_ScanResult result = internalScan(source, errorListener);
517 Source_ContentReceiver receiver = new Source_ContentReceiver_1(source, error Listener, tokens); 739 return result._token;
740 }
741 HtmlScanResult scanHtml(Source source) {
742 HtmlScanner scanner = new HtmlScanner(source);
518 try { 743 try {
519 source.getContents(receiver); 744 source.getContents(scanner);
520 } on JavaException catch (exception) { 745 } on JavaException catch (exception) {
746 throw new AnalysisException.con3(exception);
521 } 747 }
522 return tokens[0]; 748 return scanner.result;
523 } 749 }
524 void set sourceFactory(SourceFactory sourceFactory2) { 750 void set sourceFactory(SourceFactory sourceFactory2) {
525 this._sourceFactory = sourceFactory2; 751 this._sourceFactory = sourceFactory2;
526 } 752 }
527 void sourceAvailable(Source source) { 753 Iterable<Source> sourcesToResolve(List<Source> changedSources) {
528 { 754 List<Source> librarySources = new List<Source>();
529 javaSetAdd(_availableSources, source); 755 for (Source source in changedSources) {
530 } 756 if (identical(getOrComputeKindOf(source), SourceKind.LIBRARY)) {
531 } 757 librarySources.add(source);
532 void sourceChanged(Source source) {
533 {
534 _parseCache.remove(source);
535 _libraryElementCache.remove(source);
536 _publicNamespaceCache.remove(source);
537 }
538 }
539 void sourceDeleted(Source source) {
540 {
541 _availableSources.remove(source);
542 sourceChanged(source);
543 }
544 }
545 void sourcesDeleted(SourceContainer container) {
546 {
547 _parseCache.clear();
548 _libraryElementCache.clear();
549 _publicNamespaceCache.clear();
550 JavaIterator<Source> iter = new JavaIterator(_availableSources);
551 while (iter.hasNext) {
552 if (container.contains(iter.next())) {
553 iter.remove();
554 }
555 } 758 }
556 } 759 }
760 return librarySources;
557 } 761 }
558 Iterable<Source> sourcesToResolve(List<Source> changedSources) => JavaArrays.a sList(changedSources);
559 /** 762 /**
560 * Return {@code true} if the given compilation unit has a part-of directive. 763 * Return {@code true} if the given compilation unit has a part-of directive.
561 * @param unit the compilation unit being tested 764 * @param unit the compilation unit being tested
562 * @return {@code true} if the compilation unit has a part-of directive 765 * @return {@code true} if the compilation unit has a part-of directive
563 */ 766 */
564 bool hasPartOfDirective(CompilationUnit unit) { 767 bool hasPartOfDirective(CompilationUnit unit) {
565 for (Directive directive in unit.directives) { 768 for (Directive directive in unit.directives) {
566 if (directive is PartOfDirective) { 769 if (directive is PartOfDirective) {
567 return true; 770 return true;
568 } 771 }
569 } 772 }
570 return false; 773 return false;
571 } 774 }
775 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen er errorListener) {
776 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult() ;
777 Source_ContentReceiver receiver = new Source_ContentReceiver_2(source, error Listener, result);
778 try {
779 source.getContents(receiver);
780 } on JavaException catch (exception) {
781 throw new AnalysisException.con3(exception);
782 }
783 return result;
784 }
785 /**
786 * Note: This method must only be invoked while we are synchronized on {@link #cacheLock}.
787 * @param source the source that has been added
788 */
789 void sourceAvailable(Source source) {
790 SourceInfo existingInfo = _sourceMap[source];
791 if (existingInfo == null) {
792 _sourceMap[source] = new SourceInfo.con1(source, getOrComputeKindOf(source ));
793 }
794 }
795 /**
796 * Note: This method must only be invoked while we are synchronized on {@link #cacheLock}.
797 * @param source the source that has been changed
798 */
799 void sourceChanged(Source source) {
800 SourceInfo info = _sourceMap[source];
801 if (info == null) {
802 return;
803 }
804 _parseCache.remove(source);
805 _htmlParseCache.remove(source);
806 _libraryElementCache.remove(source);
807 _publicNamespaceCache.remove(source);
808 for (Source librarySource in info.librarySources) {
809 _libraryElementCache.remove(librarySource);
810 _publicNamespaceCache.remove(librarySource);
811 }
812 }
813 /**
814 * Note: This method must only be invoked while we are synchronized on {@link #cacheLock}.
815 * @param source the source that has been deleted
816 */
817 void sourceDeleted(Source source) {
818 _sourceMap.remove(source);
819 sourceChanged(source);
820 }
821 /**
822 * Note: This method must only be invoked while we are synchronized on {@link #cacheLock}.
823 * @param container the source container specifying the sources that have been deleted
824 */
825 void sourcesDeleted(SourceContainer container) {
826 List<Source> sourcesToRemove = new List<Source>();
827 for (Source source in _sourceMap.keys.toSet()) {
828 if (container.contains(source)) {
829 sourcesToRemove.add(source);
830 }
831 }
832 }
572 } 833 }
573 class Source_ContentReceiver_1 implements Source_ContentReceiver { 834 /**
835 * Instances of the class {@code ScanResult} represent the results of scanning a source.
836 */
837 class AnalysisContextImpl_ScanResult {
838 /**
839 * The first token in the token stream.
840 */
841 Token _token;
842 /**
843 * The line start information that was produced.
844 */
845 List<int> _lineStarts;
846 /**
847 * Initialize a newly created result object to be empty.
848 */
849 AnalysisContextImpl_ScanResult() : super() {
850 }
851 }
852 class Source_ContentReceiver_2 implements Source_ContentReceiver {
574 Source source; 853 Source source;
575 AnalysisErrorListener errorListener; 854 AnalysisErrorListener errorListener;
576 List<Token> tokens; 855 AnalysisContextImpl_ScanResult result;
577 Source_ContentReceiver_1(this.source, this.errorListener, this.tokens); 856 Source_ContentReceiver_2(this.source, this.errorListener, this.result);
578 accept(CharBuffer contents) { 857 accept(CharBuffer contents) {
579 CharBufferScanner scanner = new CharBufferScanner(source, contents, errorLis tener); 858 CharBufferScanner scanner = new CharBufferScanner(source, contents, errorLis tener);
580 tokens[0] = scanner.tokenize(); 859 result._token = scanner.tokenize();
860 result._lineStarts = scanner.lineStarts;
581 } 861 }
582 void accept2(String contents) { 862 void accept2(String contents) {
583 StringScanner scanner = new StringScanner(source, contents, errorListener); 863 StringScanner scanner = new StringScanner(source, contents, errorListener);
584 tokens[0] = scanner.tokenize(); 864 result._token = scanner.tokenize();
865 result._lineStarts = scanner.lineStarts;
585 } 866 }
586 } 867 }
587 /** 868 /**
588 * Instances of the class {@code RecordingErrorListener} implement an error list ener that will 869 * Instances of the class {@code RecordingErrorListener} implement an error list ener that will
589 * record the errors that are reported to it in a way that is appropriate for ca ching those errors 870 * record the errors that are reported to it in a way that is appropriate for ca ching those errors
590 * within an analysis context. 871 * within an analysis context.
591 */ 872 */
592 class RecordingErrorListener implements AnalysisErrorListener { 873 class RecordingErrorListener implements AnalysisErrorListener {
593 /** 874 /**
594 * A list containing the errors that were collected. 875 * A HashMap of lists containing the errors that were collected, keyed by each {@link Source}.
595 */ 876 */
596 List<AnalysisError> _errors = null; 877 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError> >();
597 /** 878 /**
598 * Answer the errors collected by the listener. 879 * Answer the errors collected by the listener.
599 * @return an array of errors (not {@code null}, contains no {@code null}s) 880 * @return an array of errors (not {@code null}, contains no {@code null}s)
600 */ 881 */
601 List<AnalysisError> get errors => _errors != null ? new List.from(_errors) : A nalysisError.NO_ERRORS; 882 List<AnalysisError> get errors {
883 Set<MapEntry<Source, List<AnalysisError>>> entrySet2 = getMapEntrySet(_error s);
884 if (entrySet2.length == 0) {
885 return AnalysisError.NO_ERRORS;
886 }
887 List<AnalysisError> resultList = new List<AnalysisError>(entrySet2.length);
888 for (MapEntry<Source, List<AnalysisError>> entry in entrySet2) {
889 resultList.addAll(entry.getValue());
890 }
891 return new List.from(resultList);
892 }
893 /**
894 * Answer the errors collected by the listener for some passed {@link Source}.
895 * @param source some {@link Source} for which the caller wants the set of {@l ink AnalysisError}s
896 * collected by this listener
897 * @return the errors collected by the listener for the passed {@link Source}
898 */
899 List<AnalysisError> getErrors2(Source source) {
900 List<AnalysisError> errorsForSource = _errors[source];
901 if (errorsForSource == null) {
902 return AnalysisError.NO_ERRORS;
903 } else {
904 return new List.from(errorsForSource);
905 }
906 }
602 void onError(AnalysisError event) { 907 void onError(AnalysisError event) {
603 if (_errors == null) { 908 Source source9 = event.source;
604 _errors = new List<AnalysisError>(); 909 List<AnalysisError> errorsForSource = _errors[source9];
910 if (_errors[source9] == null) {
911 errorsForSource = new List<AnalysisError>();
912 _errors[source9] = errorsForSource;
605 } 913 }
606 _errors.add(event); 914 errorsForSource.add(event);
607 } 915 }
608 } 916 }
609 /** 917 /**
918 * Instances of the class {@code SourceInfo} maintain the information known by a n analysis context
919 * about an individual source.
920 */
921 class SourceInfo {
922 /**
923 * The kind of the source.
924 */
925 SourceKind _kind;
926 /**
927 * The sources for the defining compilation units for the libraries containing the source, or{@code null} if the libraries containing the source are not yet k nown.
928 */
929 List<Source> _librarySources = null;
930 SourceInfo.con1(Source source, SourceKind kind3) {
931 _jtd_constructor_151_impl(source, kind3);
932 }
933 _jtd_constructor_151_impl(Source source, SourceKind kind3) {
934 this._kind = kind3;
935 }
936 /**
937 * Initialize a newly created information holder to hold the same information as the given holder.
938 * @param info the information holder used to initialize this holder
939 */
940 SourceInfo.con2(SourceInfo info) {
941 _jtd_constructor_152_impl(info);
942 }
943 _jtd_constructor_152_impl(SourceInfo info) {
944 _kind = info._kind;
945 _librarySources = new List<Source>.from(info._librarySources);
946 }
947 /**
948 * Add the given source to the list of sources for the defining compilation un its for the
949 * libraries containing this source.
950 * @param source the source to be added to the list
951 */
952 void addLibrarySource(Source source) {
953 if (_librarySources == null) {
954 _librarySources = new List<Source>();
955 }
956 _librarySources.add(source);
957 }
958 /**
959 * Return the kind of the source.
960 * @return the kind of the source
961 */
962 SourceKind get kind => _kind;
963 /**
964 * Return the sources for the defining compilation units for the libraries con taining this source.
965 * @return the sources for the defining compilation units for the libraries co ntaining this source
966 */
967 List<Source> get librarySources {
968 if (_librarySources == null) {
969 return Source.EMPTY_ARRAY;
970 }
971 return new List.from(_librarySources);
972 }
973 /**
974 * Remove the given source from the list of sources for the defining compilati on units for the
975 * libraries containing this source.
976 * @param source the source to be removed to the list
977 */
978 void removeLibrarySource(Source source) {
979 _librarySources.remove(source);
980 if (_librarySources.isEmpty) {
981 _librarySources = null;
982 }
983 }
984 /**
985 * Set the kind of the source to the given kind.
986 * @param kind the kind of the source
987 */
988 void set kind(SourceKind kind4) {
989 this._kind = kind4;
990 }
991 }
992 /**
610 * The interface {@code Logger} defines the behavior of objects that can be used to receive 993 * The interface {@code Logger} defines the behavior of objects that can be used to receive
611 * information about errors within the analysis engine. Implementations usually write this 994 * information about errors within the analysis engine. Implementations usually write this
612 * information to a file, but can also record the information for later use (suc h as during testing) 995 * information to a file, but can also record the information for later use (suc h as during testing)
613 * or even ignore the information. 996 * or even ignore the information.
614 */ 997 */
615 abstract class Logger { 998 abstract class Logger {
616 static Logger NULL = new Logger_NullLogger(); 999 static Logger NULL = new Logger_NullLogger();
617 /** 1000 /**
618 * Log the given message as an error. 1001 * Log the given message as an error.
619 * @param message an explanation of why the error occurred or what it means 1002 * @param message an explanation of why the error occurred or what it means
(...skipping 30 matching lines...) Expand all
650 void logError(String message) { 1033 void logError(String message) {
651 } 1034 }
652 void logError2(String message, Exception exception) { 1035 void logError2(String message, Exception exception) {
653 } 1036 }
654 void logError3(Exception exception) { 1037 void logError3(Exception exception) {
655 } 1038 }
656 void logInformation(String message) { 1039 void logInformation(String message) {
657 } 1040 }
658 void logInformation2(String message, Exception exception) { 1041 void logInformation2(String message, Exception exception) {
659 } 1042 }
660 } 1043 }
OLDNEW
« no previous file with comments | « pkg/analyzer-experimental/lib/src/generated/element.dart ('k') | pkg/analyzer-experimental/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698