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

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

Issue 16256021: Remove trailing spaces in analyzer_experimental (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/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
4 library engine; 3 library engine;
5
6 import 'dart:collection' show HasNextIterator; 4 import 'dart:collection' show HasNextIterator;
7 import 'java_core.dart'; 5 import 'java_core.dart';
8 import 'java_engine.dart'; 6 import 'java_engine.dart';
9 import 'instrumentation.dart'; 7 import 'instrumentation.dart';
10 import 'error.dart'; 8 import 'error.dart';
11 import 'source.dart'; 9 import 'source.dart';
12 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; 10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner;
13 import 'ast.dart'; 11 import 'ast.dart';
14 import 'parser.dart' show Parser; 12 import 'parser.dart' show Parser;
15 import 'sdk.dart' show DartSdk; 13 import 'sdk.dart' show DartSdk;
16 import 'element.dart'; 14 import 'element.dart';
17 import 'resolver.dart'; 15 import 'resolver.dart';
18 import 'html.dart' show XmlTagNode, XmlAttributeNode, RecursiveXmlVisitor, HtmlS canner, HtmlScanResult, HtmlParser, HtmlParseResult, HtmlUnit; 16 import 'html.dart' show XmlTagNode, XmlAttributeNode, RecursiveXmlVisitor, HtmlS canner, HtmlScanResult, HtmlParser, HtmlParseResult, HtmlUnit;
19
20
21 /** 17 /**
22 * The unique instance of the class {@code AnalysisEngine} serves as the entry p oint for the 18 * The unique instance of the class {@code AnalysisEngine} serves as the entry p oint for the
23 * functionality provided by the analysis engine. 19 * functionality provided by the analysis engine.
24 * @coverage dart.engine 20 * @coverage dart.engine
25 */ 21 */
26 class AnalysisEngine { 22 class AnalysisEngine {
27 23
28 /** 24 /**
29 * The suffix used for Dart source files. 25 * The suffix used for Dart source files.
30 */ 26 */
31 static String SUFFIX_DART = "dart"; 27 static String SUFFIX_DART = "dart";
32 28
33 /** 29 /**
34 * The short suffix used for HTML files. 30 * The short suffix used for HTML files.
35 */ 31 */
36 static String SUFFIX_HTM = "htm"; 32 static String SUFFIX_HTM = "htm";
37 33
38 /** 34 /**
39 * The long suffix used for HTML files. 35 * The long suffix used for HTML files.
40 */ 36 */
41 static String SUFFIX_HTML = "html"; 37 static String SUFFIX_HTML = "html";
42 38
43 /** 39 /**
44 * The unique instance of this class. 40 * The unique instance of this class.
45 */ 41 */
46 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); 42 static AnalysisEngine _UniqueInstance = new AnalysisEngine();
47 43
48 /** 44 /**
49 * Return the unique instance of this class. 45 * Return the unique instance of this class.
50 * @return the unique instance of this class 46 * @return the unique instance of this class
51 */ 47 */
52 static AnalysisEngine get instance => _UniqueInstance; 48 static AnalysisEngine get instance => _UniqueInstance;
53 49
54 /** 50 /**
55 * Return {@code true} if the given file name is assumed to contain Dart sourc e code. 51 * Return {@code true} if the given file name is assumed to contain Dart sourc e code.
56 * @param fileName the name of the file being tested 52 * @param fileName the name of the file being tested
57 * @return {@code true} if the given file name is assumed to contain Dart sour ce code 53 * @return {@code true} if the given file name is assumed to contain Dart sour ce code
58 */ 54 */
59 static bool isDartFileName(String fileName) { 55 static bool isDartFileName(String fileName) {
60 if (fileName == null) { 56 if (fileName == null) {
61 return false; 57 return false;
62 } 58 }
63 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName), SUFFIX_DART); 59 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName), SUFFIX_DART);
64 } 60 }
65 61
66 /** 62 /**
67 * Return {@code true} if the given file name is assumed to contain HTML. 63 * Return {@code true} if the given file name is assumed to contain HTML.
68 * @param fileName the name of the file being tested 64 * @param fileName the name of the file being tested
69 * @return {@code true} if the given file name is assumed to contain HTML 65 * @return {@code true} if the given file name is assumed to contain HTML
70 */ 66 */
71 static bool isHtmlFileName(String fileName) { 67 static bool isHtmlFileName(String fileName) {
72 if (fileName == null) { 68 if (fileName == null) {
73 return false; 69 return false;
74 } 70 }
75 String extension = FileNameUtilities.getExtension(fileName); 71 String extension = FileNameUtilities.getExtension(fileName);
76 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual sIgnoreCase(extension, SUFFIX_HTM); 72 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual sIgnoreCase(extension, SUFFIX_HTM);
77 } 73 }
78 74
79 /** 75 /**
80 * The logger that should receive information about errors within the analysis engine. 76 * The logger that should receive information about errors within the analysis engine.
81 */ 77 */
82 Logger _logger = Logger.NULL; 78 Logger _logger = Logger.NULL;
83 79
84 /** 80 /**
85 * Create a new context in which analysis can be performed. 81 * Create a new context in which analysis can be performed.
86 * @return the analysis context that was created 82 * @return the analysis context that was created
87 */ 83 */
88 AnalysisContext createAnalysisContext() { 84 AnalysisContext createAnalysisContext() {
89 if (Instrumentation.isNullLogger()) { 85 if (Instrumentation.isNullLogger()) {
90 return new DelegatingAnalysisContextImpl(); 86 return new DelegatingAnalysisContextImpl();
91 } else { 87 } else {
92 return new InstrumentedAnalysisContextImpl.con1(new DelegatingAnalysisCont extImpl()); 88 return new InstrumentedAnalysisContextImpl.con1(new DelegatingAnalysisCont extImpl());
93 } 89 }
94 } 90 }
95 91
96 /** 92 /**
97 * Return the logger that should receive information about errors within the a nalysis engine. 93 * Return the logger that should receive information about errors within the a nalysis engine.
98 * @return the logger that should receive information about errors within the analysis engine 94 * @return the logger that should receive information about errors within the analysis engine
99 */ 95 */
100 Logger get logger => _logger; 96 Logger get logger => _logger;
101 97
102 /** 98 /**
103 * Set the logger that should receive information about errors within the anal ysis engine to the 99 * Set the logger that should receive information about errors within the anal ysis engine to the
104 * given logger. 100 * given logger.
105 * @param logger the logger that should receive information about errors withi n the analysis 101 * @param logger the logger that should receive information about errors withi n the analysis
106 * engine 102 * engine
107 */ 103 */
108 void set logger(Logger logger2) { 104 void set logger(Logger logger2) {
109 this._logger = logger2 == null ? Logger.NULL : logger2; 105 this._logger = logger2 == null ? Logger.NULL : logger2;
110 } 106 }
111 } 107 }
112
113 /** 108 /**
114 * The interface {@code AnalysisContext} defines the behavior of objects that re present a context in 109 * The interface {@code AnalysisContext} defines the behavior of objects that re present a context in
115 * which a single analysis can be performed and incrementally maintained. The co ntext includes such 110 * which a single analysis can be performed and incrementally maintained. The co ntext includes such
116 * information as the version of the SDK being analyzed against as well as the p ackage-root used to 111 * information as the version of the SDK being analyzed against as well as the p ackage-root used to
117 * resolve 'package:' URI's. (Both of which are known indirectly through the {@l ink SourceFactorysource factory}.) 112 * resolve 'package:' URI's. (Both of which are known indirectly through the {@l ink SourceFactorysource factory}.)
118 * <p> 113 * <p>
119 * An analysis context also represents the state of the analysis, which includes knowing which 114 * An analysis context also represents the state of the analysis, which includes knowing which
120 * sources have been included in the analysis (either directly or indirectly) an d the results of the 115 * sources have been included in the analysis (either directly or indirectly) an d the results of the
121 * analysis. Sources must be added and removed from the context using the method {@link #applyChanges(ChangeSet)}, which is also used to notify the context when sources have been 116 * analysis. Sources must be added and removed from the context using the method {@link #applyChanges(ChangeSet)}, which is also used to notify the context when sources have been
122 * modified and, consequently, previously known results might have been invalida ted. 117 * modified and, consequently, previously known results might have been invalida ted.
(...skipping 13 matching lines...) Expand all
136 * up-to-date. For such clients there is a mechanism that allows them to increme ntally perform 131 * up-to-date. For such clients there is a mechanism that allows them to increme ntally perform
137 * needed analysis and get notified of the consequent changes to the analysis re sults. This 132 * needed analysis and get notified of the consequent changes to the analysis re sults. This
138 * mechanism is realized by the method {@link #performAnalysisTask()}. 133 * mechanism is realized by the method {@link #performAnalysisTask()}.
139 * <p> 134 * <p>
140 * Analysis engine allows for having more than one context. This can be used, fo r example, to 135 * Analysis engine allows for having more than one context. This can be used, fo r example, to
141 * perform one analysis based on the state of files on disk and a separate analy sis based on the 136 * perform one analysis based on the state of files on disk and a separate analy sis based on the
142 * state of those files in open editors. It can also be used to perform an analy sis based on a 137 * state of those files in open editors. It can also be used to perform an analy sis based on a
143 * proposed future state, such as the state after a refactoring. 138 * proposed future state, such as the state after a refactoring.
144 */ 139 */
145 abstract class AnalysisContext { 140 abstract class AnalysisContext {
146 141
147 /** 142 /**
148 * Apply the changes specified by the given change set to this context. Any an alysis results that 143 * Apply the changes specified by the given change set to this context. Any an alysis results that
149 * have been invalidated by these changes will be removed. 144 * have been invalidated by these changes will be removed.
150 * @param changeSet a description of the changes that are to be applied 145 * @param changeSet a description of the changes that are to be applied
151 */ 146 */
152 void applyChanges(ChangeSet changeSet); 147 void applyChanges(ChangeSet changeSet);
153 148
154 /** 149 /**
155 * Return the documentation comment for the given element as it appears in the original source 150 * Return the documentation comment for the given element as it appears in the original source
156 * (complete with the beginning and ending delimiters), or {@code null} if the element does not 151 * (complete with the beginning and ending delimiters), or {@code null} if the element does not
157 * have a documentation comment associated with it. This can be a long-running operation if the 152 * have a documentation comment associated with it. This can be a long-running operation if the
158 * information needed to access the comment is not cached. 153 * information needed to access the comment is not cached.
159 * @param element the element whose documentation comment is to be returned 154 * @param element the element whose documentation comment is to be returned
160 * @return the element's documentation comment 155 * @return the element's documentation comment
161 * @throws AnalysisException if the documentation comment could not be determi ned because the 156 * @throws AnalysisException if the documentation comment could not be determi ned because the
162 * analysis could not be performed 157 * analysis could not be performed
163 */ 158 */
164 String computeDocumentationComment(Element element); 159 String computeDocumentationComment(Element element);
165 160
166 /** 161 /**
167 * Return an array containing all of the errors associated with the given sour ce. If the errors 162 * Return an array containing all of the errors associated with the given sour ce. If the errors
168 * are not already known then the source will be analyzed in order to determin e the errors 163 * are not already known then the source will be analyzed in order to determin e the errors
169 * associated with it. 164 * associated with it.
170 * @param source the source whose errors are to be returned 165 * @param source the source whose errors are to be returned
171 * @return all of the errors associated with the given source 166 * @return all of the errors associated with the given source
172 * @throws AnalysisException if the errors could not be determined because the analysis could not 167 * @throws AnalysisException if the errors could not be determined because the analysis could not
173 * be performed 168 * be performed
174 * @see #getErrors(Source) 169 * @see #getErrors(Source)
175 */ 170 */
176 List<AnalysisError> computeErrors(Source source); 171 List<AnalysisError> computeErrors(Source source);
177 172
178 /** 173 /**
179 * Return the element model corresponding to the HTML file defined by the give n source. If the 174 * Return the element model corresponding to the HTML file defined by the give n source. If the
180 * element model does not yet exist it will be created. The process of creatin g an element model 175 * element model does not yet exist it will be created. The process of creatin g an element model
181 * for an HTML file can long-running, depending on the size of the file and th e number of 176 * for an HTML file can long-running, depending on the size of the file and th e number of
182 * libraries that are defined in it (via script tags) that also need to have a model built for 177 * libraries that are defined in it (via script tags) that also need to have a model built for
183 * them. 178 * them.
184 * @param source the source defining the HTML file whose element model is to b e returned 179 * @param source the source defining the HTML file whose element model is to b e returned
185 * @return the element model corresponding to the HTML file defined by the giv en source 180 * @return the element model corresponding to the HTML file defined by the giv en source
186 * @throws AnalysisException if the element model could not be determined beca use the analysis 181 * @throws AnalysisException if the element model could not be determined beca use the analysis
187 * could not be performed 182 * could not be performed
188 * @see #getHtmlElement(Source) 183 * @see #getHtmlElement(Source)
189 */ 184 */
190 HtmlElement computeHtmlElement(Source source); 185 HtmlElement computeHtmlElement(Source source);
191 186
192 /** 187 /**
193 * Return the kind of the given source, computing it's kind if it is not alrea dy known. Return{@link SourceKind#UNKNOWN} if the source is not contained in thi s context. 188 * Return the kind of the given source, computing it's kind if it is not alrea dy known. Return{@link SourceKind#UNKNOWN} if the source is not contained in thi s context.
194 * @param source the source whose kind is to be returned 189 * @param source the source whose kind is to be returned
195 * @return the kind of the given source 190 * @return the kind of the given source
196 * @see #getKindOf(Source) 191 * @see #getKindOf(Source)
197 */ 192 */
198 SourceKind computeKindOf(Source source); 193 SourceKind computeKindOf(Source source);
199 194
200 /** 195 /**
201 * Return the element model corresponding to the library defined by the given source. If the 196 * Return the element model corresponding to the library defined by the given source. If the
202 * element model does not yet exist it will be created. The process of creatin g an element model 197 * element model does not yet exist it will be created. The process of creatin g an element model
203 * for a library can long-running, depending on the size of the library and th e number of 198 * for a library can long-running, depending on the size of the library and th e number of
204 * libraries that are imported into it that also need to have a model built fo r them. 199 * libraries that are imported into it that also need to have a model built fo r them.
205 * @param source the source defining the library whose element model is to be returned 200 * @param source the source defining the library whose element model is to be returned
206 * @return the element model corresponding to the library defined by the given source 201 * @return the element model corresponding to the library defined by the given source
207 * @throws AnalysisException if the element model could not be determined beca use the analysis 202 * @throws AnalysisException if the element model could not be determined beca use the analysis
208 * could not be performed 203 * could not be performed
209 * @see #getLibraryElement(Source) 204 * @see #getLibraryElement(Source)
210 */ 205 */
211 LibraryElement computeLibraryElement(Source source); 206 LibraryElement computeLibraryElement(Source source);
212 207
213 /** 208 /**
214 * Return the line information for the given source, or {@code null} if the so urce is not of a 209 * Return the line information for the given source, or {@code null} if the so urce is not of a
215 * recognized kind (neither a Dart nor HTML file). If the line information was not previously 210 * recognized kind (neither a Dart nor HTML file). If the line information was not previously
216 * known it will be created. The line information is used to map offsets from the beginning of the 211 * known it will be created. The line information is used to map offsets from the beginning of the
217 * source to line and column pairs. 212 * source to line and column pairs.
218 * @param source the source whose line information is to be returned 213 * @param source the source whose line information is to be returned
219 * @return the line information for the given source 214 * @return the line information for the given source
220 * @throws AnalysisException if the line information could not be determined b ecause the analysis 215 * @throws AnalysisException if the line information could not be determined b ecause the analysis
221 * could not be performed 216 * could not be performed
222 * @see #getLineInfo(Source) 217 * @see #getLineInfo(Source)
223 */ 218 */
224 LineInfo computeLineInfo(Source source); 219 LineInfo computeLineInfo(Source source);
225 220
226 /** 221 /**
227 * Create a new context in which analysis can be performed. Any sources in the specified container 222 * Create a new context in which analysis can be performed. Any sources in the specified container
228 * will be removed from this context and added to the newly created context. 223 * will be removed from this context and added to the newly created context.
229 * @param container the container containing sources that should be removed fr om this context and 224 * @param container the container containing sources that should be removed fr om this context and
230 * added to the returned context 225 * added to the returned context
231 * @return the analysis context that was created 226 * @return the analysis context that was created
232 */ 227 */
233 AnalysisContext extractContext(SourceContainer container); 228 AnalysisContext extractContext(SourceContainer container);
234 229
235 /** 230 /**
236 * Return the set of analysis options controlling the behavior of this context . 231 * Return the set of analysis options controlling the behavior of this context .
237 * @return the set of analysis options controlling the behavior of this contex t 232 * @return the set of analysis options controlling the behavior of this contex t
238 */ 233 */
239 AnalysisOptions get analysisOptions; 234 AnalysisOptions get analysisOptions;
240 235
241 /** 236 /**
242 * Return the element referenced by the given location, or {@code null} if the element is not 237 * Return the element referenced by the given location, or {@code null} if the element is not
243 * immediately available or if there is no element with the given location. Th e latter condition 238 * immediately available or if there is no element with the given location. Th e latter condition
244 * can occur, for example, if the location describes an element from a differe nt context or if the 239 * can occur, for example, if the location describes an element from a differe nt context or if the
245 * element has been removed from this context as a result of some change since it was originally 240 * element has been removed from this context as a result of some change since it was originally
246 * obtained. 241 * obtained.
247 * @param location the reference describing the element to be returned 242 * @param location the reference describing the element to be returned
248 * @return the element referenced by the given location 243 * @return the element referenced by the given location
249 */ 244 */
250 Element getElement(ElementLocation location); 245 Element getElement(ElementLocation location);
251 246
252 /** 247 /**
253 * Return an analysis error info containing the array of all of the errors and the line info 248 * Return an analysis error info containing the array of all of the errors and the line info
254 * associated with the given source. The array of errors will be empty if the source is not known 249 * associated with the given source. The array of errors will be empty if the source is not known
255 * to this context or if there are no errors in the source. The errors contain ed in the array can 250 * to this context or if there are no errors in the source. The errors contain ed in the array can
256 * be incomplete. 251 * be incomplete.
257 * @param source the source whose errors are to be returned 252 * @param source the source whose errors are to be returned
258 * @return all of the errors associated with the given source and the line inf o 253 * @return all of the errors associated with the given source and the line inf o
259 * @see #computeErrors(Source) 254 * @see #computeErrors(Source)
260 */ 255 */
261 AnalysisErrorInfo getErrors(Source source); 256 AnalysisErrorInfo getErrors(Source source);
262 257
263 /** 258 /**
264 * Return the element model corresponding to the HTML file defined by the give n source, or{@code null} if the source does not represent an HTML file, the elem ent representing the file 259 * Return the element model corresponding to the HTML file defined by the give n source, or{@code null} if the source does not represent an HTML file, the elem ent representing the file
265 * has not yet been created, or the analysis of the HTML file failed for some reason. 260 * has not yet been created, or the analysis of the HTML file failed for some reason.
266 * @param source the source defining the HTML file whose element model is to b e returned 261 * @param source the source defining the HTML file whose element model is to b e returned
267 * @return the element model corresponding to the HTML file defined by the giv en source 262 * @return the element model corresponding to the HTML file defined by the giv en source
268 * @see #computeHtmlElement(Source) 263 * @see #computeHtmlElement(Source)
269 */ 264 */
270 HtmlElement getHtmlElement(Source source); 265 HtmlElement getHtmlElement(Source source);
271 266
272 /** 267 /**
273 * Return the sources for the HTML files that reference the given compilation unit. If the source 268 * Return the sources for the HTML files that reference the given compilation unit. If the source
274 * does not represent a Dart source or is not known to this context, the retur ned array will be 269 * does not represent a Dart source or is not known to this context, the retur ned array will be
275 * empty. The contents of the array can be incomplete. 270 * empty. The contents of the array can be incomplete.
276 * @param source the source referenced by the returned HTML files 271 * @param source the source referenced by the returned HTML files
277 * @return the sources for the HTML files that reference the given compilation unit 272 * @return the sources for the HTML files that reference the given compilation unit
278 */ 273 */
279 List<Source> getHtmlFilesReferencing(Source source); 274 List<Source> getHtmlFilesReferencing(Source source);
280 275
281 /** 276 /**
282 * Return an array containing all of the sources known to this context that re present HTML files. 277 * Return an array containing all of the sources known to this context that re present HTML files.
283 * The contents of the array can be incomplete. 278 * The contents of the array can be incomplete.
284 * @return the sources known to this context that represent HTML files 279 * @return the sources known to this context that represent HTML files
285 */ 280 */
286 List<Source> get htmlSources; 281 List<Source> get htmlSources;
287 282
288 /** 283 /**
289 * Return the kind of the given source, or {@code null} if the kind is not kno wn to this context. 284 * Return the kind of the given source, or {@code null} if the kind is not kno wn to this context.
290 * @param source the source whose kind is to be returned 285 * @param source the source whose kind is to be returned
291 * @return the kind of the given source 286 * @return the kind of the given source
292 * @see #computeKindOf(Source) 287 * @see #computeKindOf(Source)
293 */ 288 */
294 SourceKind getKindOf(Source source); 289 SourceKind getKindOf(Source source);
295 290
296 /** 291 /**
297 * Return an array containing all of the sources known to this context that re present the defining 292 * Return an array containing all of the sources known to this context that re present the defining
298 * compilation unit of a library that can be run within a browser. The sources that are returned 293 * compilation unit of a library that can be run within a browser. The sources that are returned
299 * represent libraries that have a 'main' method and are either referenced by an HTML file or 294 * represent libraries that have a 'main' method and are either referenced by an HTML file or
300 * import, directly or indirectly, a client-only library. The contents of the array can be 295 * import, directly or indirectly, a client-only library. The contents of the array can be
301 * incomplete. 296 * incomplete.
302 * @return the sources known to this context that represent the defining compi lation unit of a 297 * @return the sources known to this context that represent the defining compi lation unit of a
303 * library that can be run within a browser 298 * library that can be run within a browser
304 */ 299 */
305 List<Source> get launchableClientLibrarySources; 300 List<Source> get launchableClientLibrarySources;
306 301
307 /** 302 /**
308 * Return an array containing all of the sources known to this context that re present the defining 303 * Return an array containing all of the sources known to this context that re present the defining
309 * compilation unit of a library that can be run outside of a browser. The con tents of the array 304 * compilation unit of a library that can be run outside of a browser. The con tents of the array
310 * can be incomplete. 305 * can be incomplete.
311 * @return the sources known to this context that represent the defining compi lation unit of a 306 * @return the sources known to this context that represent the defining compi lation unit of a
312 * library that can be run outside of a browser 307 * library that can be run outside of a browser
313 */ 308 */
314 List<Source> get launchableServerLibrarySources; 309 List<Source> get launchableServerLibrarySources;
315 310
316 /** 311 /**
317 * Return the sources for the defining compilation units of any libraries of w hich the given 312 * Return the sources for the defining compilation units of any libraries of w hich the given
318 * source is a part. The array will normally contain a single library because most Dart sources 313 * source is a part. The array will normally contain a single library because most Dart sources
319 * are only included in a single library, but it is possible to have a part th at is contained in 314 * are only included in a single library, but it is possible to have a part th at is contained in
320 * multiple identically named libraries. If the source represents the defining compilation unit of 315 * multiple identically named libraries. If the source represents the defining compilation unit of
321 * a library, then the returned array will contain the given source as its onl y element. If the 316 * a library, then the returned array will contain the given source as its onl y element. If the
322 * source does not represent a Dart source or is not known to this context, th e returned array 317 * source does not represent a Dart source or is not known to this context, th e returned array
323 * will be empty. The contents of the array can be incomplete. 318 * will be empty. The contents of the array can be incomplete.
324 * @param source the source contained in the returned libraries 319 * @param source the source contained in the returned libraries
325 * @return the sources for the libraries containing the given source 320 * @return the sources for the libraries containing the given source
326 */ 321 */
327 List<Source> getLibrariesContaining(Source source); 322 List<Source> getLibrariesContaining(Source source);
328 323
329 /** 324 /**
330 * Return the sources for the defining compilation units of any libraries that depend on the given 325 * Return the sources for the defining compilation units of any libraries that depend on the given
331 * library. One library depends on another if it either imports or exports tha t library. 326 * library. One library depends on another if it either imports or exports tha t library.
332 * @param librarySource the source for the defining compilation unit of the li brary being depended 327 * @param librarySource the source for the defining compilation unit of the li brary being depended
333 * on 328 * on
334 * @return the sources for the libraries that depend on the given library 329 * @return the sources for the libraries that depend on the given library
335 */ 330 */
336 List<Source> getLibrariesDependingOn(Source librarySource); 331 List<Source> getLibrariesDependingOn(Source librarySource);
337 332
338 /** 333 /**
339 * Return the element model corresponding to the library defined by the given source, or{@code null} if the element model does not currently exist or if the l ibrary cannot be analyzed 334 * Return the element model corresponding to the library defined by the given source, or{@code null} if the element model does not currently exist or if the l ibrary cannot be analyzed
340 * for some reason. 335 * for some reason.
341 * @param source the source defining the library whose element model is to be returned 336 * @param source the source defining the library whose element model is to be returned
342 * @return the element model corresponding to the library defined by the given source 337 * @return the element model corresponding to the library defined by the given source
343 */ 338 */
344 LibraryElement getLibraryElement(Source source); 339 LibraryElement getLibraryElement(Source source);
345 340
346 /** 341 /**
347 * Return an array containing all of the sources known to this context that re present the defining 342 * Return an array containing all of the sources known to this context that re present the defining
348 * compilation unit of a library. The contents of the array can be incomplete. 343 * compilation unit of a library. The contents of the array can be incomplete.
349 * @return the sources known to this context that represent the defining compi lation unit of a 344 * @return the sources known to this context that represent the defining compi lation unit of a
350 * library 345 * library
351 */ 346 */
352 List<Source> get librarySources; 347 List<Source> get librarySources;
353 348
354 /** 349 /**
355 * Return the line information for the given source, or {@code null} if the li ne information is 350 * Return the line information for the given source, or {@code null} if the li ne information is
356 * not known. The line information is used to map offsets from the beginning o f the source to line 351 * not known. The line information is used to map offsets from the beginning o f the source to line
357 * and column pairs. 352 * and column pairs.
358 * @param source the source whose line information is to be returned 353 * @param source the source whose line information is to be returned
359 * @return the line information for the given source 354 * @return the line information for the given source
360 * @see #computeLineInfo(Source) 355 * @see #computeLineInfo(Source)
361 */ 356 */
362 LineInfo getLineInfo(Source source); 357 LineInfo getLineInfo(Source source);
363 358
364 /** 359 /**
365 * Return a fully resolved AST for a single compilation unit within the given library, or{@code null} if the resolved AST is not already computed. 360 * Return a fully resolved AST for a single compilation unit within the given library, or{@code null} if the resolved AST is not already computed.
366 * @param unitSource the source of the compilation unit 361 * @param unitSource the source of the compilation unit
367 * @param library the library containing the compilation unit 362 * @param library the library containing the compilation unit
368 * @return a fully resolved AST for the compilation unit 363 * @return a fully resolved AST for the compilation unit
369 * @see #resolveCompilationUnit(Source,LibraryElement) 364 * @see #resolveCompilationUnit(Source,LibraryElement)
370 */ 365 */
371 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary); 366 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary);
372 367
373 /** 368 /**
374 * Return a fully resolved AST for a single compilation unit within the given library, or{@code null} if the resolved AST is not already computed. 369 * Return a fully resolved AST for a single compilation unit within the given library, or{@code null} if the resolved AST is not already computed.
375 * @param unitSource the source of the compilation unit 370 * @param unitSource the source of the compilation unit
376 * @param librarySource the source of the defining compilation unit of the lib rary containing the 371 * @param librarySource the source of the defining compilation unit of the lib rary containing the
377 * compilation unit 372 * compilation unit
378 * @return a fully resolved AST for the compilation unit 373 * @return a fully resolved AST for the compilation unit
379 * @see #resolveCompilationUnit(Source,Source) 374 * @see #resolveCompilationUnit(Source,Source)
380 */ 375 */
381 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource); 376 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource);
382 377
383 /** 378 /**
384 * Return the source factory used to create the sources that can be analyzed i n this context. 379 * Return the source factory used to create the sources that can be analyzed i n this context.
385 * @return the source factory used to create the sources that can be analyzed in this context 380 * @return the source factory used to create the sources that can be analyzed in this context
386 */ 381 */
387 SourceFactory get sourceFactory; 382 SourceFactory get sourceFactory;
388 383
389 /** 384 /**
390 * Return {@code true} if the given source is known to be the defining compila tion unit of a 385 * Return {@code true} if the given source is known to be the defining compila tion unit of a
391 * library that can be run on a client (references 'dart:html', either directl y or indirectly). 386 * library that can be run on a client (references 'dart:html', either directl y or indirectly).
392 * <p> 387 * <p>
393 * <b>Note:</b> In addition to the expected case of returning {@code false} if the source is known 388 * <b>Note:</b> In addition to the expected case of returning {@code false} if the source is known
394 * to be a library that cannot be run on a client, this method will also retur n {@code false} if 389 * to be a library that cannot be run on a client, this method will also retur n {@code false} if
395 * the source is not known to be a library or if we do not know whether it can be run on a client. 390 * the source is not known to be a library or if we do not know whether it can be run on a client.
396 * @param librarySource the source being tested 391 * @param librarySource the source being tested
397 * @return {@code true} if the given source is known to be a library that can be run on a client 392 * @return {@code true} if the given source is known to be a library that can be run on a client
398 */ 393 */
399 bool isClientLibrary(Source librarySource); 394 bool isClientLibrary(Source librarySource);
400 395
401 /** 396 /**
402 * Return {@code true} if the given source is known to be the defining compila tion unit of a 397 * Return {@code true} if the given source is known to be the defining compila tion unit of a
403 * library that can be run on the server (does not reference 'dart:html', eith er directly or 398 * library that can be run on the server (does not reference 'dart:html', eith er directly or
404 * indirectly). 399 * indirectly).
405 * <p> 400 * <p>
406 * <b>Note:</b> In addition to the expected case of returning {@code false} if the source is known 401 * <b>Note:</b> In addition to the expected case of returning {@code false} if the source is known
407 * to be a library that cannot be run on the server, this method will also ret urn {@code false} if 402 * to be a library that cannot be run on the server, this method will also ret urn {@code false} if
408 * the source is not known to be a library or if we do not know whether it can be run on the 403 * the source is not known to be a library or if we do not know whether it can be run on the
409 * server. 404 * server.
410 * @param librarySource the source being tested 405 * @param librarySource the source being tested
411 * @return {@code true} if the given source is known to be a library that can be run on the server 406 * @return {@code true} if the given source is known to be a library that can be run on the server
412 */ 407 */
413 bool isServerLibrary(Source librarySource); 408 bool isServerLibrary(Source librarySource);
414 409
415 /** 410 /**
416 * Add the sources contained in the specified context to this context's collec tion of sources. 411 * Add the sources contained in the specified context to this context's collec tion of sources.
417 * This method is called when an existing context's pubspec has been removed, and the contained 412 * This method is called when an existing context's pubspec has been removed, and the contained
418 * sources should be reanalyzed as part of this context. 413 * sources should be reanalyzed as part of this context.
419 * @param context the context being merged 414 * @param context the context being merged
420 */ 415 */
421 void mergeContext(AnalysisContext context); 416 void mergeContext(AnalysisContext context);
422 417
423 /** 418 /**
424 * Parse a single source to produce an AST structure. The resulting AST struct ure may or may not 419 * Parse a single source to produce an AST structure. The resulting AST struct ure may or may not
425 * be resolved, and may have a slightly different structure depending upon whe ther it is resolved. 420 * be resolved, and may have a slightly different structure depending upon whe ther it is resolved.
426 * @param source the source to be parsed 421 * @param source the source to be parsed
427 * @return the AST structure representing the content of the source 422 * @return the AST structure representing the content of the source
428 * @throws AnalysisException if the analysis could not be performed 423 * @throws AnalysisException if the analysis could not be performed
429 */ 424 */
430 CompilationUnit parseCompilationUnit(Source source); 425 CompilationUnit parseCompilationUnit(Source source);
431 426
432 /** 427 /**
433 * Parse a single HTML source to produce an AST structure. The resulting HTML AST structure may or 428 * Parse a single HTML source to produce an AST structure. The resulting HTML AST structure may or
434 * may not be resolved, and may have a slightly different structure depending upon whether it is 429 * may not be resolved, and may have a slightly different structure depending upon whether it is
435 * resolved. 430 * resolved.
436 * @param source the HTML source to be parsed 431 * @param source the HTML source to be parsed
437 * @return the parse result (not {@code null}) 432 * @return the parse result (not {@code null})
438 * @throws AnalysisException if the analysis could not be performed 433 * @throws AnalysisException if the analysis could not be performed
439 */ 434 */
440 HtmlUnit parseHtmlUnit(Source source); 435 HtmlUnit parseHtmlUnit(Source source);
441 436
442 /** 437 /**
443 * Perform the next unit of work required to keep the analysis results up-to-d ate and return 438 * Perform the next unit of work required to keep the analysis results up-to-d ate and return
444 * information about the consequent changes to the analysis results. If there were no results the 439 * information about the consequent changes to the analysis results. If there were no results the
445 * returned array will be empty. If there are no more units of work required, then this method 440 * returned array will be empty. If there are no more units of work required, then this method
446 * returns {@code null}. This method can be long running. 441 * returns {@code null}. This method can be long running.
447 * @return an array containing notices of changes to the analysis results 442 * @return an array containing notices of changes to the analysis results
448 */ 443 */
449 List<ChangeNotice> performAnalysisTask(); 444 List<ChangeNotice> performAnalysisTask();
450 445
451 /** 446 /**
452 * Parse and resolve a single source within the given context to produce a ful ly resolved AST. 447 * Parse and resolve a single source within the given context to produce a ful ly resolved AST.
453 * @param unitSource the source to be parsed and resolved 448 * @param unitSource the source to be parsed and resolved
454 * @param library the library containing the source to be resolved 449 * @param library the library containing the source to be resolved
455 * @return the result of resolving the AST structure representing the content of the source in the 450 * @return the result of resolving the AST structure representing the content of the source in the
456 * context of the given library 451 * context of the given library
457 * @throws AnalysisException if the analysis could not be performed 452 * @throws AnalysisException if the analysis could not be performed
458 * @see #getResolvedCompilationUnit(Source,LibraryElement) 453 * @see #getResolvedCompilationUnit(Source,LibraryElement)
459 */ 454 */
460 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry); 455 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry);
461 456
462 /** 457 /**
463 * Parse and resolve a single source within the given context to produce a ful ly resolved AST. 458 * Parse and resolve a single source within the given context to produce a ful ly resolved AST.
464 * @param unitSource the source to be parsed and resolved 459 * @param unitSource the source to be parsed and resolved
465 * @param librarySource the source of the defining compilation unit of the lib rary containing the 460 * @param librarySource the source of the defining compilation unit of the lib rary containing the
466 * source to be resolved 461 * source to be resolved
467 * @return the result of resolving the AST structure representing the content of the source in the 462 * @return the result of resolving the AST structure representing the content of the source in the
468 * context of the given library 463 * context of the given library
469 * @throws AnalysisException if the analysis could not be performed 464 * @throws AnalysisException if the analysis could not be performed
470 * @see #getResolvedCompilationUnit(Source,Source) 465 * @see #getResolvedCompilationUnit(Source,Source)
471 */ 466 */
472 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc e); 467 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc e);
473 468
474 /** 469 /**
475 * Parse and resolve a single source within the given context to produce a ful ly resolved AST. 470 * Parse and resolve a single source within the given context to produce a ful ly resolved AST.
476 * @param htmlSource the source to be parsed and resolved 471 * @param htmlSource the source to be parsed and resolved
477 * @return the result of resolving the AST structure representing the content of the source 472 * @return the result of resolving the AST structure representing the content of the source
478 * @throws AnalysisException if the analysis could not be performed 473 * @throws AnalysisException if the analysis could not be performed
479 */ 474 */
480 HtmlUnit resolveHtmlUnit(Source htmlSource); 475 HtmlUnit resolveHtmlUnit(Source htmlSource);
481 476
482 /** 477 /**
483 * Set the set of analysis options controlling the behavior of this context to the given options. 478 * Set the set of analysis options controlling the behavior of this context to the given options.
484 * Clients can safely assume that all necessary analysis results have been inv alidated. 479 * Clients can safely assume that all necessary analysis results have been inv alidated.
485 * @param options the set of analysis options that will control the behavior o f this context 480 * @param options the set of analysis options that will control the behavior o f this context
486 */ 481 */
487 void set analysisOptions(AnalysisOptions options); 482 void set analysisOptions(AnalysisOptions options);
488 483
489 /** 484 /**
490 * Set the contents of the given source to the given contents and mark the sou rce as having 485 * Set the contents of the given source to the given contents and mark the sou rce as having
491 * changed. This has the effect of overriding the default contents of the sour ce. If the contents 486 * changed. This has the effect of overriding the default contents of the sour ce. If the contents
492 * are {@code null} the override is removed so that the default contents will be returned. 487 * are {@code null} the override is removed so that the default contents will be returned.
493 * @param source the source whose contents are being overridden 488 * @param source the source whose contents are being overridden
494 * @param contents the new contents of the source 489 * @param contents the new contents of the source
495 */ 490 */
496 void setContents(Source source, String contents); 491 void setContents(Source source, String contents);
497 492
498 /** 493 /**
499 * Set the source factory used to create the sources that can be analyzed in t his context to the 494 * Set the source factory used to create the sources that can be analyzed in t his context to the
500 * given source factory. Clients can safely assume that all analysis results h ave been 495 * given source factory. Clients can safely assume that all analysis results h ave been
501 * invalidated. 496 * invalidated.
502 * @param factory the source factory used to create the sources that can be an alyzed in this 497 * @param factory the source factory used to create the sources that can be an alyzed in this
503 * context 498 * context
504 */ 499 */
505 void set sourceFactory(SourceFactory factory); 500 void set sourceFactory(SourceFactory factory);
506 501
507 /** 502 /**
508 * Given a collection of sources with content that has changed, return an {@li nk Iterable}identifying the sources that need to be resolved. 503 * Given a collection of sources with content that has changed, return an {@li nk Iterable}identifying the sources that need to be resolved.
509 * @param changedSources an array of sources (not {@code null}, contains no {@ code null}s) 504 * @param changedSources an array of sources (not {@code null}, contains no {@ code null}s)
510 * @return An iterable returning the sources to be resolved 505 * @return An iterable returning the sources to be resolved
511 */ 506 */
512 Iterable<Source> sourcesToResolve(List<Source> changedSources); 507 Iterable<Source> sourcesToResolve(List<Source> changedSources);
513 } 508 }
514
515 /** 509 /**
516 * The interface {@code AnalysisErrorInfo} contains the analysis errors and line information for the 510 * The interface {@code AnalysisErrorInfo} contains the analysis errors and line information for the
517 * errors. 511 * errors.
518 */ 512 */
519 abstract class AnalysisErrorInfo { 513 abstract class AnalysisErrorInfo {
520 514
521 /** 515 /**
522 * Return the errors that as a result of the analysis, or {@code null} if ther e were no errors. 516 * Return the errors that as a result of the analysis, or {@code null} if ther e were no errors.
523 * @return the errors as a result of the analysis 517 * @return the errors as a result of the analysis
524 */ 518 */
525 List<AnalysisError> get errors; 519 List<AnalysisError> get errors;
526 520
527 /** 521 /**
528 * Return the line information associated with the errors, or {@code null} if there were no 522 * Return the line information associated with the errors, or {@code null} if there were no
529 * errors. 523 * errors.
530 * @return the line information associated with the errors 524 * @return the line information associated with the errors
531 */ 525 */
532 LineInfo get lineInfo; 526 LineInfo get lineInfo;
533 } 527 }
534
535 /** 528 /**
536 * Instances of the class {@code AnalysisException} represent an exception that occurred during the 529 * Instances of the class {@code AnalysisException} represent an exception that occurred during the
537 * analysis of one or more sources. 530 * analysis of one or more sources.
538 * @coverage dart.engine 531 * @coverage dart.engine
539 */ 532 */
540 class AnalysisException extends JavaException { 533 class AnalysisException extends JavaException {
541 534
542 /** 535 /**
543 * Initialize a newly created exception. 536 * Initialize a newly created exception.
544 */ 537 */
545 AnalysisException() : super() { 538 AnalysisException() : super() {
546 _jtd_constructor_125_impl(); 539 _jtd_constructor_125_impl();
547 } 540 }
548 _jtd_constructor_125_impl() { 541 _jtd_constructor_125_impl() {
549 } 542 }
550 543
551 /** 544 /**
552 * Initialize a newly created exception to have the given message. 545 * Initialize a newly created exception to have the given message.
553 * @param message the message associated with the exception 546 * @param message the message associated with the exception
554 */ 547 */
555 AnalysisException.con1(String message) : super(message) { 548 AnalysisException.con1(String message) : super(message) {
556 _jtd_constructor_126_impl(message); 549 _jtd_constructor_126_impl(message);
557 } 550 }
558 _jtd_constructor_126_impl(String message) { 551 _jtd_constructor_126_impl(String message) {
559 } 552 }
560 553
561 /** 554 /**
562 * Initialize a newly created exception to have the given message and cause. 555 * Initialize a newly created exception to have the given message and cause.
563 * @param message the message associated with the exception 556 * @param message the message associated with the exception
564 * @param cause the underlying exception that caused this exception 557 * @param cause the underlying exception that caused this exception
565 */ 558 */
566 AnalysisException.con2(String message, Exception cause) : super(message, cause ) { 559 AnalysisException.con2(String message, Exception cause) : super(message, cause ) {
567 _jtd_constructor_127_impl(message, cause); 560 _jtd_constructor_127_impl(message, cause);
568 } 561 }
569 _jtd_constructor_127_impl(String message, Exception cause) { 562 _jtd_constructor_127_impl(String message, Exception cause) {
570 } 563 }
571 564
572 /** 565 /**
573 * Initialize a newly created exception to have the given cause. 566 * Initialize a newly created exception to have the given cause.
574 * @param cause the underlying exception that caused this exception 567 * @param cause the underlying exception that caused this exception
575 */ 568 */
576 AnalysisException.con3(Exception cause) : super.withCause(cause) { 569 AnalysisException.con3(Exception cause) : super.withCause(cause) {
577 _jtd_constructor_128_impl(cause); 570 _jtd_constructor_128_impl(cause);
578 } 571 }
579 _jtd_constructor_128_impl(Exception cause) { 572 _jtd_constructor_128_impl(Exception cause) {
580 } 573 }
581 } 574 }
582
583 /** 575 /**
584 * The interface {@code AnalysisOptions} defines the behavior of objects that pr ovide access to a 576 * The interface {@code AnalysisOptions} defines the behavior of objects that pr ovide access to a
585 * set of analysis options used to control the behavior of an analysis context. 577 * set of analysis options used to control the behavior of an analysis context.
586 */ 578 */
587 abstract class AnalysisOptions { 579 abstract class AnalysisOptions {
588 580
589 /** 581 /**
590 * Return {@code true} if analysis is to use strict mode. In strict mode, erro r reporting is based 582 * Return {@code true} if analysis is to use strict mode. In strict mode, erro r reporting is based
591 * exclusively on the static type information. 583 * exclusively on the static type information.
592 * @return {@code true} if analysis is to use strict mode 584 * @return {@code true} if analysis is to use strict mode
593 */ 585 */
594 bool get strictMode; 586 bool get strictMode;
595 } 587 }
596
597 /** 588 /**
598 * The interface {@code ChangeNotice} defines the behavior of objects that repre sent a change to the 589 * The interface {@code ChangeNotice} defines the behavior of objects that repre sent a change to the
599 * analysis results associated with a given source. 590 * analysis results associated with a given source.
600 * @coverage dart.engine 591 * @coverage dart.engine
601 */ 592 */
602 abstract class ChangeNotice implements AnalysisErrorInfo { 593 abstract class ChangeNotice implements AnalysisErrorInfo {
603 594
604 /** 595 /**
605 * Return the fully resolved AST that changed as a result of the analysis, or {@code null} if the 596 * Return the fully resolved AST that changed as a result of the analysis, or {@code null} if the
606 * AST was not changed. 597 * AST was not changed.
607 * @return the fully resolved AST that changed as a result of the analysis 598 * @return the fully resolved AST that changed as a result of the analysis
608 */ 599 */
609 CompilationUnit get compilationUnit; 600 CompilationUnit get compilationUnit;
610 601
611 /** 602 /**
612 * Return the source for which the result is being reported. 603 * Return the source for which the result is being reported.
613 * @return the source for which the result is being reported 604 * @return the source for which the result is being reported
614 */ 605 */
615 Source get source; 606 Source get source;
616 } 607 }
617
618 /** 608 /**
619 * Instances of the class {@code ChangeSet} indicate what sources have been adde d, changed, or 609 * Instances of the class {@code ChangeSet} indicate what sources have been adde d, changed, or
620 * removed. 610 * removed.
621 * @coverage dart.engine 611 * @coverage dart.engine
622 */ 612 */
623 class ChangeSet { 613 class ChangeSet {
624 614
625 /** 615 /**
626 * A list containing the sources that have been added. 616 * A list containing the sources that have been added.
627 */ 617 */
628 List<Source> _added2 = new List<Source>(); 618 List<Source> _added2 = new List<Source>();
629 619
630 /** 620 /**
631 * A list containing the sources that have been changed. 621 * A list containing the sources that have been changed.
632 */ 622 */
633 List<Source> _changed2 = new List<Source>(); 623 List<Source> _changed2 = new List<Source>();
634 624
635 /** 625 /**
636 * A list containing the sources that have been removed. 626 * A list containing the sources that have been removed.
637 */ 627 */
638 List<Source> _removed2 = new List<Source>(); 628 List<Source> _removed2 = new List<Source>();
639 629
640 /** 630 /**
641 * A list containing the source containers specifying additional sources that have been removed. 631 * A list containing the source containers specifying additional sources that have been removed.
642 */ 632 */
643 List<SourceContainer> _removedContainers = new List<SourceContainer>(); 633 List<SourceContainer> _removedContainers = new List<SourceContainer>();
644 634
645 /** 635 /**
646 * Record that the specified source has been added and that it's content is th e default contents 636 * Record that the specified source has been added and that it's content is th e default contents
647 * of the source. 637 * of the source.
648 * @param source the source that was added 638 * @param source the source that was added
649 */ 639 */
650 void added(Source source) { 640 void added(Source source) {
651 _added2.add(source); 641 _added2.add(source);
652 } 642 }
653 643
654 /** 644 /**
655 * Record that the specified source has been changed and that it's content is the default contents 645 * Record that the specified source has been changed and that it's content is the default contents
656 * of the source. 646 * of the source.
657 * @param source the source that was changed 647 * @param source the source that was changed
658 */ 648 */
659 void changed(Source source) { 649 void changed(Source source) {
660 _changed2.add(source); 650 _changed2.add(source);
661 } 651 }
662 652
663 /** 653 /**
664 * Return a collection of the sources that have been added. 654 * Return a collection of the sources that have been added.
665 * @return a collection of the sources that have been added 655 * @return a collection of the sources that have been added
666 */ 656 */
667 List<Source> get added3 => _added2; 657 List<Source> get added3 => _added2;
668 658
669 /** 659 /**
670 * Return a collection of sources that have been changed. 660 * Return a collection of sources that have been changed.
671 * @return a collection of sources that have been changed 661 * @return a collection of sources that have been changed
672 */ 662 */
673 List<Source> get changed3 => _changed2; 663 List<Source> get changed3 => _changed2;
674 664
675 /** 665 /**
676 * Return a list containing the sources that were removed. 666 * Return a list containing the sources that were removed.
677 * @return a list containing the sources that were removed 667 * @return a list containing the sources that were removed
678 */ 668 */
679 List<Source> get removed => _removed2; 669 List<Source> get removed => _removed2;
680 670
681 /** 671 /**
682 * Return a list containing the source containers that were removed. 672 * Return a list containing the source containers that were removed.
683 * @return a list containing the source containers that were removed 673 * @return a list containing the source containers that were removed
684 */ 674 */
685 List<SourceContainer> get removedContainers => _removedContainers; 675 List<SourceContainer> get removedContainers => _removedContainers;
686 676
687 /** 677 /**
688 * Return {@code true} if this change set does not contain any changes. 678 * Return {@code true} if this change set does not contain any changes.
689 * @return {@code true} if this change set does not contain any changes 679 * @return {@code true} if this change set does not contain any changes
690 */ 680 */
691 bool isEmpty() => _added2.isEmpty && _changed2.isEmpty && _removed2.isEmpty && _removedContainers.isEmpty; 681 bool isEmpty() => _added2.isEmpty && _changed2.isEmpty && _removed2.isEmpty && _removedContainers.isEmpty;
692 682
693 /** 683 /**
694 * Record that the specified source has been removed. 684 * Record that the specified source has been removed.
695 * @param source the source that was removed 685 * @param source the source that was removed
696 */ 686 */
697 void removed3(Source source) { 687 void removed3(Source source) {
698 if (source != null) { 688 if (source != null) {
699 _removed2.add(source); 689 _removed2.add(source);
700 } 690 }
701 } 691 }
702 692
703 /** 693 /**
704 * Record that the specified source container has been removed. 694 * Record that the specified source container has been removed.
705 * @param container the source container that was removed 695 * @param container the source container that was removed
706 */ 696 */
707 void removedContainer(SourceContainer container) { 697 void removedContainer(SourceContainer container) {
708 if (container != null) { 698 if (container != null) {
709 _removedContainers.add(container); 699 _removedContainers.add(container);
710 } 700 }
711 } 701 }
712 } 702 }
713
714 /** 703 /**
715 * The interface {@code DartEntry} defines the behavior of objects that maintain the information 704 * The interface {@code DartEntry} defines the behavior of objects that maintain the information
716 * cached by an analysis context about an individual Dart file. 705 * cached by an analysis context about an individual Dart file.
717 * @coverage dart.engine 706 * @coverage dart.engine
718 */ 707 */
719 abstract class DartEntry implements SourceEntry { 708 abstract class DartEntry implements SourceEntry {
720 709
721 /** 710 /**
722 * The data descriptor representing the library element for the library. This data is only 711 * The data descriptor representing the library element for the library. This data is only
723 * available for Dart files that are the defining compilation unit of a librar y. 712 * available for Dart files that are the defining compilation unit of a librar y.
724 */ 713 */
725 static DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<LibraryElem ent>("DartEntry.ELEMENT"); 714 static DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<LibraryElem ent>("DartEntry.ELEMENT");
726 715
727 /** 716 /**
728 * The data descriptor representing the list of referenced libraries. This dat a is only available 717 * The data descriptor representing the list of referenced libraries. This dat a is only available
729 * for Dart files that are the defining compilation unit of a library. 718 * for Dart files that are the defining compilation unit of a library.
730 */ 719 */
731 static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor< List<Source>>("DartEntry.REFERENCED_LIBRARIES"); 720 static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor< List<Source>>("DartEntry.REFERENCED_LIBRARIES");
732 721
733 /** 722 /**
734 * The data descriptor representing the list of included parts. This data is o nly available for 723 * The data descriptor representing the list of included parts. This data is o nly available for
735 * Dart files that are the defining compilation unit of a library. 724 * Dart files that are the defining compilation unit of a library.
736 */ 725 */
737 static DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<List<S ource>>("DartEntry.INCLUDED_PARTS"); 726 static DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<List<S ource>>("DartEntry.INCLUDED_PARTS");
738 727
739 /** 728 /**
740 * The data descriptor representing the client flag. This data is only availab le for Dart files 729 * The data descriptor representing the client flag. This data is only availab le for Dart files
741 * that are the defining compilation unit of a library. 730 * that are the defining compilation unit of a library.
742 */ 731 */
743 static DataDescriptor<bool> IS_CLIENT = new DataDescriptor<bool>("DartEntry.IS _CLIENT"); 732 static DataDescriptor<bool> IS_CLIENT = new DataDescriptor<bool>("DartEntry.IS _CLIENT");
744 733
745 /** 734 /**
746 * The data descriptor representing the launchable flag. This data is only ava ilable for Dart 735 * The data descriptor representing the launchable flag. This data is only ava ilable for Dart
747 * files that are the defining compilation unit of a library. 736 * files that are the defining compilation unit of a library.
748 */ 737 */
749 static DataDescriptor<bool> IS_LAUNCHABLE = new DataDescriptor<bool>("DartEntr y.IS_LAUNCHABLE"); 738 static DataDescriptor<bool> IS_LAUNCHABLE = new DataDescriptor<bool>("DartEntr y.IS_LAUNCHABLE");
750 739
751 /** 740 /**
752 * The data descriptor representing the errors resulting from parsing the sour ce. 741 * The data descriptor representing the errors resulting from parsing the sour ce.
753 */ 742 */
754 static DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescriptor<L ist<AnalysisError>>("DartEntry.PARSE_ERRORS"); 743 static DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescriptor<L ist<AnalysisError>>("DartEntry.PARSE_ERRORS");
755 744
756 /** 745 /**
757 * The data descriptor representing the parsed AST structure. 746 * The data descriptor representing the parsed AST structure.
758 */ 747 */
759 static DataDescriptor<CompilationUnit> PARSED_UNIT = new DataDescriptor<Compil ationUnit>("DartEntry.PARSED_UNIT"); 748 static DataDescriptor<CompilationUnit> PARSED_UNIT = new DataDescriptor<Compil ationUnit>("DartEntry.PARSED_UNIT");
760 749
761 /** 750 /**
762 * The data descriptor representing the public namespace of the library. This data is only 751 * The data descriptor representing the public namespace of the library. This data is only
763 * available for Dart files that are the defining compilation unit of a librar y. 752 * available for Dart files that are the defining compilation unit of a librar y.
764 */ 753 */
765 static DataDescriptor<Namespace> PUBLIC_NAMESPACE = new DataDescriptor<Namespa ce>("DartEntry.PUBLIC_NAMESPACE"); 754 static DataDescriptor<Namespace> PUBLIC_NAMESPACE = new DataDescriptor<Namespa ce>("DartEntry.PUBLIC_NAMESPACE");
766 755
767 /** 756 /**
768 * The data descriptor representing the errors resulting from resolving the so urce. 757 * The data descriptor representing the errors resulting from resolving the so urce.
769 */ 758 */
770 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip tor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS"); 759 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip tor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS");
771 760
772 /** 761 /**
773 * The data descriptor representing the resolved AST structure. 762 * The data descriptor representing the resolved AST structure.
774 */ 763 */
775 static DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescriptor<Comp ilationUnit>("DartEntry.RESOLVED_UNIT"); 764 static DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescriptor<Comp ilationUnit>("DartEntry.RESOLVED_UNIT");
776 765
777 /** 766 /**
778 * The data descriptor representing the source kind. 767 * The data descriptor representing the source kind.
779 */ 768 */
780 static DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<SourceKind> ("DartEntry.SOURCE_KIND"); 769 static DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<SourceKind> ("DartEntry.SOURCE_KIND");
781 770
782 /** 771 /**
783 * Return all of the errors associated with the compilation unit that are curr ently cached. 772 * Return all of the errors associated with the compilation unit that are curr ently cached.
784 * @return all of the errors associated with the compilation unit 773 * @return all of the errors associated with the compilation unit
785 */ 774 */
786 List<AnalysisError> get allErrors; 775 List<AnalysisError> get allErrors;
787 776
788 /** 777 /**
789 * Return a valid parsed compilation unit, either an unresolved AST structure or the result of 778 * Return a valid parsed compilation unit, either an unresolved AST structure or the result of
790 * resolving the AST structure in the context of some library, or {@code null} if there is no 779 * resolving the AST structure in the context of some library, or {@code null} if there is no
791 * parsed compilation unit available. 780 * parsed compilation unit available.
792 * @return a valid parsed compilation unit 781 * @return a valid parsed compilation unit
793 */ 782 */
794 CompilationUnit get anyParsedCompilationUnit; 783 CompilationUnit get anyParsedCompilationUnit;
795 784
796 /** 785 /**
797 * Return the result of resolving the compilation unit as part of any library, or {@code null} if 786 * Return the result of resolving the compilation unit as part of any library, or {@code null} if
798 * there is no cached resolved compilation unit. 787 * there is no cached resolved compilation unit.
799 * @return any resolved compilation unit 788 * @return any resolved compilation unit
800 */ 789 */
801 CompilationUnit get anyResolvedCompilationUnit; 790 CompilationUnit get anyResolvedCompilationUnit;
802 791
803 /** 792 /**
804 * Return the state of the data represented by the given descriptor in the con text of the given 793 * Return the state of the data represented by the given descriptor in the con text of the given
805 * library. 794 * library.
806 * @param descriptor the descriptor representing the data whose state is to be returned 795 * @param descriptor the descriptor representing the data whose state is to be returned
807 * @param librarySource the source of the defining compilation unit of the lib rary that is the 796 * @param librarySource the source of the defining compilation unit of the lib rary that is the
808 * context for the data 797 * context for the data
809 * @return the value of the data represented by the given descriptor and libra ry 798 * @return the value of the data represented by the given descriptor and libra ry
810 */ 799 */
811 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource); 800 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource);
812 801
813 /** 802 /**
814 * Return the value of the data represented by the given descriptor in the con text of the given 803 * Return the value of the data represented by the given descriptor in the con text of the given
815 * library, or {@code null} if the data represented by the descriptor is not i n the cache. 804 * library, or {@code null} if the data represented by the descriptor is not i n the cache.
816 * @param descriptor the descriptor representing which data is to be returned 805 * @param descriptor the descriptor representing which data is to be returned
817 * @param librarySource the source of the defining compilation unit of the lib rary that is the 806 * @param librarySource the source of the defining compilation unit of the lib rary that is the
818 * context for the data 807 * context for the data
819 * @return the value of the data represented by the given descriptor and libra ry 808 * @return the value of the data represented by the given descriptor and libra ry
820 */ 809 */
821 Object getValue2(DataDescriptor descriptor, Source librarySource); 810 Object getValue2(DataDescriptor descriptor, Source librarySource);
822 DartEntryImpl get writableCopy; 811 DartEntryImpl get writableCopy;
823 } 812 }
824
825 /** 813 /**
826 * Instances of the class {@code DartEntryImpl} implement a {@link DartEntry}. 814 * Instances of the class {@code DartEntryImpl} implement a {@link DartEntry}.
827 * @coverage dart.engine 815 * @coverage dart.engine
828 */ 816 */
829 class DartEntryImpl extends SourceEntryImpl implements DartEntry { 817 class DartEntryImpl extends SourceEntryImpl implements DartEntry {
830 818
831 /** 819 /**
832 * The state of the cached source kind. 820 * The state of the cached source kind.
833 */ 821 */
834 CacheState _sourceKindState = CacheState.INVALID; 822 CacheState _sourceKindState = CacheState.INVALID;
835 823
836 /** 824 /**
837 * The kind of this source. 825 * The kind of this source.
838 */ 826 */
839 SourceKind _sourceKind = SourceKind.UNKNOWN; 827 SourceKind _sourceKind = SourceKind.UNKNOWN;
840 828
841 /** 829 /**
842 * The state of the cached parsed compilation unit. 830 * The state of the cached parsed compilation unit.
843 */ 831 */
844 CacheState _parsedUnitState = CacheState.INVALID; 832 CacheState _parsedUnitState = CacheState.INVALID;
845 833
846 /** 834 /**
847 * The parsed compilation unit, or {@code null} if the parsed compilation unit is not currently 835 * The parsed compilation unit, or {@code null} if the parsed compilation unit is not currently
848 * cached. 836 * cached.
849 */ 837 */
850 CompilationUnit _parsedUnit; 838 CompilationUnit _parsedUnit;
851 839
852 /** 840 /**
853 * The state of the cached parse errors. 841 * The state of the cached parse errors.
854 */ 842 */
855 CacheState _parseErrorsState = CacheState.INVALID; 843 CacheState _parseErrorsState = CacheState.INVALID;
856 844
857 /** 845 /**
858 * The errors produced while scanning and parsing the compilation unit, or {@c ode null} if the 846 * The errors produced while scanning and parsing the compilation unit, or {@c ode null} if the
859 * errors are not currently cached. 847 * errors are not currently cached.
860 */ 848 */
861 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; 849 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS;
862 850
863 /** 851 /**
864 * The state of the cached list of included parts. 852 * The state of the cached list of included parts.
865 */ 853 */
866 CacheState _includedPartsState = CacheState.INVALID; 854 CacheState _includedPartsState = CacheState.INVALID;
867 855
868 /** 856 /**
869 * The list of parts included in the library, or an empty array if the list is not currently 857 * The list of parts included in the library, or an empty array if the list is not currently
870 * cached. The list will be empty if the Dart file is a part rather than a lib rary. 858 * cached. The list will be empty if the Dart file is a part rather than a lib rary.
871 */ 859 */
872 List<Source> _includedParts = Source.EMPTY_ARRAY; 860 List<Source> _includedParts = Source.EMPTY_ARRAY;
873 861
874 /** 862 /**
875 * The state of the cached list of referenced libraries. 863 * The state of the cached list of referenced libraries.
876 */ 864 */
877 CacheState _referencedLibrariesState = CacheState.INVALID; 865 CacheState _referencedLibrariesState = CacheState.INVALID;
878 866
879 /** 867 /**
880 * The list of libraries referenced (imported or exported) by the library, or an empty array if 868 * The list of libraries referenced (imported or exported) by the library, or an empty array if
881 * the list is not currently cached. The list will be empty if the Dart file i s a part rather than 869 * the list is not currently cached. The list will be empty if the Dart file i s a part rather than
882 * a library. 870 * a library.
883 */ 871 */
884 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; 872 List<Source> _referencedLibraries = Source.EMPTY_ARRAY;
885 873
886 /** 874 /**
887 * The information known as a result of resolving this compilation unit as par t of the library 875 * The information known as a result of resolving this compilation unit as par t of the library
888 * that contains this unit. This field will never be {@code null}. 876 * that contains this unit. This field will never be {@code null}.
889 */ 877 */
890 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS tate(); 878 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS tate();
891 879
892 /** 880 /**
893 * The state of the cached library element. 881 * The state of the cached library element.
894 */ 882 */
895 CacheState _elementState = CacheState.INVALID; 883 CacheState _elementState = CacheState.INVALID;
896 884
897 /** 885 /**
898 * The element representing the library, or {@code null} if the element is not currently cached. 886 * The element representing the library, or {@code null} if the element is not currently cached.
899 */ 887 */
900 LibraryElement _element; 888 LibraryElement _element;
901 889
902 /** 890 /**
903 * The state of the cached public namespace. 891 * The state of the cached public namespace.
904 */ 892 */
905 CacheState _publicNamespaceState = CacheState.INVALID; 893 CacheState _publicNamespaceState = CacheState.INVALID;
906 894
907 /** 895 /**
908 * The public namespace of the library, or {@code null} if the namespace is no t currently cached. 896 * The public namespace of the library, or {@code null} if the namespace is no t currently cached.
909 */ 897 */
910 Namespace _publicNamespace; 898 Namespace _publicNamespace;
911 899
912 /** 900 /**
913 * The state of the cached client/ server flag. 901 * The state of the cached client/ server flag.
914 */ 902 */
915 CacheState _clientServerState = CacheState.INVALID; 903 CacheState _clientServerState = CacheState.INVALID;
916 904
917 /** 905 /**
918 * The state of the cached launchable flag. 906 * The state of the cached launchable flag.
919 */ 907 */
920 CacheState _launchableState = CacheState.INVALID; 908 CacheState _launchableState = CacheState.INVALID;
921 909
922 /** 910 /**
923 * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT _CODE}. 911 * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT _CODE}.
924 */ 912 */
925 int _bitmask = 0; 913 int _bitmask = 0;
926 914
927 /** 915 /**
928 * Mask indicating that this library is launchable: that the file has a main m ethod. 916 * Mask indicating that this library is launchable: that the file has a main m ethod.
929 */ 917 */
930 static int _LAUNCHABLE = 1 << 1; 918 static int _LAUNCHABLE = 1 << 1;
931 919
932 /** 920 /**
933 * Mask indicating that the library is client code: that the library depends o n the html library. 921 * Mask indicating that the library is client code: that the library depends o n the html library.
934 * If the library is not "client code", then it is referenced as "server code" . 922 * If the library is not "client code", then it is referenced as "server code" .
935 */ 923 */
936 static int _CLIENT_CODE = 1 << 2; 924 static int _CLIENT_CODE = 1 << 2;
937 List<AnalysisError> get allErrors { 925 List<AnalysisError> get allErrors {
938 List<AnalysisError> errors = new List<AnalysisError>(); 926 List<AnalysisError> errors = new List<AnalysisError>();
939 for (AnalysisError error in _parseErrors) { 927 for (AnalysisError error in _parseErrors) {
940 errors.add(error); 928 errors.add(error);
941 } 929 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 return null; 1041 return null;
1054 } else { 1042 } else {
1055 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1043 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1056 } 1044 }
1057 } 1045 }
1058 DartEntryImpl get writableCopy { 1046 DartEntryImpl get writableCopy {
1059 DartEntryImpl copy = new DartEntryImpl(); 1047 DartEntryImpl copy = new DartEntryImpl();
1060 copy.copyFrom(this); 1048 copy.copyFrom(this);
1061 return copy; 1049 return copy;
1062 } 1050 }
1063 1051
1064 /** 1052 /**
1065 * Invalidate all of the information associated with the compilation unit. 1053 * Invalidate all of the information associated with the compilation unit.
1066 */ 1054 */
1067 void invalidateAllInformation() { 1055 void invalidateAllInformation() {
1068 setState(SourceEntry.LINE_INFO, CacheState.INVALID); 1056 setState(SourceEntry.LINE_INFO, CacheState.INVALID);
1069 _sourceKind = SourceKind.UNKNOWN; 1057 _sourceKind = SourceKind.UNKNOWN;
1070 _sourceKindState = CacheState.INVALID; 1058 _sourceKindState = CacheState.INVALID;
1071 _parseErrors = AnalysisError.NO_ERRORS; 1059 _parseErrors = AnalysisError.NO_ERRORS;
1072 _parseErrorsState = CacheState.INVALID; 1060 _parseErrorsState = CacheState.INVALID;
1073 _parsedUnit = null; 1061 _parsedUnit = null;
1074 _parsedUnitState = CacheState.INVALID; 1062 _parsedUnitState = CacheState.INVALID;
1075 invalidateAllResolutionInformation(); 1063 invalidateAllResolutionInformation();
1076 } 1064 }
1077 1065
1078 /** 1066 /**
1079 * Invalidate all of the resolution information associated with the compilatio n unit. 1067 * Invalidate all of the resolution information associated with the compilatio n unit.
1080 */ 1068 */
1081 void invalidateAllResolutionInformation() { 1069 void invalidateAllResolutionInformation() {
1082 _element = null; 1070 _element = null;
1083 _elementState = CacheState.INVALID; 1071 _elementState = CacheState.INVALID;
1084 _includedParts = Source.EMPTY_ARRAY; 1072 _includedParts = Source.EMPTY_ARRAY;
1085 _includedPartsState = CacheState.INVALID; 1073 _includedPartsState = CacheState.INVALID;
1086 _referencedLibraries = Source.EMPTY_ARRAY; 1074 _referencedLibraries = Source.EMPTY_ARRAY;
1087 _referencedLibrariesState = CacheState.INVALID; 1075 _referencedLibrariesState = CacheState.INVALID;
1088 _bitmask = 0; 1076 _bitmask = 0;
1089 _clientServerState = CacheState.INVALID; 1077 _clientServerState = CacheState.INVALID;
1090 _launchableState = CacheState.INVALID; 1078 _launchableState = CacheState.INVALID;
1091 _publicNamespace = null; 1079 _publicNamespace = null;
1092 _publicNamespaceState = CacheState.INVALID; 1080 _publicNamespaceState = CacheState.INVALID;
1093 _resolutionState.invalidateAllResolutionInformation(); 1081 _resolutionState.invalidateAllResolutionInformation();
1094 } 1082 }
1095 1083
1096 /** 1084 /**
1097 * Record that an error occurred while attempting to scan or parse the entry r epresented by this 1085 * Record that an error occurred while attempting to scan or parse the entry r epresented by this
1098 * entry. This will set the state of all information, including any resolution -based information, 1086 * entry. This will set the state of all information, including any resolution -based information,
1099 * as being in error. 1087 * as being in error.
1100 */ 1088 */
1101 void recordParseError() { 1089 void recordParseError() {
1102 setState(SourceEntry.LINE_INFO, CacheState.ERROR); 1090 setState(SourceEntry.LINE_INFO, CacheState.ERROR);
1103 _sourceKind = SourceKind.UNKNOWN; 1091 _sourceKind = SourceKind.UNKNOWN;
1104 _sourceKindState = CacheState.ERROR; 1092 _sourceKindState = CacheState.ERROR;
1105 _parseErrors = AnalysisError.NO_ERRORS; 1093 _parseErrors = AnalysisError.NO_ERRORS;
1106 _parseErrorsState = CacheState.ERROR; 1094 _parseErrorsState = CacheState.ERROR;
1107 _parsedUnit = null; 1095 _parsedUnit = null;
1108 _parsedUnitState = CacheState.ERROR; 1096 _parsedUnitState = CacheState.ERROR;
1109 recordResolutionError(); 1097 recordResolutionError();
1110 } 1098 }
1111 1099
1112 /** 1100 /**
1113 * Record that the parse-related information for the associated source is abou t to be computed by 1101 * Record that the parse-related information for the associated source is abou t to be computed by
1114 * the current thread. 1102 * the current thread.
1115 */ 1103 */
1116 void recordParseInProcess() { 1104 void recordParseInProcess() {
1117 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { 1105 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
1118 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS); 1106 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS);
1119 } 1107 }
1120 if (_sourceKindState != CacheState.VALID) { 1108 if (_sourceKindState != CacheState.VALID) {
1121 _sourceKindState = CacheState.IN_PROCESS; 1109 _sourceKindState = CacheState.IN_PROCESS;
1122 } 1110 }
1123 if (_parseErrorsState != CacheState.VALID) { 1111 if (_parseErrorsState != CacheState.VALID) {
1124 _parseErrorsState = CacheState.IN_PROCESS; 1112 _parseErrorsState = CacheState.IN_PROCESS;
1125 } 1113 }
1126 if (_parsedUnitState != CacheState.VALID) { 1114 if (_parsedUnitState != CacheState.VALID) {
1127 _parsedUnitState = CacheState.IN_PROCESS; 1115 _parsedUnitState = CacheState.IN_PROCESS;
1128 } 1116 }
1129 } 1117 }
1130 1118
1131 /** 1119 /**
1132 * Record that an error occurred while attempting to scan or parse the entry r epresented by this 1120 * Record that an error occurred while attempting to scan or parse the entry r epresented by this
1133 * entry. This will set the state of all resolution-based information as being in error, but will 1121 * entry. This will set the state of all resolution-based information as being in error, but will
1134 * not change the state of any parse results. 1122 * not change the state of any parse results.
1135 */ 1123 */
1136 void recordResolutionError() { 1124 void recordResolutionError() {
1137 _element = null; 1125 _element = null;
1138 _elementState = CacheState.ERROR; 1126 _elementState = CacheState.ERROR;
1139 _includedParts = Source.EMPTY_ARRAY; 1127 _includedParts = Source.EMPTY_ARRAY;
1140 _includedPartsState = CacheState.ERROR; 1128 _includedPartsState = CacheState.ERROR;
1141 _referencedLibraries = Source.EMPTY_ARRAY; 1129 _referencedLibraries = Source.EMPTY_ARRAY;
1142 _referencedLibrariesState = CacheState.ERROR; 1130 _referencedLibrariesState = CacheState.ERROR;
1143 _bitmask = 0; 1131 _bitmask = 0;
1144 _clientServerState = CacheState.ERROR; 1132 _clientServerState = CacheState.ERROR;
1145 _launchableState = CacheState.ERROR; 1133 _launchableState = CacheState.ERROR;
1146 _publicNamespace = null; 1134 _publicNamespace = null;
1147 _publicNamespaceState = CacheState.ERROR; 1135 _publicNamespaceState = CacheState.ERROR;
1148 _resolutionState.recordResolutionError(); 1136 _resolutionState.recordResolutionError();
1149 } 1137 }
1150 1138
1151 /** 1139 /**
1152 * Remove any resolution information associated with this compilation unit bei ng part of the given 1140 * Remove any resolution information associated with this compilation unit bei ng part of the given
1153 * library, presumably because it is no longer part of the library. 1141 * library, presumably because it is no longer part of the library.
1154 * @param librarySource the source of the defining compilation unit of the lib rary that used to 1142 * @param librarySource the source of the defining compilation unit of the lib rary that used to
1155 * contain this part but no longer does 1143 * contain this part but no longer does
1156 */ 1144 */
1157 void removeResolution(Source librarySource2) { 1145 void removeResolution(Source librarySource2) {
1158 if (librarySource2 != null) { 1146 if (librarySource2 != null) {
1159 if (librarySource2 == _resolutionState._librarySource) { 1147 if (librarySource2 == _resolutionState._librarySource) {
1160 if (_resolutionState._nextState == null) { 1148 if (_resolutionState._nextState == null) {
1161 _resolutionState.invalidateAllResolutionInformation(); 1149 _resolutionState.invalidateAllResolutionInformation();
1162 } else { 1150 } else {
1163 _resolutionState = _resolutionState._nextState; 1151 _resolutionState = _resolutionState._nextState;
1164 } 1152 }
1165 } else { 1153 } else {
1166 DartEntryImpl_ResolutionState priorState = _resolutionState; 1154 DartEntryImpl_ResolutionState priorState = _resolutionState;
1167 DartEntryImpl_ResolutionState state = _resolutionState._nextState; 1155 DartEntryImpl_ResolutionState state = _resolutionState._nextState;
1168 while (state != null) { 1156 while (state != null) {
1169 if (librarySource2 == state._librarySource) { 1157 if (librarySource2 == state._librarySource) {
1170 priorState._nextState = state._nextState; 1158 priorState._nextState = state._nextState;
1171 break; 1159 break;
1172 } 1160 }
1173 priorState = state; 1161 priorState = state;
1174 state = state._nextState; 1162 state = state._nextState;
1175 } 1163 }
1176 } 1164 }
1177 } 1165 }
1178 } 1166 }
1179 1167
1180 /** 1168 /**
1181 * Set the results of parsing the compilation unit at the given time to the gi ven values. 1169 * Set the results of parsing the compilation unit at the given time to the gi ven values.
1182 * @param modificationStamp the earliest time at which the source was last mod ified before the 1170 * @param modificationStamp the earliest time at which the source was last mod ified before the
1183 * parsing was started 1171 * parsing was started
1184 * @param lineInfo the line information resulting from parsing the compilation unit 1172 * @param lineInfo the line information resulting from parsing the compilation unit
1185 * @param unit the AST structure resulting from parsing the compilation unit 1173 * @param unit the AST structure resulting from parsing the compilation unit
1186 * @param errors the parse errors resulting from parsing the compilation unit 1174 * @param errors the parse errors resulting from parsing the compilation unit
1187 */ 1175 */
1188 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit unit, List<AnalysisError> errors) { 1176 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit unit, List<AnalysisError> errors) {
1189 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { 1177 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { 1209 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) {
1222 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM PTY_ARRAY); 1210 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM PTY_ARRAY);
1223 _referencedLibrariesState = state; 1211 _referencedLibrariesState = state;
1224 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 1212 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
1225 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN); 1213 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN);
1226 _sourceKindState = state; 1214 _sourceKindState = state;
1227 } else { 1215 } else {
1228 super.setState(descriptor, state); 1216 super.setState(descriptor, state);
1229 } 1217 }
1230 } 1218 }
1231 1219
1232 /** 1220 /**
1233 * Set the state of the data represented by the given descriptor in the contex t of the given 1221 * Set the state of the data represented by the given descriptor in the contex t of the given
1234 * library to the given state. 1222 * library to the given state.
1235 * @param descriptor the descriptor representing the data whose state is to be set 1223 * @param descriptor the descriptor representing the data whose state is to be set
1236 * @param librarySource the source of the defining compilation unit of the lib rary that is the 1224 * @param librarySource the source of the defining compilation unit of the lib rary that is the
1237 * context for the data 1225 * context for the data
1238 * @param cacheState the new state of the data represented by the given descri ptor 1226 * @param cacheState the new state of the data represented by the given descri ptor
1239 */ 1227 */
1240 void setState2(DataDescriptor<Object> descriptor, Source librarySource, CacheS tate cacheState) { 1228 void setState2(DataDescriptor<Object> descriptor, Source librarySource, CacheS tate cacheState) {
1241 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour ce); 1229 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour ce);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { 1270 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) {
1283 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List <Source>); 1271 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List <Source>);
1284 _referencedLibrariesState = CacheState.VALID; 1272 _referencedLibrariesState = CacheState.VALID;
1285 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 1273 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
1286 _sourceKind = value as SourceKind; 1274 _sourceKind = value as SourceKind;
1287 _sourceKindState = CacheState.VALID; 1275 _sourceKindState = CacheState.VALID;
1288 } else { 1276 } else {
1289 super.setValue(descriptor, value); 1277 super.setValue(descriptor, value);
1290 } 1278 }
1291 } 1279 }
1292 1280
1293 /** 1281 /**
1294 * Set the value of the data represented by the given descriptor in the contex t of the given 1282 * Set the value of the data represented by the given descriptor in the contex t of the given
1295 * library to the given value, and set the state of that data to {@link CacheS tate#VALID}. 1283 * library to the given value, and set the state of that data to {@link CacheS tate#VALID}.
1296 * @param descriptor the descriptor representing which data is to have its val ue set 1284 * @param descriptor the descriptor representing which data is to have its val ue set
1297 * @param librarySource the source of the defining compilation unit of the lib rary that is the 1285 * @param librarySource the source of the defining compilation unit of the lib rary that is the
1298 * context for the data 1286 * context for the data
1299 * @param value the new value of the data represented by the given descriptor and library 1287 * @param value the new value of the data represented by the given descriptor and library
1300 */ 1288 */
1301 void setValue2(DataDescriptor descriptor, Source librarySource, Object value) { 1289 void setValue2(DataDescriptor descriptor, Source librarySource, Object value) {
1302 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour ce); 1290 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour ce);
(...skipping 20 matching lines...) Expand all
1323 _referencedLibraries = other._referencedLibraries; 1311 _referencedLibraries = other._referencedLibraries;
1324 _resolutionState.copyFrom(other._resolutionState); 1312 _resolutionState.copyFrom(other._resolutionState);
1325 _elementState = other._elementState; 1313 _elementState = other._elementState;
1326 _element = other._element; 1314 _element = other._element;
1327 _publicNamespaceState = other._publicNamespaceState; 1315 _publicNamespaceState = other._publicNamespaceState;
1328 _publicNamespace = other._publicNamespace; 1316 _publicNamespace = other._publicNamespace;
1329 _clientServerState = other._clientServerState; 1317 _clientServerState = other._clientServerState;
1330 _launchableState = other._launchableState; 1318 _launchableState = other._launchableState;
1331 _bitmask = other._bitmask; 1319 _bitmask = other._bitmask;
1332 } 1320 }
1333 1321
1334 /** 1322 /**
1335 * Return a resolution state for the specified library, creating one as necess ary. 1323 * Return a resolution state for the specified library, creating one as necess ary.
1336 * @param librarySource the library source (not {@code null}) 1324 * @param librarySource the library source (not {@code null})
1337 * @return the resolution state (not {@code null}) 1325 * @return the resolution state (not {@code null})
1338 */ 1326 */
1339 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2 ) { 1327 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2 ) {
1340 DartEntryImpl_ResolutionState state = _resolutionState; 1328 DartEntryImpl_ResolutionState state = _resolutionState;
1341 if (state._librarySource == null) { 1329 if (state._librarySource == null) {
1342 state._librarySource = librarySource2; 1330 state._librarySource = librarySource2;
1343 return state; 1331 return state;
1344 } 1332 }
1345 while (state._librarySource != librarySource2) { 1333 while (state._librarySource != librarySource2) {
1346 if (state._nextState == null) { 1334 if (state._nextState == null) {
1347 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta te(); 1335 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta te();
1348 newState._librarySource = librarySource2; 1336 newState._librarySource = librarySource2;
1349 state._nextState = newState; 1337 state._nextState = newState;
1350 return newState; 1338 return newState;
1351 } 1339 }
1352 state = state._nextState; 1340 state = state._nextState;
1353 } 1341 }
1354 return state; 1342 return state;
1355 } 1343 }
1356 1344
1357 /** 1345 /**
1358 * Given that one of the flags is being transitioned to the given state, retur n the value of the 1346 * Given that one of the flags is being transitioned to the given state, retur n the value of the
1359 * flags that should be kept in the cache. 1347 * flags that should be kept in the cache.
1360 * @param state the state to which the data is being transitioned 1348 * @param state the state to which the data is being transitioned
1361 * @param currentValue the value of the flags before the transition 1349 * @param currentValue the value of the flags before the transition
1362 * @param bitMask the mask used to access the bit whose state is being set 1350 * @param bitMask the mask used to access the bit whose state is being set
1363 * @return the value of the data that should be kept in the cache 1351 * @return the value of the data that should be kept in the cache
1364 */ 1352 */
1365 int updatedValue2(CacheState state, int currentValue, int bitMask) { 1353 int updatedValue2(CacheState state, int currentValue, int bitMask) {
1366 if (identical(state, CacheState.VALID)) { 1354 if (identical(state, CacheState.VALID)) {
1367 throw new IllegalArgumentException("Use setValue() to set the state to VAL ID"); 1355 throw new IllegalArgumentException("Use setValue() to set the state to VAL ID");
1368 } else if (identical(state, CacheState.IN_PROCESS)) { 1356 } else if (identical(state, CacheState.IN_PROCESS)) {
1369 return currentValue; 1357 return currentValue;
1370 } 1358 }
1371 return currentValue &= ~bitMask; 1359 return currentValue &= ~bitMask;
1372 } 1360 }
1373 } 1361 }
1374
1375 /** 1362 /**
1376 * Instances of the class {@code ResolutionState} represent the information prod uced by resolving 1363 * Instances of the class {@code ResolutionState} represent the information prod uced by resolving
1377 * a compilation unit as part of a specific library. 1364 * a compilation unit as part of a specific library.
1378 */ 1365 */
1379 class DartEntryImpl_ResolutionState { 1366 class DartEntryImpl_ResolutionState {
1380 1367
1381 /** 1368 /**
1382 * The next resolution state or {@code null} if none. 1369 * The next resolution state or {@code null} if none.
1383 */ 1370 */
1384 DartEntryImpl_ResolutionState _nextState; 1371 DartEntryImpl_ResolutionState _nextState;
1385 1372
1386 /** 1373 /**
1387 * The source for the defining compilation unit of the library that contains t his unit. If this 1374 * The source for the defining compilation unit of the library that contains t his unit. If this
1388 * unit is the defining compilation unit for it's library, then this will be t he source for this 1375 * unit is the defining compilation unit for it's library, then this will be t he source for this
1389 * unit. 1376 * unit.
1390 */ 1377 */
1391 Source _librarySource; 1378 Source _librarySource;
1392 1379
1393 /** 1380 /**
1394 * The state of the cached resolved compilation unit. 1381 * The state of the cached resolved compilation unit.
1395 */ 1382 */
1396 CacheState _resolvedUnitState = CacheState.INVALID; 1383 CacheState _resolvedUnitState = CacheState.INVALID;
1397 1384
1398 /** 1385 /**
1399 * The resolved compilation unit, or {@code null} if the resolved compilation unit is not 1386 * The resolved compilation unit, or {@code null} if the resolved compilation unit is not
1400 * currently cached. 1387 * currently cached.
1401 */ 1388 */
1402 CompilationUnit _resolvedUnit; 1389 CompilationUnit _resolvedUnit;
1403 1390
1404 /** 1391 /**
1405 * The state of the cached resolution errors. 1392 * The state of the cached resolution errors.
1406 */ 1393 */
1407 CacheState _resolutionErrorsState = CacheState.INVALID; 1394 CacheState _resolutionErrorsState = CacheState.INVALID;
1408 1395
1409 /** 1396 /**
1410 * The errors produced while resolving the compilation unit, or {@code null} i f the errors are 1397 * The errors produced while resolving the compilation unit, or {@code null} i f the errors are
1411 * not currently cached. 1398 * not currently cached.
1412 */ 1399 */
1413 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; 1400 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS;
1414 1401
1415 /** 1402 /**
1416 * Set this state to be exactly like the given state, recursively copying the next state as 1403 * Set this state to be exactly like the given state, recursively copying the next state as
1417 * necessary. 1404 * necessary.
1418 * @param other the state to be copied 1405 * @param other the state to be copied
1419 */ 1406 */
1420 void copyFrom(DartEntryImpl_ResolutionState other) { 1407 void copyFrom(DartEntryImpl_ResolutionState other) {
1421 _librarySource = other._librarySource; 1408 _librarySource = other._librarySource;
1422 _resolvedUnitState = other._resolvedUnitState; 1409 _resolvedUnitState = other._resolvedUnitState;
1423 _resolvedUnit = other._resolvedUnit; 1410 _resolvedUnit = other._resolvedUnit;
1424 _resolutionErrorsState = other._resolutionErrorsState; 1411 _resolutionErrorsState = other._resolutionErrorsState;
1425 _resolutionErrors = other._resolutionErrors; 1412 _resolutionErrors = other._resolutionErrors;
1426 if (other._nextState != null) { 1413 if (other._nextState != null) {
1427 _nextState = new DartEntryImpl_ResolutionState(); 1414 _nextState = new DartEntryImpl_ResolutionState();
1428 _nextState.copyFrom(other._nextState); 1415 _nextState.copyFrom(other._nextState);
1429 } 1416 }
1430 } 1417 }
1431 1418
1432 /** 1419 /**
1433 * Invalidate all of the resolution information associated with the compilatio n unit. 1420 * Invalidate all of the resolution information associated with the compilatio n unit.
1434 */ 1421 */
1435 void invalidateAllResolutionInformation() { 1422 void invalidateAllResolutionInformation() {
1436 _nextState = null; 1423 _nextState = null;
1437 _librarySource = null; 1424 _librarySource = null;
1438 _resolvedUnitState = CacheState.INVALID; 1425 _resolvedUnitState = CacheState.INVALID;
1439 _resolvedUnit = null; 1426 _resolvedUnit = null;
1440 _resolutionErrorsState = CacheState.INVALID; 1427 _resolutionErrorsState = CacheState.INVALID;
1441 _resolutionErrors = AnalysisError.NO_ERRORS; 1428 _resolutionErrors = AnalysisError.NO_ERRORS;
1442 } 1429 }
1443 1430
1444 /** 1431 /**
1445 * Record that an error occurred while attempting to scan or parse the entry r epresented by this 1432 * Record that an error occurred while attempting to scan or parse the entry r epresented by this
1446 * entry. This will set the state of all resolution-based information as being in error, but 1433 * entry. This will set the state of all resolution-based information as being in error, but
1447 * will not change the state of any parse results. 1434 * will not change the state of any parse results.
1448 */ 1435 */
1449 void recordResolutionError() { 1436 void recordResolutionError() {
1450 _nextState = null; 1437 _nextState = null;
1451 _librarySource = null; 1438 _librarySource = null;
1452 _resolvedUnitState = CacheState.ERROR; 1439 _resolvedUnitState = CacheState.ERROR;
1453 _resolvedUnit = null; 1440 _resolvedUnit = null;
1454 _resolutionErrorsState = CacheState.ERROR; 1441 _resolutionErrorsState = CacheState.ERROR;
1455 _resolutionErrors = AnalysisError.NO_ERRORS; 1442 _resolutionErrors = AnalysisError.NO_ERRORS;
1456 } 1443 }
1457 } 1444 }
1458
1459 /** 1445 /**
1460 * Instances of the class {@code DataDescriptor} are immutable constants represe nting data that can 1446 * Instances of the class {@code DataDescriptor} are immutable constants represe nting data that can
1461 * be stored in the cache. 1447 * be stored in the cache.
1462 */ 1448 */
1463 class DataDescriptor<E> { 1449 class DataDescriptor<E> {
1464 1450
1465 /** 1451 /**
1466 * The name of the descriptor, used for debugging purposes. 1452 * The name of the descriptor, used for debugging purposes.
1467 */ 1453 */
1468 String _name; 1454 String _name;
1469 1455
1470 /** 1456 /**
1471 * Initialize a newly created descriptor to have the given name. 1457 * Initialize a newly created descriptor to have the given name.
1472 * @param name the name of the descriptor 1458 * @param name the name of the descriptor
1473 */ 1459 */
1474 DataDescriptor(String name) { 1460 DataDescriptor(String name) {
1475 this._name = name; 1461 this._name = name;
1476 } 1462 }
1477 String toString() => _name; 1463 String toString() => _name;
1478 } 1464 }
1479
1480 /** 1465 /**
1481 * The interface {@code HtmlEntry} defines the behavior of objects that maintain the information 1466 * The interface {@code HtmlEntry} defines the behavior of objects that maintain the information
1482 * cached by an analysis context about an individual HTML file. 1467 * cached by an analysis context about an individual HTML file.
1483 * @coverage dart.engine 1468 * @coverage dart.engine
1484 */ 1469 */
1485 abstract class HtmlEntry implements SourceEntry { 1470 abstract class HtmlEntry implements SourceEntry {
1486 1471
1487 /** 1472 /**
1488 * The data descriptor representing the HTML element. 1473 * The data descriptor representing the HTML element.
1489 */ 1474 */
1490 static DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElement>(" HtmlEntry.ELEMENT"); 1475 static DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElement>(" HtmlEntry.ELEMENT");
1491 1476
1492 /** 1477 /**
1493 * The data descriptor representing the parsed AST structure. 1478 * The data descriptor representing the parsed AST structure.
1494 */ 1479 */
1495 static DataDescriptor<HtmlUnit> PARSED_UNIT = new DataDescriptor<HtmlUnit>("Ht mlEntry.PARSED_UNIT"); 1480 static DataDescriptor<HtmlUnit> PARSED_UNIT = new DataDescriptor<HtmlUnit>("Ht mlEntry.PARSED_UNIT");
1496 1481
1497 /** 1482 /**
1498 * The data descriptor representing the list of referenced libraries. 1483 * The data descriptor representing the list of referenced libraries.
1499 */ 1484 */
1500 static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor< List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); 1485 static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor< List<Source>>("HtmlEntry.REFERENCED_LIBRARIES");
1501 1486
1502 /** 1487 /**
1503 * The data descriptor representing the errors resulting from resolving the so urce. 1488 * The data descriptor representing the errors resulting from resolving the so urce.
1504 */ 1489 */
1505 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip tor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); 1490 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip tor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS");
1506 1491
1507 /** 1492 /**
1508 * The data descriptor representing the resolved AST structure. 1493 * The data descriptor representing the resolved AST structure.
1509 */ 1494 */
1510 static DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlUnit>(" HtmlEntry.RESOLVED_UNIT"); 1495 static DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlUnit>(" HtmlEntry.RESOLVED_UNIT");
1511 1496
1512 /** 1497 /**
1513 * Return all of the errors associated with the compilation unit that are curr ently cached. 1498 * Return all of the errors associated with the compilation unit that are curr ently cached.
1514 * @return all of the errors associated with the compilation unit 1499 * @return all of the errors associated with the compilation unit
1515 */ 1500 */
1516 List<AnalysisError> get allErrors; 1501 List<AnalysisError> get allErrors;
1517 HtmlEntryImpl get writableCopy; 1502 HtmlEntryImpl get writableCopy;
1518 } 1503 }
1519
1520 /** 1504 /**
1521 * Instances of the class {@code HtmlEntryImpl} implement an {@link HtmlEntry}. 1505 * Instances of the class {@code HtmlEntryImpl} implement an {@link HtmlEntry}.
1522 * @coverage dart.engine 1506 * @coverage dart.engine
1523 */ 1507 */
1524 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { 1508 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry {
1525 1509
1526 /** 1510 /**
1527 * The state of the cached parsed (but not resolved) HTML unit. 1511 * The state of the cached parsed (but not resolved) HTML unit.
1528 */ 1512 */
1529 CacheState _parsedUnitState = CacheState.INVALID; 1513 CacheState _parsedUnitState = CacheState.INVALID;
1530 1514
1531 /** 1515 /**
1532 * The parsed HTML unit, or {@code null} if the parsed HTML unit is not curren tly cached. 1516 * The parsed HTML unit, or {@code null} if the parsed HTML unit is not curren tly cached.
1533 */ 1517 */
1534 HtmlUnit _parsedUnit; 1518 HtmlUnit _parsedUnit;
1535 1519
1536 /** 1520 /**
1537 * The state of the cached resolution errors. 1521 * The state of the cached resolution errors.
1538 */ 1522 */
1539 CacheState _resolutionErrorsState = CacheState.INVALID; 1523 CacheState _resolutionErrorsState = CacheState.INVALID;
1540 1524
1541 /** 1525 /**
1542 * The errors produced while resolving the compilation unit, or {@code null} i f the errors are not 1526 * The errors produced while resolving the compilation unit, or {@code null} i f the errors are not
1543 * currently cached. 1527 * currently cached.
1544 */ 1528 */
1545 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; 1529 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS;
1546 1530
1547 /** 1531 /**
1548 * The state of the cached parsed and resolved HTML unit. 1532 * The state of the cached parsed and resolved HTML unit.
1549 */ 1533 */
1550 CacheState _resolvedUnitState = CacheState.INVALID; 1534 CacheState _resolvedUnitState = CacheState.INVALID;
1551 1535
1552 /** 1536 /**
1553 * The resolved HTML unit, or {@code null} if the resolved HTML unit is not cu rrently cached. 1537 * The resolved HTML unit, or {@code null} if the resolved HTML unit is not cu rrently cached.
1554 */ 1538 */
1555 HtmlUnit _resolvedUnit; 1539 HtmlUnit _resolvedUnit;
1556 1540
1557 /** 1541 /**
1558 * The state of the cached list of referenced libraries. 1542 * The state of the cached list of referenced libraries.
1559 */ 1543 */
1560 CacheState _referencedLibrariesState = CacheState.INVALID; 1544 CacheState _referencedLibrariesState = CacheState.INVALID;
1561 1545
1562 /** 1546 /**
1563 * The list of libraries referenced in the HTML, or {@code null} if the list i s not currently 1547 * The list of libraries referenced in the HTML, or {@code null} if the list i s not currently
1564 * cached. Note that this list does not include libraries defined directly wit hin the HTML file. 1548 * cached. Note that this list does not include libraries defined directly wit hin the HTML file.
1565 */ 1549 */
1566 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; 1550 List<Source> _referencedLibraries = Source.EMPTY_ARRAY;
1567 1551
1568 /** 1552 /**
1569 * The state of the cached HTML element. 1553 * The state of the cached HTML element.
1570 */ 1554 */
1571 CacheState _elementState = CacheState.INVALID; 1555 CacheState _elementState = CacheState.INVALID;
1572 1556
1573 /** 1557 /**
1574 * The element representing the HTML file, or {@code null} if the element is n ot currently cached. 1558 * The element representing the HTML file, or {@code null} if the element is n ot currently cached.
1575 */ 1559 */
1576 HtmlElement _element; 1560 HtmlElement _element;
1577 List<AnalysisError> get allErrors { 1561 List<AnalysisError> get allErrors {
1578 List<AnalysisError> errors = new List<AnalysisError>(); 1562 List<AnalysisError> errors = new List<AnalysisError>();
1579 for (AnalysisError error in _resolutionErrors) { 1563 for (AnalysisError error in _resolutionErrors) {
1580 errors.add(error); 1564 errors.add(error);
1581 } 1565 }
1582 if (errors.length == 0) { 1566 if (errors.length == 0) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 _referencedLibrariesState = other._referencedLibrariesState; 1650 _referencedLibrariesState = other._referencedLibrariesState;
1667 _referencedLibraries = other._referencedLibraries; 1651 _referencedLibraries = other._referencedLibraries;
1668 _resolutionErrors = other._resolutionErrors; 1652 _resolutionErrors = other._resolutionErrors;
1669 _resolutionErrorsState = other._resolutionErrorsState; 1653 _resolutionErrorsState = other._resolutionErrorsState;
1670 _resolvedUnitState = other._resolvedUnitState; 1654 _resolvedUnitState = other._resolvedUnitState;
1671 _resolvedUnit = other._resolvedUnit; 1655 _resolvedUnit = other._resolvedUnit;
1672 _elementState = other._elementState; 1656 _elementState = other._elementState;
1673 _element = other._element; 1657 _element = other._element;
1674 } 1658 }
1675 } 1659 }
1676
1677 /** 1660 /**
1678 * The interface {@code SourceEntry} defines the behavior of objects that mainta in the information 1661 * The interface {@code SourceEntry} defines the behavior of objects that mainta in the information
1679 * cached by an analysis context about an individual source, no matter what kind of source it is. 1662 * cached by an analysis context about an individual source, no matter what kind of source it is.
1680 * <p> 1663 * <p>
1681 * Source entries should be treated as if they were immutable unless a writable copy of the entry 1664 * Source entries should be treated as if they were immutable unless a writable copy of the entry
1682 * has been obtained and has not yet been made visible to other threads. 1665 * has been obtained and has not yet been made visible to other threads.
1683 * @coverage dart.engine 1666 * @coverage dart.engine
1684 */ 1667 */
1685 abstract class SourceEntry { 1668 abstract class SourceEntry {
1686 1669
1687 /** 1670 /**
1688 * The data descriptor representing the line information. 1671 * The data descriptor representing the line information.
1689 */ 1672 */
1690 static DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>("Sour ceEntry.LINE_INFO"); 1673 static DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>("Sour ceEntry.LINE_INFO");
1691 1674
1692 /** 1675 /**
1693 * Return the kind of the source, or {@code null} if the kind is not currently cached. 1676 * Return the kind of the source, or {@code null} if the kind is not currently cached.
1694 * @return the kind of the source 1677 * @return the kind of the source
1695 */ 1678 */
1696 SourceKind get kind; 1679 SourceKind get kind;
1697 1680
1698 /** 1681 /**
1699 * Return the most recent time at which the state of the source matched the st ate represented by 1682 * Return the most recent time at which the state of the source matched the st ate represented by
1700 * this entry. 1683 * this entry.
1701 * @return the modification time of this entry 1684 * @return the modification time of this entry
1702 */ 1685 */
1703 int get modificationTime; 1686 int get modificationTime;
1704 1687
1705 /** 1688 /**
1706 * Return the state of the data represented by the given descriptor. 1689 * Return the state of the data represented by the given descriptor.
1707 * @param descriptor the descriptor representing the data whose state is to be returned 1690 * @param descriptor the descriptor representing the data whose state is to be returned
1708 * @return the state of the data represented by the given descriptor 1691 * @return the state of the data represented by the given descriptor
1709 */ 1692 */
1710 CacheState getState(DataDescriptor<Object> descriptor); 1693 CacheState getState(DataDescriptor<Object> descriptor);
1711 1694
1712 /** 1695 /**
1713 * Return the value of the data represented by the given descriptor, or {@code null} if the data 1696 * Return the value of the data represented by the given descriptor, or {@code null} if the data
1714 * represented by the descriptor is not in the cache. 1697 * represented by the descriptor is not in the cache.
1715 * @param descriptor the descriptor representing which data is to be returned 1698 * @param descriptor the descriptor representing which data is to be returned
1716 * @return the value of the data represented by the given descriptor 1699 * @return the value of the data represented by the given descriptor
1717 */ 1700 */
1718 Object getValue(DataDescriptor descriptor); 1701 Object getValue(DataDescriptor descriptor);
1719 1702
1720 /** 1703 /**
1721 * Return a new entry that is initialized to the same state as this entry but that can be 1704 * Return a new entry that is initialized to the same state as this entry but that can be
1722 * modified. 1705 * modified.
1723 * @return a writable copy of this entry 1706 * @return a writable copy of this entry
1724 */ 1707 */
1725 SourceEntryImpl get writableCopy; 1708 SourceEntryImpl get writableCopy;
1726 } 1709 }
1727
1728 /** 1710 /**
1729 * Instances of the abstract class {@code SourceEntryImpl} implement the behavio r common to all{@link SourceEntry source entries}. 1711 * Instances of the abstract class {@code SourceEntryImpl} implement the behavio r common to all{@link SourceEntry source entries}.
1730 * @coverage dart.engine 1712 * @coverage dart.engine
1731 */ 1713 */
1732 abstract class SourceEntryImpl implements SourceEntry { 1714 abstract class SourceEntryImpl implements SourceEntry {
1733 1715
1734 /** 1716 /**
1735 * The most recent time at which the state of the source matched the state rep resented by this 1717 * The most recent time at which the state of the source matched the state rep resented by this
1736 * entry. 1718 * entry.
1737 */ 1719 */
1738 int _modificationTime = 0; 1720 int _modificationTime = 0;
1739 1721
1740 /** 1722 /**
1741 * The state of the cached line information. 1723 * The state of the cached line information.
1742 */ 1724 */
1743 CacheState _lineInfoState = CacheState.INVALID; 1725 CacheState _lineInfoState = CacheState.INVALID;
1744 1726
1745 /** 1727 /**
1746 * The line information computed for the source, or {@code null} if the line i nformation is not 1728 * The line information computed for the source, or {@code null} if the line i nformation is not
1747 * currently cached. 1729 * currently cached.
1748 */ 1730 */
1749 LineInfo _lineInfo; 1731 LineInfo _lineInfo;
1750 int get modificationTime => _modificationTime; 1732 int get modificationTime => _modificationTime;
1751 CacheState getState(DataDescriptor<Object> descriptor) { 1733 CacheState getState(DataDescriptor<Object> descriptor) {
1752 if (identical(descriptor, SourceEntry.LINE_INFO)) { 1734 if (identical(descriptor, SourceEntry.LINE_INFO)) {
1753 return _lineInfoState; 1735 return _lineInfoState;
1754 } else { 1736 } else {
1755 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1737 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1756 } 1738 }
1757 } 1739 }
1758 Object getValue(DataDescriptor descriptor) { 1740 Object getValue(DataDescriptor descriptor) {
1759 if (identical(descriptor, SourceEntry.LINE_INFO)) { 1741 if (identical(descriptor, SourceEntry.LINE_INFO)) {
1760 return _lineInfo as Object; 1742 return _lineInfo as Object;
1761 } else { 1743 } else {
1762 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1744 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1763 } 1745 }
1764 } 1746 }
1765 1747
1766 /** 1748 /**
1767 * Set the most recent time at which the state of the source matched the state represented by this 1749 * Set the most recent time at which the state of the source matched the state represented by this
1768 * entry to the given time. 1750 * entry to the given time.
1769 * @param time the new modification time of this entry 1751 * @param time the new modification time of this entry
1770 */ 1752 */
1771 void set modificationTime(int time) { 1753 void set modificationTime(int time) {
1772 _modificationTime = time; 1754 _modificationTime = time;
1773 } 1755 }
1774 1756
1775 /** 1757 /**
1776 * Set the state of the data represented by the given descriptor to the given state. 1758 * Set the state of the data represented by the given descriptor to the given state.
1777 * @param descriptor the descriptor representing the data whose state is to be set 1759 * @param descriptor the descriptor representing the data whose state is to be set
1778 * @param the new state of the data represented by the given descriptor 1760 * @param the new state of the data represented by the given descriptor
1779 */ 1761 */
1780 void setState(DataDescriptor<Object> descriptor, CacheState state) { 1762 void setState(DataDescriptor<Object> descriptor, CacheState state) {
1781 if (identical(descriptor, SourceEntry.LINE_INFO)) { 1763 if (identical(descriptor, SourceEntry.LINE_INFO)) {
1782 _lineInfo = updatedValue(state, _lineInfo, null); 1764 _lineInfo = updatedValue(state, _lineInfo, null);
1783 _lineInfoState = state; 1765 _lineInfoState = state;
1784 } else { 1766 } else {
1785 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1767 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1786 } 1768 }
1787 } 1769 }
1788 1770
1789 /** 1771 /**
1790 * Set the value of the data represented by the given descriptor to the given value. 1772 * Set the value of the data represented by the given descriptor to the given value.
1791 * @param descriptor the descriptor representing the data whose value is to be set 1773 * @param descriptor the descriptor representing the data whose value is to be set
1792 * @param value the new value of the data represented by the given descriptor 1774 * @param value the new value of the data represented by the given descriptor
1793 */ 1775 */
1794 void setValue(DataDescriptor descriptor, Object value) { 1776 void setValue(DataDescriptor descriptor, Object value) {
1795 if (identical(descriptor, SourceEntry.LINE_INFO)) { 1777 if (identical(descriptor, SourceEntry.LINE_INFO)) {
1796 _lineInfo = value as LineInfo; 1778 _lineInfo = value as LineInfo;
1797 _lineInfoState = CacheState.VALID; 1779 _lineInfoState = CacheState.VALID;
1798 } else { 1780 } else {
1799 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1781 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1800 } 1782 }
1801 } 1783 }
1802 1784
1803 /** 1785 /**
1804 * Copy the information from the given cache entry. 1786 * Copy the information from the given cache entry.
1805 * @param entry the cache entry from which information will be copied 1787 * @param entry the cache entry from which information will be copied
1806 */ 1788 */
1807 void copyFrom(SourceEntryImpl entry) { 1789 void copyFrom(SourceEntryImpl entry) {
1808 _modificationTime = entry._modificationTime; 1790 _modificationTime = entry._modificationTime;
1809 _lineInfoState = entry._lineInfoState; 1791 _lineInfoState = entry._lineInfoState;
1810 _lineInfo = entry._lineInfo; 1792 _lineInfo = entry._lineInfo;
1811 } 1793 }
1812 1794
1813 /** 1795 /**
1814 * Given that some data is being transitioned to the given state, return the v alue that should be 1796 * Given that some data is being transitioned to the given state, return the v alue that should be
1815 * kept in the cache. 1797 * kept in the cache.
1816 * @param state the state to which the data is being transitioned 1798 * @param state the state to which the data is being transitioned
1817 * @param currentValue the value of the data before the transition 1799 * @param currentValue the value of the data before the transition
1818 * @param defaultValue the value to be used if the current value is to be remo ved from the cache 1800 * @param defaultValue the value to be used if the current value is to be remo ved from the cache
1819 * @return the value of the data that should be kept in the cache 1801 * @return the value of the data that should be kept in the cache
1820 */ 1802 */
1821 Object updatedValue(CacheState state, Object currentValue, Object defaultValue ) { 1803 Object updatedValue(CacheState state, Object currentValue, Object defaultValue ) {
1822 if (identical(state, CacheState.VALID)) { 1804 if (identical(state, CacheState.VALID)) {
1823 throw new IllegalArgumentException("Use setValue() to set the state to VAL ID"); 1805 throw new IllegalArgumentException("Use setValue() to set the state to VAL ID");
1824 } else if (identical(state, CacheState.IN_PROCESS)) { 1806 } else if (identical(state, CacheState.IN_PROCESS)) {
1825 return currentValue; 1807 return currentValue;
1826 } 1808 }
1827 return defaultValue; 1809 return defaultValue;
1828 } 1810 }
1829 } 1811 }
1830
1831 /** 1812 /**
1832 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys isContext analysis 1813 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys isContext analysis
1833 * context}. 1814 * context}.
1834 * @coverage dart.engine 1815 * @coverage dart.engine
1835 */ 1816 */
1836 class AnalysisContextImpl implements InternalAnalysisContext { 1817 class AnalysisContextImpl implements InternalAnalysisContext {
1837 1818
1838 /** 1819 /**
1839 * The set of analysis options controlling the behavior of this context. 1820 * The set of analysis options controlling the behavior of this context.
1840 */ 1821 */
1841 AnalysisOptions _options = new AnalysisOptionsImpl(); 1822 AnalysisOptions _options = new AnalysisOptionsImpl();
1842 1823
1843 /** 1824 /**
1844 * The source factory used to create the sources that can be analyzed in this context. 1825 * The source factory used to create the sources that can be analyzed in this context.
1845 */ 1826 */
1846 SourceFactory _sourceFactory; 1827 SourceFactory _sourceFactory;
1847 1828
1848 /** 1829 /**
1849 * A table mapping the sources known to the context to the information known a bout the source. 1830 * A table mapping the sources known to the context to the information known a bout the source.
1850 */ 1831 */
1851 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); 1832 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>();
1852 1833
1853 /** 1834 /**
1854 * A table mapping sources to the change notices that are waiting to be return ed related to that 1835 * A table mapping sources to the change notices that are waiting to be return ed related to that
1855 * source. 1836 * source.
1856 */ 1837 */
1857 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm pl>(); 1838 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm pl>();
1858 1839
1859 /** 1840 /**
1860 * A list containing the most recently accessed sources with the most recently used at the end of 1841 * A list containing the most recently accessed sources with the most recently used at the end of
1861 * the list. When more sources are added than the maximum allowed then the lea st recently used 1842 * the list. When more sources are added than the maximum allowed then the lea st recently used
1862 * source will be removed and will have it's cached AST structure flushed. 1843 * source will be removed and will have it's cached AST structure flushed.
1863 */ 1844 */
1864 List<Source> _recentlyUsed = new List<Source>(); 1845 List<Source> _recentlyUsed = new List<Source>();
1865 1846
1866 /** 1847 /**
1867 * The object used to synchronize access to all of the caches. 1848 * The object used to synchronize access to all of the caches.
1868 */ 1849 */
1869 Object _cacheLock = new Object(); 1850 Object _cacheLock = new Object();
1870 1851
1871 /** 1852 /**
1872 * The maximum number of sources for which data should be kept in the cache. 1853 * The maximum number of sources for which data should be kept in the cache.
1873 */ 1854 */
1874 static int _MAX_CACHE_SIZE = 64; 1855 static int _MAX_CACHE_SIZE = 64;
1875 1856
1876 /** 1857 /**
1877 * The name of the 'src' attribute in a HTML tag. 1858 * The name of the 'src' attribute in a HTML tag.
1878 */ 1859 */
1879 static String _ATTRIBUTE_SRC = "src"; 1860 static String _ATTRIBUTE_SRC = "src";
1880 1861
1862 /**
1863 * The name of the 'type' attribute in a HTML tag.
1864 */
1865 static String _ATTRIBUTE_TYPE = "type";
1866
1881 /** 1867 /**
1882 * The name of the 'script' tag in an HTML file. 1868 * The name of the 'script' tag in an HTML file.
1883 */ 1869 */
1884 static String _TAG_SCRIPT = "script"; 1870 static String _TAG_SCRIPT = "script";
1885 1871
1872 /**
1873 * The value of the 'type' attribute of a 'script' tag that indicates that the script is written
1874 * in Dart.
1875 */
1876 static String _TYPE_DART = "application/dart";
1877
1886 /** 1878 /**
1887 * The number of times that the flushing of information from the cache has bee n disabled without 1879 * The number of times that the flushing of information from the cache has bee n disabled without
1888 * being re-enabled. 1880 * being re-enabled.
1889 */ 1881 */
1890 int _cacheRemovalCount = 0; 1882 int _cacheRemovalCount = 0;
1891 void addSourceInfo(Source source, SourceEntry info) { 1883 void addSourceInfo(Source source, SourceEntry info) {
1892 _sourceMap[source] = info; 1884 _sourceMap[source] = info;
1893 } 1885 }
1894 void applyChanges(ChangeSet changeSet) { 1886 void applyChanges(ChangeSet changeSet) {
1895 if (changeSet.isEmpty()) { 1887 if (changeSet.isEmpty()) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND); 2021 CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND);
2030 if (sourceKindState != CacheState.VALID && sourceKindState != CacheState .ERROR) { 2022 if (sourceKindState != CacheState.VALID && sourceKindState != CacheState .ERROR) {
2031 internalComputeKindOf(source); 2023 internalComputeKindOf(source);
2032 sourceEntry = getSourceEntry(source); 2024 sourceEntry = getSourceEntry(source);
2033 } 2025 }
2034 } 2026 }
2035 return sourceEntry.kind; 2027 return sourceEntry.kind;
2036 } 2028 }
2037 } 2029 }
2038 LibraryElement computeLibraryElement(Source source) { 2030 LibraryElement computeLibraryElement(Source source) {
2039 if (!AnalysisEngine.isDartFileName(source.shortName)) {
2040 return null;
2041 }
2042 { 2031 {
2043 DartEntry dartEntry = getDartEntry(source); 2032 DartEntry dartEntry = getDartEntry(source);
2044 if (dartEntry == null) { 2033 if (dartEntry == null) {
2045 return null; 2034 return null;
2046 } 2035 }
2047 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT); 2036 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT);
2048 if (element == null) { 2037 if (element == null) {
2049 LibraryResolver resolver = new LibraryResolver(this); 2038 LibraryResolver resolver = new LibraryResolver(this);
2050 try { 2039 try {
2051 element = resolver.resolveLibrary(source, true); 2040 element = resolver.resolveLibrary(source, true);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2504 } 2493 }
2505 Iterable<Source> sourcesToResolve(List<Source> changedSources) { 2494 Iterable<Source> sourcesToResolve(List<Source> changedSources) {
2506 List<Source> librarySources = new List<Source>(); 2495 List<Source> librarySources = new List<Source>();
2507 for (Source source in changedSources) { 2496 for (Source source in changedSources) {
2508 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { 2497 if (identical(computeKindOf(source), SourceKind.LIBRARY)) {
2509 librarySources.add(source); 2498 librarySources.add(source);
2510 } 2499 }
2511 } 2500 }
2512 return librarySources; 2501 return librarySources;
2513 } 2502 }
2514 2503
2515 /** 2504 /**
2516 * Return a list of the sources that would be processed by {@link #performAnal ysisTask()}. This 2505 * Return a list of the sources that would be processed by {@link #performAnal ysisTask()}. This
2517 * method is intended to be used for testing purposes only. 2506 * method is intended to be used for testing purposes only.
2518 * @return a list of the sources that would be processed by {@link #performAna lysisTask()} 2507 * @return a list of the sources that would be processed by {@link #performAna lysisTask()}
2519 */ 2508 */
2520 List<Source> get sourcesNeedingProcessing { 2509 List<Source> get sourcesNeedingProcessing {
2521 List<Source> sources = new List<Source>(); 2510 List<Source> sources = new List<Source>();
2522 { 2511 {
2523 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 2512 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2524 SourceEntry sourceEntry = entry.getValue(); 2513 SourceEntry sourceEntry = entry.getValue();
2525 if (sourceEntry is DartEntry) { 2514 if (sourceEntry is DartEntry) {
2526 DartEntry dartEntry = sourceEntry as DartEntry; 2515 DartEntry dartEntry = sourceEntry as DartEntry;
2527 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT) ; 2516 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT) ;
2528 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); 2517 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT);
2529 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen tState, CacheState.INVALID)) { 2518 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen tState, CacheState.INVALID)) {
2530 sources.add(entry.getKey()); 2519 sources.add(entry.getKey());
2531 } 2520 }
2532 } else if (sourceEntry is HtmlEntry) { 2521 } else if (sourceEntry is HtmlEntry) {
2533 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; 2522 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
2534 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT) ; 2523 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT) ;
2535 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_U NIT); 2524 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_U NIT);
2536 if (identical(parsedUnitState, CacheState.INVALID) || identical(resolv edUnitState, CacheState.INVALID)) { 2525 if (identical(parsedUnitState, CacheState.INVALID) || identical(resolv edUnitState, CacheState.INVALID)) {
2537 sources.add(entry.getKey()); 2526 sources.add(entry.getKey());
2538 } 2527 }
2539 } 2528 }
2540 } 2529 }
2541 } 2530 }
2542 return sources; 2531 return sources;
2543 } 2532 }
2544 2533
2545 /** 2534 /**
2546 * Record that the given source was just accessed for some unspecified purpose . 2535 * Record that the given source was just accessed for some unspecified purpose .
2547 * <p> 2536 * <p>
2548 * Note: This method must only be invoked while we are synchronized on {@link #cacheLock}. 2537 * Note: This method must only be invoked while we are synchronized on {@link #cacheLock}.
2549 * @param source the source that was accessed 2538 * @param source the source that was accessed
2550 */ 2539 */
2551 void accessed(Source source) { 2540 void accessed(Source source) {
2552 if (_recentlyUsed.contains(source)) { 2541 if (_recentlyUsed.contains(source)) {
2553 _recentlyUsed.remove(source); 2542 _recentlyUsed.remove(source);
2554 _recentlyUsed.add(source); 2543 _recentlyUsed.add(source);
(...skipping 11 matching lines...) Expand all
2566 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 2555 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy;
2567 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 2556 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
2568 for (Source librarySource in getLibrariesContaining(source)) { 2557 for (Source librarySource in getLibrariesContaining(source)) {
2569 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState. FLUSHED); 2558 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState. FLUSHED);
2570 } 2559 }
2571 _sourceMap[removedSource] = dartCopy; 2560 _sourceMap[removedSource] = dartCopy;
2572 } 2561 }
2573 } 2562 }
2574 _recentlyUsed.add(source); 2563 _recentlyUsed.add(source);
2575 } 2564 }
2576 2565
2577 /** 2566 /**
2578 * Add all of the sources contained in the given source container to the given list of sources. 2567 * Add all of the sources contained in the given source container to the given list of sources.
2579 * <p> 2568 * <p>
2580 * Note: This method must only be invoked while we are synchronized on {@link #cacheLock}. 2569 * Note: This method must only be invoked while we are synchronized on {@link #cacheLock}.
2581 * @param sources the list to which sources are to be added 2570 * @param sources the list to which sources are to be added
2582 * @param container the source container containing the sources to be added to the list 2571 * @param container the source container containing the sources to be added to the list
2583 */ 2572 */
2584 void addSourcesInContainer(List<Source> sources, SourceContainer container) { 2573 void addSourcesInContainer(List<Source> sources, SourceContainer container) {
2585 for (Source source in _sourceMap.keys.toSet()) { 2574 for (Source source in _sourceMap.keys.toSet()) {
2586 if (container.contains(source)) { 2575 if (container.contains(source)) {
2587 sources.add(source); 2576 sources.add(source);
2588 } 2577 }
2589 } 2578 }
2590 } 2579 }
2591 2580
2592 /** 2581 /**
2593 * Return {@code true} if the given array of sources contains the given source . 2582 * Return {@code true} if the given array of sources contains the given source .
2594 * @param sources the sources being searched 2583 * @param sources the sources being searched
2595 * @param targetSource the source being searched for 2584 * @param targetSource the source being searched for
2596 * @return {@code true} if the given source is in the array 2585 * @return {@code true} if the given source is in the array
2597 */ 2586 */
2598 bool contains(List<Source> sources, Source targetSource) { 2587 bool contains(List<Source> sources, Source targetSource) {
2599 for (Source source in sources) { 2588 for (Source source in sources) {
2600 if (source == targetSource) { 2589 if (source == targetSource) {
2601 return true; 2590 return true;
2602 } 2591 }
2603 } 2592 }
2604 return false; 2593 return false;
2605 } 2594 }
2606 2595
2607 /** 2596 /**
2608 * Return {@code true} if the given array of sources contains any of the given target sources. 2597 * Return {@code true} if the given array of sources contains any of the given target sources.
2609 * @param sources the sources being searched 2598 * @param sources the sources being searched
2610 * @param targetSources the sources being searched for 2599 * @param targetSources the sources being searched for
2611 * @return {@code true} if any of the given target sources are in the array 2600 * @return {@code true} if any of the given target sources are in the array
2612 */ 2601 */
2613 bool containsAny(List<Source> sources, List<Source> targetSources) { 2602 bool containsAny(List<Source> sources, List<Source> targetSources) {
2614 for (Source targetSource in targetSources) { 2603 for (Source targetSource in targetSources) {
2615 if (contains(sources, targetSource)) { 2604 if (contains(sources, targetSource)) {
2616 return true; 2605 return true;
2617 } 2606 }
2618 } 2607 }
2619 return false; 2608 return false;
2620 } 2609 }
2621 2610
2622 /** 2611 /**
2623 * Create a source information object suitable for the given source. Return th e source information 2612 * Create a source information object suitable for the given source. Return th e source information
2624 * object that was created, or {@code null} if the source should not be tracke d by this context. 2613 * object that was created, or {@code null} if the source should not be tracke d by this context.
2625 * @param source the source for which an information object is being created 2614 * @param source the source for which an information object is being created
2626 * @return the source information object that was created 2615 * @return the source information object that was created
2627 */ 2616 */
2628 SourceEntry createSourceEntry(Source source) { 2617 SourceEntry createSourceEntry(Source source) {
2629 String name = source.shortName; 2618 String name = source.shortName;
2630 if (AnalysisEngine.isHtmlFileName(name)) { 2619 if (AnalysisEngine.isHtmlFileName(name)) {
2631 HtmlEntry htmlEntry = new HtmlEntryImpl(); 2620 HtmlEntry htmlEntry = new HtmlEntryImpl();
2632 _sourceMap[source] = htmlEntry; 2621 _sourceMap[source] = htmlEntry;
2633 return htmlEntry; 2622 return htmlEntry;
2634 } else if (AnalysisEngine.isDartFileName(name)) { 2623 } else {
2635 DartEntry dartEntry = new DartEntryImpl(); 2624 DartEntry dartEntry = new DartEntryImpl();
2636 _sourceMap[source] = dartEntry; 2625 _sourceMap[source] = dartEntry;
2637 return dartEntry; 2626 return dartEntry;
2638 } 2627 }
2639 return null;
2640 } 2628 }
2641 2629
2642 /** 2630 /**
2643 * Disable flushing information from the cache until {@link #enableCacheRemova l()} has been 2631 * Disable flushing information from the cache until {@link #enableCacheRemova l()} has been
2644 * called. 2632 * called.
2645 */ 2633 */
2646 void disableCacheRemoval() { 2634 void disableCacheRemoval() {
2647 _cacheRemovalCount++; 2635 _cacheRemovalCount++;
2648 } 2636 }
2649 2637
2650 /** 2638 /**
2651 * Re-enable flushing information from the cache. 2639 * Re-enable flushing information from the cache.
2652 */ 2640 */
2653 void enableCacheRemoval() { 2641 void enableCacheRemoval() {
2654 if (_cacheRemovalCount > 0) { 2642 if (_cacheRemovalCount > 0) {
2655 _cacheRemovalCount--; 2643 _cacheRemovalCount--;
2656 } 2644 }
2657 if (_cacheRemovalCount == 0) { 2645 if (_cacheRemovalCount == 0) {
2658 while (_recentlyUsed.length >= _MAX_CACHE_SIZE) { 2646 while (_recentlyUsed.length >= _MAX_CACHE_SIZE) {
2659 Source removedSource = _recentlyUsed.removeAt(0); 2647 Source removedSource = _recentlyUsed.removeAt(0);
2660 SourceEntry sourceEntry = _sourceMap[removedSource]; 2648 SourceEntry sourceEntry = _sourceMap[removedSource];
2661 if (sourceEntry is HtmlEntry) { 2649 if (sourceEntry is HtmlEntry) {
2662 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 2650 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy;
2663 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); 2651 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
2664 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.FLUSHED); 2652 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.FLUSHED);
2665 _sourceMap[removedSource] = htmlCopy; 2653 _sourceMap[removedSource] = htmlCopy;
2666 } else if (sourceEntry is DartEntry) { 2654 } else if (sourceEntry is DartEntry) {
2667 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 2655 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy;
2668 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 2656 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
2669 for (Source librarySource in getLibrariesContaining(removedSource)) { 2657 for (Source librarySource in getLibrariesContaining(removedSource)) {
2670 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat e.FLUSHED); 2658 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat e.FLUSHED);
2671 } 2659 }
2672 _sourceMap[removedSource] = dartCopy; 2660 _sourceMap[removedSource] = dartCopy;
2673 } 2661 }
2674 } 2662 }
2675 } 2663 }
2676 } 2664 }
2677 2665
2678 /** 2666 /**
2679 * Search the compilation units that are part of the given library and return the element 2667 * Search the compilation units that are part of the given library and return the element
2680 * representing the compilation unit with the given source. Return {@code null } if there is no 2668 * representing the compilation unit with the given source. Return {@code null } if there is no
2681 * such compilation unit. 2669 * such compilation unit.
2682 * @param libraryElement the element representing the library being searched t hrough 2670 * @param libraryElement the element representing the library being searched t hrough
2683 * @param unitSource the source for the compilation unit whose element is to b e returned 2671 * @param unitSource the source for the compilation unit whose element is to b e returned
2684 * @return the element representing the compilation unit 2672 * @return the element representing the compilation unit
2685 */ 2673 */
2686 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource) { 2674 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource) {
2687 CompilationUnitElement element = libraryElement.definingCompilationUnit; 2675 CompilationUnitElement element = libraryElement.definingCompilationUnit;
2688 if (element.source == unitSource) { 2676 if (element.source == unitSource) {
2689 return element; 2677 return element;
2690 } 2678 }
2691 for (CompilationUnitElement partElement in libraryElement.parts) { 2679 for (CompilationUnitElement partElement in libraryElement.parts) {
2692 if (partElement.source == unitSource) { 2680 if (partElement.source == unitSource) {
2693 return partElement; 2681 return partElement;
2694 } 2682 }
2695 } 2683 }
2696 return null; 2684 return null;
2697 } 2685 }
2698 2686
2699 /** 2687 /**
2700 * Return the compilation unit information associated with the given source, o r {@code null} if 2688 * Return the compilation unit information associated with the given source, o r {@code null} if
2701 * the source is not known to this context. This method should be used to acce ss the compilation 2689 * the source is not known to this context. This method should be used to acce ss the compilation
2702 * unit information rather than accessing the compilation unit map directly be cause sources in the 2690 * unit information rather than accessing the compilation unit map directly be cause sources in the
2703 * SDK are implicitly part of every analysis context and are therefore only ad ded to the map when 2691 * SDK are implicitly part of every analysis context and are therefore only ad ded to the map when
2704 * first accessed. 2692 * first accessed.
2705 * <p> 2693 * <p>
2706 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}. 2694 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
2707 * @param source the source for which information is being sought 2695 * @param source the source for which information is being sought
2708 * @return the compilation unit information associated with the given source 2696 * @return the compilation unit information associated with the given source
2709 */ 2697 */
2710 DartEntry getDartEntry(Source source) { 2698 DartEntry getDartEntry(Source source) {
2711 SourceEntry sourceEntry = getSourceEntry(source); 2699 SourceEntry sourceEntry = getSourceEntry(source);
2712 if (sourceEntry == null) { 2700 if (sourceEntry == null) {
2713 sourceEntry = new DartEntryImpl(); 2701 sourceEntry = new DartEntryImpl();
2714 _sourceMap[source] = sourceEntry; 2702 _sourceMap[source] = sourceEntry;
2715 return sourceEntry as DartEntry; 2703 return sourceEntry as DartEntry;
2716 } else if (sourceEntry is DartEntry) { 2704 } else if (sourceEntry is DartEntry) {
2717 return sourceEntry as DartEntry; 2705 return sourceEntry as DartEntry;
2718 } 2706 }
2719 return null; 2707 return null;
2720 } 2708 }
2721 2709
2722 /** 2710 /**
2723 * Return the HTML unit information associated with the given source, or {@cod e null} if the 2711 * Return the HTML unit information associated with the given source, or {@cod e null} if the
2724 * source is not known to this context. This method should be used to access t he HTML unit 2712 * source is not known to this context. This method should be used to access t he HTML unit
2725 * information rather than accessing the HTML unit map directly because source s in the SDK are 2713 * information rather than accessing the HTML unit map directly because source s in the SDK are
2726 * implicitly part of every analysis context and are therefore only added to t he map when first 2714 * implicitly part of every analysis context and are therefore only added to t he map when first
2727 * accessed. 2715 * accessed.
2728 * <p> 2716 * <p>
2729 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}. 2717 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
2730 * @param source the source for which information is being sought 2718 * @param source the source for which information is being sought
2731 * @return the HTML unit information associated with the given source 2719 * @return the HTML unit information associated with the given source
2732 */ 2720 */
2733 HtmlEntry getHtmlEntry(Source source) { 2721 HtmlEntry getHtmlEntry(Source source) {
2734 SourceEntry sourceEntry = getSourceEntry(source); 2722 SourceEntry sourceEntry = getSourceEntry(source);
2735 if (sourceEntry == null) { 2723 if (sourceEntry == null) {
2736 sourceEntry = new HtmlEntryImpl(); 2724 sourceEntry = new HtmlEntryImpl();
2737 _sourceMap[source] = sourceEntry; 2725 _sourceMap[source] = sourceEntry;
2738 return sourceEntry as HtmlEntry; 2726 return sourceEntry as HtmlEntry;
2739 } else if (sourceEntry is HtmlEntry) { 2727 } else if (sourceEntry is HtmlEntry) {
2740 return sourceEntry as HtmlEntry; 2728 return sourceEntry as HtmlEntry;
2741 } 2729 }
2742 return null; 2730 return null;
2743 } 2731 }
2744 2732
2745 /** 2733 /**
2746 * Return the sources of libraries that are referenced in the specified HTML f ile. 2734 * Return the sources of libraries that are referenced in the specified HTML f ile.
2747 * @param htmlSource the source of the HTML file being analyzed 2735 * @param htmlSource the source of the HTML file being analyzed
2748 * @param htmlUnit the AST for the HTML file being analyzed 2736 * @param htmlUnit the AST for the HTML file being analyzed
2749 * @return the sources of libraries that are referenced in the HTML file 2737 * @return the sources of libraries that are referenced in the HTML file
2750 */ 2738 */
2751 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) { 2739 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) {
2752 List<Source> libraries = new List<Source>(); 2740 List<Source> libraries = new List<Source>();
2753 htmlUnit.accept(new RecursiveXmlVisitor_7(this, htmlSource, libraries)); 2741 htmlUnit.accept(new RecursiveXmlVisitor_7(this, htmlSource, libraries));
2754 if (libraries.isEmpty) { 2742 if (libraries.isEmpty) {
2755 return Source.EMPTY_ARRAY; 2743 return Source.EMPTY_ARRAY;
2756 } 2744 }
2757 return new List.from(libraries); 2745 return new List.from(libraries);
2758 } 2746 }
2759 2747
2760 /** 2748 /**
2761 * Return a change notice for the given source, creating one if one does not a lready exist. 2749 * Return a change notice for the given source, creating one if one does not a lready exist.
2762 * @param source the source for which changes are being reported 2750 * @param source the source for which changes are being reported
2763 * @return a change notice for the given source 2751 * @return a change notice for the given source
2764 */ 2752 */
2765 ChangeNoticeImpl getNotice(Source source) { 2753 ChangeNoticeImpl getNotice(Source source) {
2766 ChangeNoticeImpl notice = _pendingNotices[source]; 2754 ChangeNoticeImpl notice = _pendingNotices[source];
2767 if (notice == null) { 2755 if (notice == null) {
2768 notice = new ChangeNoticeImpl(source); 2756 notice = new ChangeNoticeImpl(source);
2769 _pendingNotices[source] = notice; 2757 _pendingNotices[source] = notice;
2770 } 2758 }
2771 return notice; 2759 return notice;
2772 } 2760 }
2773 2761
2774 /** 2762 /**
2775 * Return the cache entry associated with the given source, or {@code null} if there is no entry 2763 * Return the cache entry associated with the given source, or {@code null} if there is no entry
2776 * associated with the source. 2764 * associated with the source.
2777 * @param source the source for which a cache entry is being sought 2765 * @param source the source for which a cache entry is being sought
2778 * @return the source cache entry associated with the given source 2766 * @return the source cache entry associated with the given source
2779 */ 2767 */
2780 SourceEntry getReadableSourceEntry(Source source) { 2768 SourceEntry getReadableSourceEntry(Source source) {
2781 { 2769 {
2782 return _sourceMap[source]; 2770 return _sourceMap[source];
2783 } 2771 }
2784 } 2772 }
2785 2773
2786 /** 2774 /**
2787 * Return the source information associated with the given source, or {@code n ull} if the source 2775 * Return the source information associated with the given source, or {@code n ull} if the source
2788 * is not known to this context. This method should be used to access the sour ce information 2776 * is not known to this context. This method should be used to access the sour ce information
2789 * rather than accessing the source map directly because sources in the SDK ar e implicitly part of 2777 * rather than accessing the source map directly because sources in the SDK ar e implicitly part of
2790 * every analysis context and are therefore only added to the map when first a ccessed. 2778 * every analysis context and are therefore only added to the map when first a ccessed.
2791 * <p> 2779 * <p>
2792 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}. 2780 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
2793 * @param source the source for which information is being sought 2781 * @param source the source for which information is being sought
2794 * @return the source information associated with the given source 2782 * @return the source information associated with the given source
2795 */ 2783 */
2796 SourceEntry getSourceEntry(Source source) { 2784 SourceEntry getSourceEntry(Source source) {
2797 SourceEntry sourceEntry = _sourceMap[source]; 2785 SourceEntry sourceEntry = _sourceMap[source];
2798 if (sourceEntry == null) { 2786 if (sourceEntry == null) {
2799 sourceEntry = createSourceEntry(source); 2787 sourceEntry = createSourceEntry(source);
2800 } 2788 }
2801 return sourceEntry; 2789 return sourceEntry;
2802 } 2790 }
2803 2791
2804 /** 2792 /**
2805 * Return an array containing all of the sources known to this context that ha ve the given kind. 2793 * Return an array containing all of the sources known to this context that ha ve the given kind.
2806 * @param kind the kind of sources to be returned 2794 * @param kind the kind of sources to be returned
2807 * @return all of the sources known to this context that have the given kind 2795 * @return all of the sources known to this context that have the given kind
2808 */ 2796 */
2809 List<Source> getSources(SourceKind kind2) { 2797 List<Source> getSources(SourceKind kind2) {
2810 List<Source> sources = new List<Source>(); 2798 List<Source> sources = new List<Source>();
2811 { 2799 {
2812 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 2800 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2813 if (identical(entry.getValue().kind, kind2)) { 2801 if (identical(entry.getValue().kind, kind2)) {
2814 sources.add(entry.getKey()); 2802 sources.add(entry.getKey());
2815 } 2803 }
2816 } 2804 }
2817 } 2805 }
2818 return new List.from(sources); 2806 return new List.from(sources);
2819 } 2807 }
2820 2808
2821 /** 2809 /**
2822 * Return {@code true} if the given compilation unit has a part-of directive b ut no library 2810 * Return {@code true} if the given compilation unit has a part-of directive b ut no library
2823 * directive. 2811 * directive.
2824 * @param unit the compilation unit being tested 2812 * @param unit the compilation unit being tested
2825 * @return {@code true} if the compilation unit has a part-of directive 2813 * @return {@code true} if the compilation unit has a part-of directive
2826 */ 2814 */
2827 bool hasPartOfDirective(CompilationUnit unit) { 2815 bool hasPartOfDirective(CompilationUnit unit) {
2828 bool hasPartOf = false; 2816 bool hasPartOf = false;
2829 for (Directive directive in unit.directives) { 2817 for (Directive directive in unit.directives) {
2830 if (directive is PartOfDirective) { 2818 if (directive is PartOfDirective) {
2831 hasPartOf = true; 2819 hasPartOf = true;
2832 } else if (directive is LibraryDirective) { 2820 } else if (directive is LibraryDirective) {
2833 return false; 2821 return false;
2834 } 2822 }
2835 } 2823 }
2836 return hasPartOf; 2824 return hasPartOf;
2837 } 2825 }
2838 2826
2839 /** 2827 /**
2840 * Compute the kind of the given source. This method should only be invoked wh en the kind is not 2828 * Compute the kind of the given source. This method should only be invoked wh en the kind is not
2841 * already known. 2829 * already known.
2842 * @param source the source for which a kind is to be computed 2830 * @param source the source for which a kind is to be computed
2843 * @return the new source info that was created to represent the source 2831 * @return the new source info that was created to represent the source
2844 */ 2832 */
2845 DartEntry internalComputeKindOf(Source source) { 2833 DartEntry internalComputeKindOf(Source source) {
2846 try { 2834 try {
2847 accessed(source); 2835 accessed(source);
2848 RecordingErrorListener errorListener = new RecordingErrorListener(); 2836 RecordingErrorListener errorListener = new RecordingErrorListener();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen er errorListener) { 2894 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen er errorListener) {
2907 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult() ; 2895 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult() ;
2908 Source_ContentReceiver receiver = new Source_ContentReceiver_8(source, error Listener, result); 2896 Source_ContentReceiver receiver = new Source_ContentReceiver_8(source, error Listener, result);
2909 try { 2897 try {
2910 source.getContents(receiver); 2898 source.getContents(receiver);
2911 } catch (exception) { 2899 } catch (exception) {
2912 throw new AnalysisException.con3(exception); 2900 throw new AnalysisException.con3(exception);
2913 } 2901 }
2914 return result; 2902 return result;
2915 } 2903 }
2916 2904
2917 /** 2905 /**
2918 * Invalidate all of the results computed by this context. 2906 * Invalidate all of the results computed by this context.
2919 * <p> 2907 * <p>
2920 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}. 2908 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
2921 */ 2909 */
2922 void invalidateAllResults() { 2910 void invalidateAllResults() {
2923 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) { 2911 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) {
2924 SourceEntry sourceEntry = mapEntry.getValue(); 2912 SourceEntry sourceEntry = mapEntry.getValue();
2925 if (sourceEntry is HtmlEntry) { 2913 if (sourceEntry is HtmlEntry) {
2926 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 2914 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy;
2927 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); 2915 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID);
2928 mapEntry.setValue(htmlCopy); 2916 mapEntry.setValue(htmlCopy);
2929 } else if (sourceEntry is DartEntry) { 2917 } else if (sourceEntry is DartEntry) {
2930 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 2918 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy;
2931 dartCopy.invalidateAllResolutionInformation(); 2919 dartCopy.invalidateAllResolutionInformation();
2932 mapEntry.setValue(dartCopy); 2920 mapEntry.setValue(dartCopy);
2933 } 2921 }
2934 } 2922 }
2935 } 2923 }
2936 2924
2937 /** 2925 /**
2938 * In response to a change to at least one of the compilation units in the giv en library, 2926 * In response to a change to at least one of the compilation units in the giv en library,
2939 * invalidate any results that are dependent on the result of resolving that l ibrary. 2927 * invalidate any results that are dependent on the result of resolving that l ibrary.
2940 * @param librarySource the source of the library being invalidated 2928 * @param librarySource the source of the library being invalidated
2941 */ 2929 */
2942 void invalidateLibraryResolution(Source librarySource) { 2930 void invalidateLibraryResolution(Source librarySource) {
2943 DartEntry libraryEntry = getDartEntry(librarySource); 2931 DartEntry libraryEntry = getDartEntry(librarySource);
2944 if (libraryEntry != null) { 2932 if (libraryEntry != null) {
2945 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S); 2933 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S);
2946 DartEntryImpl libraryCopy = libraryEntry.writableCopy; 2934 DartEntryImpl libraryCopy = libraryEntry.writableCopy;
2947 libraryCopy.invalidateAllResolutionInformation(); 2935 libraryCopy.invalidateAllResolutionInformation();
2948 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); 2936 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID);
2949 _sourceMap[librarySource] = libraryCopy; 2937 _sourceMap[librarySource] = libraryCopy;
2950 for (Source unitSource in includedParts) { 2938 for (Source unitSource in includedParts) {
2951 DartEntry partEntry = getDartEntry(unitSource); 2939 DartEntry partEntry = getDartEntry(unitSource);
2952 if (partEntry != null) { 2940 if (partEntry != null) {
2953 DartEntryImpl dartCopy = partEntry.writableCopy; 2941 DartEntryImpl dartCopy = partEntry.writableCopy;
2954 dartCopy.invalidateAllResolutionInformation(); 2942 dartCopy.invalidateAllResolutionInformation();
2955 _sourceMap[unitSource] = dartCopy; 2943 _sourceMap[unitSource] = dartCopy;
2956 } 2944 }
2957 } 2945 }
2958 } 2946 }
2959 } 2947 }
2960 2948
2961 /** 2949 /**
2962 * Return {@code true} if this library is, or depends on, dart:html. 2950 * Return {@code true} if this library is, or depends on, dart:html.
2963 * @param library the library being tested 2951 * @param library the library being tested
2964 * @param visitedLibraries a collection of the libraries that have been visite d, used to prevent 2952 * @param visitedLibraries a collection of the libraries that have been visite d, used to prevent
2965 * infinite recursion 2953 * infinite recursion
2966 * @return {@code true} if this library is, or depends on, dart:html 2954 * @return {@code true} if this library is, or depends on, dart:html
2967 */ 2955 */
2968 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v isitedLibraries) { 2956 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v isitedLibraries) {
2969 if (visitedLibraries.contains(library)) { 2957 if (visitedLibraries.contains(library)) {
2970 return false; 2958 return false;
2971 } 2959 }
2972 if (library.source == htmlSource) { 2960 if (library.source == htmlSource) {
2973 return true; 2961 return true;
2974 } 2962 }
2975 javaSetAdd(visitedLibraries, library); 2963 javaSetAdd(visitedLibraries, library);
2976 for (LibraryElement imported in library.importedLibraries) { 2964 for (LibraryElement imported in library.importedLibraries) {
2977 if (isClient(imported, htmlSource, visitedLibraries)) { 2965 if (isClient(imported, htmlSource, visitedLibraries)) {
2978 return true; 2966 return true;
2979 } 2967 }
2980 } 2968 }
2981 for (LibraryElement exported in library.exportedLibraries) { 2969 for (LibraryElement exported in library.exportedLibraries) {
2982 if (isClient(exported, htmlSource, visitedLibraries)) { 2970 if (isClient(exported, htmlSource, visitedLibraries)) {
2983 return true; 2971 return true;
2984 } 2972 }
2985 } 2973 }
2986 return false; 2974 return false;
2987 } 2975 }
2988 2976
2989 /** 2977 /**
2990 * Perform a single analysis task. 2978 * Perform a single analysis task.
2991 * <p> 2979 * <p>
2992 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}. 2980 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
2993 * @return {@code true} if work was done, implying that there might be more wo rk to be done 2981 * @return {@code true} if work was done, implying that there might be more wo rk to be done
2994 */ 2982 */
2995 bool performSingleAnalysisTask() { 2983 bool performSingleAnalysisTask() {
2996 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 2984 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2997 SourceEntry sourceEntry = entry.getValue(); 2985 SourceEntry sourceEntry = entry.getValue();
2998 if (sourceEntry is DartEntry) { 2986 if (sourceEntry is DartEntry) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); 3040 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR);
3053 entry.setValue(htmlCopy); 3041 entry.setValue(htmlCopy);
3054 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry. getKey().fullName}", exception); 3042 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry. getKey().fullName}", exception);
3055 } 3043 }
3056 return true; 3044 return true;
3057 } 3045 }
3058 } 3046 }
3059 } 3047 }
3060 return false; 3048 return false;
3061 } 3049 }
3062 3050
3063 /** 3051 /**
3064 * Given a cache entry and a library element, record the library element and o ther information 3052 * Given a cache entry and a library element, record the library element and o ther information
3065 * gleaned from the element in the cache entry. 3053 * gleaned from the element in the cache entry.
3066 * @param dartCopy the cache entry in which data is to be recorded 3054 * @param dartCopy the cache entry in which data is to be recorded
3067 * @param library the library element used to record information 3055 * @param library the library element used to record information
3068 * @param htmlSource the source for the HTML library 3056 * @param htmlSource the source for the HTML library
3069 */ 3057 */
3070 void recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source htmlSource) { 3058 void recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source htmlSource) {
3071 dartCopy.setValue(DartEntry.ELEMENT, library); 3059 dartCopy.setValue(DartEntry.ELEMENT, library);
3072 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); 3060 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null);
3073 dartCopy.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set <LibraryElement>())); 3061 dartCopy.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set <LibraryElement>()));
3074 List<Source> unitSources = new List<Source>(); 3062 List<Source> unitSources = new List<Source>();
3075 unitSources.add(library.definingCompilationUnit.source); 3063 unitSources.add(library.definingCompilationUnit.source);
3076 for (CompilationUnitElement part in library.parts) { 3064 for (CompilationUnitElement part in library.parts) {
3077 Source partSource = part.source; 3065 Source partSource = part.source;
3078 unitSources.add(partSource); 3066 unitSources.add(partSource);
3079 } 3067 }
3080 dartCopy.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources)); 3068 dartCopy.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources));
3081 } 3069 }
3082 3070
3083 /** 3071 /**
3084 * Record the result of using the given resolver to resolve one or more librar ies. 3072 * Record the result of using the given resolver to resolve one or more librar ies.
3085 * @param resolver the resolver that has the needed results 3073 * @param resolver the resolver that has the needed results
3086 * @throws AnalysisException if the results cannot be retrieved for some reaso n 3074 * @throws AnalysisException if the results cannot be retrieved for some reaso n
3087 */ 3075 */
3088 void recordResolutionResults(LibraryResolver resolver) { 3076 void recordResolutionResults(LibraryResolver resolver) {
3089 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); 3077 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML);
3090 RecordingErrorListener errorListener2 = resolver.errorListener; 3078 RecordingErrorListener errorListener2 = resolver.errorListener;
3091 for (Library library in resolver.resolvedLibraries) { 3079 for (Library library in resolver.resolvedLibraries) {
3092 Source librarySource2 = library.librarySource; 3080 Source librarySource2 = library.librarySource;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3131 } 3119 }
3132 HtmlScanResult scanHtml(Source source) { 3120 HtmlScanResult scanHtml(Source source) {
3133 HtmlScanner scanner = new HtmlScanner(source); 3121 HtmlScanner scanner = new HtmlScanner(source);
3134 try { 3122 try {
3135 source.getContents(scanner); 3123 source.getContents(scanner);
3136 } catch (exception) { 3124 } catch (exception) {
3137 throw new AnalysisException.con3(exception); 3125 throw new AnalysisException.con3(exception);
3138 } 3126 }
3139 return scanner.result; 3127 return scanner.result;
3140 } 3128 }
3141 3129
3142 /** 3130 /**
3143 * Create an entry for the newly added source. Return {@code true} if the new source is a Dart 3131 * Create an entry for the newly added source. Return {@code true} if the new source is a Dart
3144 * file. 3132 * file.
3145 * <p> 3133 * <p>
3146 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}. 3134 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
3147 * @param source the source that has been added 3135 * @param source the source that has been added
3148 * @return {@code true} if the new source is a Dart file 3136 * @return {@code true} if the new source is a Dart file
3149 */ 3137 */
3150 bool sourceAvailable(Source source) { 3138 bool sourceAvailable(Source source) {
3151 SourceEntry sourceEntry = _sourceMap[source]; 3139 SourceEntry sourceEntry = _sourceMap[source];
3152 if (sourceEntry == null) { 3140 if (sourceEntry == null) {
3153 sourceEntry = createSourceEntry(source); 3141 sourceEntry = createSourceEntry(source);
3154 } 3142 }
3155 return sourceEntry is DartEntry; 3143 return sourceEntry is DartEntry;
3156 } 3144 }
3157 3145
3158 /** 3146 /**
3159 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}. 3147 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
3160 * @param source the source that has been changed 3148 * @param source the source that has been changed
3161 */ 3149 */
3162 void sourceChanged(Source source) { 3150 void sourceChanged(Source source) {
3163 SourceEntry sourceEntry = _sourceMap[source]; 3151 SourceEntry sourceEntry = _sourceMap[source];
3164 if (sourceEntry is HtmlEntry) { 3152 if (sourceEntry is HtmlEntry) {
3165 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 3153 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy;
3166 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); 3154 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
3167 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); 3155 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID);
3168 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); 3156 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID);
3169 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); 3157 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID);
3170 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); 3158 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID);
3171 _sourceMap[source] = htmlCopy; 3159 _sourceMap[source] = htmlCopy;
3172 } else if (sourceEntry is DartEntry) { 3160 } else if (sourceEntry is DartEntry) {
3173 List<Source> containingLibraries = getLibrariesContaining(source); 3161 List<Source> containingLibraries = getLibrariesContaining(source);
3174 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 3162 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy;
3175 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); 3163 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID);
3176 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); 3164 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID);
3177 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); 3165 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID);
3178 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); 3166 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID);
3179 _sourceMap[source] = dartCopy; 3167 _sourceMap[source] = dartCopy;
3180 invalidateLibraryResolution(source); 3168 invalidateLibraryResolution(source);
3181 for (Source librarySource in containingLibraries) { 3169 for (Source librarySource in containingLibraries) {
3182 invalidateLibraryResolution(librarySource); 3170 invalidateLibraryResolution(librarySource);
3183 } 3171 }
3184 } 3172 }
3185 } 3173 }
3186 3174
3187 /** 3175 /**
3188 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}. 3176 * <b>Note:</b> This method must only be invoked while we are synchronized on {@link #cacheLock}.
3189 * @param source the source that has been deleted 3177 * @param source the source that has been deleted
3190 */ 3178 */
3191 void sourceRemoved(Source source) { 3179 void sourceRemoved(Source source) {
3192 DartEntry dartEntry = getDartEntry(source); 3180 DartEntry dartEntry = getDartEntry(source);
3193 if (dartEntry != null) { 3181 if (dartEntry != null) {
3194 Set<Source> libraries = new Set<Source>(); 3182 Set<Source> libraries = new Set<Source>();
3195 for (Source librarySource in getLibrariesContaining(source)) { 3183 for (Source librarySource in getLibrariesContaining(source)) {
3196 javaSetAdd(libraries, librarySource); 3184 javaSetAdd(libraries, librarySource);
3197 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) { 3185 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) {
3198 javaSetAdd(libraries, dependentLibrary); 3186 javaSetAdd(libraries, dependentLibrary);
3199 } 3187 }
3200 } 3188 }
3201 for (Source librarySource in libraries) { 3189 for (Source librarySource in libraries) {
3202 invalidateLibraryResolution(librarySource); 3190 invalidateLibraryResolution(librarySource);
3203 } 3191 }
3204 } 3192 }
3205 _sourceMap.remove(source); 3193 _sourceMap.remove(source);
3206 } 3194 }
3207 } 3195 }
3208
3209 /** 3196 /**
3210 * Instances of the class {@code ScanResult} represent the results of scanning a source. 3197 * Instances of the class {@code ScanResult} represent the results of scanning a source.
3211 */ 3198 */
3212 class AnalysisContextImpl_ScanResult { 3199 class AnalysisContextImpl_ScanResult {
3213 3200
3214 /** 3201 /**
3215 * The time at which the contents of the source were last set. 3202 * The time at which the contents of the source were last set.
3216 */ 3203 */
3217 int _modificationTime = 0; 3204 int _modificationTime = 0;
3218 3205
3219 /** 3206 /**
3220 * The first token in the token stream. 3207 * The first token in the token stream.
3221 */ 3208 */
3222 Token _token; 3209 Token _token;
3223 3210
3224 /** 3211 /**
3225 * The line start information that was produced. 3212 * The line start information that was produced.
3226 */ 3213 */
3227 List<int> _lineStarts; 3214 List<int> _lineStarts;
3228 } 3215 }
3229 class Source_ContentReceiver_6 implements Source_ContentReceiver { 3216 class Source_ContentReceiver_6 implements Source_ContentReceiver {
3230 List<CharSequence> contentHolder; 3217 List<CharSequence> contentHolder;
3231 Source_ContentReceiver_6(this.contentHolder); 3218 Source_ContentReceiver_6(this.contentHolder);
3232 void accept(CharBuffer contents, int modificationTime) { 3219 void accept(CharBuffer contents, int modificationTime) {
3233 contentHolder[0] = contents; 3220 contentHolder[0] = contents;
3234 } 3221 }
3235 void accept2(String contents, int modificationTime) { 3222 void accept2(String contents, int modificationTime) {
3236 contentHolder[0] = new CharSequence(contents); 3223 contentHolder[0] = new CharSequence(contents);
3237 } 3224 }
3238 } 3225 }
3239 class RecursiveXmlVisitor_7 extends RecursiveXmlVisitor<Object> { 3226 class RecursiveXmlVisitor_7 extends RecursiveXmlVisitor<Object> {
3240 final AnalysisContextImpl AnalysisContextImpl_this; 3227 final AnalysisContextImpl AnalysisContextImpl_this;
3241 Source htmlSource; 3228 Source htmlSource;
3242 List<Source> libraries; 3229 List<Source> libraries;
3243 RecursiveXmlVisitor_7(this.AnalysisContextImpl_this, this.htmlSource, this.lib raries) : super(); 3230 RecursiveXmlVisitor_7(this.AnalysisContextImpl_this, this.htmlSource, this.lib raries) : super();
3244 Object visitXmlTagNode(XmlTagNode node) { 3231 Object visitXmlTagNode(XmlTagNode node) {
3245 if (javaStringEqualsIgnoreCase(node.tag.lexeme, AnalysisContextImpl._TAG_SCR IPT)) { 3232 if (javaStringEqualsIgnoreCase(node.tag.lexeme, AnalysisContextImpl._TAG_SCR IPT)) {
3233 bool isDartScript = false;
3234 XmlAttributeNode scriptAttribute = null;
3246 for (XmlAttributeNode attribute in node.attributes) { 3235 for (XmlAttributeNode attribute in node.attributes) {
3247 if (javaStringEqualsIgnoreCase(attribute.name.lexeme, AnalysisContextImp l._ATTRIBUTE_SRC)) { 3236 if (javaStringEqualsIgnoreCase(attribute.name.lexeme, AnalysisContextImp l._ATTRIBUTE_SRC)) {
3248 try { 3237 scriptAttribute = attribute;
3249 Uri uri = new Uri(path: attribute.text); 3238 } else if (javaStringEqualsIgnoreCase(attribute.name.lexeme, AnalysisCon textImpl._ATTRIBUTE_TYPE)) {
3250 String fileName = uri.path; 3239 if (javaStringEqualsIgnoreCase(attribute.text, AnalysisContextImpl._TY PE_DART)) {
3251 if (AnalysisEngine.isDartFileName(fileName)) { 3240 isDartScript = true;
3252 Source librarySource = AnalysisContextImpl_this._sourceFactory.res olveUri(htmlSource, fileName);
3253 if (librarySource.exists()) {
3254 libraries.add(librarySource);
3255 }
3256 }
3257 } catch (exception) {
3258 AnalysisEngine.instance.logger.logError2("Invalid URL ('${attribute. text}') in script tag in '${htmlSource.fullName}'", exception);
3259 } 3241 }
3260 } 3242 }
3261 } 3243 }
3244 if (isDartScript && scriptAttribute != null) {
3245 try {
3246 Uri uri = new Uri(path: scriptAttribute.text);
3247 String fileName = uri.path;
3248 Source librarySource = AnalysisContextImpl_this._sourceFactory.resolve Uri(htmlSource, fileName);
3249 if (librarySource.exists()) {
3250 libraries.add(librarySource);
3251 }
3252 } catch (exception) {
3253 AnalysisEngine.instance.logger.logError2("Invalid URL ('${scriptAttrib ute.text}') in script tag in '${htmlSource.fullName}'", exception);
3254 }
3255 }
3262 } 3256 }
3263 return super.visitXmlTagNode(node); 3257 return super.visitXmlTagNode(node);
3264 } 3258 }
3265 } 3259 }
3266 class Source_ContentReceiver_8 implements Source_ContentReceiver { 3260 class Source_ContentReceiver_8 implements Source_ContentReceiver {
3267 Source source; 3261 Source source;
3268 AnalysisErrorListener errorListener; 3262 AnalysisErrorListener errorListener;
3269 AnalysisContextImpl_ScanResult result; 3263 AnalysisContextImpl_ScanResult result;
3270 Source_ContentReceiver_8(this.source, this.errorListener, this.result); 3264 Source_ContentReceiver_8(this.source, this.errorListener, this.result);
3271 void accept(CharBuffer contents, int modificationTime2) { 3265 void accept(CharBuffer contents, int modificationTime2) {
3272 CharBufferScanner scanner = new CharBufferScanner(source, contents, errorLis tener); 3266 CharBufferScanner scanner = new CharBufferScanner(source, contents, errorLis tener);
3273 result._modificationTime = modificationTime2; 3267 result._modificationTime = modificationTime2;
3274 result._token = scanner.tokenize(); 3268 result._token = scanner.tokenize();
3275 result._lineStarts = scanner.lineStarts; 3269 result._lineStarts = scanner.lineStarts;
3276 } 3270 }
3277 void accept2(String contents, int modificationTime2) { 3271 void accept2(String contents, int modificationTime2) {
3278 StringScanner scanner = new StringScanner(source, contents, errorListener); 3272 StringScanner scanner = new StringScanner(source, contents, errorListener);
3279 result._modificationTime = modificationTime2; 3273 result._modificationTime = modificationTime2;
3280 result._token = scanner.tokenize(); 3274 result._token = scanner.tokenize();
3281 result._lineStarts = scanner.lineStarts; 3275 result._lineStarts = scanner.lineStarts;
3282 } 3276 }
3283 } 3277 }
3284
3285 /** 3278 /**
3286 * Instances of the class {@code AnalysisErrorInfoImpl} represent the analysis e rrors and line info 3279 * Instances of the class {@code AnalysisErrorInfoImpl} represent the analysis e rrors and line info
3287 * associated with a source. 3280 * associated with a source.
3288 */ 3281 */
3289 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { 3282 class AnalysisErrorInfoImpl implements AnalysisErrorInfo {
3290 3283
3291 /** 3284 /**
3292 * The analysis errors associated with a source, or {@code null} if there are no errors. 3285 * The analysis errors associated with a source, or {@code null} if there are no errors.
3293 */ 3286 */
3294 List<AnalysisError> _errors; 3287 List<AnalysisError> _errors;
3295 3288
3296 /** 3289 /**
3297 * The line information associated with the errors, or {@code null} if there a re no errors. 3290 * The line information associated with the errors, or {@code null} if there a re no errors.
3298 */ 3291 */
3299 LineInfo _lineInfo; 3292 LineInfo _lineInfo;
3300 3293
3301 /** 3294 /**
3302 * Initialize an newly created error info with the errors and line information 3295 * Initialize an newly created error info with the errors and line information
3303 * @param errors the errors as a result of analysis 3296 * @param errors the errors as a result of analysis
3304 * @param lineinfo the line info for the errors 3297 * @param lineinfo the line info for the errors
3305 */ 3298 */
3306 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { 3299 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) {
3307 this._errors = errors; 3300 this._errors = errors;
3308 this._lineInfo = lineInfo; 3301 this._lineInfo = lineInfo;
3309 } 3302 }
3310 3303
3311 /** 3304 /**
3312 * Return the errors of analysis, or {@code null} if there were no errors. 3305 * Return the errors of analysis, or {@code null} if there were no errors.
3313 * @return the errors as a result of the analysis 3306 * @return the errors as a result of the analysis
3314 */ 3307 */
3315 List<AnalysisError> get errors => _errors; 3308 List<AnalysisError> get errors => _errors;
3316 3309
3317 /** 3310 /**
3318 * Return the line information associated with the errors, or {@code null} if there were no 3311 * Return the line information associated with the errors, or {@code null} if there were no
3319 * errors. 3312 * errors.
3320 * @return the line information associated with the errors 3313 * @return the line information associated with the errors
3321 */ 3314 */
3322 LineInfo get lineInfo => _lineInfo; 3315 LineInfo get lineInfo => _lineInfo;
3323 } 3316 }
3324
3325 /** 3317 /**
3326 * Instances of the class {@code AnalysisOptions} represent a set of analysis op tions used to 3318 * Instances of the class {@code AnalysisOptions} represent a set of analysis op tions used to
3327 * control the behavior of an analysis context. 3319 * control the behavior of an analysis context.
3328 */ 3320 */
3329 class AnalysisOptionsImpl implements AnalysisOptions { 3321 class AnalysisOptionsImpl implements AnalysisOptions {
3330 3322
3331 /** 3323 /**
3332 * A flag indicating whether analysis is to use strict mode. In strict mode, e rror reporting is 3324 * A flag indicating whether analysis is to use strict mode. In strict mode, e rror reporting is
3333 * based exclusively on the static type information. 3325 * based exclusively on the static type information.
3334 */ 3326 */
3335 bool _strictMode = false; 3327 bool _strictMode = false;
3336 3328
3337 /** 3329 /**
3338 * Return {@code true} if analysis is to use strict mode. In strict mode, erro r reporting is based 3330 * Return {@code true} if analysis is to use strict mode. In strict mode, erro r reporting is based
3339 * exclusively on the static type information. 3331 * exclusively on the static type information.
3340 * @return {@code true} if analysis is to use strict mode 3332 * @return {@code true} if analysis is to use strict mode
3341 */ 3333 */
3342 bool get strictMode => _strictMode; 3334 bool get strictMode => _strictMode;
3343 3335
3344 /** 3336 /**
3345 * Set whether analysis is to use strict mode to the given value. In strict mo de, error reporting 3337 * Set whether analysis is to use strict mode to the given value. In strict mo de, error reporting
3346 * is based exclusively on the static type information. 3338 * is based exclusively on the static type information.
3347 * @param isStrict {@code true} if analysis is to use strict mode 3339 * @param isStrict {@code true} if analysis is to use strict mode
3348 */ 3340 */
3349 void set strictMode(bool isStrict) { 3341 void set strictMode(bool isStrict) {
3350 _strictMode = isStrict; 3342 _strictMode = isStrict;
3351 } 3343 }
3352 } 3344 }
3353
3354 /** 3345 /**
3355 * The enumeration {@code CacheState} defines the possible states of cached data . 3346 * The enumeration {@code CacheState} defines the possible states of cached data .
3356 */ 3347 */
3357 class CacheState implements Comparable<CacheState> { 3348 class CacheState implements Comparable<CacheState> {
3358 3349
3359 /** 3350 /**
3360 * The data is not in the cache and the last time an attempt was made to compu te the data an 3351 * The data is not in the cache and the last time an attempt was made to compu te the data an
3361 * exception occurred, making it pointless to attempt. 3352 * exception occurred, making it pointless to attempt.
3362 * <p> 3353 * <p>
3363 * Valid Transitions: 3354 * Valid Transitions:
3364 * <ul> 3355 * <ul>
3365 * <li>{@link #INVALID} if a source was modified that might cause the data to be computable</li> 3356 * <li>{@link #INVALID} if a source was modified that might cause the data to be computable</li>
3366 * </ul> 3357 * </ul>
3367 */ 3358 */
3368 static final CacheState ERROR = new CacheState('ERROR', 0); 3359 static final CacheState ERROR = new CacheState('ERROR', 0);
3369 3360
3370 /** 3361 /**
3371 * The data is not in the cache because it was flushed from the cache in order to control memory 3362 * The data is not in the cache because it was flushed from the cache in order to control memory
3372 * usage. If the data is recomputed, results do not need to be reported. 3363 * usage. If the data is recomputed, results do not need to be reported.
3373 * <p> 3364 * <p>
3374 * Valid Transitions: 3365 * Valid Transitions:
3375 * <ul> 3366 * <ul>
3376 * <li>{@link #IN_PROCESS} if the data is being recomputed</li> 3367 * <li>{@link #IN_PROCESS} if the data is being recomputed</li>
3377 * <li>{@link #INVALID} if a source was modified that causes the data to need to be recomputed</li> 3368 * <li>{@link #INVALID} if a source was modified that causes the data to need to be recomputed</li>
3378 * </ul> 3369 * </ul>
3379 */ 3370 */
3380 static final CacheState FLUSHED = new CacheState('FLUSHED', 1); 3371 static final CacheState FLUSHED = new CacheState('FLUSHED', 1);
3381 3372
3382 /** 3373 /**
3383 * The data might or might not be in the cache but is in the process of being recomputed. 3374 * The data might or might not be in the cache but is in the process of being recomputed.
3384 * <p> 3375 * <p>
3385 * Valid Transitions: 3376 * Valid Transitions:
3386 * <ul> 3377 * <ul>
3387 * <li>{@link #ERROR} if an exception occurred while trying to compute the dat a</li> 3378 * <li>{@link #ERROR} if an exception occurred while trying to compute the dat a</li>
3388 * <li>{@link #VALID} if the data was successfully computed and stored in the cache</li> 3379 * <li>{@link #VALID} if the data was successfully computed and stored in the cache</li>
3389 * </ul> 3380 * </ul>
3390 */ 3381 */
3391 static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2); 3382 static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2);
3392 3383
3393 /** 3384 /**
3394 * The data is not in the cache and needs to be recomputed so that results can be reported. 3385 * The data is not in the cache and needs to be recomputed so that results can be reported.
3395 * <p> 3386 * <p>
3396 * Valid Transitions: 3387 * Valid Transitions:
3397 * <ul> 3388 * <ul>
3398 * <li>{@link #IN_PROCESS} if an attempt is being made to recompute the data</ li> 3389 * <li>{@link #IN_PROCESS} if an attempt is being made to recompute the data</ li>
3399 * </ul> 3390 * </ul>
3400 */ 3391 */
3401 static final CacheState INVALID = new CacheState('INVALID', 3); 3392 static final CacheState INVALID = new CacheState('INVALID', 3);
3402 3393
3403 /** 3394 /**
3404 * The data is in the cache and up-to-date. 3395 * The data is in the cache and up-to-date.
3405 * <p> 3396 * <p>
3406 * Valid Transitions: 3397 * Valid Transitions:
3407 * <ul> 3398 * <ul>
3408 * <li>{@link #FLUSHED} if the data is removed in order to manage memory usage </li> 3399 * <li>{@link #FLUSHED} if the data is removed in order to manage memory usage </li>
3409 * <li>{@link #INVALID} if a source was modified in such a way as to invalidat e the previous data</li> 3400 * <li>{@link #INVALID} if a source was modified in such a way as to invalidat e the previous data</li>
3410 * </ul> 3401 * </ul>
3411 */ 3402 */
3412 static final CacheState VALID = new CacheState('VALID', 4); 3403 static final CacheState VALID = new CacheState('VALID', 4);
3413 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V ALID]; 3404 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V ALID];
3414 3405
3415 /// The name of this enum constant, as declared in the enum declaration. 3406 /// The name of this enum constant, as declared in the enum declaration.
3416 final String name; 3407 final String name;
3417 3408
3418 /// The position in the enum declaration. 3409 /// The position in the enum declaration.
3419 final int ordinal; 3410 final int ordinal;
3420 CacheState(this.name, this.ordinal) { 3411 CacheState(this.name, this.ordinal) {
3421 } 3412 }
3422 int compareTo(CacheState other) => ordinal - other.ordinal; 3413 int compareTo(CacheState other) => ordinal - other.ordinal;
3423 String toString() => name; 3414 String toString() => name;
3424 } 3415 }
3425
3426 /** 3416 /**
3427 * Instances of the class {@code ChangeNoticeImpl} represent a change to the ana lysis results 3417 * Instances of the class {@code ChangeNoticeImpl} represent a change to the ana lysis results
3428 * associated with a given source. 3418 * associated with a given source.
3429 * @coverage dart.engine 3419 * @coverage dart.engine
3430 */ 3420 */
3431 class ChangeNoticeImpl implements ChangeNotice { 3421 class ChangeNoticeImpl implements ChangeNotice {
3432 3422
3433 /** 3423 /**
3434 * The source for which the result is being reported. 3424 * The source for which the result is being reported.
3435 */ 3425 */
3436 Source _source; 3426 Source _source;
3437 3427
3438 /** 3428 /**
3439 * The fully resolved AST that changed as a result of the analysis, or {@code null} if the AST was 3429 * The fully resolved AST that changed as a result of the analysis, or {@code null} if the AST was
3440 * not changed. 3430 * not changed.
3441 */ 3431 */
3442 CompilationUnit _compilationUnit; 3432 CompilationUnit _compilationUnit;
3443 3433
3444 /** 3434 /**
3445 * The errors that changed as a result of the analysis, or {@code null} if err ors were not 3435 * The errors that changed as a result of the analysis, or {@code null} if err ors were not
3446 * changed. 3436 * changed.
3447 */ 3437 */
3448 List<AnalysisError> _errors; 3438 List<AnalysisError> _errors;
3449 3439
3450 /** 3440 /**
3451 * The line information associated with the source, or {@code null} if errors were not changed. 3441 * The line information associated with the source, or {@code null} if errors were not changed.
3452 */ 3442 */
3453 LineInfo _lineInfo; 3443 LineInfo _lineInfo;
3454 3444
3455 /** 3445 /**
3456 * An empty array of change notices. 3446 * An empty array of change notices.
3457 */ 3447 */
3458 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); 3448 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0);
3459 3449
3460 /** 3450 /**
3461 * Initialize a newly created notice associated with the given source. 3451 * Initialize a newly created notice associated with the given source.
3462 * @param source the source for which the change is being reported 3452 * @param source the source for which the change is being reported
3463 */ 3453 */
3464 ChangeNoticeImpl(Source source) { 3454 ChangeNoticeImpl(Source source) {
3465 this._source = source; 3455 this._source = source;
3466 } 3456 }
3467 3457
3468 /** 3458 /**
3469 * Return the fully resolved AST that changed as a result of the analysis, or {@code null} if the 3459 * Return the fully resolved AST that changed as a result of the analysis, or {@code null} if the
3470 * AST was not changed. 3460 * AST was not changed.
3471 * @return the fully resolved AST that changed as a result of the analysis 3461 * @return the fully resolved AST that changed as a result of the analysis
3472 */ 3462 */
3473 CompilationUnit get compilationUnit => _compilationUnit; 3463 CompilationUnit get compilationUnit => _compilationUnit;
3474 3464
3475 /** 3465 /**
3476 * Return the errors that changed as a result of the analysis, or {@code null} if errors were not 3466 * Return the errors that changed as a result of the analysis, or {@code null} if errors were not
3477 * changed. 3467 * changed.
3478 * @return the errors that changed as a result of the analysis 3468 * @return the errors that changed as a result of the analysis
3479 */ 3469 */
3480 List<AnalysisError> get errors => _errors; 3470 List<AnalysisError> get errors => _errors;
3481 3471
3482 /** 3472 /**
3483 * Return the line information associated with the source, or {@code null} if errors were not 3473 * Return the line information associated with the source, or {@code null} if errors were not
3484 * changed. 3474 * changed.
3485 * @return the line information associated with the source 3475 * @return the line information associated with the source
3486 */ 3476 */
3487 LineInfo get lineInfo => _lineInfo; 3477 LineInfo get lineInfo => _lineInfo;
3488 3478
3489 /** 3479 /**
3490 * Return the source for which the result is being reported. 3480 * Return the source for which the result is being reported.
3491 * @return the source for which the result is being reported 3481 * @return the source for which the result is being reported
3492 */ 3482 */
3493 Source get source => _source; 3483 Source get source => _source;
3494 3484
3495 /** 3485 /**
3496 * Set the fully resolved AST that changed as a result of the analysis to the given AST. 3486 * Set the fully resolved AST that changed as a result of the analysis to the given AST.
3497 * @param compilationUnit the fully resolved AST that changed as a result of t he analysis 3487 * @param compilationUnit the fully resolved AST that changed as a result of t he analysis
3498 */ 3488 */
3499 void set compilationUnit(CompilationUnit compilationUnit2) { 3489 void set compilationUnit(CompilationUnit compilationUnit2) {
3500 this._compilationUnit = compilationUnit2; 3490 this._compilationUnit = compilationUnit2;
3501 } 3491 }
3502 3492
3503 /** 3493 /**
3504 * Set the errors that changed as a result of the analysis to the given errors and set the line 3494 * Set the errors that changed as a result of the analysis to the given errors and set the line
3505 * information to the given line information. 3495 * information to the given line information.
3506 * @param errors the errors that changed as a result of the analysis 3496 * @param errors the errors that changed as a result of the analysis
3507 * @param lineInfo the line information associated with the source 3497 * @param lineInfo the line information associated with the source
3508 */ 3498 */
3509 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { 3499 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) {
3510 this._errors = errors2; 3500 this._errors = errors2;
3511 this._lineInfo = lineInfo2; 3501 this._lineInfo = lineInfo2;
3512 } 3502 }
3513 } 3503 }
3514
3515 /** 3504 /**
3516 * Instances of the class {@code DelegatingAnalysisContextImpl} extend {@link An alysisContextImplanalysis context} to delegate sources to the appropriate analys is context. For instance, if the 3505 * Instances of the class {@code DelegatingAnalysisContextImpl} extend {@link An alysisContextImplanalysis context} to delegate sources to the appropriate analys is context. For instance, if the
3517 * source is in a system library then the analysis context from the {@link DartS dk} is used. 3506 * source is in a system library then the analysis context from the {@link DartS dk} is used.
3518 * @coverage dart.engine 3507 * @coverage dart.engine
3519 */ 3508 */
3520 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { 3509 class DelegatingAnalysisContextImpl extends AnalysisContextImpl {
3521 3510
3522 /** 3511 /**
3523 * This references the {@link InternalAnalysisContext} held onto by the {@link DartSdk} which is 3512 * This references the {@link InternalAnalysisContext} held onto by the {@link DartSdk} which is
3524 * used (instead of this {@link AnalysisContext}) for SDK sources. This field is set when 3513 * used (instead of this {@link AnalysisContext}) for SDK sources. This field is set when
3525 * #setSourceFactory(SourceFactory) is called, and references the analysis con text in the{@link DartUriResolver} in the {@link SourceFactory}, this analysis c ontext assumes that there 3514 * #setSourceFactory(SourceFactory) is called, and references the analysis con text in the{@link DartUriResolver} in the {@link SourceFactory}, this analysis c ontext assumes that there
3526 * will be such a resolver. 3515 * will be such a resolver.
3527 */ 3516 */
3528 InternalAnalysisContext _sdkAnalysisContext; 3517 InternalAnalysisContext _sdkAnalysisContext;
3529 void addSourceInfo(Source source, SourceEntry info) { 3518 void addSourceInfo(Source source, SourceEntry info) {
3530 if (source.isInSystemLibrary()) { 3519 if (source.isInSystemLibrary()) {
3531 _sdkAnalysisContext.addSourceInfo(source, info); 3520 _sdkAnalysisContext.addSourceInfo(source, info);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3735 _sdkAnalysisContext = sdk.context as InternalAnalysisContext; 3724 _sdkAnalysisContext = sdk.context as InternalAnalysisContext;
3736 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { 3725 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) {
3737 _sdkAnalysisContext = null; 3726 _sdkAnalysisContext = null;
3738 throw new IllegalStateException("The context provided by an SDK cannot i tself be a delegating analysis context"); 3727 throw new IllegalStateException("The context provided by an SDK cannot i tself be a delegating analysis context");
3739 } 3728 }
3740 } else { 3729 } else {
3741 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal ysisContextImpls must have a DartSdk associated with the provided SourceFactory. "); 3730 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal ysisContextImpls must have a DartSdk associated with the provided SourceFactory. ");
3742 } 3731 }
3743 } 3732 }
3744 } 3733 }
3745
3746 /** 3734 /**
3747 * Instances of the class {@code InstrumentedAnalysisContextImpl} implement an{@ link AnalysisContext analysis context} by recording instrumentation data and del egating to 3735 * Instances of the class {@code InstrumentedAnalysisContextImpl} implement an{@ link AnalysisContext analysis context} by recording instrumentation data and del egating to
3748 * another analysis context to do the non-instrumentation work. 3736 * another analysis context to do the non-instrumentation work.
3749 * @coverage dart.engine 3737 * @coverage dart.engine
3750 */ 3738 */
3751 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { 3739 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext {
3752 3740
3753 /** 3741 /**
3754 * Record an exception that was thrown during analysis. 3742 * Record an exception that was thrown during analysis.
3755 * @param instrumentation the instrumentation builder being used to record the exception 3743 * @param instrumentation the instrumentation builder being used to record the exception
3756 * @param exception the exception being reported 3744 * @param exception the exception being reported
3757 */ 3745 */
3758 static void recordAnalysisException(InstrumentationBuilder instrumentation, An alysisException exception) { 3746 static void recordAnalysisException(InstrumentationBuilder instrumentation, An alysisException exception) {
3759 instrumentation.record(exception); 3747 instrumentation.record(exception);
3760 } 3748 }
3761 3749
3762 /** 3750 /**
3763 * The unique identifier used to identify this analysis context in the instrum entation data. 3751 * The unique identifier used to identify this analysis context in the instrum entation data.
3764 */ 3752 */
3765 String _contextId = UUID.randomUUID().toString(); 3753 String _contextId = UUID.randomUUID().toString();
3766 3754
3767 /** 3755 /**
3768 * The analysis context to which all of the non-instrumentation work is delega ted. 3756 * The analysis context to which all of the non-instrumentation work is delega ted.
3769 */ 3757 */
3770 InternalAnalysisContext _basis; 3758 InternalAnalysisContext _basis;
3771 3759
3772 /** 3760 /**
3773 * Create a new {@link InstrumentedAnalysisContextImpl} which wraps a new{@lin k AnalysisContextImpl} as the basis context. 3761 * Create a new {@link InstrumentedAnalysisContextImpl} which wraps a new{@lin k AnalysisContextImpl} as the basis context.
3774 */ 3762 */
3775 InstrumentedAnalysisContextImpl() { 3763 InstrumentedAnalysisContextImpl() {
3776 _jtd_constructor_182_impl(); 3764 _jtd_constructor_183_impl();
3777 } 3765 }
3778 _jtd_constructor_182_impl() { 3766 _jtd_constructor_183_impl() {
3779 _jtd_constructor_183_impl(new AnalysisContextImpl()); 3767 _jtd_constructor_184_impl(new AnalysisContextImpl());
3780 } 3768 }
3781 3769
3782 /** 3770 /**
3783 * Create a new {@link InstrumentedAnalysisContextImpl} with a specified basis context, aka the 3771 * Create a new {@link InstrumentedAnalysisContextImpl} with a specified basis context, aka the
3784 * context to wrap and instrument. 3772 * context to wrap and instrument.
3785 * @param context some {@link InstrumentedAnalysisContext} to wrap and instrum ent 3773 * @param context some {@link InstrumentedAnalysisContext} to wrap and instrum ent
3786 */ 3774 */
3787 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { 3775 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) {
3788 _jtd_constructor_183_impl(context); 3776 _jtd_constructor_184_impl(context);
3789 } 3777 }
3790 _jtd_constructor_183_impl(InternalAnalysisContext context) { 3778 _jtd_constructor_184_impl(InternalAnalysisContext context) {
3791 _basis = context; 3779 _basis = context;
3792 } 3780 }
3793 void addSourceInfo(Source source, SourceEntry info) { 3781 void addSourceInfo(Source source, SourceEntry info) {
3794 _basis.addSourceInfo(source, info); 3782 _basis.addSourceInfo(source, info);
3795 } 3783 }
3796 void applyChanges(ChangeSet changeSet) { 3784 void applyChanges(ChangeSet changeSet) {
3797 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- applyChanges"); 3785 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- applyChanges");
3798 try { 3786 try {
3799 instrumentation.metric3("contextId", _contextId); 3787 instrumentation.metric3("contextId", _contextId);
3800 _basis.applyChanges(changeSet); 3788 _basis.applyChanges(changeSet);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3882 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) => _basis.extractContextInto(container, newContext); 3870 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) => _basis.extractContextInto(container, newContext);
3883 AnalysisOptions get analysisOptions { 3871 AnalysisOptions get analysisOptions {
3884 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getAnalysisOptions"); 3872 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getAnalysisOptions");
3885 try { 3873 try {
3886 instrumentation.metric3("contextId", _contextId); 3874 instrumentation.metric3("contextId", _contextId);
3887 return _basis.analysisOptions; 3875 return _basis.analysisOptions;
3888 } finally { 3876 } finally {
3889 instrumentation.log(); 3877 instrumentation.log();
3890 } 3878 }
3891 } 3879 }
3892 3880
3893 /** 3881 /**
3894 * @return the underlying {@link AnalysisContext}. 3882 * @return the underlying {@link AnalysisContext}.
3895 */ 3883 */
3896 AnalysisContext get basis => _basis; 3884 AnalysisContext get basis => _basis;
3897 Element getElement(ElementLocation location) { 3885 Element getElement(ElementLocation location) {
3898 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getElement"); 3886 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getElement");
3899 try { 3887 try {
3900 instrumentation.metric3("contextId", _contextId); 3888 instrumentation.metric3("contextId", _contextId);
3901 return _basis.getElement(location); 3889 return _basis.getElement(location);
3902 } finally { 3890 } finally {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
4208 Iterable<Source> sourcesToResolve(List<Source> changedSources) { 4196 Iterable<Source> sourcesToResolve(List<Source> changedSources) {
4209 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- sourcesToResolve"); 4197 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- sourcesToResolve");
4210 try { 4198 try {
4211 instrumentation.metric3("contextId", _contextId); 4199 instrumentation.metric3("contextId", _contextId);
4212 return _basis.sourcesToResolve(changedSources); 4200 return _basis.sourcesToResolve(changedSources);
4213 } finally { 4201 } finally {
4214 instrumentation.log(); 4202 instrumentation.log();
4215 } 4203 }
4216 } 4204 }
4217 } 4205 }
4218
4219 /** 4206 /**
4220 * The interface {@code InternalAnalysisContext} defines additional behavior for an analysis context 4207 * The interface {@code InternalAnalysisContext} defines additional behavior for an analysis context
4221 * that is required by internal users of the context. 4208 * that is required by internal users of the context.
4222 */ 4209 */
4223 abstract class InternalAnalysisContext implements AnalysisContext { 4210 abstract class InternalAnalysisContext implements AnalysisContext {
4224 4211
4225 /** 4212 /**
4226 * Add the given source with the given information to this context. 4213 * Add the given source with the given information to this context.
4227 * @param source the source to be added 4214 * @param source the source to be added
4228 * @param info the information about the source 4215 * @param info the information about the source
4229 */ 4216 */
4230 void addSourceInfo(Source source, SourceEntry info); 4217 void addSourceInfo(Source source, SourceEntry info);
4231 4218
4232 /** 4219 /**
4233 * Return an AST structure corresponding to the given source, but ensure that the structure has 4220 * Return an AST structure corresponding to the given source, but ensure that the structure has
4234 * not already been resolved and will not be resolved by any other threads or in any other 4221 * not already been resolved and will not be resolved by any other threads or in any other
4235 * library. 4222 * library.
4236 * @param source the compilation unit for which an AST structure should be ret urned 4223 * @param source the compilation unit for which an AST structure should be ret urned
4237 * @return the AST structure representing the content of the source 4224 * @return the AST structure representing the content of the source
4238 * @throws AnalysisException if the analysis could not be performed 4225 * @throws AnalysisException if the analysis could not be performed
4239 */ 4226 */
4240 CompilationUnit computeResolvableCompilationUnit(Source source); 4227 CompilationUnit computeResolvableCompilationUnit(Source source);
4241 4228
4242 /** 4229 /**
4243 * Initialize the specified context by removing the specified sources from the receiver and adding 4230 * Initialize the specified context by removing the specified sources from the receiver and adding
4244 * them to the specified context. 4231 * them to the specified context.
4245 * @param container the container containing sources that should be removed fr om this context and 4232 * @param container the container containing sources that should be removed fr om this context and
4246 * added to the returned context 4233 * added to the returned context
4247 * @param newContext the context to be initialized 4234 * @param newContext the context to be initialized
4248 * @return the analysis context that was initialized 4235 * @return the analysis context that was initialized
4249 */ 4236 */
4250 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext); 4237 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext);
4251 4238
4252 /** 4239 /**
4253 * Return a namespace containing mappings for all of the public names defined by the given 4240 * Return a namespace containing mappings for all of the public names defined by the given
4254 * library. 4241 * library.
4255 * @param library the library whose public namespace is to be returned 4242 * @param library the library whose public namespace is to be returned
4256 * @return the public namespace of the given library 4243 * @return the public namespace of the given library
4257 */ 4244 */
4258 Namespace getPublicNamespace(LibraryElement library); 4245 Namespace getPublicNamespace(LibraryElement library);
4259 4246
4260 /** 4247 /**
4261 * Return a namespace containing mappings for all of the public names defined by the library 4248 * Return a namespace containing mappings for all of the public names defined by the library
4262 * defined by the given source. 4249 * defined by the given source.
4263 * @param source the source defining the library whose public namespace is to be returned 4250 * @param source the source defining the library whose public namespace is to be returned
4264 * @return the public namespace corresponding to the library defined by the gi ven source 4251 * @return the public namespace corresponding to the library defined by the gi ven source
4265 * @throws AnalysisException if the public namespace could not be computed 4252 * @throws AnalysisException if the public namespace could not be computed
4266 */ 4253 */
4267 Namespace getPublicNamespace2(Source source); 4254 Namespace getPublicNamespace2(Source source);
4268 4255
4269 /** 4256 /**
4270 * Given a table mapping the source for the libraries represented by the corre sponding elements to 4257 * Given a table mapping the source for the libraries represented by the corre sponding elements to
4271 * the elements representing the libraries, record those mappings. 4258 * the elements representing the libraries, record those mappings.
4272 * @param elementMap a table mapping the source for the libraries represented by the elements to 4259 * @param elementMap a table mapping the source for the libraries represented by the elements to
4273 * the elements representing the libraries 4260 * the elements representing the libraries
4274 */ 4261 */
4275 void recordLibraryElements(Map<Source, LibraryElement> elementMap); 4262 void recordLibraryElements(Map<Source, LibraryElement> elementMap);
4276 } 4263 }
4277
4278 /** 4264 /**
4279 * Instances of the class {@code RecordingErrorListener} implement an error list ener that will 4265 * Instances of the class {@code RecordingErrorListener} implement an error list ener that will
4280 * record the errors that are reported to it in a way that is appropriate for ca ching those errors 4266 * record the errors that are reported to it in a way that is appropriate for ca ching those errors
4281 * within an analysis context. 4267 * within an analysis context.
4282 * @coverage dart.engine 4268 * @coverage dart.engine
4283 */ 4269 */
4284 class RecordingErrorListener implements AnalysisErrorListener { 4270 class RecordingErrorListener implements AnalysisErrorListener {
4285 4271
4286 /** 4272 /**
4287 * A HashMap of lists containing the errors that were collected, keyed by each {@link Source}. 4273 * A HashMap of lists containing the errors that were collected, keyed by each {@link Source}.
4288 */ 4274 */
4289 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError> >(); 4275 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError> >();
4290 4276
4291 /** 4277 /**
4292 * Add all of the errors recorded by the given listener to this listener. 4278 * Add all of the errors recorded by the given listener to this listener.
4293 * @param listener the listener that has recorded the errors to be added 4279 * @param listener the listener that has recorded the errors to be added
4294 */ 4280 */
4295 void addAll(RecordingErrorListener listener) { 4281 void addAll(RecordingErrorListener listener) {
4296 for (AnalysisError error in listener.errors) { 4282 for (AnalysisError error in listener.errors) {
4297 onError(error); 4283 onError(error);
4298 } 4284 }
4299 } 4285 }
4300 4286
4301 /** 4287 /**
4302 * Answer the errors collected by the listener. 4288 * Answer the errors collected by the listener.
4303 * @return an array of errors (not {@code null}, contains no {@code null}s) 4289 * @return an array of errors (not {@code null}, contains no {@code null}s)
4304 */ 4290 */
4305 List<AnalysisError> get errors { 4291 List<AnalysisError> get errors {
4306 Set<MapEntry<Source, List<AnalysisError>>> entrySet2 = getMapEntrySet(_error s); 4292 Set<MapEntry<Source, List<AnalysisError>>> entrySet2 = getMapEntrySet(_error s);
4307 if (entrySet2.length == 0) { 4293 if (entrySet2.length == 0) {
4308 return AnalysisError.NO_ERRORS; 4294 return AnalysisError.NO_ERRORS;
4309 } 4295 }
4310 List<AnalysisError> resultList = new List<AnalysisError>(); 4296 List<AnalysisError> resultList = new List<AnalysisError>();
4311 for (MapEntry<Source, List<AnalysisError>> entry in entrySet2) { 4297 for (MapEntry<Source, List<AnalysisError>> entry in entrySet2) {
4312 resultList.addAll(entry.getValue()); 4298 resultList.addAll(entry.getValue());
4313 } 4299 }
4314 return new List.from(resultList); 4300 return new List.from(resultList);
4315 } 4301 }
4316 4302
4317 /** 4303 /**
4318 * Answer the errors collected by the listener for some passed {@link Source}. 4304 * Answer the errors collected by the listener for some passed {@link Source}.
4319 * @param source some {@link Source} for which the caller wants the set of {@l ink AnalysisError}s 4305 * @param source some {@link Source} for which the caller wants the set of {@l ink AnalysisError}s
4320 * collected by this listener 4306 * collected by this listener
4321 * @return the errors collected by the listener for the passed {@link Source} 4307 * @return the errors collected by the listener for the passed {@link Source}
4322 */ 4308 */
4323 List<AnalysisError> getErrors2(Source source) { 4309 List<AnalysisError> getErrors2(Source source) {
4324 List<AnalysisError> errorsForSource = _errors[source]; 4310 List<AnalysisError> errorsForSource = _errors[source];
4325 if (errorsForSource == null) { 4311 if (errorsForSource == null) {
4326 return AnalysisError.NO_ERRORS; 4312 return AnalysisError.NO_ERRORS;
4327 } else { 4313 } else {
4328 return new List.from(errorsForSource); 4314 return new List.from(errorsForSource);
4329 } 4315 }
4330 } 4316 }
4331 void onError(AnalysisError event) { 4317 void onError(AnalysisError event) {
4332 Source source2 = event.source; 4318 Source source2 = event.source;
4333 List<AnalysisError> errorsForSource = _errors[source2]; 4319 List<AnalysisError> errorsForSource = _errors[source2];
4334 if (_errors[source2] == null) { 4320 if (_errors[source2] == null) {
4335 errorsForSource = new List<AnalysisError>(); 4321 errorsForSource = new List<AnalysisError>();
4336 _errors[source2] = errorsForSource; 4322 _errors[source2] = errorsForSource;
4337 } 4323 }
4338 errorsForSource.add(event); 4324 errorsForSource.add(event);
4339 } 4325 }
4340 } 4326 }
4341
4342 /** 4327 /**
4343 * Instances of the class {@code ResolutionEraser} remove any resolution informa tion from an AST 4328 * Instances of the class {@code ResolutionEraser} remove any resolution informa tion from an AST
4344 * structure when used to visit that structure. 4329 * structure when used to visit that structure.
4345 */ 4330 */
4346 class ResolutionEraser extends GeneralizingASTVisitor<Object> { 4331 class ResolutionEraser extends GeneralizingASTVisitor<Object> {
4347 Object visitAssignmentExpression(AssignmentExpression node) { 4332 Object visitAssignmentExpression(AssignmentExpression node) {
4348 node.element = null; 4333 node.element = null;
4349 return super.visitAssignmentExpression(node); 4334 return super.visitAssignmentExpression(node);
4350 } 4335 }
4351 Object visitBinaryExpression(BinaryExpression node) { 4336 Object visitBinaryExpression(BinaryExpression node) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4403 } 4388 }
4404 Object visitSimpleIdentifier(SimpleIdentifier node) { 4389 Object visitSimpleIdentifier(SimpleIdentifier node) {
4405 node.element = null; 4390 node.element = null;
4406 return super.visitSimpleIdentifier(node); 4391 return super.visitSimpleIdentifier(node);
4407 } 4392 }
4408 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { 4393 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
4409 node.element = null; 4394 node.element = null;
4410 return super.visitSuperConstructorInvocation(node); 4395 return super.visitSuperConstructorInvocation(node);
4411 } 4396 }
4412 } 4397 }
4413
4414 /** 4398 /**
4415 * The interface {@code Logger} defines the behavior of objects that can be used to receive 4399 * The interface {@code Logger} defines the behavior of objects that can be used to receive
4416 * information about errors within the analysis engine. Implementations usually write this 4400 * information about errors within the analysis engine. Implementations usually write this
4417 * information to a file, but can also record the information for later use (suc h as during testing) 4401 * information to a file, but can also record the information for later use (suc h as during testing)
4418 * or even ignore the information. 4402 * or even ignore the information.
4419 * @coverage dart.engine.utilities 4403 * @coverage dart.engine.utilities
4420 */ 4404 */
4421 abstract class Logger { 4405 abstract class Logger {
4422 static Logger NULL = new Logger_NullLogger(); 4406 static Logger NULL = new Logger_NullLogger();
4423 4407
4424 /** 4408 /**
4425 * Log the given message as an error. 4409 * Log the given message as an error.
4426 * @param message an explanation of why the error occurred or what it means 4410 * @param message an explanation of why the error occurred or what it means
4427 */ 4411 */
4428 void logError(String message); 4412 void logError(String message);
4429 4413
4430 /** 4414 /**
4431 * Log the given exception as one representing an error. 4415 * Log the given exception as one representing an error.
4432 * @param message an explanation of why the error occurred or what it means 4416 * @param message an explanation of why the error occurred or what it means
4433 * @param exception the exception being logged 4417 * @param exception the exception being logged
4434 */ 4418 */
4435 void logError2(String message, Exception exception); 4419 void logError2(String message, Exception exception);
4436 4420
4437 /** 4421 /**
4438 * Log the given exception as one representing an error. 4422 * Log the given exception as one representing an error.
4439 * @param exception the exception being logged 4423 * @param exception the exception being logged
4440 */ 4424 */
4441 void logError3(Exception exception); 4425 void logError3(Exception exception);
4442 4426
4443 /** 4427 /**
4444 * Log the given informational message. 4428 * Log the given informational message.
4445 * @param message an explanation of why the error occurred or what it means 4429 * @param message an explanation of why the error occurred or what it means
4446 * @param exception the exception being logged 4430 * @param exception the exception being logged
4447 */ 4431 */
4448 void logInformation(String message); 4432 void logInformation(String message);
4449 4433
4450 /** 4434 /**
4451 * Log the given exception as one representing an informational message. 4435 * Log the given exception as one representing an informational message.
4452 * @param message an explanation of why the error occurred or what it means 4436 * @param message an explanation of why the error occurred or what it means
4453 * @param exception the exception being logged 4437 * @param exception the exception being logged
4454 */ 4438 */
4455 void logInformation2(String message, Exception exception); 4439 void logInformation2(String message, Exception exception);
4456 } 4440 }
4457
4458 /** 4441 /**
4459 * Implementation of {@link Logger} that does nothing. 4442 * Implementation of {@link Logger} that does nothing.
4460 */ 4443 */
4461 class Logger_NullLogger implements Logger { 4444 class Logger_NullLogger implements Logger {
4462 void logError(String message) { 4445 void logError(String message) {
4463 } 4446 }
4464 void logError2(String message, Exception exception) { 4447 void logError2(String message, Exception exception) {
4465 } 4448 }
4466 void logError3(Exception exception) { 4449 void logError3(Exception exception) {
4467 } 4450 }
4468 void logInformation(String message) { 4451 void logInformation(String message) {
4469 } 4452 }
4470 void logInformation2(String message, Exception exception) { 4453 void logInformation2(String message, Exception exception) {
4471 } 4454 }
4472 } 4455 }
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