OLD | NEW |
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 library engine; | 3 library engine; |
4 import 'dart:collection' show HasNextIterator; | 4 import 'dart:collection' show HasNextIterator; |
5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
6 import 'java_engine.dart'; | 6 import 'java_engine.dart'; |
7 import 'instrumentation.dart'; | 7 import 'instrumentation.dart'; |
8 import 'error.dart'; | 8 import 'error.dart'; |
9 import 'source.dart'; | 9 import 'source.dart'; |
10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; | 10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; |
11 import 'ast.dart'; | 11 import 'ast.dart'; |
12 import 'parser.dart' show Parser; | 12 import 'parser.dart' show Parser; |
13 import 'sdk.dart' show DartSdk; | 13 import 'sdk.dart' show DartSdk; |
14 import 'element.dart'; | 14 import 'element.dart'; |
15 import 'resolver.dart'; | 15 import 'resolver.dart'; |
16 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; |
17 /** | 17 /** |
18 * The unique instance of the class `AnalysisEngine` serves as the entry point f
or the | 18 * The unique instance of the class `AnalysisEngine` serves as the entry point f
or the |
19 * functionality provided by the analysis engine. | 19 * functionality provided by the analysis engine. |
| 20 * |
20 * @coverage dart.engine | 21 * @coverage dart.engine |
21 */ | 22 */ |
22 class AnalysisEngine { | 23 class AnalysisEngine { |
23 | 24 |
24 /** | 25 /** |
25 * The suffix used for Dart source files. | 26 * The suffix used for Dart source files. |
26 */ | 27 */ |
27 static String SUFFIX_DART = "dart"; | 28 static String SUFFIX_DART = "dart"; |
28 | 29 |
29 /** | 30 /** |
30 * The short suffix used for HTML files. | 31 * The short suffix used for HTML files. |
31 */ | 32 */ |
32 static String SUFFIX_HTM = "htm"; | 33 static String SUFFIX_HTM = "htm"; |
33 | 34 |
34 /** | 35 /** |
35 * The long suffix used for HTML files. | 36 * The long suffix used for HTML files. |
36 */ | 37 */ |
37 static String SUFFIX_HTML = "html"; | 38 static String SUFFIX_HTML = "html"; |
38 | 39 |
39 /** | 40 /** |
40 * The unique instance of this class. | 41 * The unique instance of this class. |
41 */ | 42 */ |
42 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); | 43 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); |
43 | 44 |
44 /** | 45 /** |
45 * Return the unique instance of this class. | 46 * Return the unique instance of this class. |
| 47 * |
46 * @return the unique instance of this class | 48 * @return the unique instance of this class |
47 */ | 49 */ |
48 static AnalysisEngine get instance => _UniqueInstance; | 50 static AnalysisEngine get instance => _UniqueInstance; |
49 | 51 |
50 /** | 52 /** |
51 * Return `true` if the given file name is assumed to contain Dart source code
. | 53 * Return `true` if the given file name is assumed to contain Dart source code
. |
| 54 * |
52 * @param fileName the name of the file being tested | 55 * @param fileName the name of the file being tested |
53 * @return `true` if the given file name is assumed to contain Dart source cod
e | 56 * @return `true` if the given file name is assumed to contain Dart source cod
e |
54 */ | 57 */ |
55 static bool isDartFileName(String fileName) { | 58 static bool isDartFileName(String fileName) { |
56 if (fileName == null) { | 59 if (fileName == null) { |
57 return false; | 60 return false; |
58 } | 61 } |
59 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName),
SUFFIX_DART); | 62 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName),
SUFFIX_DART); |
60 } | 63 } |
61 | 64 |
62 /** | 65 /** |
63 * Return `true` if the given file name is assumed to contain HTML. | 66 * Return `true` if the given file name is assumed to contain HTML. |
| 67 * |
64 * @param fileName the name of the file being tested | 68 * @param fileName the name of the file being tested |
65 * @return `true` if the given file name is assumed to contain HTML | 69 * @return `true` if the given file name is assumed to contain HTML |
66 */ | 70 */ |
67 static bool isHtmlFileName(String fileName) { | 71 static bool isHtmlFileName(String fileName) { |
68 if (fileName == null) { | 72 if (fileName == null) { |
69 return false; | 73 return false; |
70 } | 74 } |
71 String extension = FileNameUtilities.getExtension(fileName); | 75 String extension = FileNameUtilities.getExtension(fileName); |
72 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual
sIgnoreCase(extension, SUFFIX_HTM); | 76 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual
sIgnoreCase(extension, SUFFIX_HTM); |
73 } | 77 } |
74 | 78 |
75 /** | 79 /** |
76 * The logger that should receive information about errors within the analysis
engine. | 80 * The logger that should receive information about errors within the analysis
engine. |
77 */ | 81 */ |
78 Logger _logger = Logger.NULL; | 82 Logger _logger = Logger.NULL; |
79 | 83 |
80 /** | 84 /** |
81 * Create a new context in which analysis can be performed. | 85 * Create a new context in which analysis can be performed. |
| 86 * |
82 * @return the analysis context that was created | 87 * @return the analysis context that was created |
83 */ | 88 */ |
84 AnalysisContext createAnalysisContext() { | 89 AnalysisContext createAnalysisContext() { |
85 if (Instrumentation.isNullLogger) { | 90 if (Instrumentation.isNullLogger) { |
86 return new DelegatingAnalysisContextImpl(); | 91 return new DelegatingAnalysisContextImpl(); |
87 } else { | 92 } else { |
88 return new InstrumentedAnalysisContextImpl.con1(new DelegatingAnalysisCont
extImpl()); | 93 return new InstrumentedAnalysisContextImpl.con1(new DelegatingAnalysisCont
extImpl()); |
89 } | 94 } |
90 } | 95 } |
91 | 96 |
92 /** | 97 /** |
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 a
nalysis engine. |
| 99 * |
94 * @return the logger that should receive information about errors within the
analysis engine | 100 * @return the logger that should receive information about errors within the
analysis engine |
95 */ | 101 */ |
96 Logger get logger => _logger; | 102 Logger get logger => _logger; |
97 | 103 |
98 /** | 104 /** |
99 * Set the logger that should receive information about errors within the anal
ysis engine to the | 105 * Set the logger that should receive information about errors within the anal
ysis engine to the |
100 * given logger. | 106 * given logger. |
| 107 * |
101 * @param logger the logger that should receive information about errors withi
n the analysis | 108 * @param logger the logger that should receive information about errors withi
n the analysis |
102 * engine | 109 * engine |
103 */ | 110 */ |
104 void set logger(Logger logger2) { | 111 void set logger(Logger logger2) { |
105 this._logger = logger2 == null ? Logger.NULL : logger2; | 112 this._logger = logger2 == null ? Logger.NULL : logger2; |
106 } | 113 } |
107 } | 114 } |
108 /** | 115 /** |
109 * The interface `AnalysisContext` defines the behavior of objects that represen
t a context in | 116 * The interface `AnalysisContext` defines the behavior of objects that represen
t a context in |
110 * which a single analysis can be performed and incrementally maintained. The co
ntext includes such | 117 * which a single analysis can be performed and incrementally maintained. The co
ntext includes such |
111 * information as the version of the SDK being analyzed against as well as the p
ackage-root used to | 118 * information as the version of the SDK being analyzed against as well as the p
ackage-root used to |
112 * resolve 'package:' URI's. (Both of which are known indirectly through the [So
urceFactorysource factory].) | 119 * resolve 'package:' URI's. (Both of which are known indirectly through the [So
urceFactory |
| 120 ].) |
113 * | 121 * |
114 * An analysis context also represents the state of the analysis, which includes
knowing which | 122 * An analysis context also represents the state of the analysis, which includes
knowing which |
115 * sources have been included in the analysis (either directly or indirectly) an
d the results of the | 123 * sources have been included in the analysis (either directly or indirectly) an
d the results of the |
116 * analysis. Sources must be added and removed from the context using the method
[applyChanges], which is also used to notify the context when sources have been | 124 * analysis. Sources must be added and removed from the context using the method |
| 125 * [applyChanges], which is also used to notify the context when sources have be
en |
117 * modified and, consequently, previously known results might have been invalida
ted. | 126 * modified and, consequently, previously known results might have been invalida
ted. |
118 * | 127 * |
119 * There are two ways to access the results of the analysis. The most common is
to use one of the | 128 * There are two ways to access the results of the analysis. The most common is
to use one of the |
120 * 'get' methods to access the results. The 'get' methods have the advantage tha
t they will always | 129 * 'get' methods to access the results. The 'get' methods have the advantage tha
t they will always |
121 * return quickly, but have the disadvantage that if the results are not current
ly available they | 130 * return quickly, but have the disadvantage that if the results are not current
ly available they |
122 * will return either nothing or in some cases an incomplete result. The second
way to access | 131 * will return either nothing or in some cases an incomplete result. The second
way to access |
123 * results is by using one of the 'compute' methods. The 'compute' methods will
always attempt to | 132 * results is by using one of the 'compute' methods. The 'compute' methods will
always attempt to |
124 * compute the requested results but might block the caller for a significant pe
riod of time. | 133 * compute the requested results but might block the caller for a significant pe
riod of time. |
125 * | 134 * |
126 * When results have been invalidated, have never been computed (as is the case
for newly added | 135 * When results have been invalidated, have never been computed (as is the case
for newly added |
127 * sources), or have been removed from the cache, they are <b>not</b> automatica
lly recreated. They | 136 * sources), or have been removed from the cache, they are <b>not</b> automatica
lly recreated. They |
128 * will only be recreated if one of the 'compute' methods is invoked. | 137 * will only be recreated if one of the 'compute' methods is invoked. |
129 * | 138 * |
130 * However, this is not always acceptable. Some clients need to keep the analysi
s results | 139 * However, this is not always acceptable. Some clients need to keep the analysi
s results |
131 * up-to-date. For such clients there is a mechanism that allows them to increme
ntally perform | 140 * up-to-date. For such clients there is a mechanism that allows them to increme
ntally perform |
132 * needed analysis and get notified of the consequent changes to the analysis re
sults. This | 141 * needed analysis and get notified of the consequent changes to the analysis re
sults. This |
133 * mechanism is realized by the method [performAnalysisTask]. | 142 * mechanism is realized by the method [performAnalysisTask]. |
134 * | 143 * |
135 * Analysis engine allows for having more than one context. This can be used, fo
r example, to | 144 * Analysis engine allows for having more than one context. This can be used, fo
r example, to |
136 * perform one analysis based on the state of files on disk and a separate analy
sis based on the | 145 * perform one analysis based on the state of files on disk and a separate analy
sis based on the |
137 * state of those files in open editors. It can also be used to perform an analy
sis based on a | 146 * state of those files in open editors. It can also be used to perform an analy
sis based on a |
138 * proposed future state, such as the state after a refactoring. | 147 * proposed future state, such as the state after a refactoring. |
139 */ | 148 */ |
140 abstract class AnalysisContext { | 149 abstract class AnalysisContext { |
141 | 150 |
142 /** | 151 /** |
143 * Apply the changes specified by the given change set to this context. Any an
alysis results that | 152 * Apply the changes specified by the given change set to this context. Any an
alysis results that |
144 * have been invalidated by these changes will be removed. | 153 * have been invalidated by these changes will be removed. |
| 154 * |
145 * @param changeSet a description of the changes that are to be applied | 155 * @param changeSet a description of the changes that are to be applied |
146 */ | 156 */ |
147 void applyChanges(ChangeSet changeSet); | 157 void applyChanges(ChangeSet changeSet); |
148 | 158 |
149 /** | 159 /** |
150 * Return the documentation comment for the given element as it appears in the
original source | 160 * Return the documentation comment for the given element as it appears in the
original source |
151 * (complete with the beginning and ending delimiters), or `null` if the eleme
nt does not | 161 * (complete with the beginning and ending delimiters), or `null` if the eleme
nt does not |
152 * have a documentation comment associated with it. This can be a long-running
operation if the | 162 * have a documentation comment associated with it. This can be a long-running
operation if the |
153 * information needed to access the comment is not cached. | 163 * information needed to access the comment is not cached. |
| 164 * |
154 * @param element the element whose documentation comment is to be returned | 165 * @param element the element whose documentation comment is to be returned |
155 * @return the element's documentation comment | 166 * @return the element's documentation comment |
156 * @throws AnalysisException if the documentation comment could not be determi
ned because the | 167 * @throws AnalysisException if the documentation comment could not be determi
ned because the |
157 * analysis could not be performed | 168 * analysis could not be performed |
158 */ | 169 */ |
159 String computeDocumentationComment(Element element); | 170 String computeDocumentationComment(Element element); |
160 | 171 |
161 /** | 172 /** |
162 * Return an array containing all of the errors associated with the given sour
ce. If the errors | 173 * Return an array containing all of the errors associated with the given sour
ce. If the errors |
163 * are not already known then the source will be analyzed in order to determin
e the errors | 174 * are not already known then the source will be analyzed in order to determin
e the errors |
164 * associated with it. | 175 * associated with it. |
| 176 * |
165 * @param source the source whose errors are to be returned | 177 * @param source the source whose errors are to be returned |
166 * @return all of the errors associated with the given source | 178 * @return all of the errors associated with the given source |
167 * @throws AnalysisException if the errors could not be determined because the
analysis could not | 179 * @throws AnalysisException if the errors could not be determined because the
analysis could not |
168 * be performed | 180 * be performed |
169 * @see #getErrors(Source) | 181 * @see #getErrors(Source) |
170 */ | 182 */ |
171 List<AnalysisError> computeErrors(Source source); | 183 List<AnalysisError> computeErrors(Source source); |
172 | 184 |
173 /** | 185 /** |
174 * Return the element model corresponding to the HTML file defined by the give
n source. If the | 186 * Return the element model corresponding to the HTML file defined by the give
n source. If the |
175 * element model does not yet exist it will be created. The process of creatin
g an element model | 187 * element model does not yet exist it will be created. The process of creatin
g an element model |
176 * for an HTML file can long-running, depending on the size of the file and th
e number of | 188 * for an HTML file can long-running, depending on the size of the file and th
e number of |
177 * libraries that are defined in it (via script tags) that also need to have a
model built for | 189 * libraries that are defined in it (via script tags) that also need to have a
model built for |
178 * them. | 190 * them. |
| 191 * |
179 * @param source the source defining the HTML file whose element model is to b
e returned | 192 * @param source the source defining the HTML file whose element model is to b
e returned |
180 * @return the element model corresponding to the HTML file defined by the giv
en source | 193 * @return the element model corresponding to the HTML file defined by the giv
en source |
181 * @throws AnalysisException if the element model could not be determined beca
use the analysis | 194 * @throws AnalysisException if the element model could not be determined beca
use the analysis |
182 * could not be performed | 195 * could not be performed |
183 * @see #getHtmlElement(Source) | 196 * @see #getHtmlElement(Source) |
184 */ | 197 */ |
185 HtmlElement computeHtmlElement(Source source); | 198 HtmlElement computeHtmlElement(Source source); |
186 | 199 |
187 /** | 200 /** |
188 * Return the kind of the given source, computing it's kind if it is not alrea
dy known. Return[SourceKind#UNKNOWN] if the source is not contained in this cont
ext. | 201 * Return the kind of the given source, computing it's kind if it is not alrea
dy known. Return |
| 202 * [SourceKind#UNKNOWN] if the source is not contained in this context. |
| 203 * |
189 * @param source the source whose kind is to be returned | 204 * @param source the source whose kind is to be returned |
190 * @return the kind of the given source | 205 * @return the kind of the given source |
191 * @see #getKindOf(Source) | 206 * @see #getKindOf(Source) |
192 */ | 207 */ |
193 SourceKind computeKindOf(Source source); | 208 SourceKind computeKindOf(Source source); |
194 | 209 |
195 /** | 210 /** |
196 * Return the element model corresponding to the library defined by the given
source. If the | 211 * Return the element model corresponding to the library defined by the given
source. If the |
197 * element model does not yet exist it will be created. The process of creatin
g an element model | 212 * element model does not yet exist it will be created. The process of creatin
g an element model |
198 * for a library can long-running, depending on the size of the library and th
e number of | 213 * for a library can long-running, depending on the size of the library and th
e number of |
199 * libraries that are imported into it that also need to have a model built fo
r them. | 214 * libraries that are imported into it that also need to have a model built fo
r them. |
| 215 * |
200 * @param source the source defining the library whose element model is to be
returned | 216 * @param source the source defining the library whose element model is to be
returned |
201 * @return the element model corresponding to the library defined by the given
source | 217 * @return the element model corresponding to the library defined by the given
source |
202 * @throws AnalysisException if the element model could not be determined beca
use the analysis | 218 * @throws AnalysisException if the element model could not be determined beca
use the analysis |
203 * could not be performed | 219 * could not be performed |
204 * @see #getLibraryElement(Source) | 220 * @see #getLibraryElement(Source) |
205 */ | 221 */ |
206 LibraryElement computeLibraryElement(Source source); | 222 LibraryElement computeLibraryElement(Source source); |
207 | 223 |
208 /** | 224 /** |
209 * Return the line information for the given source, or `null` if the source i
s not of a | 225 * Return the line information for the given source, or `null` if the source i
s not of a |
210 * recognized kind (neither a Dart nor HTML file). If the line information was
not previously | 226 * recognized kind (neither a Dart nor HTML file). If the line information was
not previously |
211 * known it will be created. The line information is used to map offsets from
the beginning of the | 227 * known it will be created. The line information is used to map offsets from
the beginning of the |
212 * source to line and column pairs. | 228 * source to line and column pairs. |
| 229 * |
213 * @param source the source whose line information is to be returned | 230 * @param source the source whose line information is to be returned |
214 * @return the line information for the given source | 231 * @return the line information for the given source |
215 * @throws AnalysisException if the line information could not be determined b
ecause the analysis | 232 * @throws AnalysisException if the line information could not be determined b
ecause the analysis |
216 * could not be performed | 233 * could not be performed |
217 * @see #getLineInfo(Source) | 234 * @see #getLineInfo(Source) |
218 */ | 235 */ |
219 LineInfo computeLineInfo(Source source); | 236 LineInfo computeLineInfo(Source source); |
220 | 237 |
221 /** | 238 /** |
222 * Create a new context in which analysis can be performed. Any sources in the
specified container | 239 * Create a new context in which analysis can be performed. Any sources in the
specified container |
223 * will be removed from this context and added to the newly created context. | 240 * will be removed from this context and added to the newly created context. |
| 241 * |
224 * @param container the container containing sources that should be removed fr
om this context and | 242 * @param container the container containing sources that should be removed fr
om this context and |
225 * added to the returned context | 243 * added to the returned context |
226 * @return the analysis context that was created | 244 * @return the analysis context that was created |
227 */ | 245 */ |
228 AnalysisContext extractContext(SourceContainer container); | 246 AnalysisContext extractContext(SourceContainer container); |
229 | 247 |
230 /** | 248 /** |
231 * Return the set of analysis options controlling the behavior of this context
. | 249 * Return the set of analysis options controlling the behavior of this context
. |
| 250 * |
232 * @return the set of analysis options controlling the behavior of this contex
t | 251 * @return the set of analysis options controlling the behavior of this contex
t |
233 */ | 252 */ |
234 AnalysisOptions get analysisOptions; | 253 AnalysisOptions get analysisOptions; |
235 | 254 |
236 /** | 255 /** |
237 * Return the element referenced by the given location, or `null` if the eleme
nt is not | 256 * Return the element referenced by the given location, or `null` if the eleme
nt is not |
238 * immediately available or if there is no element with the given location. Th
e latter condition | 257 * immediately available or if there is no element with the given location. Th
e latter condition |
239 * can occur, for example, if the location describes an element from a differe
nt context or if the | 258 * can occur, for example, if the location describes an element from a differe
nt context or if the |
240 * element has been removed from this context as a result of some change since
it was originally | 259 * element has been removed from this context as a result of some change since
it was originally |
241 * obtained. | 260 * obtained. |
| 261 * |
242 * @param location the reference describing the element to be returned | 262 * @param location the reference describing the element to be returned |
243 * @return the element referenced by the given location | 263 * @return the element referenced by the given location |
244 */ | 264 */ |
245 Element getElement(ElementLocation location); | 265 Element getElement(ElementLocation location); |
246 | 266 |
247 /** | 267 /** |
248 * Return an analysis error info containing the array of all of the errors and
the line info | 268 * Return an analysis error info containing the array of all of the errors and
the line info |
249 * associated with the given source. The array of errors will be empty if the
source is not known | 269 * associated with the given source. The array of errors will be empty if the
source is not known |
250 * to this context or if there are no errors in the source. The errors contain
ed in the array can | 270 * to this context or if there are no errors in the source. The errors contain
ed in the array can |
251 * be incomplete. | 271 * be incomplete. |
| 272 * |
252 * @param source the source whose errors are to be returned | 273 * @param source the source whose errors are to be returned |
253 * @return all of the errors associated with the given source and the line inf
o | 274 * @return all of the errors associated with the given source and the line inf
o |
254 * @see #computeErrors(Source) | 275 * @see #computeErrors(Source) |
255 */ | 276 */ |
256 AnalysisErrorInfo getErrors(Source source); | 277 AnalysisErrorInfo getErrors(Source source); |
257 | 278 |
258 /** | 279 /** |
259 * Return the element model corresponding to the HTML file defined by the give
n source, or`null` if the source does not represent an HTML file, the element re
presenting the file | 280 * Return the element model corresponding to the HTML file defined by the give
n source, or |
| 281 * `null` if the source does not represent an HTML file, the element represent
ing the file |
260 * has not yet been created, or the analysis of the HTML file failed for some
reason. | 282 * has not yet been created, or the analysis of the HTML file failed for some
reason. |
| 283 * |
261 * @param source the source defining the HTML file whose element model is to b
e returned | 284 * @param source the source defining the HTML file whose element model is to b
e returned |
262 * @return the element model corresponding to the HTML file defined by the giv
en source | 285 * @return the element model corresponding to the HTML file defined by the giv
en source |
263 * @see #computeHtmlElement(Source) | 286 * @see #computeHtmlElement(Source) |
264 */ | 287 */ |
265 HtmlElement getHtmlElement(Source source); | 288 HtmlElement getHtmlElement(Source source); |
266 | 289 |
267 /** | 290 /** |
268 * Return the sources for the HTML files that reference the given compilation
unit. If the source | 291 * Return the sources for the HTML files that reference the given compilation
unit. If the source |
269 * does not represent a Dart source or is not known to this context, the retur
ned array will be | 292 * does not represent a Dart source or is not known to this context, the retur
ned array will be |
270 * empty. The contents of the array can be incomplete. | 293 * empty. The contents of the array can be incomplete. |
| 294 * |
271 * @param source the source referenced by the returned HTML files | 295 * @param source the source referenced by the returned HTML files |
272 * @return the sources for the HTML files that reference the given compilation
unit | 296 * @return the sources for the HTML files that reference the given compilation
unit |
273 */ | 297 */ |
274 List<Source> getHtmlFilesReferencing(Source source); | 298 List<Source> getHtmlFilesReferencing(Source source); |
275 | 299 |
276 /** | 300 /** |
277 * Return an array containing all of the sources known to this context that re
present HTML files. | 301 * Return an array containing all of the sources known to this context that re
present HTML files. |
278 * The contents of the array can be incomplete. | 302 * The contents of the array can be incomplete. |
| 303 * |
279 * @return the sources known to this context that represent HTML files | 304 * @return the sources known to this context that represent HTML files |
280 */ | 305 */ |
281 List<Source> get htmlSources; | 306 List<Source> get htmlSources; |
282 | 307 |
283 /** | 308 /** |
284 * Return the kind of the given source, or `null` if the kind is not known to
this context. | 309 * Return the kind of the given source, or `null` if the kind is not known to
this context. |
| 310 * |
285 * @param source the source whose kind is to be returned | 311 * @param source the source whose kind is to be returned |
286 * @return the kind of the given source | 312 * @return the kind of the given source |
287 * @see #computeKindOf(Source) | 313 * @see #computeKindOf(Source) |
288 */ | 314 */ |
289 SourceKind getKindOf(Source source); | 315 SourceKind getKindOf(Source source); |
290 | 316 |
291 /** | 317 /** |
292 * Return an array containing all of the sources known to this context that re
present the defining | 318 * Return an array containing all of the sources known to this context that re
present the defining |
293 * compilation unit of a library that can be run within a browser. The sources
that are returned | 319 * compilation unit of a library that can be run within a browser. The sources
that are returned |
294 * represent libraries that have a 'main' method and are either referenced by
an HTML file or | 320 * represent libraries that have a 'main' method and are either referenced by
an HTML file or |
295 * import, directly or indirectly, a client-only library. The contents of the
array can be | 321 * import, directly or indirectly, a client-only library. The contents of the
array can be |
296 * incomplete. | 322 * incomplete. |
| 323 * |
297 * @return the sources known to this context that represent the defining compi
lation unit of a | 324 * @return the sources known to this context that represent the defining compi
lation unit of a |
298 * library that can be run within a browser | 325 * library that can be run within a browser |
299 */ | 326 */ |
300 List<Source> get launchableClientLibrarySources; | 327 List<Source> get launchableClientLibrarySources; |
301 | 328 |
302 /** | 329 /** |
303 * Return an array containing all of the sources known to this context that re
present the defining | 330 * Return an array containing all of the sources known to this context that re
present the defining |
304 * compilation unit of a library that can be run outside of a browser. The con
tents of the array | 331 * compilation unit of a library that can be run outside of a browser. The con
tents of the array |
305 * can be incomplete. | 332 * can be incomplete. |
| 333 * |
306 * @return the sources known to this context that represent the defining compi
lation unit of a | 334 * @return the sources known to this context that represent the defining compi
lation unit of a |
307 * library that can be run outside of a browser | 335 * library that can be run outside of a browser |
308 */ | 336 */ |
309 List<Source> get launchableServerLibrarySources; | 337 List<Source> get launchableServerLibrarySources; |
310 | 338 |
311 /** | 339 /** |
312 * Return the sources for the defining compilation units of any libraries of w
hich the given | 340 * Return the sources for the defining compilation units of any libraries of w
hich the given |
313 * source is a part. The array will normally contain a single library because
most Dart sources | 341 * source is a part. The array will normally contain a single library because
most Dart sources |
314 * are only included in a single library, but it is possible to have a part th
at is contained in | 342 * are only included in a single library, but it is possible to have a part th
at is contained in |
315 * multiple identically named libraries. If the source represents the defining
compilation unit of | 343 * multiple identically named libraries. If the source represents the defining
compilation unit of |
316 * a library, then the returned array will contain the given source as its onl
y element. If the | 344 * a library, then the returned array will contain the given source as its onl
y element. If the |
317 * source does not represent a Dart source or is not known to this context, th
e returned array | 345 * source does not represent a Dart source or is not known to this context, th
e returned array |
318 * will be empty. The contents of the array can be incomplete. | 346 * will be empty. The contents of the array can be incomplete. |
| 347 * |
319 * @param source the source contained in the returned libraries | 348 * @param source the source contained in the returned libraries |
320 * @return the sources for the libraries containing the given source | 349 * @return the sources for the libraries containing the given source |
321 */ | 350 */ |
322 List<Source> getLibrariesContaining(Source source); | 351 List<Source> getLibrariesContaining(Source source); |
323 | 352 |
324 /** | 353 /** |
325 * Return the sources for the defining compilation units of any libraries that
depend on the given | 354 * Return the sources for the defining compilation units of any libraries that
depend on the given |
326 * library. One library depends on another if it either imports or exports tha
t library. | 355 * library. One library depends on another if it either imports or exports tha
t library. |
| 356 * |
327 * @param librarySource the source for the defining compilation unit of the li
brary being depended | 357 * @param librarySource the source for the defining compilation unit of the li
brary being depended |
328 * on | 358 * on |
329 * @return the sources for the libraries that depend on the given library | 359 * @return the sources for the libraries that depend on the given library |
330 */ | 360 */ |
331 List<Source> getLibrariesDependingOn(Source librarySource); | 361 List<Source> getLibrariesDependingOn(Source librarySource); |
332 | 362 |
333 /** | 363 /** |
334 * Return the element model corresponding to the library defined by the given
source, or`null` if the element model does not currently exist or if the library
cannot be analyzed | 364 * Return the element model corresponding to the library defined by the given
source, or |
| 365 * `null` if the element model does not currently exist or if the library cann
ot be analyzed |
335 * for some reason. | 366 * for some reason. |
| 367 * |
336 * @param source the source defining the library whose element model is to be
returned | 368 * @param source the source defining the library whose element model is to be
returned |
337 * @return the element model corresponding to the library defined by the given
source | 369 * @return the element model corresponding to the library defined by the given
source |
338 */ | 370 */ |
339 LibraryElement getLibraryElement(Source source); | 371 LibraryElement getLibraryElement(Source source); |
340 | 372 |
341 /** | 373 /** |
342 * Return an array containing all of the sources known to this context that re
present the defining | 374 * Return an array containing all of the sources known to this context that re
present the defining |
343 * compilation unit of a library. The contents of the array can be incomplete. | 375 * compilation unit of a library. The contents of the array can be incomplete. |
| 376 * |
344 * @return the sources known to this context that represent the defining compi
lation unit of a | 377 * @return the sources known to this context that represent the defining compi
lation unit of a |
345 * library | 378 * library |
346 */ | 379 */ |
347 List<Source> get librarySources; | 380 List<Source> get librarySources; |
348 | 381 |
349 /** | 382 /** |
350 * Return the line information for the given source, or `null` if the line inf
ormation is | 383 * Return the line information for the given source, or `null` if the line inf
ormation is |
351 * not known. The line information is used to map offsets from the beginning o
f the source to line | 384 * not known. The line information is used to map offsets from the beginning o
f the source to line |
352 * and column pairs. | 385 * and column pairs. |
| 386 * |
353 * @param source the source whose line information is to be returned | 387 * @param source the source whose line information is to be returned |
354 * @return the line information for the given source | 388 * @return the line information for the given source |
355 * @see #computeLineInfo(Source) | 389 * @see #computeLineInfo(Source) |
356 */ | 390 */ |
357 LineInfo getLineInfo(Source source); | 391 LineInfo getLineInfo(Source source); |
358 | 392 |
359 /** | 393 /** |
360 * Return a fully resolved AST for a single compilation unit within the given
library, or`null` if the resolved AST is not already computed. | 394 * Return a fully resolved AST for a single compilation unit within the given
library, or |
| 395 * `null` if the resolved AST is not already computed. |
| 396 * |
361 * @param unitSource the source of the compilation unit | 397 * @param unitSource the source of the compilation unit |
362 * @param library the library containing the compilation unit | 398 * @param library the library containing the compilation unit |
363 * @return a fully resolved AST for the compilation unit | 399 * @return a fully resolved AST for the compilation unit |
364 * @see #resolveCompilationUnit(Source,LibraryElement) | 400 * @see #resolveCompilationUnit(Source, LibraryElement) |
365 */ | 401 */ |
366 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary); | 402 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary); |
367 | 403 |
368 /** | 404 /** |
369 * Return a fully resolved AST for a single compilation unit within the given
library, or`null` if the resolved AST is not already computed. | 405 * Return a fully resolved AST for a single compilation unit within the given
library, or |
| 406 * `null` if the resolved AST is not already computed. |
| 407 * |
370 * @param unitSource the source of the compilation unit | 408 * @param unitSource the source of the compilation unit |
371 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 409 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
372 * compilation unit | 410 * compilation unit |
373 * @return a fully resolved AST for the compilation unit | 411 * @return a fully resolved AST for the compilation unit |
374 * @see #resolveCompilationUnit(Source,Source) | 412 * @see #resolveCompilationUnit(Source, Source) |
375 */ | 413 */ |
376 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource); | 414 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource); |
377 | 415 |
378 /** | 416 /** |
379 * Return the source factory used to create the sources that can be analyzed i
n this context. | 417 * Return the source factory used to create the sources that can be analyzed i
n this context. |
| 418 * |
380 * @return the source factory used to create the sources that can be analyzed
in this context | 419 * @return the source factory used to create the sources that can be analyzed
in this context |
381 */ | 420 */ |
382 SourceFactory get sourceFactory; | 421 SourceFactory get sourceFactory; |
383 | 422 |
384 /** | 423 /** |
385 * Return `true` if the given source is known to be the defining compilation u
nit of a | 424 * Return `true` if the given source is known to be the defining compilation u
nit of a |
386 * library that can be run on a client (references 'dart:html', either directl
y or indirectly). | 425 * library that can be run on a client (references 'dart:html', either directl
y or indirectly). |
387 * | 426 * |
388 * <b>Note:</b> In addition to the expected case of returning `false` if the s
ource is known | 427 * <b>Note:</b> In addition to the expected case of returning `false` if the s
ource is known |
389 * to be a library that cannot be run on a client, this method will also retur
n `false` if | 428 * to be a library that cannot be run on a client, this method will also retur
n `false` if |
390 * the source is not known to be a library or if we do not know whether it can
be run on a client. | 429 * the source is not known to be a library or if we do not know whether it can
be run on a client. |
| 430 * |
391 * @param librarySource the source being tested | 431 * @param librarySource the source being tested |
392 * @return `true` if the given source is known to be a library that can be run
on a client | 432 * @return `true` if the given source is known to be a library that can be run
on a client |
393 */ | 433 */ |
394 bool isClientLibrary(Source librarySource); | 434 bool isClientLibrary(Source librarySource); |
395 | 435 |
396 /** | 436 /** |
397 * Return `true` if the given source is known to be the defining compilation u
nit of a | 437 * Return `true` if the given source is known to be the defining compilation u
nit of a |
398 * library that can be run on the server (does not reference 'dart:html', eith
er directly or | 438 * library that can be run on the server (does not reference 'dart:html', eith
er directly or |
399 * indirectly). | 439 * indirectly). |
400 * | 440 * |
401 * <b>Note:</b> In addition to the expected case of returning `false` if the s
ource is known | 441 * <b>Note:</b> In addition to the expected case of returning `false` if the s
ource is known |
402 * to be a library that cannot be run on the server, this method will also ret
urn `false` if | 442 * to be a library that cannot be run on the server, this method will also ret
urn `false` if |
403 * the source is not known to be a library or if we do not know whether it can
be run on the | 443 * the source is not known to be a library or if we do not know whether it can
be run on the |
404 * server. | 444 * server. |
| 445 * |
405 * @param librarySource the source being tested | 446 * @param librarySource the source being tested |
406 * @return `true` if the given source is known to be a library that can be run
on the server | 447 * @return `true` if the given source is known to be a library that can be run
on the server |
407 */ | 448 */ |
408 bool isServerLibrary(Source librarySource); | 449 bool isServerLibrary(Source librarySource); |
409 | 450 |
410 /** | 451 /** |
411 * Add the sources contained in the specified context to this context's collec
tion of sources. | 452 * Add the sources contained in the specified context to this context's collec
tion of sources. |
412 * This method is called when an existing context's pubspec has been removed,
and the contained | 453 * This method is called when an existing context's pubspec has been removed,
and the contained |
413 * sources should be reanalyzed as part of this context. | 454 * sources should be reanalyzed as part of this context. |
| 455 * |
414 * @param context the context being merged | 456 * @param context the context being merged |
415 */ | 457 */ |
416 void mergeContext(AnalysisContext context); | 458 void mergeContext(AnalysisContext context); |
417 | 459 |
418 /** | 460 /** |
419 * Parse a single source to produce an AST structure. The resulting AST struct
ure may or may not | 461 * Parse a single source to produce an AST structure. The resulting AST struct
ure may or may not |
420 * be resolved, and may have a slightly different structure depending upon whe
ther it is resolved. | 462 * be resolved, and may have a slightly different structure depending upon whe
ther it is resolved. |
| 463 * |
421 * @param source the source to be parsed | 464 * @param source the source to be parsed |
422 * @return the AST structure representing the content of the source | 465 * @return the AST structure representing the content of the source |
423 * @throws AnalysisException if the analysis could not be performed | 466 * @throws AnalysisException if the analysis could not be performed |
424 */ | 467 */ |
425 CompilationUnit parseCompilationUnit(Source source); | 468 CompilationUnit parseCompilationUnit(Source source); |
426 | 469 |
427 /** | 470 /** |
428 * Parse a single HTML source to produce an AST structure. The resulting HTML
AST structure may or | 471 * Parse a single HTML source to produce an AST structure. The resulting HTML
AST structure may or |
429 * may not be resolved, and may have a slightly different structure depending
upon whether it is | 472 * may not be resolved, and may have a slightly different structure depending
upon whether it is |
430 * resolved. | 473 * resolved. |
| 474 * |
431 * @param source the HTML source to be parsed | 475 * @param source the HTML source to be parsed |
432 * @return the parse result (not `null`) | 476 * @return the parse result (not `null`) |
433 * @throws AnalysisException if the analysis could not be performed | 477 * @throws AnalysisException if the analysis could not be performed |
434 */ | 478 */ |
435 HtmlUnit parseHtmlUnit(Source source); | 479 HtmlUnit parseHtmlUnit(Source source); |
436 | 480 |
437 /** | 481 /** |
438 * Perform the next unit of work required to keep the analysis results up-to-d
ate and return | 482 * Perform the next unit of work required to keep the analysis results up-to-d
ate and return |
439 * information about the consequent changes to the analysis results. If there
were no results the | 483 * information about the consequent changes to the analysis results. If there
were no results the |
440 * returned array will be empty. If there are no more units of work required,
then this method | 484 * returned array will be empty. If there are no more units of work required,
then this method |
441 * returns `null`. This method can be long running. | 485 * returns `null`. This method can be long running. |
| 486 * |
442 * @return an array containing notices of changes to the analysis results | 487 * @return an array containing notices of changes to the analysis results |
443 */ | 488 */ |
444 List<ChangeNotice> performAnalysisTask(); | 489 List<ChangeNotice> performAnalysisTask(); |
445 | 490 |
446 /** | 491 /** |
447 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 492 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
| 493 * |
448 * @param unitSource the source to be parsed and resolved | 494 * @param unitSource the source to be parsed and resolved |
449 * @param library the library containing the source to be resolved | 495 * @param library the library containing the source to be resolved |
450 * @return the result of resolving the AST structure representing the content
of the source in the | 496 * @return the result of resolving the AST structure representing the content
of the source in the |
451 * context of the given library | 497 * context of the given library |
452 * @throws AnalysisException if the analysis could not be performed | 498 * @throws AnalysisException if the analysis could not be performed |
453 * @see #getResolvedCompilationUnit(Source,LibraryElement) | 499 * @see #getResolvedCompilationUnit(Source, LibraryElement) |
454 */ | 500 */ |
455 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry); | 501 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry); |
456 | 502 |
457 /** | 503 /** |
458 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 504 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
| 505 * |
459 * @param unitSource the source to be parsed and resolved | 506 * @param unitSource the source to be parsed and resolved |
460 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 507 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
461 * source to be resolved | 508 * source to be resolved |
462 * @return the result of resolving the AST structure representing the content
of the source in the | 509 * @return the result of resolving the AST structure representing the content
of the source in the |
463 * context of the given library | 510 * context of the given library |
464 * @throws AnalysisException if the analysis could not be performed | 511 * @throws AnalysisException if the analysis could not be performed |
465 * @see #getResolvedCompilationUnit(Source,Source) | 512 * @see #getResolvedCompilationUnit(Source, Source) |
466 */ | 513 */ |
467 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e); | 514 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e); |
468 | 515 |
469 /** | 516 /** |
470 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 517 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
| 518 * |
471 * @param htmlSource the source to be parsed and resolved | 519 * @param htmlSource the source to be parsed and resolved |
472 * @return the result of resolving the AST structure representing the content
of the source | 520 * @return the result of resolving the AST structure representing the content
of the source |
473 * @throws AnalysisException if the analysis could not be performed | 521 * @throws AnalysisException if the analysis could not be performed |
474 */ | 522 */ |
475 HtmlUnit resolveHtmlUnit(Source htmlSource); | 523 HtmlUnit resolveHtmlUnit(Source htmlSource); |
476 | 524 |
477 /** | 525 /** |
478 * Set the set of analysis options controlling the behavior of this context to
the given options. | 526 * Set the set of analysis options controlling the behavior of this context to
the given options. |
479 * Clients can safely assume that all necessary analysis results have been inv
alidated. | 527 * Clients can safely assume that all necessary analysis results have been inv
alidated. |
| 528 * |
480 * @param options the set of analysis options that will control the behavior o
f this context | 529 * @param options the set of analysis options that will control the behavior o
f this context |
481 */ | 530 */ |
482 void set analysisOptions(AnalysisOptions options); | 531 void set analysisOptions(AnalysisOptions options); |
483 | 532 |
484 /** | 533 /** |
| 534 * Set the order in which sources will be analyzed by [performAnalysisTask] to
match the |
| 535 * order of the sources in the given list. If a source that needs to be analyz
ed is not contained |
| 536 * in the list, then it will be treated as if it were at the end of the list.
If the list is empty |
| 537 * (or `null`) then no sources will be given priority over other sources. |
| 538 * |
| 539 * Changes made to the list after this method returns will <b>not</b> be refle
cted in the priority |
| 540 * order. |
| 541 * |
| 542 * @param sources the sources to be given priority over other sources |
| 543 */ |
| 544 void set analysisPriorityOrder(List<Source> sources); |
| 545 |
| 546 /** |
485 * Set the contents of the given source to the given contents and mark the sou
rce as having | 547 * Set the contents of the given source to the given contents and mark the sou
rce as having |
486 * changed. This has the effect of overriding the default contents of the sour
ce. If the contents | 548 * changed. This has the effect of overriding the default contents of the sour
ce. If the contents |
487 * are `null` the override is removed so that the default contents will be ret
urned. | 549 * are `null` the override is removed so that the default contents will be ret
urned. |
| 550 * |
488 * @param source the source whose contents are being overridden | 551 * @param source the source whose contents are being overridden |
489 * @param contents the new contents of the source | 552 * @param contents the new contents of the source |
490 */ | 553 */ |
491 void setContents(Source source, String contents); | 554 void setContents(Source source, String contents); |
492 | 555 |
493 /** | 556 /** |
494 * Set the source factory used to create the sources that can be analyzed in t
his context to the | 557 * Set the source factory used to create the sources that can be analyzed in t
his context to the |
495 * given source factory. Clients can safely assume that all analysis results h
ave been | 558 * given source factory. Clients can safely assume that all analysis results h
ave been |
496 * invalidated. | 559 * invalidated. |
| 560 * |
497 * @param factory the source factory used to create the sources that can be an
alyzed in this | 561 * @param factory the source factory used to create the sources that can be an
alyzed in this |
498 * context | 562 * context |
499 */ | 563 */ |
500 void set sourceFactory(SourceFactory factory); | 564 void set sourceFactory(SourceFactory factory); |
501 | 565 |
502 /** | 566 /** |
503 * Given a collection of sources with content that has changed, return an [Ite
rable]identifying the sources that need to be resolved. | 567 * Given a collection of sources with content that has changed, return an [Ite
rable] |
| 568 * identifying the sources that need to be resolved. |
| 569 * |
504 * @param changedSources an array of sources (not `null`, contains no `null`s) | 570 * @param changedSources an array of sources (not `null`, contains no `null`s) |
505 * @return An iterable returning the sources to be resolved | 571 * @return An iterable returning the sources to be resolved |
506 */ | 572 */ |
507 Iterable<Source> sourcesToResolve(List<Source> changedSources); | 573 Iterable<Source> sourcesToResolve(List<Source> changedSources); |
508 } | 574 } |
509 /** | 575 /** |
510 * The interface `AnalysisErrorInfo` contains the analysis errors and line infor
mation for the | 576 * The interface `AnalysisErrorInfo` contains the analysis errors and line infor
mation for the |
511 * errors. | 577 * errors. |
512 */ | 578 */ |
513 abstract class AnalysisErrorInfo { | 579 abstract class AnalysisErrorInfo { |
514 | 580 |
515 /** | 581 /** |
516 * Return the errors that as a result of the analysis, or `null` if there were
no errors. | 582 * Return the errors that as a result of the analysis, or `null` if there were
no errors. |
| 583 * |
517 * @return the errors as a result of the analysis | 584 * @return the errors as a result of the analysis |
518 */ | 585 */ |
519 List<AnalysisError> get errors; | 586 List<AnalysisError> get errors; |
520 | 587 |
521 /** | 588 /** |
522 * Return the line information associated with the errors, or `null` if there
were no | 589 * Return the line information associated with the errors, or `null` if there
were no |
523 * errors. | 590 * errors. |
| 591 * |
524 * @return the line information associated with the errors | 592 * @return the line information associated with the errors |
525 */ | 593 */ |
526 LineInfo get lineInfo; | 594 LineInfo get lineInfo; |
527 } | 595 } |
528 /** | 596 /** |
529 * Instances of the class `AnalysisException` represent an exception that occurr
ed during the | 597 * Instances of the class `AnalysisException` represent an exception that occurr
ed during the |
530 * analysis of one or more sources. | 598 * analysis of one or more sources. |
| 599 * |
531 * @coverage dart.engine | 600 * @coverage dart.engine |
532 */ | 601 */ |
533 class AnalysisException extends JavaException { | 602 class AnalysisException extends JavaException { |
534 | 603 |
535 /** | 604 /** |
536 * Initialize a newly created exception. | 605 * Initialize a newly created exception. |
537 */ | 606 */ |
538 AnalysisException() : super() { | 607 AnalysisException() : super() { |
539 _jtd_constructor_125_impl(); | 608 _jtd_constructor_125_impl(); |
540 } | 609 } |
541 _jtd_constructor_125_impl() { | 610 _jtd_constructor_125_impl() { |
542 } | 611 } |
543 | 612 |
544 /** | 613 /** |
545 * Initialize a newly created exception to have the given message. | 614 * Initialize a newly created exception to have the given message. |
| 615 * |
546 * @param message the message associated with the exception | 616 * @param message the message associated with the exception |
547 */ | 617 */ |
548 AnalysisException.con1(String message) : super(message) { | 618 AnalysisException.con1(String message) : super(message) { |
549 _jtd_constructor_126_impl(message); | 619 _jtd_constructor_126_impl(message); |
550 } | 620 } |
551 _jtd_constructor_126_impl(String message) { | 621 _jtd_constructor_126_impl(String message) { |
552 } | 622 } |
553 | 623 |
554 /** | 624 /** |
555 * Initialize a newly created exception to have the given message and cause. | 625 * Initialize a newly created exception to have the given message and cause. |
| 626 * |
556 * @param message the message associated with the exception | 627 * @param message the message associated with the exception |
557 * @param cause the underlying exception that caused this exception | 628 * @param cause the underlying exception that caused this exception |
558 */ | 629 */ |
559 AnalysisException.con2(String message, Exception cause) : super(message, cause
) { | 630 AnalysisException.con2(String message, Exception cause) : super(message, cause
) { |
560 _jtd_constructor_127_impl(message, cause); | 631 _jtd_constructor_127_impl(message, cause); |
561 } | 632 } |
562 _jtd_constructor_127_impl(String message, Exception cause) { | 633 _jtd_constructor_127_impl(String message, Exception cause) { |
563 } | 634 } |
564 | 635 |
565 /** | 636 /** |
566 * Initialize a newly created exception to have the given cause. | 637 * Initialize a newly created exception to have the given cause. |
| 638 * |
567 * @param cause the underlying exception that caused this exception | 639 * @param cause the underlying exception that caused this exception |
568 */ | 640 */ |
569 AnalysisException.con3(Exception cause) : super.withCause(cause) { | 641 AnalysisException.con3(Exception cause) : super.withCause(cause) { |
570 _jtd_constructor_128_impl(cause); | 642 _jtd_constructor_128_impl(cause); |
571 } | 643 } |
572 _jtd_constructor_128_impl(Exception cause) { | 644 _jtd_constructor_128_impl(Exception cause) { |
573 } | 645 } |
574 } | 646 } |
575 /** | 647 /** |
576 * The interface `AnalysisOptions` defines the behavior of objects that provide
access to a | 648 * The interface `AnalysisOptions` defines the behavior of objects that provide
access to a |
577 * set of analysis options used to control the behavior of an analysis context. | 649 * set of analysis options used to control the behavior of an analysis context. |
578 */ | 650 */ |
579 abstract class AnalysisOptions { | 651 abstract class AnalysisOptions { |
580 | 652 |
581 /** | 653 /** |
| 654 * Return `true` if analysis is to generate audit results (e.g. type inference
based |
| 655 * information and pub best practices). |
| 656 * |
| 657 * @return `true` if analysis is to generate audit results |
| 658 */ |
| 659 bool get audit; |
| 660 |
| 661 /** |
582 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based | 662 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based |
583 * exclusively on the static type information. | 663 * exclusively on the static type information. |
| 664 * |
584 * @return `true` if analysis is to use strict mode | 665 * @return `true` if analysis is to use strict mode |
585 */ | 666 */ |
586 bool get strictMode; | 667 bool get strictMode; |
587 } | 668 } |
588 /** | 669 /** |
589 * The interface `ChangeNotice` defines the behavior of objects that represent a
change to the | 670 * The interface `ChangeNotice` defines the behavior of objects that represent a
change to the |
590 * analysis results associated with a given source. | 671 * analysis results associated with a given source. |
| 672 * |
591 * @coverage dart.engine | 673 * @coverage dart.engine |
592 */ | 674 */ |
593 abstract class ChangeNotice implements AnalysisErrorInfo { | 675 abstract class ChangeNotice implements AnalysisErrorInfo { |
594 | 676 |
595 /** | 677 /** |
596 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the | 678 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the |
597 * AST was not changed. | 679 * AST was not changed. |
| 680 * |
598 * @return the fully resolved AST that changed as a result of the analysis | 681 * @return the fully resolved AST that changed as a result of the analysis |
599 */ | 682 */ |
600 CompilationUnit get compilationUnit; | 683 CompilationUnit get compilationUnit; |
601 | 684 |
602 /** | 685 /** |
603 * Return the source for which the result is being reported. | 686 * Return the source for which the result is being reported. |
| 687 * |
604 * @return the source for which the result is being reported | 688 * @return the source for which the result is being reported |
605 */ | 689 */ |
606 Source get source; | 690 Source get source; |
607 } | 691 } |
608 /** | 692 /** |
609 * Instances of the class `ChangeSet` indicate what sources have been added, cha
nged, or | 693 * Instances of the class `ChangeSet` indicate what sources have been added, cha
nged, or |
610 * removed. | 694 * removed. |
| 695 * |
611 * @coverage dart.engine | 696 * @coverage dart.engine |
612 */ | 697 */ |
613 class ChangeSet { | 698 class ChangeSet { |
614 | 699 |
615 /** | 700 /** |
616 * A list containing the sources that have been added. | 701 * A list containing the sources that have been added. |
617 */ | 702 */ |
618 List<Source> _added2 = new List<Source>(); | 703 List<Source> _added2 = new List<Source>(); |
619 | 704 |
620 /** | 705 /** |
621 * A list containing the sources that have been changed. | 706 * A list containing the sources that have been changed. |
622 */ | 707 */ |
623 List<Source> _changed2 = new List<Source>(); | 708 List<Source> _changed2 = new List<Source>(); |
624 | 709 |
625 /** | 710 /** |
626 * A list containing the sources that have been removed. | 711 * A list containing the sources that have been removed. |
627 */ | 712 */ |
628 List<Source> _removed2 = new List<Source>(); | 713 List<Source> _removed2 = new List<Source>(); |
629 | 714 |
630 /** | 715 /** |
631 * A list containing the source containers specifying additional sources that
have been removed. | 716 * A list containing the source containers specifying additional sources that
have been removed. |
632 */ | 717 */ |
633 List<SourceContainer> _removedContainers = new List<SourceContainer>(); | 718 List<SourceContainer> _removedContainers = new List<SourceContainer>(); |
634 | 719 |
635 /** | 720 /** |
636 * Record that the specified source has been added and that it's content is th
e default contents | 721 * Record that the specified source has been added and that it's content is th
e default contents |
637 * of the source. | 722 * of the source. |
| 723 * |
638 * @param source the source that was added | 724 * @param source the source that was added |
639 */ | 725 */ |
640 void added(Source source) { | 726 void added(Source source) { |
641 _added2.add(source); | 727 _added2.add(source); |
642 } | 728 } |
643 | 729 |
644 /** | 730 /** |
645 * Record that the specified source has been changed and that it's content is
the default contents | 731 * Record that the specified source has been changed and that it's content is
the default contents |
646 * of the source. | 732 * of the source. |
| 733 * |
647 * @param source the source that was changed | 734 * @param source the source that was changed |
648 */ | 735 */ |
649 void changed(Source source) { | 736 void changed(Source source) { |
650 _changed2.add(source); | 737 _changed2.add(source); |
651 } | 738 } |
652 | 739 |
653 /** | 740 /** |
654 * Return a collection of the sources that have been added. | 741 * Return a collection of the sources that have been added. |
| 742 * |
655 * @return a collection of the sources that have been added | 743 * @return a collection of the sources that have been added |
656 */ | 744 */ |
657 List<Source> get added3 => _added2; | 745 List<Source> get added3 => _added2; |
658 | 746 |
659 /** | 747 /** |
660 * Return a collection of sources that have been changed. | 748 * Return a collection of sources that have been changed. |
| 749 * |
661 * @return a collection of sources that have been changed | 750 * @return a collection of sources that have been changed |
662 */ | 751 */ |
663 List<Source> get changed3 => _changed2; | 752 List<Source> get changed3 => _changed2; |
664 | 753 |
665 /** | 754 /** |
666 * Return a list containing the sources that were removed. | 755 * Return a list containing the sources that were removed. |
| 756 * |
667 * @return a list containing the sources that were removed | 757 * @return a list containing the sources that were removed |
668 */ | 758 */ |
669 List<Source> get removed => _removed2; | 759 List<Source> get removed => _removed2; |
670 | 760 |
671 /** | 761 /** |
672 * Return a list containing the source containers that were removed. | 762 * Return a list containing the source containers that were removed. |
| 763 * |
673 * @return a list containing the source containers that were removed | 764 * @return a list containing the source containers that were removed |
674 */ | 765 */ |
675 List<SourceContainer> get removedContainers => _removedContainers; | 766 List<SourceContainer> get removedContainers => _removedContainers; |
676 | 767 |
677 /** | 768 /** |
678 * Return `true` if this change set does not contain any changes. | 769 * Return `true` if this change set does not contain any changes. |
| 770 * |
679 * @return `true` if this change set does not contain any changes | 771 * @return `true` if this change set does not contain any changes |
680 */ | 772 */ |
681 bool get isEmpty => _added2.isEmpty && _changed2.isEmpty && _removed2.isEmpty
&& _removedContainers.isEmpty; | 773 bool get isEmpty => _added2.isEmpty && _changed2.isEmpty && _removed2.isEmpty
&& _removedContainers.isEmpty; |
682 | 774 |
683 /** | 775 /** |
684 * Record that the specified source has been removed. | 776 * Record that the specified source has been removed. |
| 777 * |
685 * @param source the source that was removed | 778 * @param source the source that was removed |
686 */ | 779 */ |
687 void removed3(Source source) { | 780 void removed3(Source source) { |
688 if (source != null) { | 781 if (source != null) { |
689 _removed2.add(source); | 782 _removed2.add(source); |
690 } | 783 } |
691 } | 784 } |
692 | 785 |
693 /** | 786 /** |
694 * Record that the specified source container has been removed. | 787 * Record that the specified source container has been removed. |
| 788 * |
695 * @param container the source container that was removed | 789 * @param container the source container that was removed |
696 */ | 790 */ |
697 void removedContainer(SourceContainer container) { | 791 void removedContainer(SourceContainer container) { |
698 if (container != null) { | 792 if (container != null) { |
699 _removedContainers.add(container); | 793 _removedContainers.add(container); |
700 } | 794 } |
701 } | 795 } |
702 } | 796 } |
703 /** | 797 /** |
704 * The interface `DartEntry` defines the behavior of objects that maintain the i
nformation | 798 * The interface `DartEntry` defines the behavior of objects that maintain the i
nformation |
705 * cached by an analysis context about an individual Dart file. | 799 * cached by an analysis context about an individual Dart file. |
| 800 * |
706 * @coverage dart.engine | 801 * @coverage dart.engine |
707 */ | 802 */ |
708 abstract class DartEntry implements SourceEntry { | 803 abstract class DartEntry implements SourceEntry { |
709 | 804 |
710 /** | 805 /** |
711 * The data descriptor representing the library element for the library. This
data is only | 806 * The data descriptor representing the library element for the library. This
data is only |
712 * available for Dart files that are the defining compilation unit of a librar
y. | 807 * available for Dart files that are the defining compilation unit of a librar
y. |
713 */ | 808 */ |
714 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra
ryElement>("DartEntry.ELEMENT"); | 809 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra
ryElement>("DartEntry.ELEMENT"); |
715 | 810 |
716 /** | 811 /** |
717 * The data descriptor representing the list of referenced libraries. This dat
a is only available | 812 * The data descriptor representing the list of exported libraries. This data
is only available |
718 * for Dart files that are the defining compilation unit of a library. | 813 * for Dart files that are the defining compilation unit of a library. |
719 */ | 814 */ |
720 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescr
iptor<List<Source>>("DartEntry.REFERENCED_LIBRARIES"); | 815 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES = new DataDescrip
tor<List<Source>>("DartEntry.EXPORTED_LIBRARIES"); |
| 816 |
| 817 /** |
| 818 * The data descriptor representing the list of imported libraries. This data
is only available |
| 819 * for Dart files that are the defining compilation unit of a library. |
| 820 */ |
| 821 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES = new DataDescrip
tor<List<Source>>("DartEntry.IMPORTED_LIBRARIES"); |
721 | 822 |
722 /** | 823 /** |
723 * The data descriptor representing the list of included parts. This data is o
nly available for | 824 * The data descriptor representing the list of included parts. This data is o
nly available for |
724 * Dart files that are the defining compilation unit of a library. | 825 * Dart files that are the defining compilation unit of a library. |
725 */ | 826 */ |
726 static final DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<
List<Source>>("DartEntry.INCLUDED_PARTS"); | 827 static final DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<
List<Source>>("DartEntry.INCLUDED_PARTS"); |
727 | 828 |
728 /** | 829 /** |
729 * The data descriptor representing the client flag. This data is only availab
le for Dart files | 830 * The data descriptor representing the client flag. This data is only availab
le for Dart files |
730 * that are the defining compilation unit of a library. | 831 * that are the defining compilation unit of a library. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 */ | 864 */ |
764 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescripto
r<CompilationUnit>("DartEntry.RESOLVED_UNIT"); | 865 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescripto
r<CompilationUnit>("DartEntry.RESOLVED_UNIT"); |
765 | 866 |
766 /** | 867 /** |
767 * The data descriptor representing the source kind. | 868 * The data descriptor representing the source kind. |
768 */ | 869 */ |
769 static final DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<Sourc
eKind>("DartEntry.SOURCE_KIND"); | 870 static final DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<Sourc
eKind>("DartEntry.SOURCE_KIND"); |
770 | 871 |
771 /** | 872 /** |
772 * Return all of the errors associated with the compilation unit that are curr
ently cached. | 873 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 874 * |
773 * @return all of the errors associated with the compilation unit | 875 * @return all of the errors associated with the compilation unit |
774 */ | 876 */ |
775 List<AnalysisError> get allErrors; | 877 List<AnalysisError> get allErrors; |
776 | 878 |
777 /** | 879 /** |
778 * Return a valid parsed compilation unit, either an unresolved AST structure
or the result of | 880 * Return a valid parsed compilation unit, either an unresolved AST structure
or the result of |
779 * resolving the AST structure in the context of some library, or `null` if th
ere is no | 881 * resolving the AST structure in the context of some library, or `null` if th
ere is no |
780 * parsed compilation unit available. | 882 * parsed compilation unit available. |
| 883 * |
781 * @return a valid parsed compilation unit | 884 * @return a valid parsed compilation unit |
782 */ | 885 */ |
783 CompilationUnit get anyParsedCompilationUnit; | 886 CompilationUnit get anyParsedCompilationUnit; |
784 | 887 |
785 /** | 888 /** |
786 * Return the result of resolving the compilation unit as part of any library,
or `null` if | 889 * Return the result of resolving the compilation unit as part of any library,
or `null` if |
787 * there is no cached resolved compilation unit. | 890 * there is no cached resolved compilation unit. |
| 891 * |
788 * @return any resolved compilation unit | 892 * @return any resolved compilation unit |
789 */ | 893 */ |
790 CompilationUnit get anyResolvedCompilationUnit; | 894 CompilationUnit get anyResolvedCompilationUnit; |
791 | 895 |
792 /** | 896 /** |
793 * Return the state of the data represented by the given descriptor in the con
text of the given | 897 * Return the state of the data represented by the given descriptor in the con
text of the given |
794 * library. | 898 * library. |
| 899 * |
795 * @param descriptor the descriptor representing the data whose state is to be
returned | 900 * @param descriptor the descriptor representing the data whose state is to be
returned |
796 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 901 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
797 * context for the data | 902 * context for the data |
798 * @return the value of the data represented by the given descriptor and libra
ry | 903 * @return the value of the data represented by the given descriptor and libra
ry |
799 */ | 904 */ |
800 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource); | 905 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource); |
801 | 906 |
802 /** | 907 /** |
803 * Return the value of the data represented by the given descriptor in the con
text of the given | 908 * Return the value of the data represented by the given descriptor in the con
text of the given |
804 * library, or `null` if the data represented by the descriptor is not in the
cache. | 909 * library, or `null` if the data represented by the descriptor is not in the
cache. |
| 910 * |
805 * @param descriptor the descriptor representing which data is to be returned | 911 * @param descriptor the descriptor representing which data is to be returned |
806 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 912 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
807 * context for the data | 913 * context for the data |
808 * @return the value of the data represented by the given descriptor and libra
ry | 914 * @return the value of the data represented by the given descriptor and libra
ry |
809 */ | 915 */ |
810 Object getValue2(DataDescriptor descriptor, Source librarySource); | 916 Object getValue2(DataDescriptor descriptor, Source librarySource); |
811 DartEntryImpl get writableCopy; | 917 DartEntryImpl get writableCopy; |
812 } | 918 } |
813 /** | 919 /** |
814 * Instances of the class `DartEntryImpl` implement a [DartEntry]. | 920 * Instances of the class `DartEntryImpl` implement a [DartEntry]. |
| 921 * |
815 * @coverage dart.engine | 922 * @coverage dart.engine |
816 */ | 923 */ |
817 class DartEntryImpl extends SourceEntryImpl implements DartEntry { | 924 class DartEntryImpl extends SourceEntryImpl implements DartEntry { |
818 | 925 |
819 /** | 926 /** |
820 * The state of the cached source kind. | 927 * The state of the cached source kind. |
821 */ | 928 */ |
822 CacheState _sourceKindState = CacheState.INVALID; | 929 CacheState _sourceKindState = CacheState.INVALID; |
823 | 930 |
824 /** | 931 /** |
(...skipping 28 matching lines...) Expand all Loading... |
853 */ | 960 */ |
854 CacheState _includedPartsState = CacheState.INVALID; | 961 CacheState _includedPartsState = CacheState.INVALID; |
855 | 962 |
856 /** | 963 /** |
857 * The list of parts included in the library, or an empty array if the list is
not currently | 964 * The list of parts included in the library, or an empty array if the list is
not currently |
858 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. | 965 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. |
859 */ | 966 */ |
860 List<Source> _includedParts = Source.EMPTY_ARRAY; | 967 List<Source> _includedParts = Source.EMPTY_ARRAY; |
861 | 968 |
862 /** | 969 /** |
863 * The state of the cached list of referenced libraries. | 970 * The state of the cached list of exported libraries. |
864 */ | 971 */ |
865 CacheState _referencedLibrariesState = CacheState.INVALID; | 972 CacheState _exportedLibrariesState = CacheState.INVALID; |
866 | 973 |
867 /** | 974 /** |
868 * The list of libraries referenced (imported or exported) by the library, or
an empty array if | 975 * The list of libraries exported by the library, or an empty array if the lis
t is not currently |
869 * the list is not currently cached. The list will be empty if the Dart file i
s a part rather than | 976 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. |
870 * a library. | |
871 */ | 977 */ |
872 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; | 978 List<Source> _exportedLibraries = Source.EMPTY_ARRAY; |
| 979 |
| 980 /** |
| 981 * The state of the cached list of imported libraries. |
| 982 */ |
| 983 CacheState _importedLibrariesState = CacheState.INVALID; |
| 984 |
| 985 /** |
| 986 * The list of libraries imported by the library, or an empty array if the lis
t is not currently |
| 987 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. |
| 988 */ |
| 989 List<Source> _importedLibraries = Source.EMPTY_ARRAY; |
873 | 990 |
874 /** | 991 /** |
875 * The information known as a result of resolving this compilation unit as par
t of the library | 992 * The information known as a result of resolving this compilation unit as par
t of the library |
876 * that contains this unit. This field will never be `null`. | 993 * that contains this unit. This field will never be `null`. |
877 */ | 994 */ |
878 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); | 995 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); |
879 | 996 |
880 /** | 997 /** |
881 * The state of the cached library element. | 998 * The state of the cached library element. |
882 */ | 999 */ |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 } | 1071 } |
955 state = state._nextState; | 1072 state = state._nextState; |
956 } | 1073 } |
957 ; | 1074 ; |
958 return null; | 1075 return null; |
959 } | 1076 } |
960 SourceKind get kind => _sourceKind; | 1077 SourceKind get kind => _sourceKind; |
961 CacheState getState(DataDescriptor<Object> descriptor) { | 1078 CacheState getState(DataDescriptor<Object> descriptor) { |
962 if (identical(descriptor, DartEntry.ELEMENT)) { | 1079 if (identical(descriptor, DartEntry.ELEMENT)) { |
963 return _elementState; | 1080 return _elementState; |
| 1081 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1082 return _exportedLibrariesState; |
| 1083 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 1084 return _importedLibrariesState; |
964 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1085 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
965 return _includedPartsState; | 1086 return _includedPartsState; |
966 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1087 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
967 return _clientServerState; | 1088 return _clientServerState; |
968 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 1089 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
969 return _launchableState; | 1090 return _launchableState; |
970 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1091 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
971 return _parseErrorsState; | 1092 return _parseErrorsState; |
972 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1093 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
973 return _parsedUnitState; | 1094 return _parsedUnitState; |
974 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1095 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
975 return _publicNamespaceState; | 1096 return _publicNamespaceState; |
976 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { | |
977 return _referencedLibrariesState; | |
978 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1097 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
979 return _sourceKindState; | 1098 return _sourceKindState; |
980 } else { | 1099 } else { |
981 return super.getState(descriptor); | 1100 return super.getState(descriptor); |
982 } | 1101 } |
983 } | 1102 } |
984 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource2)
{ | 1103 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource2)
{ |
985 DartEntryImpl_ResolutionState state = _resolutionState; | 1104 DartEntryImpl_ResolutionState state = _resolutionState; |
986 while (state != null) { | 1105 while (state != null) { |
987 if (librarySource2 == state._librarySource) { | 1106 if (librarySource2 == state._librarySource) { |
988 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1107 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
989 return _resolutionState._resolutionErrorsState; | 1108 return _resolutionState._resolutionErrorsState; |
990 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1109 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
991 return _resolutionState._resolvedUnitState; | 1110 return _resolutionState._resolvedUnitState; |
992 } else { | 1111 } else { |
993 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); | 1112 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); |
994 } | 1113 } |
995 } | 1114 } |
996 state = state._nextState; | 1115 state = state._nextState; |
997 } | 1116 } |
998 ; | 1117 ; |
999 return CacheState.INVALID; | 1118 return CacheState.INVALID; |
1000 } | 1119 } |
1001 Object getValue(DataDescriptor descriptor) { | 1120 Object getValue(DataDescriptor descriptor) { |
1002 if (identical(descriptor, DartEntry.ELEMENT)) { | 1121 if (identical(descriptor, DartEntry.ELEMENT)) { |
1003 return _element as Object; | 1122 return _element as Object; |
| 1123 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1124 return _exportedLibraries as Object; |
| 1125 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 1126 return _importedLibraries as Object; |
1004 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1127 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
1005 return _includedParts as Object; | 1128 return _includedParts as Object; |
1006 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1129 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
1007 return ((_bitmask & _CLIENT_CODE) != 0 ? true : false) as Object; | 1130 return ((_bitmask & _CLIENT_CODE) != 0 ? true : false) as Object; |
1008 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 1131 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
1009 return ((_bitmask & _LAUNCHABLE) != 0 ? true : false) as Object; | 1132 return ((_bitmask & _LAUNCHABLE) != 0 ? true : false) as Object; |
1010 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1133 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
1011 return _parseErrors as Object; | 1134 return _parseErrors as Object; |
1012 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1135 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
1013 return _parsedUnit as Object; | 1136 return _parsedUnit as Object; |
1014 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1137 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
1015 return _publicNamespace as Object; | 1138 return _publicNamespace as Object; |
1016 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { | |
1017 return _referencedLibraries as Object; | |
1018 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1139 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
1019 return _sourceKind as Object; | 1140 return _sourceKind as Object; |
1020 } | 1141 } |
1021 return super.getValue(descriptor); | 1142 return super.getValue(descriptor); |
1022 } | 1143 } |
1023 Object getValue2(DataDescriptor descriptor, Source librarySource2) { | 1144 Object getValue2(DataDescriptor descriptor, Source librarySource2) { |
1024 DartEntryImpl_ResolutionState state = _resolutionState; | 1145 DartEntryImpl_ResolutionState state = _resolutionState; |
1025 while (state != null) { | 1146 while (state != null) { |
1026 if (librarySource2 == state._librarySource) { | 1147 if (librarySource2 == state._librarySource) { |
1027 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1148 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 } | 1185 } |
1065 | 1186 |
1066 /** | 1187 /** |
1067 * Invalidate all of the resolution information associated with the compilatio
n unit. | 1188 * Invalidate all of the resolution information associated with the compilatio
n unit. |
1068 */ | 1189 */ |
1069 void invalidateAllResolutionInformation() { | 1190 void invalidateAllResolutionInformation() { |
1070 _element = null; | 1191 _element = null; |
1071 _elementState = CacheState.INVALID; | 1192 _elementState = CacheState.INVALID; |
1072 _includedParts = Source.EMPTY_ARRAY; | 1193 _includedParts = Source.EMPTY_ARRAY; |
1073 _includedPartsState = CacheState.INVALID; | 1194 _includedPartsState = CacheState.INVALID; |
1074 _referencedLibraries = Source.EMPTY_ARRAY; | 1195 _exportedLibraries = Source.EMPTY_ARRAY; |
1075 _referencedLibrariesState = CacheState.INVALID; | 1196 _exportedLibrariesState = CacheState.INVALID; |
| 1197 _importedLibraries = Source.EMPTY_ARRAY; |
| 1198 _importedLibrariesState = CacheState.INVALID; |
1076 _bitmask = 0; | 1199 _bitmask = 0; |
1077 _clientServerState = CacheState.INVALID; | 1200 _clientServerState = CacheState.INVALID; |
1078 _launchableState = CacheState.INVALID; | 1201 _launchableState = CacheState.INVALID; |
1079 _publicNamespace = null; | 1202 _publicNamespace = null; |
1080 _publicNamespaceState = CacheState.INVALID; | 1203 _publicNamespaceState = CacheState.INVALID; |
1081 _resolutionState.invalidateAllResolutionInformation(); | 1204 _resolutionState.invalidateAllResolutionInformation(); |
1082 } | 1205 } |
1083 | 1206 |
1084 /** | 1207 /** |
1085 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 1208 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 /** | 1242 /** |
1120 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 1243 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
1121 * entry. This will set the state of all resolution-based information as being
in error, but will | 1244 * entry. This will set the state of all resolution-based information as being
in error, but will |
1122 * not change the state of any parse results. | 1245 * not change the state of any parse results. |
1123 */ | 1246 */ |
1124 void recordResolutionError() { | 1247 void recordResolutionError() { |
1125 _element = null; | 1248 _element = null; |
1126 _elementState = CacheState.ERROR; | 1249 _elementState = CacheState.ERROR; |
1127 _includedParts = Source.EMPTY_ARRAY; | 1250 _includedParts = Source.EMPTY_ARRAY; |
1128 _includedPartsState = CacheState.ERROR; | 1251 _includedPartsState = CacheState.ERROR; |
1129 _referencedLibraries = Source.EMPTY_ARRAY; | 1252 _exportedLibraries = Source.EMPTY_ARRAY; |
1130 _referencedLibrariesState = CacheState.ERROR; | 1253 _exportedLibrariesState = CacheState.ERROR; |
| 1254 _importedLibraries = Source.EMPTY_ARRAY; |
| 1255 _importedLibrariesState = CacheState.ERROR; |
1131 _bitmask = 0; | 1256 _bitmask = 0; |
1132 _clientServerState = CacheState.ERROR; | 1257 _clientServerState = CacheState.ERROR; |
1133 _launchableState = CacheState.ERROR; | 1258 _launchableState = CacheState.ERROR; |
1134 _publicNamespace = null; | 1259 _publicNamespace = null; |
1135 _publicNamespaceState = CacheState.ERROR; | 1260 _publicNamespaceState = CacheState.ERROR; |
1136 _resolutionState.recordResolutionError(); | 1261 _resolutionState.recordResolutionError(); |
1137 } | 1262 } |
1138 | 1263 |
1139 /** | 1264 /** |
1140 * Remove any resolution information associated with this compilation unit bei
ng part of the given | 1265 * Remove any resolution information associated with this compilation unit bei
ng part of the given |
1141 * library, presumably because it is no longer part of the library. | 1266 * library, presumably because it is no longer part of the library. |
| 1267 * |
1142 * @param librarySource the source of the defining compilation unit of the lib
rary that used to | 1268 * @param librarySource the source of the defining compilation unit of the lib
rary that used to |
1143 * contain this part but no longer does | 1269 * contain this part but no longer does |
1144 */ | 1270 */ |
1145 void removeResolution(Source librarySource2) { | 1271 void removeResolution(Source librarySource2) { |
1146 if (librarySource2 != null) { | 1272 if (librarySource2 != null) { |
1147 if (librarySource2 == _resolutionState._librarySource) { | 1273 if (librarySource2 == _resolutionState._librarySource) { |
1148 if (_resolutionState._nextState == null) { | 1274 if (_resolutionState._nextState == null) { |
1149 _resolutionState.invalidateAllResolutionInformation(); | 1275 _resolutionState.invalidateAllResolutionInformation(); |
1150 } else { | 1276 } else { |
1151 _resolutionState = _resolutionState._nextState; | 1277 _resolutionState = _resolutionState._nextState; |
1152 } | 1278 } |
1153 } else { | 1279 } else { |
1154 DartEntryImpl_ResolutionState priorState = _resolutionState; | 1280 DartEntryImpl_ResolutionState priorState = _resolutionState; |
1155 DartEntryImpl_ResolutionState state = _resolutionState._nextState; | 1281 DartEntryImpl_ResolutionState state = _resolutionState._nextState; |
1156 while (state != null) { | 1282 while (state != null) { |
1157 if (librarySource2 == state._librarySource) { | 1283 if (librarySource2 == state._librarySource) { |
1158 priorState._nextState = state._nextState; | 1284 priorState._nextState = state._nextState; |
1159 break; | 1285 break; |
1160 } | 1286 } |
1161 priorState = state; | 1287 priorState = state; |
1162 state = state._nextState; | 1288 state = state._nextState; |
1163 } | 1289 } |
1164 } | 1290 } |
1165 } | 1291 } |
1166 } | 1292 } |
1167 | 1293 |
1168 /** | 1294 /** |
1169 * Set the results of parsing the compilation unit at the given time to the gi
ven values. | 1295 * Set the results of parsing the compilation unit at the given time to the gi
ven values. |
| 1296 * |
1170 * @param modificationStamp the earliest time at which the source was last mod
ified before the | 1297 * @param modificationStamp the earliest time at which the source was last mod
ified before the |
1171 * parsing was started | 1298 * parsing was started |
1172 * @param lineInfo the line information resulting from parsing the compilation
unit | 1299 * @param lineInfo the line information resulting from parsing the compilation
unit |
1173 * @param unit the AST structure resulting from parsing the compilation unit | 1300 * @param unit the AST structure resulting from parsing the compilation unit |
1174 * @param errors the parse errors resulting from parsing the compilation unit | 1301 * @param errors the parse errors resulting from parsing the compilation unit |
1175 */ | 1302 */ |
1176 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit
unit, List<AnalysisError> errors) { | 1303 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit
unit, List<AnalysisError> errors) { |
1177 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { | 1304 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { |
1178 setValue(SourceEntry.LINE_INFO, lineInfo); | 1305 setValue(SourceEntry.LINE_INFO, lineInfo); |
1179 } | 1306 } |
1180 if (_parsedUnitState != CacheState.VALID) { | 1307 if (_parsedUnitState != CacheState.VALID) { |
1181 _parsedUnit = unit; | 1308 _parsedUnit = unit; |
1182 } | 1309 } |
1183 if (_parseErrorsState != CacheState.VALID) { | 1310 if (_parseErrorsState != CacheState.VALID) { |
1184 _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors; | 1311 _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors; |
1185 } | 1312 } |
1186 } | 1313 } |
1187 void setState(DataDescriptor<Object> descriptor, CacheState state) { | 1314 void setState(DataDescriptor<Object> descriptor, CacheState state) { |
1188 if (identical(descriptor, DartEntry.ELEMENT)) { | 1315 if (identical(descriptor, DartEntry.ELEMENT)) { |
1189 _element = updatedValue(state, _element, null); | 1316 _element = updatedValue(state, _element, null); |
1190 _elementState = state; | 1317 _elementState = state; |
| 1318 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1319 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_
ARRAY); |
| 1320 _exportedLibrariesState = state; |
| 1321 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 1322 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_
ARRAY); |
| 1323 _importedLibrariesState = state; |
1191 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1324 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
1192 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); | 1325 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); |
1193 _includedPartsState = state; | 1326 _includedPartsState = state; |
1194 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1327 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
1195 _bitmask = updatedValue2(state, _bitmask, _CLIENT_CODE); | 1328 _bitmask = updatedValue2(state, _bitmask, _CLIENT_CODE); |
1196 _clientServerState = state; | 1329 _clientServerState = state; |
1197 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 1330 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
1198 _bitmask = updatedValue2(state, _bitmask, _LAUNCHABLE); | 1331 _bitmask = updatedValue2(state, _bitmask, _LAUNCHABLE); |
1199 _launchableState = state; | 1332 _launchableState = state; |
1200 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1333 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
1201 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); | 1334 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); |
1202 _parseErrorsState = state; | 1335 _parseErrorsState = state; |
1203 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1336 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
1204 _parsedUnit = updatedValue(state, _parsedUnit, null); | 1337 _parsedUnit = updatedValue(state, _parsedUnit, null); |
1205 _parsedUnitState = state; | 1338 _parsedUnitState = state; |
1206 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1339 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
1207 _publicNamespace = updatedValue(state, _publicNamespace, null); | 1340 _publicNamespace = updatedValue(state, _publicNamespace, null); |
1208 _publicNamespaceState = state; | 1341 _publicNamespaceState = state; |
1209 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { | |
1210 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM
PTY_ARRAY); | |
1211 _referencedLibrariesState = state; | |
1212 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1342 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
1213 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN); | 1343 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN); |
1214 _sourceKindState = state; | 1344 _sourceKindState = state; |
1215 } else { | 1345 } else { |
1216 super.setState(descriptor, state); | 1346 super.setState(descriptor, state); |
1217 } | 1347 } |
1218 } | 1348 } |
1219 | 1349 |
1220 /** | 1350 /** |
1221 * Set the state of the data represented by the given descriptor in the contex
t of the given | 1351 * Set the state of the data represented by the given descriptor in the contex
t of the given |
1222 * library to the given state. | 1352 * library to the given state. |
| 1353 * |
1223 * @param descriptor the descriptor representing the data whose state is to be
set | 1354 * @param descriptor the descriptor representing the data whose state is to be
set |
1224 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 1355 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
1225 * context for the data | 1356 * context for the data |
1226 * @param cacheState the new state of the data represented by the given descri
ptor | 1357 * @param cacheState the new state of the data represented by the given descri
ptor |
1227 */ | 1358 */ |
1228 void setState2(DataDescriptor<Object> descriptor, Source librarySource, CacheS
tate cacheState) { | 1359 void setState2(DataDescriptor<Object> descriptor, Source librarySource, CacheS
tate cacheState) { |
1229 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); | 1360 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); |
1230 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1361 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
1231 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors
, AnalysisError.NO_ERRORS); | 1362 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors
, AnalysisError.NO_ERRORS); |
1232 state._resolutionErrorsState = cacheState; | 1363 state._resolutionErrorsState = cacheState; |
1233 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1364 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
1234 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); | 1365 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); |
1235 state._resolvedUnitState = cacheState; | 1366 state._resolvedUnitState = cacheState; |
1236 } else { | 1367 } else { |
1237 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1368 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
1238 } | 1369 } |
1239 } | 1370 } |
1240 void setValue(DataDescriptor descriptor, Object value) { | 1371 void setValue(DataDescriptor descriptor, Object value) { |
1241 if (identical(descriptor, DartEntry.ELEMENT)) { | 1372 if (identical(descriptor, DartEntry.ELEMENT)) { |
1242 _element = value as LibraryElement; | 1373 _element = value as LibraryElement; |
1243 _elementState = CacheState.VALID; | 1374 _elementState = CacheState.VALID; |
| 1375 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1376 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); |
| 1377 _exportedLibrariesState = CacheState.VALID; |
| 1378 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 1379 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); |
| 1380 _importedLibrariesState = CacheState.VALID; |
1244 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1381 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
1245 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); | 1382 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); |
1246 _includedPartsState = CacheState.VALID; | 1383 _includedPartsState = CacheState.VALID; |
1247 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1384 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
1248 if (((value as bool))) { | 1385 if (((value as bool))) { |
1249 _bitmask |= _CLIENT_CODE; | 1386 _bitmask |= _CLIENT_CODE; |
1250 } else { | 1387 } else { |
1251 _bitmask &= ~_CLIENT_CODE; | 1388 _bitmask &= ~_CLIENT_CODE; |
1252 } | 1389 } |
1253 _clientServerState = CacheState.VALID; | 1390 _clientServerState = CacheState.VALID; |
1254 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 1391 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
1255 if (((value as bool))) { | 1392 if (((value as bool))) { |
1256 _bitmask |= _LAUNCHABLE; | 1393 _bitmask |= _LAUNCHABLE; |
1257 } else { | 1394 } else { |
1258 _bitmask &= ~_LAUNCHABLE; | 1395 _bitmask &= ~_LAUNCHABLE; |
1259 } | 1396 } |
1260 _launchableState = CacheState.VALID; | 1397 _launchableState = CacheState.VALID; |
1261 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1398 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
1262 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); | 1399 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); |
1263 _parseErrorsState = CacheState.VALID; | 1400 _parseErrorsState = CacheState.VALID; |
1264 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1401 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
1265 _parsedUnit = value as CompilationUnit; | 1402 _parsedUnit = value as CompilationUnit; |
1266 _parsedUnitState = CacheState.VALID; | 1403 _parsedUnitState = CacheState.VALID; |
1267 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1404 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
1268 _publicNamespace = value as Namespace; | 1405 _publicNamespace = value as Namespace; |
1269 _publicNamespaceState = CacheState.VALID; | 1406 _publicNamespaceState = CacheState.VALID; |
1270 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { | |
1271 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List
<Source>); | |
1272 _referencedLibrariesState = CacheState.VALID; | |
1273 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1407 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
1274 _sourceKind = value as SourceKind; | 1408 _sourceKind = value as SourceKind; |
1275 _sourceKindState = CacheState.VALID; | 1409 _sourceKindState = CacheState.VALID; |
1276 } else { | 1410 } else { |
1277 super.setValue(descriptor, value); | 1411 super.setValue(descriptor, value); |
1278 } | 1412 } |
1279 } | 1413 } |
1280 | 1414 |
1281 /** | 1415 /** |
1282 * Set the value of the data represented by the given descriptor in the contex
t of the given | 1416 * Set the value of the data represented by the given descriptor in the contex
t of the given |
1283 * library to the given value, and set the state of that data to [CacheState#V
ALID]. | 1417 * library to the given value, and set the state of that data to [CacheState#V
ALID]. |
| 1418 * |
1284 * @param descriptor the descriptor representing which data is to have its val
ue set | 1419 * @param descriptor the descriptor representing which data is to have its val
ue set |
1285 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 1420 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
1286 * context for the data | 1421 * context for the data |
1287 * @param value the new value of the data represented by the given descriptor
and library | 1422 * @param value the new value of the data represented by the given descriptor
and library |
1288 */ | 1423 */ |
1289 void setValue2(DataDescriptor descriptor, Source librarySource, Object value)
{ | 1424 void setValue2(DataDescriptor descriptor, Source librarySource, Object value)
{ |
1290 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); | 1425 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); |
1291 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1426 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
1292 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); | 1427 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); |
1293 state._resolutionErrorsState = CacheState.VALID; | 1428 state._resolutionErrorsState = CacheState.VALID; |
1294 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1429 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
1295 state._resolvedUnit = value as CompilationUnit; | 1430 state._resolvedUnit = value as CompilationUnit; |
1296 state._resolvedUnitState = CacheState.VALID; | 1431 state._resolvedUnitState = CacheState.VALID; |
1297 } | 1432 } |
1298 } | 1433 } |
1299 void copyFrom(SourceEntryImpl entry) { | 1434 void copyFrom(SourceEntryImpl entry) { |
1300 super.copyFrom(entry); | 1435 super.copyFrom(entry); |
1301 DartEntryImpl other = entry as DartEntryImpl; | 1436 DartEntryImpl other = entry as DartEntryImpl; |
1302 _sourceKindState = other._sourceKindState; | 1437 _sourceKindState = other._sourceKindState; |
1303 _sourceKind = other._sourceKind; | 1438 _sourceKind = other._sourceKind; |
1304 _parsedUnitState = other._parsedUnitState; | 1439 _parsedUnitState = other._parsedUnitState; |
1305 _parsedUnit = other._parsedUnit; | 1440 _parsedUnit = other._parsedUnit; |
1306 _parseErrorsState = other._parseErrorsState; | 1441 _parseErrorsState = other._parseErrorsState; |
1307 _parseErrors = other._parseErrors; | 1442 _parseErrors = other._parseErrors; |
1308 _includedPartsState = other._includedPartsState; | 1443 _includedPartsState = other._includedPartsState; |
1309 _includedParts = other._includedParts; | 1444 _includedParts = other._includedParts; |
1310 _referencedLibrariesState = other._referencedLibrariesState; | 1445 _exportedLibrariesState = other._exportedLibrariesState; |
1311 _referencedLibraries = other._referencedLibraries; | 1446 _exportedLibraries = other._exportedLibraries; |
| 1447 _importedLibrariesState = other._importedLibrariesState; |
| 1448 _importedLibraries = other._importedLibraries; |
1312 _resolutionState.copyFrom(other._resolutionState); | 1449 _resolutionState.copyFrom(other._resolutionState); |
1313 _elementState = other._elementState; | 1450 _elementState = other._elementState; |
1314 _element = other._element; | 1451 _element = other._element; |
1315 _publicNamespaceState = other._publicNamespaceState; | 1452 _publicNamespaceState = other._publicNamespaceState; |
1316 _publicNamespace = other._publicNamespace; | 1453 _publicNamespace = other._publicNamespace; |
1317 _clientServerState = other._clientServerState; | 1454 _clientServerState = other._clientServerState; |
1318 _launchableState = other._launchableState; | 1455 _launchableState = other._launchableState; |
1319 _bitmask = other._bitmask; | 1456 _bitmask = other._bitmask; |
1320 } | 1457 } |
1321 | 1458 |
1322 /** | 1459 /** |
1323 * Return a resolution state for the specified library, creating one as necess
ary. | 1460 * Return a resolution state for the specified library, creating one as necess
ary. |
| 1461 * |
1324 * @param librarySource the library source (not `null`) | 1462 * @param librarySource the library source (not `null`) |
1325 * @return the resolution state (not `null`) | 1463 * @return the resolution state (not `null`) |
1326 */ | 1464 */ |
1327 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2
) { | 1465 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2
) { |
1328 DartEntryImpl_ResolutionState state = _resolutionState; | 1466 DartEntryImpl_ResolutionState state = _resolutionState; |
1329 if (state._librarySource == null) { | 1467 if (state._librarySource == null) { |
1330 state._librarySource = librarySource2; | 1468 state._librarySource = librarySource2; |
1331 return state; | 1469 return state; |
1332 } | 1470 } |
1333 while (state._librarySource != librarySource2) { | 1471 while (state._librarySource != librarySource2) { |
1334 if (state._nextState == null) { | 1472 if (state._nextState == null) { |
1335 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); | 1473 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); |
1336 newState._librarySource = librarySource2; | 1474 newState._librarySource = librarySource2; |
1337 state._nextState = newState; | 1475 state._nextState = newState; |
1338 return newState; | 1476 return newState; |
1339 } | 1477 } |
1340 state = state._nextState; | 1478 state = state._nextState; |
1341 } | 1479 } |
1342 return state; | 1480 return state; |
1343 } | 1481 } |
1344 | 1482 |
1345 /** | 1483 /** |
1346 * Given that one of the flags is being transitioned to the given state, retur
n the value of the | 1484 * Given that one of the flags is being transitioned to the given state, retur
n the value of the |
1347 * flags that should be kept in the cache. | 1485 * flags that should be kept in the cache. |
| 1486 * |
1348 * @param state the state to which the data is being transitioned | 1487 * @param state the state to which the data is being transitioned |
1349 * @param currentValue the value of the flags before the transition | 1488 * @param currentValue the value of the flags before the transition |
1350 * @param bitMask the mask used to access the bit whose state is being set | 1489 * @param bitMask the mask used to access the bit whose state is being set |
1351 * @return the value of the data that should be kept in the cache | 1490 * @return the value of the data that should be kept in the cache |
1352 */ | 1491 */ |
1353 int updatedValue2(CacheState state, int currentValue, int bitMask) { | 1492 int updatedValue2(CacheState state, int currentValue, int bitMask) { |
1354 if (identical(state, CacheState.VALID)) { | 1493 if (identical(state, CacheState.VALID)) { |
1355 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 1494 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
1356 } else if (identical(state, CacheState.IN_PROCESS)) { | 1495 } else if (identical(state, CacheState.IN_PROCESS)) { |
1357 return currentValue; | 1496 return currentValue; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 | 1534 |
1396 /** | 1535 /** |
1397 * The errors produced while resolving the compilation unit, or `null` if the
errors are | 1536 * The errors produced while resolving the compilation unit, or `null` if the
errors are |
1398 * not currently cached. | 1537 * not currently cached. |
1399 */ | 1538 */ |
1400 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 1539 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
1401 | 1540 |
1402 /** | 1541 /** |
1403 * Set this state to be exactly like the given state, recursively copying the
next state as | 1542 * Set this state to be exactly like the given state, recursively copying the
next state as |
1404 * necessary. | 1543 * necessary. |
| 1544 * |
1405 * @param other the state to be copied | 1545 * @param other the state to be copied |
1406 */ | 1546 */ |
1407 void copyFrom(DartEntryImpl_ResolutionState other) { | 1547 void copyFrom(DartEntryImpl_ResolutionState other) { |
1408 _librarySource = other._librarySource; | 1548 _librarySource = other._librarySource; |
1409 _resolvedUnitState = other._resolvedUnitState; | 1549 _resolvedUnitState = other._resolvedUnitState; |
1410 _resolvedUnit = other._resolvedUnit; | 1550 _resolvedUnit = other._resolvedUnit; |
1411 _resolutionErrorsState = other._resolutionErrorsState; | 1551 _resolutionErrorsState = other._resolutionErrorsState; |
1412 _resolutionErrors = other._resolutionErrors; | 1552 _resolutionErrors = other._resolutionErrors; |
1413 if (other._nextState != null) { | 1553 if (other._nextState != null) { |
1414 _nextState = new DartEntryImpl_ResolutionState(); | 1554 _nextState = new DartEntryImpl_ResolutionState(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 */ | 1588 */ |
1449 class DataDescriptor<E> { | 1589 class DataDescriptor<E> { |
1450 | 1590 |
1451 /** | 1591 /** |
1452 * The name of the descriptor, used for debugging purposes. | 1592 * The name of the descriptor, used for debugging purposes. |
1453 */ | 1593 */ |
1454 String _name; | 1594 String _name; |
1455 | 1595 |
1456 /** | 1596 /** |
1457 * Initialize a newly created descriptor to have the given name. | 1597 * Initialize a newly created descriptor to have the given name. |
| 1598 * |
1458 * @param name the name of the descriptor | 1599 * @param name the name of the descriptor |
1459 */ | 1600 */ |
1460 DataDescriptor(String name) { | 1601 DataDescriptor(String name) { |
1461 this._name = name; | 1602 this._name = name; |
1462 } | 1603 } |
1463 String toString() => _name; | 1604 String toString() => _name; |
1464 } | 1605 } |
1465 /** | 1606 /** |
1466 * The interface `HtmlEntry` defines the behavior of objects that maintain the i
nformation | 1607 * The interface `HtmlEntry` defines the behavior of objects that maintain the i
nformation |
1467 * cached by an analysis context about an individual HTML file. | 1608 * cached by an analysis context about an individual HTML file. |
| 1609 * |
1468 * @coverage dart.engine | 1610 * @coverage dart.engine |
1469 */ | 1611 */ |
1470 abstract class HtmlEntry implements SourceEntry { | 1612 abstract class HtmlEntry implements SourceEntry { |
1471 | 1613 |
1472 /** | 1614 /** |
1473 * The data descriptor representing the HTML element. | 1615 * The data descriptor representing the HTML element. |
1474 */ | 1616 */ |
1475 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem
ent>("HtmlEntry.ELEMENT"); | 1617 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem
ent>("HtmlEntry.ELEMENT"); |
1476 | 1618 |
1477 /** | 1619 /** |
(...skipping 11 matching lines...) Expand all Loading... |
1489 */ | 1631 */ |
1490 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD
escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); | 1632 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD
escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); |
1491 | 1633 |
1492 /** | 1634 /** |
1493 * The data descriptor representing the resolved AST structure. | 1635 * The data descriptor representing the resolved AST structure. |
1494 */ | 1636 */ |
1495 static final DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlU
nit>("HtmlEntry.RESOLVED_UNIT"); | 1637 static final DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlU
nit>("HtmlEntry.RESOLVED_UNIT"); |
1496 | 1638 |
1497 /** | 1639 /** |
1498 * Return all of the errors associated with the compilation unit that are curr
ently cached. | 1640 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 1641 * |
1499 * @return all of the errors associated with the compilation unit | 1642 * @return all of the errors associated with the compilation unit |
1500 */ | 1643 */ |
1501 List<AnalysisError> get allErrors; | 1644 List<AnalysisError> get allErrors; |
1502 HtmlEntryImpl get writableCopy; | 1645 HtmlEntryImpl get writableCopy; |
1503 } | 1646 } |
1504 /** | 1647 /** |
1505 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. | 1648 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. |
| 1649 * |
1506 * @coverage dart.engine | 1650 * @coverage dart.engine |
1507 */ | 1651 */ |
1508 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { | 1652 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { |
1509 | 1653 |
1510 /** | 1654 /** |
1511 * The state of the cached parsed (but not resolved) HTML unit. | 1655 * The state of the cached parsed (but not resolved) HTML unit. |
1512 */ | 1656 */ |
1513 CacheState _parsedUnitState = CacheState.INVALID; | 1657 CacheState _parsedUnitState = CacheState.INVALID; |
1514 | 1658 |
1515 /** | 1659 /** |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 _elementState = other._elementState; | 1800 _elementState = other._elementState; |
1657 _element = other._element; | 1801 _element = other._element; |
1658 } | 1802 } |
1659 } | 1803 } |
1660 /** | 1804 /** |
1661 * The interface `SourceEntry` defines the behavior of objects that maintain the
information | 1805 * The interface `SourceEntry` defines the behavior of objects that maintain the
information |
1662 * cached by an analysis context about an individual source, no matter what kind
of source it is. | 1806 * cached by an analysis context about an individual source, no matter what kind
of source it is. |
1663 * | 1807 * |
1664 * Source entries should be treated as if they were immutable unless a writable
copy of the entry | 1808 * Source entries should be treated as if they were immutable unless a writable
copy of the entry |
1665 * has been obtained and has not yet been made visible to other threads. | 1809 * has been obtained and has not yet been made visible to other threads. |
| 1810 * |
1666 * @coverage dart.engine | 1811 * @coverage dart.engine |
1667 */ | 1812 */ |
1668 abstract class SourceEntry { | 1813 abstract class SourceEntry { |
1669 | 1814 |
1670 /** | 1815 /** |
1671 * The data descriptor representing the line information. | 1816 * The data descriptor representing the line information. |
1672 */ | 1817 */ |
1673 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>
("SourceEntry.LINE_INFO"); | 1818 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>
("SourceEntry.LINE_INFO"); |
1674 | 1819 |
1675 /** | 1820 /** |
1676 * Return the kind of the source, or `null` if the kind is not currently cache
d. | 1821 * Return the kind of the source, or `null` if the kind is not currently cache
d. |
| 1822 * |
1677 * @return the kind of the source | 1823 * @return the kind of the source |
1678 */ | 1824 */ |
1679 SourceKind get kind; | 1825 SourceKind get kind; |
1680 | 1826 |
1681 /** | 1827 /** |
1682 * Return the most recent time at which the state of the source matched the st
ate represented by | 1828 * Return the most recent time at which the state of the source matched the st
ate represented by |
1683 * this entry. | 1829 * this entry. |
| 1830 * |
1684 * @return the modification time of this entry | 1831 * @return the modification time of this entry |
1685 */ | 1832 */ |
1686 int get modificationTime; | 1833 int get modificationTime; |
1687 | 1834 |
1688 /** | 1835 /** |
1689 * Return the state of the data represented by the given descriptor. | 1836 * Return the state of the data represented by the given descriptor. |
| 1837 * |
1690 * @param descriptor the descriptor representing the data whose state is to be
returned | 1838 * @param descriptor the descriptor representing the data whose state is to be
returned |
1691 * @return the state of the data represented by the given descriptor | 1839 * @return the state of the data represented by the given descriptor |
1692 */ | 1840 */ |
1693 CacheState getState(DataDescriptor<Object> descriptor); | 1841 CacheState getState(DataDescriptor<Object> descriptor); |
1694 | 1842 |
1695 /** | 1843 /** |
1696 * Return the value of the data represented by the given descriptor, or `null`
if the data | 1844 * Return the value of the data represented by the given descriptor, or `null`
if the data |
1697 * represented by the descriptor is not in the cache. | 1845 * represented by the descriptor is not in the cache. |
| 1846 * |
1698 * @param descriptor the descriptor representing which data is to be returned | 1847 * @param descriptor the descriptor representing which data is to be returned |
1699 * @return the value of the data represented by the given descriptor | 1848 * @return the value of the data represented by the given descriptor |
1700 */ | 1849 */ |
1701 Object getValue(DataDescriptor descriptor); | 1850 Object getValue(DataDescriptor descriptor); |
1702 | 1851 |
1703 /** | 1852 /** |
1704 * Return a new entry that is initialized to the same state as this entry but
that can be | 1853 * Return a new entry that is initialized to the same state as this entry but
that can be |
1705 * modified. | 1854 * modified. |
| 1855 * |
1706 * @return a writable copy of this entry | 1856 * @return a writable copy of this entry |
1707 */ | 1857 */ |
1708 SourceEntryImpl get writableCopy; | 1858 SourceEntryImpl get writableCopy; |
1709 } | 1859 } |
1710 /** | 1860 /** |
1711 * Instances of the abstract class `SourceEntryImpl` implement the behavior comm
on to all[SourceEntry source entries]. | 1861 * Instances of the abstract class `SourceEntryImpl` implement the behavior comm
on to all |
| 1862 * [SourceEntry]. |
| 1863 * |
1712 * @coverage dart.engine | 1864 * @coverage dart.engine |
1713 */ | 1865 */ |
1714 abstract class SourceEntryImpl implements SourceEntry { | 1866 abstract class SourceEntryImpl implements SourceEntry { |
1715 | 1867 |
1716 /** | 1868 /** |
1717 * The most recent time at which the state of the source matched the state rep
resented by this | 1869 * The most recent time at which the state of the source matched the state rep
resented by this |
1718 * entry. | 1870 * entry. |
1719 */ | 1871 */ |
1720 int _modificationTime = 0; | 1872 int _modificationTime = 0; |
1721 | 1873 |
(...skipping 19 matching lines...) Expand all Loading... |
1741 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 1893 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
1742 return _lineInfo as Object; | 1894 return _lineInfo as Object; |
1743 } else { | 1895 } else { |
1744 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1896 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
1745 } | 1897 } |
1746 } | 1898 } |
1747 | 1899 |
1748 /** | 1900 /** |
1749 * Set the most recent time at which the state of the source matched the state
represented by this | 1901 * Set the most recent time at which the state of the source matched the state
represented by this |
1750 * entry to the given time. | 1902 * entry to the given time. |
| 1903 * |
1751 * @param time the new modification time of this entry | 1904 * @param time the new modification time of this entry |
1752 */ | 1905 */ |
1753 void set modificationTime(int time) { | 1906 void set modificationTime(int time) { |
1754 _modificationTime = time; | 1907 _modificationTime = time; |
1755 } | 1908 } |
1756 | 1909 |
1757 /** | 1910 /** |
1758 * Set the state of the data represented by the given descriptor to the given
state. | 1911 * Set the state of the data represented by the given descriptor to the given
state. |
| 1912 * |
1759 * @param descriptor the descriptor representing the data whose state is to be
set | 1913 * @param descriptor the descriptor representing the data whose state is to be
set |
1760 * @param the new state of the data represented by the given descriptor | 1914 * @param the new state of the data represented by the given descriptor |
1761 */ | 1915 */ |
1762 void setState(DataDescriptor<Object> descriptor, CacheState state) { | 1916 void setState(DataDescriptor<Object> descriptor, CacheState state) { |
1763 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 1917 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
1764 _lineInfo = updatedValue(state, _lineInfo, null); | 1918 _lineInfo = updatedValue(state, _lineInfo, null); |
1765 _lineInfoState = state; | 1919 _lineInfoState = state; |
1766 } else { | 1920 } else { |
1767 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1921 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
1768 } | 1922 } |
1769 } | 1923 } |
1770 | 1924 |
1771 /** | 1925 /** |
1772 * Set the value of the data represented by the given descriptor to the given
value. | 1926 * Set the value of the data represented by the given descriptor to the given
value. |
| 1927 * |
1773 * @param descriptor the descriptor representing the data whose value is to be
set | 1928 * @param descriptor the descriptor representing the data whose value is to be
set |
1774 * @param value the new value of the data represented by the given descriptor | 1929 * @param value the new value of the data represented by the given descriptor |
1775 */ | 1930 */ |
1776 void setValue(DataDescriptor descriptor, Object value) { | 1931 void setValue(DataDescriptor descriptor, Object value) { |
1777 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 1932 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
1778 _lineInfo = value as LineInfo; | 1933 _lineInfo = value as LineInfo; |
1779 _lineInfoState = CacheState.VALID; | 1934 _lineInfoState = CacheState.VALID; |
1780 } else { | 1935 } else { |
1781 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1936 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
1782 } | 1937 } |
1783 } | 1938 } |
1784 | 1939 |
1785 /** | 1940 /** |
1786 * Copy the information from the given cache entry. | 1941 * Copy the information from the given cache entry. |
| 1942 * |
1787 * @param entry the cache entry from which information will be copied | 1943 * @param entry the cache entry from which information will be copied |
1788 */ | 1944 */ |
1789 void copyFrom(SourceEntryImpl entry) { | 1945 void copyFrom(SourceEntryImpl entry) { |
1790 _modificationTime = entry._modificationTime; | 1946 _modificationTime = entry._modificationTime; |
1791 _lineInfoState = entry._lineInfoState; | 1947 _lineInfoState = entry._lineInfoState; |
1792 _lineInfo = entry._lineInfo; | 1948 _lineInfo = entry._lineInfo; |
1793 } | 1949 } |
1794 | 1950 |
1795 /** | 1951 /** |
1796 * Given that some data is being transitioned to the given state, return the v
alue that should be | 1952 * Given that some data is being transitioned to the given state, return the v
alue that should be |
1797 * kept in the cache. | 1953 * kept in the cache. |
| 1954 * |
1798 * @param state the state to which the data is being transitioned | 1955 * @param state the state to which the data is being transitioned |
1799 * @param currentValue the value of the data before the transition | 1956 * @param currentValue the value of the data before the transition |
1800 * @param defaultValue the value to be used if the current value is to be remo
ved from the cache | 1957 * @param defaultValue the value to be used if the current value is to be remo
ved from the cache |
1801 * @return the value of the data that should be kept in the cache | 1958 * @return the value of the data that should be kept in the cache |
1802 */ | 1959 */ |
1803 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { | 1960 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { |
1804 if (identical(state, CacheState.VALID)) { | 1961 if (identical(state, CacheState.VALID)) { |
1805 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 1962 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
1806 } else if (identical(state, CacheState.IN_PROCESS)) { | 1963 } else if (identical(state, CacheState.IN_PROCESS)) { |
1807 return currentValue; | 1964 return currentValue; |
1808 } | 1965 } |
1809 return defaultValue; | 1966 return defaultValue; |
1810 } | 1967 } |
1811 } | 1968 } |
1812 /** | 1969 /** |
1813 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext an
alysis | 1970 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext]. |
1814 * context]. | 1971 * |
1815 * @coverage dart.engine | 1972 * @coverage dart.engine |
1816 */ | 1973 */ |
1817 class AnalysisContextImpl implements InternalAnalysisContext { | 1974 class AnalysisContextImpl implements InternalAnalysisContext { |
1818 | 1975 |
1819 /** | 1976 /** |
1820 * The set of analysis options controlling the behavior of this context. | 1977 * The set of analysis options controlling the behavior of this context. |
1821 */ | 1978 */ |
1822 AnalysisOptions _options = new AnalysisOptionsImpl(); | 1979 AnalysisOptions _options = new AnalysisOptionsImpl(); |
1823 | 1980 |
1824 /** | 1981 /** |
1825 * The source factory used to create the sources that can be analyzed in this
context. | 1982 * The source factory used to create the sources that can be analyzed in this
context. |
1826 */ | 1983 */ |
1827 SourceFactory _sourceFactory; | 1984 SourceFactory _sourceFactory; |
1828 | 1985 |
1829 /** | 1986 /** |
1830 * A table mapping the sources known to the context to the information known a
bout the source. | 1987 * A table mapping the sources known to the context to the information known a
bout the source. |
1831 */ | 1988 */ |
1832 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); | 1989 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); |
1833 | 1990 |
1834 /** | 1991 /** |
| 1992 * An array containing the order in which sources will be analyzed by the meth
od |
| 1993 * [performAnalysisTask]. |
| 1994 */ |
| 1995 List<Source> _priorityOrder = Source.EMPTY_ARRAY; |
| 1996 |
| 1997 /** |
1835 * A table mapping sources to the change notices that are waiting to be return
ed related to that | 1998 * A table mapping sources to the change notices that are waiting to be return
ed related to that |
1836 * source. | 1999 * source. |
1837 */ | 2000 */ |
1838 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); | 2001 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); |
1839 | 2002 |
1840 /** | 2003 /** |
1841 * A list containing the most recently accessed sources with the most recently
used at the end of | 2004 * A list containing the most recently accessed sources with the most recently
used at the end of |
1842 * the list. When more sources are added than the maximum allowed then the lea
st recently used | 2005 * the list. When more sources are added than the maximum allowed then the lea
st recently used |
1843 * source will be removed and will have it's cached AST structure flushed. | 2006 * source will be removed and will have it's cached AST structure flushed. |
1844 */ | 2007 */ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 CacheState resolutionErrorsState = htmlEntry.getState(HtmlEntry.RESOLUTI
ON_ERRORS); | 2130 CacheState resolutionErrorsState = htmlEntry.getState(HtmlEntry.RESOLUTI
ON_ERRORS); |
1968 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState !
= CacheState.ERROR) { | 2131 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState !
= CacheState.ERROR) { |
1969 computeHtmlElement(source); | 2132 computeHtmlElement(source); |
1970 htmlEntry = getSourceEntry(source) as HtmlEntry; | 2133 htmlEntry = getSourceEntry(source) as HtmlEntry; |
1971 } | 2134 } |
1972 return htmlEntry.getValue(HtmlEntry.RESOLUTION_ERRORS); | 2135 return htmlEntry.getValue(HtmlEntry.RESOLUTION_ERRORS); |
1973 } | 2136 } |
1974 return AnalysisError.NO_ERRORS; | 2137 return AnalysisError.NO_ERRORS; |
1975 } | 2138 } |
1976 } | 2139 } |
| 2140 List<Source> computeExportedLibraries(Source source) { |
| 2141 { |
| 2142 accessed(source); |
| 2143 DartEntry dartEntry = getDartEntry(source); |
| 2144 if (dartEntry == null || dartEntry.kind != SourceKind.LIBRARY) { |
| 2145 return Source.EMPTY_ARRAY; |
| 2146 } |
| 2147 CacheState state = dartEntry.getState(DartEntry.EXPORTED_LIBRARIES); |
| 2148 if (identical(state, CacheState.ERROR)) { |
| 2149 return Source.EMPTY_ARRAY; |
| 2150 } else if (identical(state, CacheState.VALID)) { |
| 2151 return dartEntry.getValue(DartEntry.EXPORTED_LIBRARIES); |
| 2152 } else { |
| 2153 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 2154 internalParseCompilationUnit(dartCopy, source); |
| 2155 _sourceMap[source] = dartCopy; |
| 2156 return dartCopy.getValue(DartEntry.EXPORTED_LIBRARIES); |
| 2157 } |
| 2158 } |
| 2159 } |
1977 HtmlElement computeHtmlElement(Source source) { | 2160 HtmlElement computeHtmlElement(Source source) { |
1978 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { | 2161 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { |
1979 return null; | 2162 return null; |
1980 } | 2163 } |
1981 { | 2164 { |
1982 HtmlEntry htmlEntry = getHtmlEntry(source); | 2165 HtmlEntry htmlEntry = getHtmlEntry(source); |
1983 if (htmlEntry == null) { | 2166 if (htmlEntry == null) { |
1984 return null; | 2167 return null; |
1985 } | 2168 } |
1986 HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT); | 2169 HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT); |
(...skipping 11 matching lines...) Expand all Loading... |
1998 HtmlEntryImpl htmlCopy = getHtmlEntry(source).writableCopy; | 2181 HtmlEntryImpl htmlCopy = getHtmlEntry(source).writableCopy; |
1999 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, unit); | 2182 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, unit); |
2000 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors); | 2183 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors); |
2001 htmlCopy.setValue(HtmlEntry.ELEMENT, element); | 2184 htmlCopy.setValue(HtmlEntry.ELEMENT, element); |
2002 _sourceMap[source] = htmlCopy; | 2185 _sourceMap[source] = htmlCopy; |
2003 getNotice(source).setErrors(htmlCopy.allErrors, htmlCopy.getValue(Source
Entry.LINE_INFO)); | 2186 getNotice(source).setErrors(htmlCopy.allErrors, htmlCopy.getValue(Source
Entry.LINE_INFO)); |
2004 } | 2187 } |
2005 return element; | 2188 return element; |
2006 } | 2189 } |
2007 } | 2190 } |
| 2191 List<Source> computeImportedLibraries(Source source) { |
| 2192 { |
| 2193 accessed(source); |
| 2194 DartEntry dartEntry = getDartEntry(source); |
| 2195 if (dartEntry == null || dartEntry.kind != SourceKind.LIBRARY) { |
| 2196 return Source.EMPTY_ARRAY; |
| 2197 } |
| 2198 CacheState state = dartEntry.getState(DartEntry.IMPORTED_LIBRARIES); |
| 2199 if (identical(state, CacheState.ERROR)) { |
| 2200 return Source.EMPTY_ARRAY; |
| 2201 } else if (identical(state, CacheState.VALID)) { |
| 2202 return dartEntry.getValue(DartEntry.IMPORTED_LIBRARIES); |
| 2203 } else { |
| 2204 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 2205 internalParseCompilationUnit(dartCopy, source); |
| 2206 _sourceMap[source] = dartCopy; |
| 2207 return dartCopy.getValue(DartEntry.IMPORTED_LIBRARIES); |
| 2208 } |
| 2209 } |
| 2210 } |
2008 SourceKind computeKindOf(Source source) { | 2211 SourceKind computeKindOf(Source source) { |
2009 { | 2212 { |
2010 SourceEntry sourceEntry = getSourceEntry(source); | 2213 SourceEntry sourceEntry = getSourceEntry(source); |
2011 if (sourceEntry == null) { | 2214 if (sourceEntry == null) { |
2012 return SourceKind.UNKNOWN; | 2215 return SourceKind.UNKNOWN; |
2013 } else if (sourceEntry is DartEntry) { | 2216 } else if (sourceEntry is DartEntry) { |
2014 DartEntry dartEntry = sourceEntry as DartEntry; | 2217 DartEntry dartEntry = sourceEntry as DartEntry; |
2015 CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND); | 2218 CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND); |
2016 if (sourceKindState != CacheState.VALID && sourceKindState != CacheState
.ERROR) { | 2219 if (sourceKindState != CacheState.VALID && sourceKindState != CacheState
.ERROR) { |
2017 internalComputeKindOf(source); | 2220 internalComputeKindOf(source); |
(...skipping 10 matching lines...) Expand all Loading... |
2028 return null; | 2231 return null; |
2029 } | 2232 } |
2030 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT); | 2233 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT); |
2031 if (element == null) { | 2234 if (element == null) { |
2032 LibraryResolver resolver = new LibraryResolver(this); | 2235 LibraryResolver resolver = new LibraryResolver(this); |
2033 try { | 2236 try { |
2034 element = resolver.resolveLibrary(source, true); | 2237 element = resolver.resolveLibrary(source, true); |
2035 recordResolutionResults(resolver); | 2238 recordResolutionResults(resolver); |
2036 } on AnalysisException catch (exception) { | 2239 } on AnalysisException catch (exception) { |
2037 DartEntryImpl dartCopy = getDartEntry(source).writableCopy; | 2240 DartEntryImpl dartCopy = getDartEntry(source).writableCopy; |
| 2241 dartCopy.setState(DartEntry.RESOLVED_UNIT, CacheState.ERROR); |
2038 dartCopy.setState(DartEntry.ELEMENT, CacheState.ERROR); | 2242 dartCopy.setState(DartEntry.ELEMENT, CacheState.ERROR); |
2039 _sourceMap[source] = dartCopy; | 2243 _sourceMap[source] = dartCopy; |
2040 AnalysisEngine.instance.logger.logError2("Could not resolve the librar
y ${source.fullName}", exception); | 2244 AnalysisEngine.instance.logger.logError2("Could not resolve the librar
y ${source.fullName}", exception); |
2041 } | 2245 } |
2042 } | 2246 } |
2043 return element; | 2247 return element; |
2044 } | 2248 } |
2045 } | 2249 } |
2046 LineInfo computeLineInfo(Source source) { | 2250 LineInfo computeLineInfo(Source source) { |
2047 { | 2251 { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2206 return Source.EMPTY_ARRAY; | 2410 return Source.EMPTY_ARRAY; |
2207 } | 2411 } |
2208 return new List.from(librarySources); | 2412 return new List.from(librarySources); |
2209 } | 2413 } |
2210 } | 2414 } |
2211 List<Source> getLibrariesDependingOn(Source librarySource) { | 2415 List<Source> getLibrariesDependingOn(Source librarySource) { |
2212 { | 2416 { |
2213 List<Source> dependentLibraries = new List<Source>(); | 2417 List<Source> dependentLibraries = new List<Source>(); |
2214 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2418 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
2215 if (identical(entry.getValue().kind, SourceKind.LIBRARY)) { | 2419 if (identical(entry.getValue().kind, SourceKind.LIBRARY)) { |
2216 if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.REFE
RENCED_LIBRARIES), librarySource)) { | 2420 if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.EXPO
RTED_LIBRARIES), librarySource)) { |
| 2421 dependentLibraries.add(entry.getKey()); |
| 2422 } |
| 2423 if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.IMPO
RTED_LIBRARIES), librarySource)) { |
2217 dependentLibraries.add(entry.getKey()); | 2424 dependentLibraries.add(entry.getKey()); |
2218 } | 2425 } |
2219 } | 2426 } |
2220 } | 2427 } |
2221 if (dependentLibraries.isEmpty) { | 2428 if (dependentLibraries.isEmpty) { |
2222 return Source.EMPTY_ARRAY; | 2429 return Source.EMPTY_ARRAY; |
2223 } | 2430 } |
2224 return new List.from(dependentLibraries); | 2431 return new List.from(dependentLibraries); |
2225 } | 2432 } |
2226 } | 2433 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 { | 2547 { |
2341 accessed(source); | 2548 accessed(source); |
2342 HtmlEntry htmlEntry = getHtmlEntry(source); | 2549 HtmlEntry htmlEntry = getHtmlEntry(source); |
2343 if (htmlEntry == null) { | 2550 if (htmlEntry == null) { |
2344 return null; | 2551 return null; |
2345 } | 2552 } |
2346 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2553 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
2347 if (unit == null) { | 2554 if (unit == null) { |
2348 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); | 2555 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
2349 if (unit == null) { | 2556 if (unit == null) { |
2350 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(source)
); | 2557 try { |
2351 unit = result.htmlUnit; | 2558 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(sourc
e)); |
2352 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 2559 unit = result.htmlUnit; |
2353 htmlCopy.setValue(SourceEntry.LINE_INFO, new LineInfo(result.lineStart
s)); | 2560 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
2354 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); | 2561 htmlCopy.setValue(SourceEntry.LINE_INFO, new LineInfo(result.lineSta
rts)); |
2355 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2(s
ource, unit)); | 2562 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); |
2356 _sourceMap[source] = htmlCopy; | 2563 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2
(source, unit)); |
| 2564 _sourceMap[source] = htmlCopy; |
| 2565 } on AnalysisException catch (exception) { |
| 2566 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 2567 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 2568 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); |
| 2569 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); |
| 2570 _sourceMap[source] = htmlCopy; |
| 2571 throw exception; |
| 2572 } |
2357 } | 2573 } |
2358 } | 2574 } |
2359 return unit; | 2575 return unit; |
2360 } | 2576 } |
2361 } | 2577 } |
2362 List<ChangeNotice> performAnalysisTask() { | 2578 List<ChangeNotice> performAnalysisTask() { |
2363 { | 2579 { |
2364 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { | 2580 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { |
2365 return null; | 2581 return null; |
2366 } | 2582 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2444 } | 2660 } |
2445 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2661 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
2446 if (unit == null) { | 2662 if (unit == null) { |
2447 disableCacheRemoval(); | 2663 disableCacheRemoval(); |
2448 try { | 2664 try { |
2449 computeHtmlElement(unitSource); | 2665 computeHtmlElement(unitSource); |
2450 unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2666 unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
2451 if (unit == null) { | 2667 if (unit == null) { |
2452 unit = parseHtmlUnit(unitSource); | 2668 unit = parseHtmlUnit(unitSource); |
2453 } | 2669 } |
| 2670 } on AnalysisException catch (exception) { |
| 2671 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 2672 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); |
| 2673 _sourceMap[unitSource] = htmlCopy; |
| 2674 throw exception; |
2454 } finally { | 2675 } finally { |
2455 enableCacheRemoval(); | 2676 enableCacheRemoval(); |
2456 } | 2677 } |
2457 } | 2678 } |
2458 return unit; | 2679 return unit; |
2459 } | 2680 } |
2460 } | 2681 } |
2461 void set analysisOptions(AnalysisOptions options2) { | 2682 void set analysisOptions(AnalysisOptions options2) { |
2462 { | 2683 { |
2463 this._options = options2; | 2684 this._options = options2; |
2464 invalidateAllResults(); | 2685 invalidateAllResults(); |
2465 } | 2686 } |
2466 } | 2687 } |
| 2688 void set analysisPriorityOrder(List<Source> sources) { |
| 2689 { |
| 2690 if (sources == null || sources.isEmpty) { |
| 2691 _priorityOrder = Source.EMPTY_ARRAY; |
| 2692 } else { |
| 2693 _priorityOrder = new List.from(sources); |
| 2694 } |
| 2695 } |
| 2696 } |
2467 void setContents(Source source, String contents) { | 2697 void setContents(Source source, String contents) { |
2468 { | 2698 { |
2469 _sourceFactory.setContents(source, contents); | 2699 _sourceFactory.setContents(source, contents); |
2470 sourceChanged(source); | 2700 sourceChanged(source); |
2471 } | 2701 } |
2472 } | 2702 } |
2473 void set sourceFactory(SourceFactory factory) { | 2703 void set sourceFactory(SourceFactory factory) { |
2474 if (identical(_sourceFactory, factory)) { | 2704 if (identical(_sourceFactory, factory)) { |
2475 return; | 2705 return; |
2476 } else if (factory.context != null) { | 2706 } else if (factory.context != null) { |
(...skipping 14 matching lines...) Expand all Loading... |
2491 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { | 2721 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { |
2492 librarySources.add(source); | 2722 librarySources.add(source); |
2493 } | 2723 } |
2494 } | 2724 } |
2495 return librarySources; | 2725 return librarySources; |
2496 } | 2726 } |
2497 | 2727 |
2498 /** | 2728 /** |
2499 * Return a list of the sources that would be processed by [performAnalysisTas
k]. This | 2729 * Return a list of the sources that would be processed by [performAnalysisTas
k]. This |
2500 * method is intended to be used for testing purposes only. | 2730 * method is intended to be used for testing purposes only. |
| 2731 * |
2501 * @return a list of the sources that would be processed by [performAnalysisTa
sk] | 2732 * @return a list of the sources that would be processed by [performAnalysisTa
sk] |
2502 */ | 2733 */ |
2503 List<Source> get sourcesNeedingProcessing { | 2734 List<Source> get sourcesNeedingProcessing { |
2504 List<Source> sources = new List<Source>(); | 2735 List<Source> sources = new List<Source>(); |
2505 { | 2736 { |
2506 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2737 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
2507 SourceEntry sourceEntry = entry.getValue(); | 2738 SourceEntry sourceEntry = entry.getValue(); |
2508 if (sourceEntry is DartEntry) { | 2739 if (sourceEntry is DartEntry) { |
2509 DartEntry dartEntry = sourceEntry as DartEntry; | 2740 DartEntry dartEntry = sourceEntry as DartEntry; |
2510 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT)
; | 2741 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT)
; |
(...skipping 11 matching lines...) Expand all Loading... |
2522 } | 2753 } |
2523 } | 2754 } |
2524 } | 2755 } |
2525 return sources; | 2756 return sources; |
2526 } | 2757 } |
2527 | 2758 |
2528 /** | 2759 /** |
2529 * Record that the given source was just accessed for some unspecified purpose
. | 2760 * Record that the given source was just accessed for some unspecified purpose
. |
2530 * | 2761 * |
2531 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. | 2762 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 2763 * |
2532 * @param source the source that was accessed | 2764 * @param source the source that was accessed |
2533 */ | 2765 */ |
2534 void accessed(Source source) { | 2766 void accessed(Source source) { |
2535 if (_recentlyUsed.contains(source)) { | 2767 if (_recentlyUsed.contains(source)) { |
2536 _recentlyUsed.remove(source); | 2768 _recentlyUsed.remove(source); |
2537 _recentlyUsed.add(source); | 2769 _recentlyUsed.add(source); |
2538 return; | 2770 return; |
2539 } | 2771 } |
2540 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { | 2772 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { |
2541 Source removedSource = _recentlyUsed.removeAt(0); | 2773 Source removedSource = _recentlyUsed.removeAt(0); |
(...skipping 12 matching lines...) Expand all Loading... |
2554 _sourceMap[removedSource] = dartCopy; | 2786 _sourceMap[removedSource] = dartCopy; |
2555 } | 2787 } |
2556 } | 2788 } |
2557 _recentlyUsed.add(source); | 2789 _recentlyUsed.add(source); |
2558 } | 2790 } |
2559 | 2791 |
2560 /** | 2792 /** |
2561 * Add all of the sources contained in the given source container to the given
list of sources. | 2793 * Add all of the sources contained in the given source container to the given
list of sources. |
2562 * | 2794 * |
2563 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. | 2795 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 2796 * |
2564 * @param sources the list to which sources are to be added | 2797 * @param sources the list to which sources are to be added |
2565 * @param container the source container containing the sources to be added to
the list | 2798 * @param container the source container containing the sources to be added to
the list |
2566 */ | 2799 */ |
2567 void addSourcesInContainer(List<Source> sources, SourceContainer container) { | 2800 void addSourcesInContainer(List<Source> sources, SourceContainer container) { |
2568 for (Source source in _sourceMap.keys.toSet()) { | 2801 for (Source source in _sourceMap.keys.toSet()) { |
2569 if (container.contains(source)) { | 2802 if (container.contains(source)) { |
2570 sources.add(source); | 2803 sources.add(source); |
2571 } | 2804 } |
2572 } | 2805 } |
2573 } | 2806 } |
2574 | 2807 |
2575 /** | 2808 /** |
2576 * Return `true` if the given array of sources contains the given source. | 2809 * Return `true` if the given array of sources contains the given source. |
| 2810 * |
2577 * @param sources the sources being searched | 2811 * @param sources the sources being searched |
2578 * @param targetSource the source being searched for | 2812 * @param targetSource the source being searched for |
2579 * @return `true` if the given source is in the array | 2813 * @return `true` if the given source is in the array |
2580 */ | 2814 */ |
2581 bool contains(List<Source> sources, Source targetSource) { | 2815 bool contains(List<Source> sources, Source targetSource) { |
2582 for (Source source in sources) { | 2816 for (Source source in sources) { |
2583 if (source == targetSource) { | 2817 if (source == targetSource) { |
2584 return true; | 2818 return true; |
2585 } | 2819 } |
2586 } | 2820 } |
2587 return false; | 2821 return false; |
2588 } | 2822 } |
2589 | 2823 |
2590 /** | 2824 /** |
2591 * Return `true` if the given array of sources contains any of the given targe
t sources. | 2825 * Return `true` if the given array of sources contains any of the given targe
t sources. |
| 2826 * |
2592 * @param sources the sources being searched | 2827 * @param sources the sources being searched |
2593 * @param targetSources the sources being searched for | 2828 * @param targetSources the sources being searched for |
2594 * @return `true` if any of the given target sources are in the array | 2829 * @return `true` if any of the given target sources are in the array |
2595 */ | 2830 */ |
2596 bool containsAny(List<Source> sources, List<Source> targetSources) { | 2831 bool containsAny(List<Source> sources, List<Source> targetSources) { |
2597 for (Source targetSource in targetSources) { | 2832 for (Source targetSource in targetSources) { |
2598 if (contains(sources, targetSource)) { | 2833 if (contains(sources, targetSource)) { |
2599 return true; | 2834 return true; |
2600 } | 2835 } |
2601 } | 2836 } |
2602 return false; | 2837 return false; |
2603 } | 2838 } |
2604 | 2839 |
2605 /** | 2840 /** |
2606 * Create a source information object suitable for the given source. Return th
e source information | 2841 * Create a source information object suitable for the given source. Return th
e source information |
2607 * object that was created, or `null` if the source should not be tracked by t
his context. | 2842 * object that was created, or `null` if the source should not be tracked by t
his context. |
| 2843 * |
2608 * @param source the source for which an information object is being created | 2844 * @param source the source for which an information object is being created |
2609 * @return the source information object that was created | 2845 * @return the source information object that was created |
2610 */ | 2846 */ |
2611 SourceEntry createSourceEntry(Source source) { | 2847 SourceEntry createSourceEntry(Source source) { |
2612 String name = source.shortName; | 2848 String name = source.shortName; |
2613 if (AnalysisEngine.isHtmlFileName(name)) { | 2849 if (AnalysisEngine.isHtmlFileName(name)) { |
2614 HtmlEntry htmlEntry = new HtmlEntryImpl(); | 2850 HtmlEntry htmlEntry = new HtmlEntryImpl(); |
2615 _sourceMap[source] = htmlEntry; | 2851 _sourceMap[source] = htmlEntry; |
2616 return htmlEntry; | 2852 return htmlEntry; |
2617 } else { | 2853 } else { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2654 _sourceMap[removedSource] = dartCopy; | 2890 _sourceMap[removedSource] = dartCopy; |
2655 } | 2891 } |
2656 } | 2892 } |
2657 } | 2893 } |
2658 } | 2894 } |
2659 | 2895 |
2660 /** | 2896 /** |
2661 * Search the compilation units that are part of the given library and return
the element | 2897 * Search the compilation units that are part of the given library and return
the element |
2662 * representing the compilation unit with the given source. Return `null` if t
here is no | 2898 * representing the compilation unit with the given source. Return `null` if t
here is no |
2663 * such compilation unit. | 2899 * such compilation unit. |
| 2900 * |
2664 * @param libraryElement the element representing the library being searched t
hrough | 2901 * @param libraryElement the element representing the library being searched t
hrough |
2665 * @param unitSource the source for the compilation unit whose element is to b
e returned | 2902 * @param unitSource the source for the compilation unit whose element is to b
e returned |
2666 * @return the element representing the compilation unit | 2903 * @return the element representing the compilation unit |
2667 */ | 2904 */ |
2668 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ | 2905 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ |
2669 CompilationUnitElement element = libraryElement.definingCompilationUnit; | 2906 CompilationUnitElement element = libraryElement.definingCompilationUnit; |
2670 if (element.source == unitSource) { | 2907 if (element.source == unitSource) { |
2671 return element; | 2908 return element; |
2672 } | 2909 } |
2673 for (CompilationUnitElement partElement in libraryElement.parts) { | 2910 for (CompilationUnitElement partElement in libraryElement.parts) { |
2674 if (partElement.source == unitSource) { | 2911 if (partElement.source == unitSource) { |
2675 return partElement; | 2912 return partElement; |
2676 } | 2913 } |
2677 } | 2914 } |
2678 return null; | 2915 return null; |
2679 } | 2916 } |
2680 | 2917 |
2681 /** | 2918 /** |
2682 * Return the compilation unit information associated with the given source, o
r `null` if | 2919 * Return the compilation unit information associated with the given source, o
r `null` if |
2683 * the source is not known to this context. This method should be used to acce
ss the compilation | 2920 * the source is not known to this context. This method should be used to acce
ss the compilation |
2684 * unit information rather than accessing the compilation unit map directly be
cause sources in the | 2921 * unit information rather than accessing the compilation unit map directly be
cause sources in the |
2685 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when | 2922 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when |
2686 * first accessed. | 2923 * first accessed. |
2687 * | 2924 * |
2688 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 2925 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 2926 * |
2689 * @param source the source for which information is being sought | 2927 * @param source the source for which information is being sought |
2690 * @return the compilation unit information associated with the given source | 2928 * @return the compilation unit information associated with the given source |
2691 */ | 2929 */ |
2692 DartEntry getDartEntry(Source source) { | 2930 DartEntry getDartEntry(Source source) { |
2693 SourceEntry sourceEntry = getSourceEntry(source); | 2931 SourceEntry sourceEntry = getSourceEntry(source); |
2694 if (sourceEntry == null) { | 2932 if (sourceEntry == null) { |
2695 sourceEntry = new DartEntryImpl(); | 2933 sourceEntry = new DartEntryImpl(); |
2696 _sourceMap[source] = sourceEntry; | 2934 _sourceMap[source] = sourceEntry; |
2697 return sourceEntry as DartEntry; | 2935 return sourceEntry as DartEntry; |
2698 } else if (sourceEntry is DartEntry) { | 2936 } else if (sourceEntry is DartEntry) { |
2699 return sourceEntry as DartEntry; | 2937 return sourceEntry as DartEntry; |
2700 } | 2938 } |
2701 return null; | 2939 return null; |
2702 } | 2940 } |
2703 | 2941 |
2704 /** | 2942 /** |
2705 * Return the HTML unit information associated with the given source, or `null
` if the | 2943 * Return the HTML unit information associated with the given source, or `null
` if the |
2706 * source is not known to this context. This method should be used to access t
he HTML unit | 2944 * source is not known to this context. This method should be used to access t
he HTML unit |
2707 * information rather than accessing the HTML unit map directly because source
s in the SDK are | 2945 * information rather than accessing the HTML unit map directly because source
s in the SDK are |
2708 * implicitly part of every analysis context and are therefore only added to t
he map when first | 2946 * implicitly part of every analysis context and are therefore only added to t
he map when first |
2709 * accessed. | 2947 * accessed. |
2710 * | 2948 * |
2711 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 2949 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 2950 * |
2712 * @param source the source for which information is being sought | 2951 * @param source the source for which information is being sought |
2713 * @return the HTML unit information associated with the given source | 2952 * @return the HTML unit information associated with the given source |
2714 */ | 2953 */ |
2715 HtmlEntry getHtmlEntry(Source source) { | 2954 HtmlEntry getHtmlEntry(Source source) { |
2716 SourceEntry sourceEntry = getSourceEntry(source); | 2955 SourceEntry sourceEntry = getSourceEntry(source); |
2717 if (sourceEntry == null) { | 2956 if (sourceEntry == null) { |
2718 sourceEntry = new HtmlEntryImpl(); | 2957 sourceEntry = new HtmlEntryImpl(); |
2719 _sourceMap[source] = sourceEntry; | 2958 _sourceMap[source] = sourceEntry; |
2720 return sourceEntry as HtmlEntry; | 2959 return sourceEntry as HtmlEntry; |
2721 } else if (sourceEntry is HtmlEntry) { | 2960 } else if (sourceEntry is HtmlEntry) { |
2722 return sourceEntry as HtmlEntry; | 2961 return sourceEntry as HtmlEntry; |
2723 } | 2962 } |
2724 return null; | 2963 return null; |
2725 } | 2964 } |
2726 | 2965 |
2727 /** | 2966 /** |
2728 * Return the sources of libraries that are referenced in the specified HTML f
ile. | 2967 * Return the sources of libraries that are referenced in the specified HTML f
ile. |
| 2968 * |
2729 * @param htmlSource the source of the HTML file being analyzed | 2969 * @param htmlSource the source of the HTML file being analyzed |
2730 * @param htmlUnit the AST for the HTML file being analyzed | 2970 * @param htmlUnit the AST for the HTML file being analyzed |
2731 * @return the sources of libraries that are referenced in the HTML file | 2971 * @return the sources of libraries that are referenced in the HTML file |
2732 */ | 2972 */ |
2733 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) { | 2973 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) { |
2734 List<Source> libraries = new List<Source>(); | 2974 List<Source> libraries = new List<Source>(); |
2735 htmlUnit.accept(new RecursiveXmlVisitor_6(this, htmlSource, libraries)); | 2975 htmlUnit.accept(new RecursiveXmlVisitor_6(this, htmlSource, libraries)); |
2736 if (libraries.isEmpty) { | 2976 if (libraries.isEmpty) { |
2737 return Source.EMPTY_ARRAY; | 2977 return Source.EMPTY_ARRAY; |
2738 } | 2978 } |
2739 return new List.from(libraries); | 2979 return new List.from(libraries); |
2740 } | 2980 } |
2741 | 2981 |
2742 /** | 2982 /** |
2743 * Return a change notice for the given source, creating one if one does not a
lready exist. | 2983 * Return a change notice for the given source, creating one if one does not a
lready exist. |
| 2984 * |
2744 * @param source the source for which changes are being reported | 2985 * @param source the source for which changes are being reported |
2745 * @return a change notice for the given source | 2986 * @return a change notice for the given source |
2746 */ | 2987 */ |
2747 ChangeNoticeImpl getNotice(Source source) { | 2988 ChangeNoticeImpl getNotice(Source source) { |
2748 ChangeNoticeImpl notice = _pendingNotices[source]; | 2989 ChangeNoticeImpl notice = _pendingNotices[source]; |
2749 if (notice == null) { | 2990 if (notice == null) { |
2750 notice = new ChangeNoticeImpl(source); | 2991 notice = new ChangeNoticeImpl(source); |
2751 _pendingNotices[source] = notice; | 2992 _pendingNotices[source] = notice; |
2752 } | 2993 } |
2753 return notice; | 2994 return notice; |
2754 } | 2995 } |
2755 | 2996 |
2756 /** | 2997 /** |
2757 * Return the cache entry associated with the given source, or `null` if there
is no entry | 2998 * Return the cache entry associated with the given source, or `null` if there
is no entry |
2758 * associated with the source. | 2999 * associated with the source. |
| 3000 * |
2759 * @param source the source for which a cache entry is being sought | 3001 * @param source the source for which a cache entry is being sought |
2760 * @return the source cache entry associated with the given source | 3002 * @return the source cache entry associated with the given source |
2761 */ | 3003 */ |
2762 SourceEntry getReadableSourceEntry(Source source) { | 3004 SourceEntry getReadableSourceEntry(Source source) { |
2763 { | 3005 { |
2764 return _sourceMap[source]; | 3006 return _sourceMap[source]; |
2765 } | 3007 } |
2766 } | 3008 } |
2767 | 3009 |
2768 /** | 3010 /** |
2769 * Return the source information associated with the given source, or `null` i
f the source | 3011 * Return the source information associated with the given source, or `null` i
f the source |
2770 * is not known to this context. This method should be used to access the sour
ce information | 3012 * is not known to this context. This method should be used to access the sour
ce information |
2771 * rather than accessing the source map directly because sources in the SDK ar
e implicitly part of | 3013 * rather than accessing the source map directly because sources in the SDK ar
e implicitly part of |
2772 * every analysis context and are therefore only added to the map when first a
ccessed. | 3014 * every analysis context and are therefore only added to the map when first a
ccessed. |
2773 * | 3015 * |
2774 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3016 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3017 * |
2775 * @param source the source for which information is being sought | 3018 * @param source the source for which information is being sought |
2776 * @return the source information associated with the given source | 3019 * @return the source information associated with the given source |
2777 */ | 3020 */ |
2778 SourceEntry getSourceEntry(Source source) { | 3021 SourceEntry getSourceEntry(Source source) { |
2779 SourceEntry sourceEntry = _sourceMap[source]; | 3022 SourceEntry sourceEntry = _sourceMap[source]; |
2780 if (sourceEntry == null) { | 3023 if (sourceEntry == null) { |
2781 sourceEntry = createSourceEntry(source); | 3024 sourceEntry = createSourceEntry(source); |
2782 } | 3025 } |
2783 return sourceEntry; | 3026 return sourceEntry; |
2784 } | 3027 } |
2785 | 3028 |
2786 /** | 3029 /** |
2787 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 3030 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
| 3031 * |
2788 * @param kind the kind of sources to be returned | 3032 * @param kind the kind of sources to be returned |
2789 * @return all of the sources known to this context that have the given kind | 3033 * @return all of the sources known to this context that have the given kind |
2790 */ | 3034 */ |
2791 List<Source> getSources(SourceKind kind2) { | 3035 List<Source> getSources(SourceKind kind2) { |
2792 List<Source> sources = new List<Source>(); | 3036 List<Source> sources = new List<Source>(); |
2793 { | 3037 { |
2794 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 3038 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
2795 if (identical(entry.getValue().kind, kind2)) { | 3039 if (identical(entry.getValue().kind, kind2)) { |
2796 sources.add(entry.getKey()); | 3040 sources.add(entry.getKey()); |
2797 } | 3041 } |
2798 } | 3042 } |
2799 } | 3043 } |
2800 return new List.from(sources); | 3044 return new List.from(sources); |
2801 } | 3045 } |
2802 | 3046 |
2803 /** | 3047 /** |
2804 * Return `true` if the given compilation unit has a part-of directive but no
library | 3048 * Return `true` if the given compilation unit has a part-of directive but no
library |
2805 * directive. | 3049 * directive. |
| 3050 * |
2806 * @param unit the compilation unit being tested | 3051 * @param unit the compilation unit being tested |
2807 * @return `true` if the compilation unit has a part-of directive | 3052 * @return `true` if the compilation unit has a part-of directive |
2808 */ | 3053 */ |
2809 bool hasPartOfDirective(CompilationUnit unit) { | 3054 bool hasPartOfDirective(CompilationUnit unit) { |
2810 bool hasPartOf = false; | 3055 bool hasPartOf = false; |
2811 for (Directive directive in unit.directives) { | 3056 for (Directive directive in unit.directives) { |
2812 if (directive is PartOfDirective) { | 3057 if (directive is PartOfDirective) { |
2813 hasPartOf = true; | 3058 hasPartOf = true; |
2814 } else if (directive is LibraryDirective) { | 3059 } else if (directive is LibraryDirective) { |
2815 return false; | 3060 return false; |
2816 } | 3061 } |
2817 } | 3062 } |
2818 return hasPartOf; | 3063 return hasPartOf; |
2819 } | 3064 } |
2820 | 3065 |
2821 /** | 3066 /** |
2822 * Compute the kind of the given source. This method should only be invoked wh
en the kind is not | 3067 * Compute the kind of the given source. This method should only be invoked wh
en the kind is not |
2823 * already known. | 3068 * already known. |
| 3069 * |
2824 * @param source the source for which a kind is to be computed | 3070 * @param source the source for which a kind is to be computed |
2825 * @return the new source info that was created to represent the source | 3071 * @return the new source info that was created to represent the source |
2826 */ | 3072 */ |
2827 DartEntry internalComputeKindOf(Source source) { | 3073 DartEntry internalComputeKindOf(Source source) { |
2828 try { | 3074 try { |
2829 accessed(source); | 3075 accessed(source); |
2830 RecordingErrorListener errorListener = new RecordingErrorListener(); | 3076 RecordingErrorListener errorListener = new RecordingErrorListener(); |
2831 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); | 3077 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); |
2832 Parser parser = new Parser(source, errorListener); | 3078 Parser parser = new Parser(source, errorListener); |
2833 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); | 3079 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); |
(...skipping 24 matching lines...) Expand all Loading... |
2858 } | 3104 } |
2859 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartCopy, Source so
urce) { | 3105 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartCopy, Source so
urce) { |
2860 accessed(source); | 3106 accessed(source); |
2861 try { | 3107 try { |
2862 RecordingErrorListener errorListener = new RecordingErrorListener(); | 3108 RecordingErrorListener errorListener = new RecordingErrorListener(); |
2863 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); | 3109 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); |
2864 Parser parser = new Parser(source, errorListener); | 3110 Parser parser = new Parser(source, errorListener); |
2865 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); | 3111 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); |
2866 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); | 3112 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); |
2867 List<AnalysisError> errors = errorListener.getErrors2(source); | 3113 List<AnalysisError> errors = errorListener.getErrors2(source); |
| 3114 bool hasPartOfDirective = false; |
| 3115 bool hasLibraryDirective = false; |
| 3116 Set<Source> exportedSources = new Set<Source>(); |
| 3117 Set<Source> importedSources = new Set<Source>(); |
| 3118 Set<Source> includedSources = new Set<Source>(); |
| 3119 for (Directive directive in unit.directives) { |
| 3120 if (directive is ExportDirective) { |
| 3121 Source exportSource = resolveSource(source, (directive as ExportDirect
ive)); |
| 3122 if (exportSource != null) { |
| 3123 javaSetAdd(exportedSources, exportSource); |
| 3124 } |
| 3125 } else if (directive is ImportDirective) { |
| 3126 Source importSource = resolveSource(source, (directive as ImportDirect
ive)); |
| 3127 if (importSource != null) { |
| 3128 javaSetAdd(importedSources, importSource); |
| 3129 } |
| 3130 } else if (directive is LibraryDirective) { |
| 3131 hasLibraryDirective = true; |
| 3132 } else if (directive is PartDirective) { |
| 3133 Source partSource = resolveSource(source, (directive as PartDirective)
); |
| 3134 if (partSource != null) { |
| 3135 javaSetAdd(includedSources, partSource); |
| 3136 } |
| 3137 } else if (directive is PartOfDirective) { |
| 3138 hasPartOfDirective = true; |
| 3139 } |
| 3140 } |
2868 unit.parsingErrors = errors; | 3141 unit.parsingErrors = errors; |
2869 unit.lineInfo = lineInfo; | 3142 unit.lineInfo = lineInfo; |
2870 if (identical(dartCopy.getState(DartEntry.SOURCE_KIND), CacheState.INVALID
)) { | 3143 if (identical(dartCopy.getState(DartEntry.SOURCE_KIND), CacheState.INVALID
)) { |
2871 if (hasPartOfDirective(unit)) { | 3144 if (hasPartOfDirective && !hasLibraryDirective) { |
2872 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 3145 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
2873 } else { | 3146 } else { |
2874 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 3147 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
2875 } | 3148 } |
2876 } | 3149 } |
2877 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 3150 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
2878 dartCopy.setValue(DartEntry.PARSED_UNIT, unit); | 3151 dartCopy.setValue(DartEntry.PARSED_UNIT, unit); |
2879 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors); | 3152 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors); |
| 3153 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, toArray(exportedSources)); |
| 3154 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, toArray(importedSources)); |
| 3155 dartCopy.setValue(DartEntry.INCLUDED_PARTS, toArray(includedSources)); |
2880 return unit; | 3156 return unit; |
2881 } on AnalysisException catch (exception) { | 3157 } on AnalysisException catch (exception) { |
2882 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); | 3158 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
2883 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); | 3159 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); |
2884 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR); | 3160 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR); |
2885 throw exception; | 3161 throw exception; |
2886 } | 3162 } |
2887 } | 3163 } |
2888 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen
er errorListener) { | 3164 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen
er errorListener) { |
2889 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult()
; | 3165 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult()
; |
(...skipping 22 matching lines...) Expand all Loading... |
2912 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; | 3188 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
2913 dartCopy.invalidateAllResolutionInformation(); | 3189 dartCopy.invalidateAllResolutionInformation(); |
2914 mapEntry.setValue(dartCopy); | 3190 mapEntry.setValue(dartCopy); |
2915 } | 3191 } |
2916 } | 3192 } |
2917 } | 3193 } |
2918 | 3194 |
2919 /** | 3195 /** |
2920 * In response to a change to at least one of the compilation units in the giv
en library, | 3196 * In response to a change to at least one of the compilation units in the giv
en library, |
2921 * invalidate any results that are dependent on the result of resolving that l
ibrary. | 3197 * invalidate any results that are dependent on the result of resolving that l
ibrary. |
| 3198 * |
2922 * @param librarySource the source of the library being invalidated | 3199 * @param librarySource the source of the library being invalidated |
2923 */ | 3200 */ |
2924 void invalidateLibraryResolution(Source librarySource) { | 3201 void invalidateLibraryResolution(Source librarySource) { |
2925 DartEntry libraryEntry = getDartEntry(librarySource); | 3202 DartEntry libraryEntry = getDartEntry(librarySource); |
2926 if (libraryEntry != null) { | 3203 if (libraryEntry != null) { |
2927 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); | 3204 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); |
2928 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 3205 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
2929 libraryCopy.invalidateAllResolutionInformation(); | 3206 libraryCopy.invalidateAllResolutionInformation(); |
2930 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); | 3207 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); |
2931 _sourceMap[librarySource] = libraryCopy; | 3208 _sourceMap[librarySource] = libraryCopy; |
2932 for (Source unitSource in includedParts) { | 3209 for (Source unitSource in includedParts) { |
2933 DartEntry partEntry = getDartEntry(unitSource); | 3210 DartEntry partEntry = getDartEntry(unitSource); |
2934 if (partEntry != null) { | 3211 if (partEntry != null) { |
2935 DartEntryImpl dartCopy = partEntry.writableCopy; | 3212 DartEntryImpl dartCopy = partEntry.writableCopy; |
2936 dartCopy.invalidateAllResolutionInformation(); | 3213 dartCopy.invalidateAllResolutionInformation(); |
2937 _sourceMap[unitSource] = dartCopy; | 3214 _sourceMap[unitSource] = dartCopy; |
2938 } | 3215 } |
2939 } | 3216 } |
2940 } | 3217 } |
2941 } | 3218 } |
2942 | 3219 |
2943 /** | 3220 /** |
2944 * Return `true` if this library is, or depends on, dart:html. | 3221 * Return `true` if this library is, or depends on, dart:html. |
| 3222 * |
2945 * @param library the library being tested | 3223 * @param library the library being tested |
2946 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent | 3224 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent |
2947 * infinite recursion | 3225 * infinite recursion |
2948 * @return `true` if this library is, or depends on, dart:html | 3226 * @return `true` if this library is, or depends on, dart:html |
2949 */ | 3227 */ |
2950 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { | 3228 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { |
2951 if (visitedLibraries.contains(library)) { | 3229 if (visitedLibraries.contains(library)) { |
2952 return false; | 3230 return false; |
2953 } | 3231 } |
2954 if (library.source == htmlSource) { | 3232 if (library.source == htmlSource) { |
2955 return true; | 3233 return true; |
2956 } | 3234 } |
2957 javaSetAdd(visitedLibraries, library); | 3235 javaSetAdd(visitedLibraries, library); |
2958 for (LibraryElement imported in library.importedLibraries) { | 3236 for (LibraryElement imported in library.importedLibraries) { |
2959 if (isClient(imported, htmlSource, visitedLibraries)) { | 3237 if (isClient(imported, htmlSource, visitedLibraries)) { |
2960 return true; | 3238 return true; |
2961 } | 3239 } |
2962 } | 3240 } |
2963 for (LibraryElement exported in library.exportedLibraries) { | 3241 for (LibraryElement exported in library.exportedLibraries) { |
2964 if (isClient(exported, htmlSource, visitedLibraries)) { | 3242 if (isClient(exported, htmlSource, visitedLibraries)) { |
2965 return true; | 3243 return true; |
2966 } | 3244 } |
2967 } | 3245 } |
2968 return false; | 3246 return false; |
2969 } | 3247 } |
2970 | 3248 |
2971 /** | 3249 /** |
2972 * Perform a single analysis task. | 3250 * Perform a single analysis task. |
2973 * | 3251 * |
2974 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3252 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3253 * |
2975 * @return `true` if work was done, implying that there might be more work to
be done | 3254 * @return `true` if work was done, implying that there might be more work to
be done |
2976 */ | 3255 */ |
2977 bool performSingleAnalysisTask() { | 3256 bool performSingleAnalysisTask() { |
| 3257 for (Source source in _priorityOrder) { |
| 3258 SourceEntry sourceEntry = _sourceMap[source]; |
| 3259 if (sourceEntry is DartEntry) { |
| 3260 DartEntry dartEntry = sourceEntry as DartEntry; |
| 3261 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.INVA
LID)) { |
| 3262 safelyParseCompilationUnit(source, dartEntry); |
| 3263 return true; |
| 3264 } else if (identical(dartEntry.getState(DartEntry.RESOLVED_UNIT), CacheS
tate.INVALID)) { |
| 3265 safelyResolveCompilationUnit(source); |
| 3266 return true; |
| 3267 } |
| 3268 } else if (sourceEntry is HtmlEntry) { |
| 3269 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 3270 if (identical(htmlEntry.getState(HtmlEntry.PARSED_UNIT), CacheState.INVA
LID)) { |
| 3271 safelyParseHtmlUnit(source); |
| 3272 return true; |
| 3273 } else if (identical(htmlEntry.getState(HtmlEntry.RESOLVED_UNIT), CacheS
tate.INVALID)) { |
| 3274 safelyResolveHtmlUnit(source); |
| 3275 return true; |
| 3276 } |
| 3277 } |
| 3278 } |
2978 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 3279 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
2979 SourceEntry sourceEntry = entry.getValue(); | 3280 SourceEntry sourceEntry = entry.getValue(); |
2980 if (sourceEntry is DartEntry) { | 3281 if (sourceEntry is DartEntry) { |
2981 DartEntry dartEntry = sourceEntry as DartEntry; | 3282 DartEntry dartEntry = sourceEntry as DartEntry; |
2982 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT); | 3283 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT); |
2983 if (identical(parsedUnitState, CacheState.INVALID)) { | 3284 if (identical(parsedUnitState, CacheState.INVALID)) { |
2984 try { | 3285 safelyParseCompilationUnit(entry.getKey(), dartEntry); |
2985 parseCompilationUnit(entry.getKey()); | |
2986 } on AnalysisException catch (exception) { | |
2987 DartEntryImpl dartCopy = ((entry.getValue() as DartEntry)).writableC
opy; | |
2988 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); | |
2989 entry.setValue(dartCopy); | |
2990 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); | |
2991 } | |
2992 return true; | 3286 return true; |
2993 } | 3287 } |
2994 } else if (sourceEntry is HtmlEntry) { | 3288 } else if (sourceEntry is HtmlEntry) { |
2995 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 3289 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
2996 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); | 3290 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); |
2997 if (identical(parsedUnitState, CacheState.INVALID)) { | 3291 if (identical(parsedUnitState, CacheState.INVALID)) { |
2998 try { | 3292 safelyParseHtmlUnit(entry.getKey()); |
2999 parseHtmlUnit(entry.getKey()); | |
3000 } on AnalysisException catch (exception) { | |
3001 HtmlEntryImpl htmlCopy = ((entry.getValue() as HtmlEntry)).writableC
opy; | |
3002 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); | |
3003 entry.setValue(htmlCopy); | |
3004 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); | |
3005 } | |
3006 return true; | 3293 return true; |
3007 } | 3294 } |
3008 } | 3295 } |
3009 } | 3296 } |
3010 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 3297 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
3011 SourceEntry sourceEntry = entry.getValue(); | 3298 SourceEntry sourceEntry = entry.getValue(); |
3012 if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.LIB
RARY)) { | 3299 if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.LIB
RARY)) { |
3013 DartEntry dartEntry = sourceEntry as DartEntry; | 3300 DartEntry dartEntry = sourceEntry as DartEntry; |
3014 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); | 3301 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
3015 if (identical(elementState, CacheState.INVALID)) { | 3302 if (identical(elementState, CacheState.INVALID)) { |
3016 try { | 3303 safelyResolveCompilationUnit(entry.getKey()); |
3017 computeLibraryElement(entry.getKey()); | |
3018 } on AnalysisException catch (exception) { | |
3019 DartEntryImpl dartCopy = ((entry.getValue() as DartEntry)).writableC
opy; | |
3020 dartCopy.setState(DartEntry.ELEMENT, CacheState.ERROR); | |
3021 entry.setValue(dartCopy); | |
3022 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); | |
3023 } | |
3024 return true; | 3304 return true; |
3025 } | 3305 } |
3026 } else if (sourceEntry is HtmlEntry) { | 3306 } else if (sourceEntry is HtmlEntry) { |
3027 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 3307 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
3028 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNI
T); | 3308 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNI
T); |
3029 if (identical(resolvedUnitState, CacheState.INVALID)) { | 3309 if (identical(resolvedUnitState, CacheState.INVALID)) { |
3030 try { | 3310 safelyResolveHtmlUnit(entry.getKey()); |
3031 resolveHtmlUnit(entry.getKey()); | |
3032 } on AnalysisException catch (exception) { | |
3033 HtmlEntryImpl htmlCopy = ((entry.getValue() as HtmlEntry)).writableC
opy; | |
3034 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); | |
3035 entry.setValue(htmlCopy); | |
3036 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); | |
3037 } | |
3038 return true; | 3311 return true; |
3039 } | 3312 } |
3040 } | 3313 } |
3041 } | 3314 } |
3042 return false; | 3315 return false; |
3043 } | 3316 } |
3044 | 3317 |
3045 /** | 3318 /** |
3046 * Given a cache entry and a library element, record the library element and o
ther information | 3319 * Given a cache entry and a library element, record the library element and o
ther information |
3047 * gleaned from the element in the cache entry. | 3320 * gleaned from the element in the cache entry. |
| 3321 * |
3048 * @param dartCopy the cache entry in which data is to be recorded | 3322 * @param dartCopy the cache entry in which data is to be recorded |
3049 * @param library the library element used to record information | 3323 * @param library the library element used to record information |
3050 * @param htmlSource the source for the HTML library | 3324 * @param htmlSource the source for the HTML library |
3051 */ | 3325 */ |
3052 void recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source
htmlSource) { | 3326 void recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source
htmlSource) { |
3053 dartCopy.setValue(DartEntry.ELEMENT, library); | 3327 dartCopy.setValue(DartEntry.ELEMENT, library); |
3054 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); | 3328 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); |
3055 dartCopy.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set
<LibraryElement>())); | 3329 dartCopy.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set
<LibraryElement>())); |
3056 List<Source> unitSources = new List<Source>(); | 3330 List<Source> unitSources = new List<Source>(); |
3057 unitSources.add(library.definingCompilationUnit.source); | 3331 unitSources.add(library.definingCompilationUnit.source); |
3058 for (CompilationUnitElement part in library.parts) { | 3332 for (CompilationUnitElement part in library.parts) { |
3059 Source partSource = part.source; | 3333 Source partSource = part.source; |
3060 unitSources.add(partSource); | 3334 unitSources.add(partSource); |
3061 } | 3335 } |
3062 dartCopy.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources)); | 3336 dartCopy.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources)); |
3063 } | 3337 } |
3064 | 3338 |
3065 /** | 3339 /** |
3066 * Record the result of using the given resolver to resolve one or more librar
ies. | 3340 * Record the result of using the given resolver to resolve one or more librar
ies. |
| 3341 * |
3067 * @param resolver the resolver that has the needed results | 3342 * @param resolver the resolver that has the needed results |
3068 * @throws AnalysisException if the results cannot be retrieved for some reaso
n | 3343 * @throws AnalysisException if the results cannot be retrieved for some reaso
n |
3069 */ | 3344 */ |
3070 void recordResolutionResults(LibraryResolver resolver) { | 3345 void recordResolutionResults(LibraryResolver resolver) { |
3071 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); | 3346 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
3072 RecordingErrorListener errorListener = resolver.errorListener; | 3347 RecordingErrorListener errorListener = resolver.errorListener; |
3073 for (Library library in resolver.resolvedLibraries) { | 3348 for (Library library in resolver.resolvedLibraries) { |
3074 Source librarySource = library.librarySource; | 3349 Source librarySource = library.librarySource; |
3075 Set<Source> referencedLibraries = new Set<Source>(); | |
3076 for (Library referencedLibrary in library.exports) { | |
3077 javaSetAdd(referencedLibraries, referencedLibrary.librarySource); | |
3078 } | |
3079 for (Library referencedLibrary in library.imports) { | |
3080 javaSetAdd(referencedLibraries, referencedLibrary.librarySource); | |
3081 } | |
3082 for (Source source in library.compilationUnitSources) { | 3350 for (Source source in library.compilationUnitSources) { |
3083 CompilationUnit unit = library.getAST(source); | 3351 CompilationUnit unit = library.getAST(source); |
3084 List<AnalysisError> errors = errorListener.getErrors2(source); | 3352 List<AnalysisError> errors = errorListener.getErrors2(source); |
3085 unit.resolutionErrors = errors; | 3353 unit.resolutionErrors = errors; |
3086 LineInfo lineInfo = unit.lineInfo; | 3354 LineInfo lineInfo = unit.lineInfo; |
3087 { | 3355 { |
3088 DartEntry dartEntry = getDartEntry(source); | 3356 DartEntry dartEntry = getDartEntry(source); |
3089 if (dartEntry != null) { | 3357 if (dartEntry != null) { |
3090 DartEntryImpl dartCopy = dartEntry.writableCopy; | 3358 DartEntryImpl dartCopy = dartEntry.writableCopy; |
3091 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 3359 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
3092 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 3360 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
3093 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit); | 3361 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit); |
3094 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, error
s); | 3362 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, error
s); |
3095 if (identical(source, librarySource)) { | 3363 if (identical(source, librarySource)) { |
3096 recordElementData(dartCopy, library.libraryElement, htmlSource); | 3364 recordElementData(dartCopy, library.libraryElement, htmlSource); |
3097 List<Source> libraries; | |
3098 if (referencedLibraries.isEmpty) { | |
3099 libraries = Source.EMPTY_ARRAY; | |
3100 } else { | |
3101 libraries = new List.from(referencedLibraries); | |
3102 } | |
3103 dartCopy.setValue(DartEntry.REFERENCED_LIBRARIES, libraries); | |
3104 } | 3365 } |
3105 _sourceMap[source] = dartCopy; | 3366 _sourceMap[source] = dartCopy; |
3106 ChangeNoticeImpl notice = getNotice(source); | 3367 ChangeNoticeImpl notice = getNotice(source); |
3107 notice.compilationUnit = unit; | 3368 notice.compilationUnit = unit; |
3108 notice.setErrors(dartCopy.allErrors, lineInfo); | 3369 notice.setErrors(dartCopy.allErrors, lineInfo); |
3109 } | 3370 } |
3110 } | 3371 } |
3111 } | 3372 } |
3112 } | 3373 } |
3113 } | 3374 } |
| 3375 |
| 3376 /** |
| 3377 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the |
| 3378 * given library, or `null` if the URI is not valid. |
| 3379 * |
| 3380 * @param librarySource the source representing the library containing the dir
ective |
| 3381 * @param directive the directive which URI should be resolved |
| 3382 * @return the result of resolving the URI against the URI of the library |
| 3383 */ |
| 3384 Source resolveSource(Source librarySource, UriBasedDirective directive) { |
| 3385 StringLiteral uriLiteral = directive.uri; |
| 3386 if (uriLiteral is StringInterpolation) { |
| 3387 return null; |
| 3388 } |
| 3389 String uriContent = uriLiteral.stringValue.trim(); |
| 3390 if (uriContent == null) { |
| 3391 return null; |
| 3392 } |
| 3393 try { |
| 3394 parseUriWithException(uriContent); |
| 3395 return _sourceFactory.resolveUri(librarySource, uriContent); |
| 3396 } on URISyntaxException catch (exception) { |
| 3397 return null; |
| 3398 } |
| 3399 } |
| 3400 |
| 3401 /** |
| 3402 * Parse the given source and update the cache. |
| 3403 * |
| 3404 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3405 * |
| 3406 * @param source the source to be parsed |
| 3407 * @param dartEntry the cache entry associated with the source |
| 3408 */ |
| 3409 void safelyParseCompilationUnit(Source source, DartEntry dartEntry) { |
| 3410 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3411 try { |
| 3412 internalParseCompilationUnit(dartCopy, source); |
| 3413 } on AnalysisException catch (exception) { |
| 3414 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullNam
e}", exception); |
| 3415 } |
| 3416 _sourceMap[source] = dartCopy; |
| 3417 } |
| 3418 |
| 3419 /** |
| 3420 * Parse the given source and update the cache. |
| 3421 * |
| 3422 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3423 * |
| 3424 * @param source the source to be parsed |
| 3425 */ |
| 3426 void safelyParseHtmlUnit(Source source) { |
| 3427 try { |
| 3428 parseHtmlUnit(source); |
| 3429 } on AnalysisException catch (exception) { |
| 3430 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullNam
e}", exception); |
| 3431 } |
| 3432 } |
| 3433 |
| 3434 /** |
| 3435 * Resolve the given source and update the cache. |
| 3436 * |
| 3437 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3438 * |
| 3439 * @param source the source to be resolved |
| 3440 */ |
| 3441 void safelyResolveCompilationUnit(Source source) { |
| 3442 try { |
| 3443 computeLibraryElement(source); |
| 3444 } on AnalysisException catch (exception) { |
| 3445 } |
| 3446 } |
| 3447 |
| 3448 /** |
| 3449 * Resolve the given source and update the cache. |
| 3450 * |
| 3451 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3452 * |
| 3453 * @param source the source to be resolved |
| 3454 */ |
| 3455 void safelyResolveHtmlUnit(Source source) { |
| 3456 try { |
| 3457 resolveHtmlUnit(source); |
| 3458 } on AnalysisException catch (exception) { |
| 3459 AnalysisEngine.instance.logger.logError2("Could not resolve ${source.fullN
ame}", exception); |
| 3460 } |
| 3461 } |
3114 HtmlScanResult scanHtml(Source source) { | 3462 HtmlScanResult scanHtml(Source source) { |
3115 HtmlScanner scanner = new HtmlScanner(source); | 3463 HtmlScanner scanner = new HtmlScanner(source); |
3116 try { | 3464 try { |
3117 source.getContents(scanner); | 3465 source.getContents(scanner); |
3118 } catch (exception) { | 3466 } catch (exception) { |
3119 throw new AnalysisException.con3(exception); | 3467 throw new AnalysisException.con3(exception); |
3120 } | 3468 } |
3121 return scanner.result; | 3469 return scanner.result; |
3122 } | 3470 } |
3123 | 3471 |
3124 /** | 3472 /** |
3125 * Create an entry for the newly added source. Return `true` if the new source
is a Dart | 3473 * Create an entry for the newly added source. Return `true` if the new source
is a Dart |
3126 * file. | 3474 * file. |
3127 * | 3475 * |
3128 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3476 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3477 * |
3129 * @param source the source that has been added | 3478 * @param source the source that has been added |
3130 * @return `true` if the new source is a Dart file | 3479 * @return `true` if the new source is a Dart file |
3131 */ | 3480 */ |
3132 bool sourceAvailable(Source source) { | 3481 bool sourceAvailable(Source source) { |
3133 SourceEntry sourceEntry = _sourceMap[source]; | 3482 SourceEntry sourceEntry = _sourceMap[source]; |
3134 if (sourceEntry == null) { | 3483 if (sourceEntry == null) { |
3135 sourceEntry = createSourceEntry(source); | 3484 sourceEntry = createSourceEntry(source); |
3136 } | 3485 } |
3137 return sourceEntry is DartEntry; | 3486 return sourceEntry is DartEntry; |
3138 } | 3487 } |
3139 | 3488 |
3140 /** | 3489 /** |
3141 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3490 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3491 * |
3142 * @param source the source that has been changed | 3492 * @param source the source that has been changed |
3143 */ | 3493 */ |
3144 void sourceChanged(Source source) { | 3494 void sourceChanged(Source source) { |
3145 SourceEntry sourceEntry = _sourceMap[source]; | 3495 SourceEntry sourceEntry = _sourceMap[source]; |
3146 if (sourceEntry is HtmlEntry) { | 3496 if (sourceEntry is HtmlEntry) { |
3147 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; | 3497 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
3148 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); | 3498 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
3149 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 3499 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
3150 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); | 3500 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); |
3151 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); | 3501 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); |
3152 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); | 3502 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); |
3153 _sourceMap[source] = htmlCopy; | 3503 _sourceMap[source] = htmlCopy; |
3154 } else if (sourceEntry is DartEntry) { | 3504 } else if (sourceEntry is DartEntry) { |
3155 List<Source> containingLibraries = getLibrariesContaining(source); | 3505 List<Source> containingLibraries = getLibrariesContaining(source); |
3156 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; | 3506 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
3157 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 3507 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
3158 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); | 3508 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); |
3159 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); | 3509 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); |
3160 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); | 3510 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); |
3161 _sourceMap[source] = dartCopy; | 3511 _sourceMap[source] = dartCopy; |
3162 for (Source library in containingLibraries) { | 3512 for (Source library in containingLibraries) { |
3163 invalidateLibraryResolution(library); | 3513 invalidateLibraryResolution(library); |
3164 } | 3514 } |
3165 } | 3515 } |
3166 } | 3516 } |
3167 | 3517 |
3168 /** | 3518 /** |
3169 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3519 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3520 * |
3170 * @param source the source that has been deleted | 3521 * @param source the source that has been deleted |
3171 */ | 3522 */ |
3172 void sourceRemoved(Source source) { | 3523 void sourceRemoved(Source source) { |
3173 DartEntry dartEntry = getDartEntry(source); | 3524 DartEntry dartEntry = getDartEntry(source); |
3174 if (dartEntry != null) { | 3525 if (dartEntry != null) { |
3175 Set<Source> libraries = new Set<Source>(); | 3526 Set<Source> libraries = new Set<Source>(); |
3176 for (Source librarySource in getLibrariesContaining(source)) { | 3527 for (Source librarySource in getLibrariesContaining(source)) { |
3177 javaSetAdd(libraries, librarySource); | 3528 javaSetAdd(libraries, librarySource); |
3178 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ | 3529 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ |
3179 javaSetAdd(libraries, dependentLibrary); | 3530 javaSetAdd(libraries, dependentLibrary); |
3180 } | 3531 } |
3181 } | 3532 } |
3182 for (Source librarySource in libraries) { | 3533 for (Source librarySource in libraries) { |
3183 invalidateLibraryResolution(librarySource); | 3534 invalidateLibraryResolution(librarySource); |
3184 } | 3535 } |
3185 } | 3536 } |
3186 _sourceMap.remove(source); | 3537 _sourceMap.remove(source); |
3187 } | 3538 } |
| 3539 |
| 3540 /** |
| 3541 * Efficiently convert the given set of sources to an array. |
| 3542 * |
| 3543 * @param sources the set to be converted |
| 3544 * @return an array containing all of the sources in the given set |
| 3545 */ |
| 3546 List<Source> toArray(Set<Source> sources) { |
| 3547 int size = sources.length; |
| 3548 if (size == 0) { |
| 3549 return Source.EMPTY_ARRAY; |
| 3550 } |
| 3551 return new List.from(sources); |
| 3552 } |
3188 } | 3553 } |
3189 /** | 3554 /** |
3190 * Instances of the class `ScanResult` represent the results of scanning a sourc
e. | 3555 * Instances of the class `ScanResult` represent the results of scanning a sourc
e. |
3191 */ | 3556 */ |
3192 class AnalysisContextImpl_ScanResult { | 3557 class AnalysisContextImpl_ScanResult { |
3193 | 3558 |
3194 /** | 3559 /** |
3195 * The time at which the contents of the source were last set. | 3560 * The time at which the contents of the source were last set. |
3196 */ | 3561 */ |
3197 int _modificationTime = 0; | 3562 int _modificationTime = 0; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3269 */ | 3634 */ |
3270 List<AnalysisError> _errors; | 3635 List<AnalysisError> _errors; |
3271 | 3636 |
3272 /** | 3637 /** |
3273 * The line information associated with the errors, or `null` if there are no
errors. | 3638 * The line information associated with the errors, or `null` if there are no
errors. |
3274 */ | 3639 */ |
3275 LineInfo _lineInfo; | 3640 LineInfo _lineInfo; |
3276 | 3641 |
3277 /** | 3642 /** |
3278 * Initialize an newly created error info with the errors and line information | 3643 * Initialize an newly created error info with the errors and line information |
| 3644 * |
3279 * @param errors the errors as a result of analysis | 3645 * @param errors the errors as a result of analysis |
3280 * @param lineinfo the line info for the errors | 3646 * @param lineinfo the line info for the errors |
3281 */ | 3647 */ |
3282 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { | 3648 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { |
3283 this._errors = errors; | 3649 this._errors = errors; |
3284 this._lineInfo = lineInfo; | 3650 this._lineInfo = lineInfo; |
3285 } | 3651 } |
3286 | 3652 |
3287 /** | 3653 /** |
3288 * Return the errors of analysis, or `null` if there were no errors. | 3654 * Return the errors of analysis, or `null` if there were no errors. |
| 3655 * |
3289 * @return the errors as a result of the analysis | 3656 * @return the errors as a result of the analysis |
3290 */ | 3657 */ |
3291 List<AnalysisError> get errors => _errors; | 3658 List<AnalysisError> get errors => _errors; |
3292 | 3659 |
3293 /** | 3660 /** |
3294 * Return the line information associated with the errors, or `null` if there
were no | 3661 * Return the line information associated with the errors, or `null` if there
were no |
3295 * errors. | 3662 * errors. |
| 3663 * |
3296 * @return the line information associated with the errors | 3664 * @return the line information associated with the errors |
3297 */ | 3665 */ |
3298 LineInfo get lineInfo => _lineInfo; | 3666 LineInfo get lineInfo => _lineInfo; |
3299 } | 3667 } |
3300 /** | 3668 /** |
3301 * Instances of the class `AnalysisOptions` represent a set of analysis options
used to | 3669 * Instances of the class `AnalysisOptions` represent a set of analysis options
used to |
3302 * control the behavior of an analysis context. | 3670 * control the behavior of an analysis context. |
3303 */ | 3671 */ |
3304 class AnalysisOptionsImpl implements AnalysisOptions { | 3672 class AnalysisOptionsImpl implements AnalysisOptions { |
3305 | 3673 |
3306 /** | 3674 /** |
3307 * A flag indicating whether analysis is to use strict mode. In strict mode, e
rror reporting is | 3675 * A flag indicating whether analysis is to use strict mode. In strict mode, e
rror reporting is |
3308 * based exclusively on the static type information. | 3676 * based exclusively on the static type information. |
3309 */ | 3677 */ |
3310 bool _strictMode = false; | 3678 bool _strictMode = false; |
3311 | 3679 |
3312 /** | 3680 /** |
| 3681 * A flag indicating whether analysis is to generate audit results (e.g. type
inference based |
| 3682 * information and pub best practices). |
| 3683 */ |
| 3684 bool _audit = false; |
| 3685 bool get audit => _audit; |
| 3686 |
| 3687 /** |
3313 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based | 3688 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based |
3314 * exclusively on the static type information. | 3689 * exclusively on the static type information. |
| 3690 * |
3315 * @return `true` if analysis is to use strict mode | 3691 * @return `true` if analysis is to use strict mode |
3316 */ | 3692 */ |
3317 bool get strictMode => _strictMode; | 3693 bool get strictMode => _strictMode; |
3318 | 3694 |
3319 /** | 3695 /** |
| 3696 * Set whether analysis is to generate audit results (e.g. type inference base
d information and |
| 3697 * pub best practices). |
| 3698 * |
| 3699 * @param audit `true` if analysis is to generate audit results |
| 3700 */ |
| 3701 void set audit(bool audit2) { |
| 3702 this._audit = audit2; |
| 3703 } |
| 3704 |
| 3705 /** |
3320 * Set whether analysis is to use strict mode to the given value. In strict mo
de, error reporting | 3706 * Set whether analysis is to use strict mode to the given value. In strict mo
de, error reporting |
3321 * is based exclusively on the static type information. | 3707 * is based exclusively on the static type information. |
| 3708 * |
3322 * @param isStrict `true` if analysis is to use strict mode | 3709 * @param isStrict `true` if analysis is to use strict mode |
3323 */ | 3710 */ |
3324 void set strictMode(bool isStrict) { | 3711 void set strictMode(bool isStrict) { |
3325 _strictMode = isStrict; | 3712 _strictMode = isStrict; |
3326 } | 3713 } |
3327 } | 3714 } |
3328 /** | 3715 /** |
3329 * The enumeration `CacheState` defines the possible states of cached data. | 3716 * The enumeration `CacheState` defines the possible states of cached data. |
3330 */ | 3717 */ |
3331 class CacheState implements Comparable<CacheState> { | 3718 class CacheState implements Comparable<CacheState> { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3393 final int ordinal; | 3780 final int ordinal; |
3394 CacheState(this.name, this.ordinal) { | 3781 CacheState(this.name, this.ordinal) { |
3395 } | 3782 } |
3396 int compareTo(CacheState other) => ordinal - other.ordinal; | 3783 int compareTo(CacheState other) => ordinal - other.ordinal; |
3397 int get hashCode => ordinal; | 3784 int get hashCode => ordinal; |
3398 String toString() => name; | 3785 String toString() => name; |
3399 } | 3786 } |
3400 /** | 3787 /** |
3401 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results | 3788 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results |
3402 * associated with a given source. | 3789 * associated with a given source. |
| 3790 * |
3403 * @coverage dart.engine | 3791 * @coverage dart.engine |
3404 */ | 3792 */ |
3405 class ChangeNoticeImpl implements ChangeNotice { | 3793 class ChangeNoticeImpl implements ChangeNotice { |
3406 | 3794 |
3407 /** | 3795 /** |
3408 * The source for which the result is being reported. | 3796 * The source for which the result is being reported. |
3409 */ | 3797 */ |
3410 Source _source; | 3798 Source _source; |
3411 | 3799 |
3412 /** | 3800 /** |
(...skipping 13 matching lines...) Expand all Loading... |
3426 */ | 3814 */ |
3427 LineInfo _lineInfo; | 3815 LineInfo _lineInfo; |
3428 | 3816 |
3429 /** | 3817 /** |
3430 * An empty array of change notices. | 3818 * An empty array of change notices. |
3431 */ | 3819 */ |
3432 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); | 3820 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); |
3433 | 3821 |
3434 /** | 3822 /** |
3435 * Initialize a newly created notice associated with the given source. | 3823 * Initialize a newly created notice associated with the given source. |
| 3824 * |
3436 * @param source the source for which the change is being reported | 3825 * @param source the source for which the change is being reported |
3437 */ | 3826 */ |
3438 ChangeNoticeImpl(Source source) { | 3827 ChangeNoticeImpl(Source source) { |
3439 this._source = source; | 3828 this._source = source; |
3440 } | 3829 } |
3441 | 3830 |
3442 /** | 3831 /** |
3443 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the | 3832 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the |
3444 * AST was not changed. | 3833 * AST was not changed. |
| 3834 * |
3445 * @return the fully resolved AST that changed as a result of the analysis | 3835 * @return the fully resolved AST that changed as a result of the analysis |
3446 */ | 3836 */ |
3447 CompilationUnit get compilationUnit => _compilationUnit; | 3837 CompilationUnit get compilationUnit => _compilationUnit; |
3448 | 3838 |
3449 /** | 3839 /** |
3450 * Return the errors that changed as a result of the analysis, or `null` if er
rors were not | 3840 * Return the errors that changed as a result of the analysis, or `null` if er
rors were not |
3451 * changed. | 3841 * changed. |
| 3842 * |
3452 * @return the errors that changed as a result of the analysis | 3843 * @return the errors that changed as a result of the analysis |
3453 */ | 3844 */ |
3454 List<AnalysisError> get errors => _errors; | 3845 List<AnalysisError> get errors => _errors; |
3455 | 3846 |
3456 /** | 3847 /** |
3457 * Return the line information associated with the source, or `null` if errors
were not | 3848 * Return the line information associated with the source, or `null` if errors
were not |
3458 * changed. | 3849 * changed. |
| 3850 * |
3459 * @return the line information associated with the source | 3851 * @return the line information associated with the source |
3460 */ | 3852 */ |
3461 LineInfo get lineInfo => _lineInfo; | 3853 LineInfo get lineInfo => _lineInfo; |
3462 | 3854 |
3463 /** | 3855 /** |
3464 * Return the source for which the result is being reported. | 3856 * Return the source for which the result is being reported. |
| 3857 * |
3465 * @return the source for which the result is being reported | 3858 * @return the source for which the result is being reported |
3466 */ | 3859 */ |
3467 Source get source => _source; | 3860 Source get source => _source; |
3468 | 3861 |
3469 /** | 3862 /** |
3470 * Set the fully resolved AST that changed as a result of the analysis to the
given AST. | 3863 * Set the fully resolved AST that changed as a result of the analysis to the
given AST. |
| 3864 * |
3471 * @param compilationUnit the fully resolved AST that changed as a result of t
he analysis | 3865 * @param compilationUnit the fully resolved AST that changed as a result of t
he analysis |
3472 */ | 3866 */ |
3473 void set compilationUnit(CompilationUnit compilationUnit2) { | 3867 void set compilationUnit(CompilationUnit compilationUnit2) { |
3474 this._compilationUnit = compilationUnit2; | 3868 this._compilationUnit = compilationUnit2; |
3475 } | 3869 } |
3476 | 3870 |
3477 /** | 3871 /** |
3478 * Set the errors that changed as a result of the analysis to the given errors
and set the line | 3872 * Set the errors that changed as a result of the analysis to the given errors
and set the line |
3479 * information to the given line information. | 3873 * information to the given line information. |
| 3874 * |
3480 * @param errors the errors that changed as a result of the analysis | 3875 * @param errors the errors that changed as a result of the analysis |
3481 * @param lineInfo the line information associated with the source | 3876 * @param lineInfo the line information associated with the source |
3482 */ | 3877 */ |
3483 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { | 3878 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { |
3484 this._errors = errors2; | 3879 this._errors = errors2; |
3485 this._lineInfo = lineInfo2; | 3880 this._lineInfo = lineInfo2; |
3486 } | 3881 } |
3487 } | 3882 } |
3488 /** | 3883 /** |
3489 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex
tImplanalysis context] to delegate sources to the appropriate analysis context.
For instance, if the | 3884 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex
tImpl |
| 3885 ] to delegate sources to the appropriate analysis context. For instance, if the |
3490 * source is in a system library then the analysis context from the [DartSdk] is
used. | 3886 * source is in a system library then the analysis context from the [DartSdk] is
used. |
| 3887 * |
3491 * @coverage dart.engine | 3888 * @coverage dart.engine |
3492 */ | 3889 */ |
3493 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { | 3890 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { |
3494 | 3891 |
3495 /** | 3892 /** |
3496 * This references the [InternalAnalysisContext] held onto by the [DartSdk] wh
ich is | 3893 * This references the [InternalAnalysisContext] held onto by the [DartSdk] wh
ich is |
3497 * used (instead of this [AnalysisContext]) for SDK sources. This field is set
when | 3894 * used (instead of this [AnalysisContext]) for SDK sources. This field is set
when |
3498 * #setSourceFactory(SourceFactory) is called, and references the analysis con
text in the[DartUriResolver] in the [SourceFactory], this analysis context assum
es that there | 3895 * #setSourceFactory(SourceFactory) is called, and references the analysis con
text in the |
| 3896 * [DartUriResolver] in the [SourceFactory], this analysis context assumes tha
t there |
3499 * will be such a resolver. | 3897 * will be such a resolver. |
3500 */ | 3898 */ |
3501 InternalAnalysisContext _sdkAnalysisContext; | 3899 InternalAnalysisContext _sdkAnalysisContext; |
3502 void addSourceInfo(Source source, SourceEntry info) { | 3900 void addSourceInfo(Source source, SourceEntry info) { |
3503 if (source.isInSystemLibrary) { | 3901 if (source.isInSystemLibrary) { |
3504 _sdkAnalysisContext.addSourceInfo(source, info); | 3902 _sdkAnalysisContext.addSourceInfo(source, info); |
3505 } else { | 3903 } else { |
3506 super.addSourceInfo(source, info); | 3904 super.addSourceInfo(source, info); |
3507 } | 3905 } |
3508 } | 3906 } |
3509 List<AnalysisError> computeErrors(Source source) { | 3907 List<AnalysisError> computeErrors(Source source) { |
3510 if (source.isInSystemLibrary) { | 3908 if (source.isInSystemLibrary) { |
3511 return _sdkAnalysisContext.computeErrors(source); | 3909 return _sdkAnalysisContext.computeErrors(source); |
3512 } else { | 3910 } else { |
3513 return super.computeErrors(source); | 3911 return super.computeErrors(source); |
3514 } | 3912 } |
3515 } | 3913 } |
| 3914 List<Source> computeExportedLibraries(Source source) { |
| 3915 if (source.isInSystemLibrary) { |
| 3916 return _sdkAnalysisContext.computeExportedLibraries(source); |
| 3917 } else { |
| 3918 return super.computeExportedLibraries(source); |
| 3919 } |
| 3920 } |
3516 HtmlElement computeHtmlElement(Source source) { | 3921 HtmlElement computeHtmlElement(Source source) { |
3517 if (source.isInSystemLibrary) { | 3922 if (source.isInSystemLibrary) { |
3518 return _sdkAnalysisContext.computeHtmlElement(source); | 3923 return _sdkAnalysisContext.computeHtmlElement(source); |
3519 } else { | 3924 } else { |
3520 return super.computeHtmlElement(source); | 3925 return super.computeHtmlElement(source); |
3521 } | 3926 } |
3522 } | 3927 } |
| 3928 List<Source> computeImportedLibraries(Source source) { |
| 3929 if (source.isInSystemLibrary) { |
| 3930 return _sdkAnalysisContext.computeImportedLibraries(source); |
| 3931 } else { |
| 3932 return super.computeImportedLibraries(source); |
| 3933 } |
| 3934 } |
3523 SourceKind computeKindOf(Source source) { | 3935 SourceKind computeKindOf(Source source) { |
3524 if (source.isInSystemLibrary) { | 3936 if (source.isInSystemLibrary) { |
3525 return _sdkAnalysisContext.computeKindOf(source); | 3937 return _sdkAnalysisContext.computeKindOf(source); |
3526 } else { | 3938 } else { |
3527 return super.computeKindOf(source); | 3939 return super.computeKindOf(source); |
3528 } | 3940 } |
3529 } | 3941 } |
3530 LibraryElement computeLibraryElement(Source source) { | 3942 LibraryElement computeLibraryElement(Source source) { |
3531 if (source.isInSystemLibrary) { | 3943 if (source.isInSystemLibrary) { |
3532 return _sdkAnalysisContext.computeLibraryElement(source); | 3944 return _sdkAnalysisContext.computeLibraryElement(source); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3709 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { | 4121 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { |
3710 _sdkAnalysisContext = null; | 4122 _sdkAnalysisContext = null; |
3711 throw new IllegalStateException("The context provided by an SDK cannot i
tself be a delegating analysis context"); | 4123 throw new IllegalStateException("The context provided by an SDK cannot i
tself be a delegating analysis context"); |
3712 } | 4124 } |
3713 } else { | 4125 } else { |
3714 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal
ysisContextImpls must have a DartSdk associated with the provided SourceFactory.
"); | 4126 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal
ysisContextImpls must have a DartSdk associated with the provided SourceFactory.
"); |
3715 } | 4127 } |
3716 } | 4128 } |
3717 } | 4129 } |
3718 /** | 4130 /** |
3719 * Instances of the class `InstrumentedAnalysisContextImpl` implement an[Analysi
sContext analysis context] by recording instrumentation data and delegating to | 4131 * Instances of the class `InstrumentedAnalysisContextImpl` implement an |
| 4132 * [AnalysisContext] by recording instrumentation data and delegating to |
3720 * another analysis context to do the non-instrumentation work. | 4133 * another analysis context to do the non-instrumentation work. |
| 4134 * |
3721 * @coverage dart.engine | 4135 * @coverage dart.engine |
3722 */ | 4136 */ |
3723 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { | 4137 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { |
3724 | 4138 |
3725 /** | 4139 /** |
3726 * Record an exception that was thrown during analysis. | 4140 * Record an exception that was thrown during analysis. |
| 4141 * |
3727 * @param instrumentation the instrumentation builder being used to record the
exception | 4142 * @param instrumentation the instrumentation builder being used to record the
exception |
3728 * @param exception the exception being reported | 4143 * @param exception the exception being reported |
3729 */ | 4144 */ |
3730 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { | 4145 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { |
3731 instrumentation.record(exception); | 4146 instrumentation.record(exception); |
3732 } | 4147 } |
3733 | 4148 |
3734 /** | 4149 /** |
3735 * The unique identifier used to identify this analysis context in the instrum
entation data. | 4150 * The unique identifier used to identify this analysis context in the instrum
entation data. |
3736 */ | 4151 */ |
3737 String _contextId = UUID.randomUUID().toString(); | 4152 String _contextId = UUID.randomUUID().toString(); |
3738 | 4153 |
3739 /** | 4154 /** |
3740 * The analysis context to which all of the non-instrumentation work is delega
ted. | 4155 * The analysis context to which all of the non-instrumentation work is delega
ted. |
3741 */ | 4156 */ |
3742 InternalAnalysisContext _basis; | 4157 InternalAnalysisContext _basis; |
3743 | 4158 |
3744 /** | 4159 /** |
3745 * Create a new [InstrumentedAnalysisContextImpl] which wraps a new[AnalysisCo
ntextImpl] as the basis context. | 4160 * Create a new [InstrumentedAnalysisContextImpl] which wraps a new |
| 4161 * [AnalysisContextImpl] as the basis context. |
3746 */ | 4162 */ |
3747 InstrumentedAnalysisContextImpl() { | 4163 InstrumentedAnalysisContextImpl() { |
3748 _jtd_constructor_183_impl(); | 4164 _jtd_constructor_183_impl(); |
3749 } | 4165 } |
3750 _jtd_constructor_183_impl() { | 4166 _jtd_constructor_183_impl() { |
3751 _jtd_constructor_184_impl(new AnalysisContextImpl()); | 4167 _jtd_constructor_184_impl(new AnalysisContextImpl()); |
3752 } | 4168 } |
3753 | 4169 |
3754 /** | 4170 /** |
3755 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte
xt, aka the | 4171 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte
xt, aka the |
3756 * context to wrap and instrument. | 4172 * context to wrap and instrument. |
| 4173 * |
3757 * @param context some [InstrumentedAnalysisContext] to wrap and instrument | 4174 * @param context some [InstrumentedAnalysisContext] to wrap and instrument |
3758 */ | 4175 */ |
3759 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { | 4176 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { |
3760 _jtd_constructor_184_impl(context); | 4177 _jtd_constructor_184_impl(context); |
3761 } | 4178 } |
3762 _jtd_constructor_184_impl(InternalAnalysisContext context) { | 4179 _jtd_constructor_184_impl(InternalAnalysisContext context) { |
3763 _basis = context; | 4180 _basis = context; |
3764 } | 4181 } |
3765 void addSourceInfo(Source source, SourceEntry info) { | 4182 void addSourceInfo(Source source, SourceEntry info) { |
3766 _basis.addSourceInfo(source, info); | 4183 _basis.addSourceInfo(source, info); |
(...skipping 20 matching lines...) Expand all Loading... |
3787 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeErrors"); | 4204 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeErrors"); |
3788 try { | 4205 try { |
3789 instrumentation.metric3("contextId", _contextId); | 4206 instrumentation.metric3("contextId", _contextId); |
3790 List<AnalysisError> errors = _basis.computeErrors(source); | 4207 List<AnalysisError> errors = _basis.computeErrors(source); |
3791 instrumentation.metric2("Errors-count", errors.length); | 4208 instrumentation.metric2("Errors-count", errors.length); |
3792 return errors; | 4209 return errors; |
3793 } finally { | 4210 } finally { |
3794 instrumentation.log(); | 4211 instrumentation.log(); |
3795 } | 4212 } |
3796 } | 4213 } |
| 4214 List<Source> computeExportedLibraries(Source source) { |
| 4215 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeExportedLibraries"); |
| 4216 try { |
| 4217 instrumentation.metric3("contextId", _contextId); |
| 4218 return _basis.computeExportedLibraries(source); |
| 4219 } finally { |
| 4220 instrumentation.log(); |
| 4221 } |
| 4222 } |
3797 HtmlElement computeHtmlElement(Source source) { | 4223 HtmlElement computeHtmlElement(Source source) { |
3798 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeHtmlElement"); | 4224 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeHtmlElement"); |
3799 try { | 4225 try { |
3800 instrumentation.metric3("contextId", _contextId); | 4226 instrumentation.metric3("contextId", _contextId); |
3801 return _basis.computeHtmlElement(source); | 4227 return _basis.computeHtmlElement(source); |
3802 } on AnalysisException catch (e) { | 4228 } on AnalysisException catch (e) { |
3803 recordAnalysisException(instrumentation, e); | 4229 recordAnalysisException(instrumentation, e); |
3804 throw e; | 4230 throw e; |
3805 } finally { | 4231 } finally { |
3806 instrumentation.log(); | 4232 instrumentation.log(); |
3807 } | 4233 } |
3808 } | 4234 } |
| 4235 List<Source> computeImportedLibraries(Source source) { |
| 4236 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeImportedLibraries"); |
| 4237 try { |
| 4238 instrumentation.metric3("contextId", _contextId); |
| 4239 return _basis.computeImportedLibraries(source); |
| 4240 } finally { |
| 4241 instrumentation.log(); |
| 4242 } |
| 4243 } |
3809 SourceKind computeKindOf(Source source) { | 4244 SourceKind computeKindOf(Source source) { |
3810 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeKindOf"); | 4245 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeKindOf"); |
3811 try { | 4246 try { |
3812 instrumentation.metric3("contextId", _contextId); | 4247 instrumentation.metric3("contextId", _contextId); |
3813 return _basis.computeKindOf(source); | 4248 return _basis.computeKindOf(source); |
3814 } finally { | 4249 } finally { |
3815 instrumentation.log(); | 4250 instrumentation.log(); |
3816 } | 4251 } |
3817 } | 4252 } |
3818 LibraryElement computeLibraryElement(Source source) { | 4253 LibraryElement computeLibraryElement(Source source) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4152 } | 4587 } |
4153 void set analysisOptions(AnalysisOptions options) { | 4588 void set analysisOptions(AnalysisOptions options) { |
4154 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisOptions"); | 4589 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisOptions"); |
4155 try { | 4590 try { |
4156 instrumentation.metric3("contextId", _contextId); | 4591 instrumentation.metric3("contextId", _contextId); |
4157 _basis.analysisOptions = options; | 4592 _basis.analysisOptions = options; |
4158 } finally { | 4593 } finally { |
4159 instrumentation.log(); | 4594 instrumentation.log(); |
4160 } | 4595 } |
4161 } | 4596 } |
| 4597 void set analysisPriorityOrder(List<Source> sources) { |
| 4598 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisPriorityOrder"); |
| 4599 try { |
| 4600 instrumentation.metric3("contextId", _contextId); |
| 4601 _basis.analysisPriorityOrder = sources; |
| 4602 } finally { |
| 4603 instrumentation.log(); |
| 4604 } |
| 4605 } |
4162 void setContents(Source source, String contents) { | 4606 void setContents(Source source, String contents) { |
4163 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setContents"); | 4607 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setContents"); |
4164 try { | 4608 try { |
4165 instrumentation.metric3("contextId", _contextId); | 4609 instrumentation.metric3("contextId", _contextId); |
4166 _basis.setContents(source, contents); | 4610 _basis.setContents(source, contents); |
4167 } finally { | 4611 } finally { |
4168 instrumentation.log(); | 4612 instrumentation.log(); |
4169 } | 4613 } |
4170 } | 4614 } |
4171 void set sourceFactory(SourceFactory factory) { | 4615 void set sourceFactory(SourceFactory factory) { |
(...skipping 16 matching lines...) Expand all Loading... |
4188 } | 4632 } |
4189 } | 4633 } |
4190 /** | 4634 /** |
4191 * The interface `InternalAnalysisContext` defines additional behavior for an an
alysis context | 4635 * The interface `InternalAnalysisContext` defines additional behavior for an an
alysis context |
4192 * that is required by internal users of the context. | 4636 * that is required by internal users of the context. |
4193 */ | 4637 */ |
4194 abstract class InternalAnalysisContext implements AnalysisContext { | 4638 abstract class InternalAnalysisContext implements AnalysisContext { |
4195 | 4639 |
4196 /** | 4640 /** |
4197 * Add the given source with the given information to this context. | 4641 * Add the given source with the given information to this context. |
| 4642 * |
4198 * @param source the source to be added | 4643 * @param source the source to be added |
4199 * @param info the information about the source | 4644 * @param info the information about the source |
4200 */ | 4645 */ |
4201 void addSourceInfo(Source source, SourceEntry info); | 4646 void addSourceInfo(Source source, SourceEntry info); |
4202 | 4647 |
4203 /** | 4648 /** |
| 4649 * Return an array containing the sources of the libraries that are exported b
y the library with |
| 4650 * the given source. The array will be empty if the given source is invalid, i
f the given source |
| 4651 * does not represent a library, or if the library does not export any other l
ibraries. |
| 4652 * |
| 4653 * @param source the source representing the library whose exports are to be r
eturned |
| 4654 * @return the sources of the libraries that are exported by the given library |
| 4655 * @throws AnalysisException if the exported libraries could not be computed |
| 4656 */ |
| 4657 List<Source> computeExportedLibraries(Source source); |
| 4658 |
| 4659 /** |
| 4660 * Return an array containing the sources of the libraries that are imported b
y the library with |
| 4661 * the given source. The array will be empty if the given source is invalid, i
f the given source |
| 4662 * does not represent a library, or if the library does not import any other l
ibraries. |
| 4663 * |
| 4664 * @param source the source representing the library whose imports are to be r
eturned |
| 4665 * @return the sources of the libraries that are imported by the given library |
| 4666 * @throws AnalysisException if the imported libraries could not be computed |
| 4667 */ |
| 4668 List<Source> computeImportedLibraries(Source source); |
| 4669 |
| 4670 /** |
4204 * Return an AST structure corresponding to the given source, but ensure that
the structure has | 4671 * Return an AST structure corresponding to the given source, but ensure that
the structure has |
4205 * not already been resolved and will not be resolved by any other threads or
in any other | 4672 * not already been resolved and will not be resolved by any other threads or
in any other |
4206 * library. | 4673 * library. |
| 4674 * |
4207 * @param source the compilation unit for which an AST structure should be ret
urned | 4675 * @param source the compilation unit for which an AST structure should be ret
urned |
4208 * @return the AST structure representing the content of the source | 4676 * @return the AST structure representing the content of the source |
4209 * @throws AnalysisException if the analysis could not be performed | 4677 * @throws AnalysisException if the analysis could not be performed |
4210 */ | 4678 */ |
4211 CompilationUnit computeResolvableCompilationUnit(Source source); | 4679 CompilationUnit computeResolvableCompilationUnit(Source source); |
4212 | 4680 |
4213 /** | 4681 /** |
4214 * Initialize the specified context by removing the specified sources from the
receiver and adding | 4682 * Initialize the specified context by removing the specified sources from the
receiver and adding |
4215 * them to the specified context. | 4683 * them to the specified context. |
| 4684 * |
4216 * @param container the container containing sources that should be removed fr
om this context and | 4685 * @param container the container containing sources that should be removed fr
om this context and |
4217 * added to the returned context | 4686 * added to the returned context |
4218 * @param newContext the context to be initialized | 4687 * @param newContext the context to be initialized |
4219 * @return the analysis context that was initialized | 4688 * @return the analysis context that was initialized |
4220 */ | 4689 */ |
4221 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext); | 4690 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext); |
4222 | 4691 |
4223 /** | 4692 /** |
4224 * Return a namespace containing mappings for all of the public names defined
by the given | 4693 * Return a namespace containing mappings for all of the public names defined
by the given |
4225 * library. | 4694 * library. |
| 4695 * |
4226 * @param library the library whose public namespace is to be returned | 4696 * @param library the library whose public namespace is to be returned |
4227 * @return the public namespace of the given library | 4697 * @return the public namespace of the given library |
4228 */ | 4698 */ |
4229 Namespace getPublicNamespace(LibraryElement library); | 4699 Namespace getPublicNamespace(LibraryElement library); |
4230 | 4700 |
4231 /** | 4701 /** |
4232 * Return a namespace containing mappings for all of the public names defined
by the library | 4702 * Return a namespace containing mappings for all of the public names defined
by the library |
4233 * defined by the given source. | 4703 * defined by the given source. |
| 4704 * |
4234 * @param source the source defining the library whose public namespace is to
be returned | 4705 * @param source the source defining the library whose public namespace is to
be returned |
4235 * @return the public namespace corresponding to the library defined by the gi
ven source | 4706 * @return the public namespace corresponding to the library defined by the gi
ven source |
4236 * @throws AnalysisException if the public namespace could not be computed | 4707 * @throws AnalysisException if the public namespace could not be computed |
4237 */ | 4708 */ |
4238 Namespace getPublicNamespace2(Source source); | 4709 Namespace getPublicNamespace2(Source source); |
4239 | 4710 |
4240 /** | 4711 /** |
4241 * Given a table mapping the source for the libraries represented by the corre
sponding elements to | 4712 * Given a table mapping the source for the libraries represented by the corre
sponding elements to |
4242 * the elements representing the libraries, record those mappings. | 4713 * the elements representing the libraries, record those mappings. |
| 4714 * |
4243 * @param elementMap a table mapping the source for the libraries represented
by the elements to | 4715 * @param elementMap a table mapping the source for the libraries represented
by the elements to |
4244 * the elements representing the libraries | 4716 * the elements representing the libraries |
4245 */ | 4717 */ |
4246 void recordLibraryElements(Map<Source, LibraryElement> elementMap); | 4718 void recordLibraryElements(Map<Source, LibraryElement> elementMap); |
4247 } | 4719 } |
4248 /** | 4720 /** |
4249 * Instances of the class `RecordingErrorListener` implement an error listener t
hat will | 4721 * Instances of the class `RecordingErrorListener` implement an error listener t
hat will |
4250 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors | 4722 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors |
4251 * within an analysis context. | 4723 * within an analysis context. |
| 4724 * |
4252 * @coverage dart.engine | 4725 * @coverage dart.engine |
4253 */ | 4726 */ |
4254 class RecordingErrorListener implements AnalysisErrorListener { | 4727 class RecordingErrorListener implements AnalysisErrorListener { |
4255 | 4728 |
4256 /** | 4729 /** |
4257 * A HashMap of lists containing the errors that were collected, keyed by each
[Source]. | 4730 * A HashMap of lists containing the errors that were collected, keyed by each
[Source]. |
4258 */ | 4731 */ |
4259 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError>
>(); | 4732 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError>
>(); |
4260 | 4733 |
4261 /** | 4734 /** |
4262 * Add all of the errors recorded by the given listener to this listener. | 4735 * Add all of the errors recorded by the given listener to this listener. |
| 4736 * |
4263 * @param listener the listener that has recorded the errors to be added | 4737 * @param listener the listener that has recorded the errors to be added |
4264 */ | 4738 */ |
4265 void addAll(RecordingErrorListener listener) { | 4739 void addAll(RecordingErrorListener listener) { |
4266 for (AnalysisError error in listener.errors) { | 4740 for (AnalysisError error in listener.errors) { |
4267 onError(error); | 4741 onError(error); |
4268 } | 4742 } |
4269 } | 4743 } |
4270 | 4744 |
4271 /** | 4745 /** |
4272 * Answer the errors collected by the listener. | 4746 * Answer the errors collected by the listener. |
| 4747 * |
4273 * @return an array of errors (not `null`, contains no `null`s) | 4748 * @return an array of errors (not `null`, contains no `null`s) |
4274 */ | 4749 */ |
4275 List<AnalysisError> get errors { | 4750 List<AnalysisError> get errors { |
4276 Iterable<MapEntry<Source, List<AnalysisError>>> entrySet = getMapEntrySet(_e
rrors); | 4751 Iterable<MapEntry<Source, List<AnalysisError>>> entrySet = getMapEntrySet(_e
rrors); |
4277 int numEntries = entrySet.length; | 4752 int numEntries = entrySet.length; |
4278 if (numEntries == 0) { | 4753 if (numEntries == 0) { |
4279 return AnalysisError.NO_ERRORS; | 4754 return AnalysisError.NO_ERRORS; |
4280 } | 4755 } |
4281 List<AnalysisError> resultList = new List<AnalysisError>(); | 4756 List<AnalysisError> resultList = new List<AnalysisError>(); |
4282 for (MapEntry<Source, List<AnalysisError>> entry in entrySet) { | 4757 for (MapEntry<Source, List<AnalysisError>> entry in entrySet) { |
4283 resultList.addAll(entry.getValue()); | 4758 resultList.addAll(entry.getValue()); |
4284 } | 4759 } |
4285 return new List.from(resultList); | 4760 return new List.from(resultList); |
4286 } | 4761 } |
4287 | 4762 |
4288 /** | 4763 /** |
4289 * Answer the errors collected by the listener for some passed [Source]. | 4764 * Answer the errors collected by the listener for some passed [Source]. |
| 4765 * |
4290 * @param source some [Source] for which the caller wants the set of [Analysis
Error]s | 4766 * @param source some [Source] for which the caller wants the set of [Analysis
Error]s |
4291 * collected by this listener | 4767 * collected by this listener |
4292 * @return the errors collected by the listener for the passed [Source] | 4768 * @return the errors collected by the listener for the passed [Source] |
4293 */ | 4769 */ |
4294 List<AnalysisError> getErrors2(Source source) { | 4770 List<AnalysisError> getErrors2(Source source) { |
4295 List<AnalysisError> errorsForSource = _errors[source]; | 4771 List<AnalysisError> errorsForSource = _errors[source]; |
4296 if (errorsForSource == null) { | 4772 if (errorsForSource == null) { |
4297 return AnalysisError.NO_ERRORS; | 4773 return AnalysisError.NO_ERRORS; |
4298 } else { | 4774 } else { |
4299 return new List.from(errorsForSource); | 4775 return new List.from(errorsForSource); |
4300 } | 4776 } |
4301 } | 4777 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4378 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 4854 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
4379 node.element = null; | 4855 node.element = null; |
4380 return super.visitSuperConstructorInvocation(node); | 4856 return super.visitSuperConstructorInvocation(node); |
4381 } | 4857 } |
4382 } | 4858 } |
4383 /** | 4859 /** |
4384 * The interface `Logger` defines the behavior of objects that can be used to re
ceive | 4860 * The interface `Logger` defines the behavior of objects that can be used to re
ceive |
4385 * information about errors within the analysis engine. Implementations usually
write this | 4861 * information about errors within the analysis engine. Implementations usually
write this |
4386 * information to a file, but can also record the information for later use (suc
h as during testing) | 4862 * information to a file, but can also record the information for later use (suc
h as during testing) |
4387 * or even ignore the information. | 4863 * or even ignore the information. |
| 4864 * |
4388 * @coverage dart.engine.utilities | 4865 * @coverage dart.engine.utilities |
4389 */ | 4866 */ |
4390 abstract class Logger { | 4867 abstract class Logger { |
4391 static final Logger NULL = new Logger_NullLogger(); | 4868 static final Logger NULL = new Logger_NullLogger(); |
4392 | 4869 |
4393 /** | 4870 /** |
4394 * Log the given message as an error. | 4871 * Log the given message as an error. |
| 4872 * |
4395 * @param message an explanation of why the error occurred or what it means | 4873 * @param message an explanation of why the error occurred or what it means |
4396 */ | 4874 */ |
4397 void logError(String message); | 4875 void logError(String message); |
4398 | 4876 |
4399 /** | 4877 /** |
4400 * Log the given exception as one representing an error. | 4878 * Log the given exception as one representing an error. |
| 4879 * |
4401 * @param message an explanation of why the error occurred or what it means | 4880 * @param message an explanation of why the error occurred or what it means |
4402 * @param exception the exception being logged | 4881 * @param exception the exception being logged |
4403 */ | 4882 */ |
4404 void logError2(String message, Exception exception); | 4883 void logError2(String message, Exception exception); |
4405 | 4884 |
4406 /** | 4885 /** |
4407 * Log the given exception as one representing an error. | 4886 * Log the given exception as one representing an error. |
| 4887 * |
4408 * @param exception the exception being logged | 4888 * @param exception the exception being logged |
4409 */ | 4889 */ |
4410 void logError3(Exception exception); | 4890 void logError3(Exception exception); |
4411 | 4891 |
4412 /** | 4892 /** |
4413 * Log the given informational message. | 4893 * Log the given informational message. |
| 4894 * |
4414 * @param message an explanation of why the error occurred or what it means | 4895 * @param message an explanation of why the error occurred or what it means |
4415 * @param exception the exception being logged | 4896 * @param exception the exception being logged |
4416 */ | 4897 */ |
4417 void logInformation(String message); | 4898 void logInformation(String message); |
4418 | 4899 |
4419 /** | 4900 /** |
4420 * Log the given exception as one representing an informational message. | 4901 * Log the given exception as one representing an informational message. |
| 4902 * |
4421 * @param message an explanation of why the error occurred or what it means | 4903 * @param message an explanation of why the error occurred or what it means |
4422 * @param exception the exception being logged | 4904 * @param exception the exception being logged |
4423 */ | 4905 */ |
4424 void logInformation2(String message, Exception exception); | 4906 void logInformation2(String message, Exception exception); |
4425 } | 4907 } |
4426 /** | 4908 /** |
4427 * Implementation of [Logger] that does nothing. | 4909 * Implementation of [Logger] that does nothing. |
4428 */ | 4910 */ |
4429 class Logger_NullLogger implements Logger { | 4911 class Logger_NullLogger implements Logger { |
4430 void logError(String message) { | 4912 void logError(String message) { |
4431 } | 4913 } |
4432 void logError2(String message, Exception exception) { | 4914 void logError2(String message, Exception exception) { |
4433 } | 4915 } |
4434 void logError3(Exception exception) { | 4916 void logError3(Exception exception) { |
4435 } | 4917 } |
4436 void logInformation(String message) { | 4918 void logInformation(String message) { |
4437 } | 4919 } |
4438 void logInformation2(String message, Exception exception) { | 4920 void logInformation2(String message, Exception exception) { |
4439 } | 4921 } |
4440 } | 4922 } |
OLD | NEW |