| 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 {@code AnalysisEngine} serves as the entry p
oint for 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 * @coverage dart.engine | 20 * @coverage dart.engine |
| 21 */ | 21 */ |
| 22 class AnalysisEngine { | 22 class AnalysisEngine { |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * The suffix used for Dart source files. | 25 * The suffix used for Dart source files. |
| 26 */ | 26 */ |
| 27 static String SUFFIX_DART = "dart"; | 27 static String SUFFIX_DART = "dart"; |
| 28 | 28 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 41 */ | 41 */ |
| 42 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); | 42 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Return the unique instance of this class. | 45 * Return the unique instance of this class. |
| 46 * @return the unique instance of this class | 46 * @return the unique instance of this class |
| 47 */ | 47 */ |
| 48 static AnalysisEngine get instance => _UniqueInstance; | 48 static AnalysisEngine get instance => _UniqueInstance; |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Return {@code true} if the given file name is assumed to contain Dart sourc
e code. | 51 * Return `true` if the given file name is assumed to contain Dart source code
. |
| 52 * @param fileName the name of the file being tested | 52 * @param fileName the name of the file being tested |
| 53 * @return {@code true} if the given file name is assumed to contain Dart sour
ce code | 53 * @return `true` if the given file name is assumed to contain Dart source cod
e |
| 54 */ | 54 */ |
| 55 static bool isDartFileName(String fileName) { | 55 static bool isDartFileName(String fileName) { |
| 56 if (fileName == null) { | 56 if (fileName == null) { |
| 57 return false; | 57 return false; |
| 58 } | 58 } |
| 59 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName),
SUFFIX_DART); | 59 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName),
SUFFIX_DART); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Return {@code true} if the given file name is assumed to contain HTML. | 63 * Return `true` if the given file name is assumed to contain HTML. |
| 64 * @param fileName the name of the file being tested | 64 * @param fileName the name of the file being tested |
| 65 * @return {@code true} if the given file name is assumed to contain HTML | 65 * @return `true` if the given file name is assumed to contain HTML |
| 66 */ | 66 */ |
| 67 static bool isHtmlFileName(String fileName) { | 67 static bool isHtmlFileName(String fileName) { |
| 68 if (fileName == null) { | 68 if (fileName == null) { |
| 69 return false; | 69 return false; |
| 70 } | 70 } |
| 71 String extension = FileNameUtilities.getExtension(fileName); | 71 String extension = FileNameUtilities.getExtension(fileName); |
| 72 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual
sIgnoreCase(extension, SUFFIX_HTM); | 72 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual
sIgnoreCase(extension, SUFFIX_HTM); |
| 73 } | 73 } |
| 74 | 74 |
| 75 /** | 75 /** |
| (...skipping 23 matching lines...) Expand all Loading... |
| 99 * Set the logger that should receive information about errors within the anal
ysis engine to the | 99 * Set the logger that should receive information about errors within the anal
ysis engine to the |
| 100 * given logger. | 100 * given logger. |
| 101 * @param logger the logger that should receive information about errors withi
n the analysis | 101 * @param logger the logger that should receive information about errors withi
n the analysis |
| 102 * engine | 102 * engine |
| 103 */ | 103 */ |
| 104 void set logger(Logger logger2) { | 104 void set logger(Logger logger2) { |
| 105 this._logger = logger2 == null ? Logger.NULL : logger2; | 105 this._logger = logger2 == null ? Logger.NULL : logger2; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 /** | 108 /** |
| 109 * The interface {@code AnalysisContext} defines the behavior of objects that re
present a context in | 109 * 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 | 110 * 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 | 111 * 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 {@l
ink SourceFactorysource factory}.) | 112 * resolve 'package:' URI's. (Both of which are known indirectly through the [So
urceFactorysource factory].) |
| 113 * <p> | 113 * |
| 114 * An analysis context also represents the state of the analysis, which includes
knowing which | 114 * An analysis context also represents the state of the analysis, which includes
knowing which |
| 115 * sources have been included in the analysis (either directly or indirectly) an
d the results of the | 115 * sources have been included in the analysis (either directly or indirectly) an
d the results of the |
| 116 * analysis. Sources must be added and removed from the context using the method
{@link #applyChanges(ChangeSet)}, which is also used to notify the context when
sources have been | 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 |
| 117 * modified and, consequently, previously known results might have been invalida
ted. | 117 * modified and, consequently, previously known results might have been invalida
ted. |
| 118 * <p> | 118 * |
| 119 * There are two ways to access the results of the analysis. The most common is
to use one of the | 119 * 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 | 120 * '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 | 121 * 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 | 122 * 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 | 123 * 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. | 124 * compute the requested results but might block the caller for a significant pe
riod of time. |
| 125 * <p> | 125 * |
| 126 * When results have been invalidated, have never been computed (as is the case
for newly added | 126 * 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 | 127 * 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. | 128 * will only be recreated if one of the 'compute' methods is invoked. |
| 129 * <p> | 129 * |
| 130 * However, this is not always acceptable. Some clients need to keep the analysi
s results | 130 * 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 | 131 * 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 | 132 * needed analysis and get notified of the consequent changes to the analysis re
sults. This |
| 133 * mechanism is realized by the method {@link #performAnalysisTask()}. | 133 * mechanism is realized by the method [performAnalysisTask]. |
| 134 * <p> | 134 * |
| 135 * Analysis engine allows for having more than one context. This can be used, fo
r example, to | 135 * Analysis engine allows for having more than one context. This can be used, fo
r example, to |
| 136 * perform one analysis based on the state of files on disk and a separate analy
sis based on the | 136 * perform one analysis based on the state of files on disk and a separate analy
sis based on the |
| 137 * state of those files in open editors. It can also be used to perform an analy
sis based on a | 137 * state of those files in open editors. It can also be used to perform an analy
sis based on a |
| 138 * proposed future state, such as the state after a refactoring. | 138 * proposed future state, such as the state after a refactoring. |
| 139 */ | 139 */ |
| 140 abstract class AnalysisContext { | 140 abstract class AnalysisContext { |
| 141 | 141 |
| 142 /** | 142 /** |
| 143 * Apply the changes specified by the given change set to this context. Any an
alysis results that | 143 * Apply the changes specified by the given change set to this context. Any an
alysis results that |
| 144 * have been invalidated by these changes will be removed. | 144 * have been invalidated by these changes will be removed. |
| 145 * @param changeSet a description of the changes that are to be applied | 145 * @param changeSet a description of the changes that are to be applied |
| 146 */ | 146 */ |
| 147 void applyChanges(ChangeSet changeSet); | 147 void applyChanges(ChangeSet changeSet); |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Return the documentation comment for the given element as it appears in the
original source | 150 * Return the documentation comment for the given element as it appears in the
original source |
| 151 * (complete with the beginning and ending delimiters), or {@code null} if the
element does not | 151 * (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 | 152 * 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. | 153 * information needed to access the comment is not cached. |
| 154 * @param element the element whose documentation comment is to be returned | 154 * @param element the element whose documentation comment is to be returned |
| 155 * @return the element's documentation comment | 155 * @return the element's documentation comment |
| 156 * @throws AnalysisException if the documentation comment could not be determi
ned because the | 156 * @throws AnalysisException if the documentation comment could not be determi
ned because the |
| 157 * analysis could not be performed | 157 * analysis could not be performed |
| 158 */ | 158 */ |
| 159 String computeDocumentationComment(Element element); | 159 String computeDocumentationComment(Element element); |
| 160 | 160 |
| 161 /** | 161 /** |
| (...skipping 16 matching lines...) Expand all Loading... |
| 178 * them. | 178 * them. |
| 179 * @param source the source defining the HTML file whose element model is to b
e returned | 179 * @param source the source defining the HTML file whose element model is to b
e returned |
| 180 * @return the element model corresponding to the HTML file defined by the giv
en source | 180 * @return the element model corresponding to the HTML file defined by the giv
en source |
| 181 * @throws AnalysisException if the element model could not be determined beca
use the analysis | 181 * @throws AnalysisException if the element model could not be determined beca
use the analysis |
| 182 * could not be performed | 182 * could not be performed |
| 183 * @see #getHtmlElement(Source) | 183 * @see #getHtmlElement(Source) |
| 184 */ | 184 */ |
| 185 HtmlElement computeHtmlElement(Source source); | 185 HtmlElement computeHtmlElement(Source source); |
| 186 | 186 |
| 187 /** | 187 /** |
| 188 * Return the kind of the given source, computing it's kind if it is not alrea
dy known. Return{@link SourceKind#UNKNOWN} if the source is not contained in thi
s context. | 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. |
| 189 * @param source the source whose kind is to be returned | 189 * @param source the source whose kind is to be returned |
| 190 * @return the kind of the given source | 190 * @return the kind of the given source |
| 191 * @see #getKindOf(Source) | 191 * @see #getKindOf(Source) |
| 192 */ | 192 */ |
| 193 SourceKind computeKindOf(Source source); | 193 SourceKind computeKindOf(Source source); |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * Return the element model corresponding to the library defined by the given
source. If the | 196 * Return the element model corresponding to the library defined by the given
source. If the |
| 197 * element model does not yet exist it will be created. The process of creatin
g an element model | 197 * element model does not yet exist it will be created. The process of creatin
g an element model |
| 198 * for a library can long-running, depending on the size of the library and th
e number of | 198 * for a library can long-running, depending on the size of the library and th
e number of |
| 199 * libraries that are imported into it that also need to have a model built fo
r them. | 199 * libraries that are imported into it that also need to have a model built fo
r them. |
| 200 * @param source the source defining the library whose element model is to be
returned | 200 * @param source the source defining the library whose element model is to be
returned |
| 201 * @return the element model corresponding to the library defined by the given
source | 201 * @return the element model corresponding to the library defined by the given
source |
| 202 * @throws AnalysisException if the element model could not be determined beca
use the analysis | 202 * @throws AnalysisException if the element model could not be determined beca
use the analysis |
| 203 * could not be performed | 203 * could not be performed |
| 204 * @see #getLibraryElement(Source) | 204 * @see #getLibraryElement(Source) |
| 205 */ | 205 */ |
| 206 LibraryElement computeLibraryElement(Source source); | 206 LibraryElement computeLibraryElement(Source source); |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * Return the line information for the given source, or {@code null} if the so
urce is not of a | 209 * Return the line information for the given source, or `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 | 210 * 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 | 211 * 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. | 212 * source to line and column pairs. |
| 213 * @param source the source whose line information is to be returned | 213 * @param source the source whose line information is to be returned |
| 214 * @return the line information for the given source | 214 * @return the line information for the given source |
| 215 * @throws AnalysisException if the line information could not be determined b
ecause the analysis | 215 * @throws AnalysisException if the line information could not be determined b
ecause the analysis |
| 216 * could not be performed | 216 * could not be performed |
| 217 * @see #getLineInfo(Source) | 217 * @see #getLineInfo(Source) |
| 218 */ | 218 */ |
| 219 LineInfo computeLineInfo(Source source); | 219 LineInfo computeLineInfo(Source source); |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * Create a new context in which analysis can be performed. Any sources in the
specified container | 222 * Create a new context in which analysis can be performed. Any sources in the
specified container |
| 223 * will be removed from this context and added to the newly created context. | 223 * will be removed from this context and added to the newly created context. |
| 224 * @param container the container containing sources that should be removed fr
om this context and | 224 * @param container the container containing sources that should be removed fr
om this context and |
| 225 * added to the returned context | 225 * added to the returned context |
| 226 * @return the analysis context that was created | 226 * @return the analysis context that was created |
| 227 */ | 227 */ |
| 228 AnalysisContext extractContext(SourceContainer container); | 228 AnalysisContext extractContext(SourceContainer container); |
| 229 | 229 |
| 230 /** | 230 /** |
| 231 * Return the set of analysis options controlling the behavior of this context
. | 231 * Return the set of analysis options controlling the behavior of this context
. |
| 232 * @return the set of analysis options controlling the behavior of this contex
t | 232 * @return the set of analysis options controlling the behavior of this contex
t |
| 233 */ | 233 */ |
| 234 AnalysisOptions get analysisOptions; | 234 AnalysisOptions get analysisOptions; |
| 235 | 235 |
| 236 /** | 236 /** |
| 237 * Return the element referenced by the given location, or {@code null} if the
element is not | 237 * Return the element referenced by the given location, or `null` if the eleme
nt is not |
| 238 * immediately available or if there is no element with the given location. Th
e latter condition | 238 * immediately available or if there is no element with the given location. Th
e latter condition |
| 239 * can occur, for example, if the location describes an element from a differe
nt context or if the | 239 * can occur, for example, if the location describes an element from a differe
nt context or if the |
| 240 * element has been removed from this context as a result of some change since
it was originally | 240 * element has been removed from this context as a result of some change since
it was originally |
| 241 * obtained. | 241 * obtained. |
| 242 * @param location the reference describing the element to be returned | 242 * @param location the reference describing the element to be returned |
| 243 * @return the element referenced by the given location | 243 * @return the element referenced by the given location |
| 244 */ | 244 */ |
| 245 Element getElement(ElementLocation location); | 245 Element getElement(ElementLocation location); |
| 246 | 246 |
| 247 /** | 247 /** |
| 248 * Return an analysis error info containing the array of all of the errors and
the line info | 248 * Return an analysis error info containing the array of all of the errors and
the line info |
| 249 * associated with the given source. The array of errors will be empty if the
source is not known | 249 * associated with the given source. The array of errors will be empty if the
source is not known |
| 250 * to this context or if there are no errors in the source. The errors contain
ed in the array can | 250 * to this context or if there are no errors in the source. The errors contain
ed in the array can |
| 251 * be incomplete. | 251 * be incomplete. |
| 252 * @param source the source whose errors are to be returned | 252 * @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 | 253 * @return all of the errors associated with the given source and the line inf
o |
| 254 * @see #computeErrors(Source) | 254 * @see #computeErrors(Source) |
| 255 */ | 255 */ |
| 256 AnalysisErrorInfo getErrors(Source source); | 256 AnalysisErrorInfo getErrors(Source source); |
| 257 | 257 |
| 258 /** | 258 /** |
| 259 * Return the element model corresponding to the HTML file defined by the give
n source, or{@code null} if the source does not represent an HTML file, the elem
ent representing the file | 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 |
| 260 * has not yet been created, or the analysis of the HTML file failed for some
reason. | 260 * has not yet been created, or the analysis of the HTML file failed for some
reason. |
| 261 * @param source the source defining the HTML file whose element model is to b
e returned | 261 * @param source the source defining the HTML file whose element model is to b
e returned |
| 262 * @return the element model corresponding to the HTML file defined by the giv
en source | 262 * @return the element model corresponding to the HTML file defined by the giv
en source |
| 263 * @see #computeHtmlElement(Source) | 263 * @see #computeHtmlElement(Source) |
| 264 */ | 264 */ |
| 265 HtmlElement getHtmlElement(Source source); | 265 HtmlElement getHtmlElement(Source source); |
| 266 | 266 |
| 267 /** | 267 /** |
| 268 * Return the sources for the HTML files that reference the given compilation
unit. If the source | 268 * Return the sources for the HTML files that reference the given compilation
unit. If the source |
| 269 * does not represent a Dart source or is not known to this context, the retur
ned array will be | 269 * does not represent a Dart source or is not known to this context, the retur
ned array will be |
| 270 * empty. The contents of the array can be incomplete. | 270 * empty. The contents of the array can be incomplete. |
| 271 * @param source the source referenced by the returned HTML files | 271 * @param source the source referenced by the returned HTML files |
| 272 * @return the sources for the HTML files that reference the given compilation
unit | 272 * @return the sources for the HTML files that reference the given compilation
unit |
| 273 */ | 273 */ |
| 274 List<Source> getHtmlFilesReferencing(Source source); | 274 List<Source> getHtmlFilesReferencing(Source source); |
| 275 | 275 |
| 276 /** | 276 /** |
| 277 * Return an array containing all of the sources known to this context that re
present HTML files. | 277 * Return an array containing all of the sources known to this context that re
present HTML files. |
| 278 * The contents of the array can be incomplete. | 278 * The contents of the array can be incomplete. |
| 279 * @return the sources known to this context that represent HTML files | 279 * @return the sources known to this context that represent HTML files |
| 280 */ | 280 */ |
| 281 List<Source> get htmlSources; | 281 List<Source> get htmlSources; |
| 282 | 282 |
| 283 /** | 283 /** |
| 284 * Return the kind of the given source, or {@code null} if the kind is not kno
wn to this context. | 284 * Return the kind of the given source, or `null` if the kind is not known to
this context. |
| 285 * @param source the source whose kind is to be returned | 285 * @param source the source whose kind is to be returned |
| 286 * @return the kind of the given source | 286 * @return the kind of the given source |
| 287 * @see #computeKindOf(Source) | 287 * @see #computeKindOf(Source) |
| 288 */ | 288 */ |
| 289 SourceKind getKindOf(Source source); | 289 SourceKind getKindOf(Source source); |
| 290 | 290 |
| 291 /** | 291 /** |
| 292 * Return an array containing all of the sources known to this context that re
present the defining | 292 * Return an array containing all of the sources known to this context that re
present the defining |
| 293 * compilation unit of a library that can be run within a browser. The sources
that are returned | 293 * compilation unit of a library that can be run within a browser. The sources
that are returned |
| 294 * represent libraries that have a 'main' method and are either referenced by
an HTML file or | 294 * represent libraries that have a 'main' method and are either referenced by
an HTML file or |
| (...skipping 29 matching lines...) Expand all Loading... |
| 324 /** | 324 /** |
| 325 * Return the sources for the defining compilation units of any libraries that
depend on the given | 325 * Return the sources for the defining compilation units of any libraries that
depend on the given |
| 326 * library. One library depends on another if it either imports or exports tha
t library. | 326 * library. One library depends on another if it either imports or exports tha
t library. |
| 327 * @param librarySource the source for the defining compilation unit of the li
brary being depended | 327 * @param librarySource the source for the defining compilation unit of the li
brary being depended |
| 328 * on | 328 * on |
| 329 * @return the sources for the libraries that depend on the given library | 329 * @return the sources for the libraries that depend on the given library |
| 330 */ | 330 */ |
| 331 List<Source> getLibrariesDependingOn(Source librarySource); | 331 List<Source> getLibrariesDependingOn(Source librarySource); |
| 332 | 332 |
| 333 /** | 333 /** |
| 334 * Return the element model corresponding to the library defined by the given
source, or{@code null} if the element model does not currently exist or if the l
ibrary cannot be analyzed | 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 |
| 335 * for some reason. | 335 * for some reason. |
| 336 * @param source the source defining the library whose element model is to be
returned | 336 * @param source the source defining the library whose element model is to be
returned |
| 337 * @return the element model corresponding to the library defined by the given
source | 337 * @return the element model corresponding to the library defined by the given
source |
| 338 */ | 338 */ |
| 339 LibraryElement getLibraryElement(Source source); | 339 LibraryElement getLibraryElement(Source source); |
| 340 | 340 |
| 341 /** | 341 /** |
| 342 * Return an array containing all of the sources known to this context that re
present the defining | 342 * Return an array containing all of the sources known to this context that re
present the defining |
| 343 * compilation unit of a library. The contents of the array can be incomplete. | 343 * compilation unit of a library. The contents of the array can be incomplete. |
| 344 * @return the sources known to this context that represent the defining compi
lation unit of a | 344 * @return the sources known to this context that represent the defining compi
lation unit of a |
| 345 * library | 345 * library |
| 346 */ | 346 */ |
| 347 List<Source> get librarySources; | 347 List<Source> get librarySources; |
| 348 | 348 |
| 349 /** | 349 /** |
| 350 * Return the line information for the given source, or {@code null} if the li
ne information is | 350 * Return the line information for the given source, or `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 | 351 * not known. The line information is used to map offsets from the beginning o
f the source to line |
| 352 * and column pairs. | 352 * and column pairs. |
| 353 * @param source the source whose line information is to be returned | 353 * @param source the source whose line information is to be returned |
| 354 * @return the line information for the given source | 354 * @return the line information for the given source |
| 355 * @see #computeLineInfo(Source) | 355 * @see #computeLineInfo(Source) |
| 356 */ | 356 */ |
| 357 LineInfo getLineInfo(Source source); | 357 LineInfo getLineInfo(Source source); |
| 358 | 358 |
| 359 /** | 359 /** |
| 360 * Return a fully resolved AST for a single compilation unit within the given
library, or{@code null} if the resolved AST is not already computed. | 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. |
| 361 * @param unitSource the source of the compilation unit | 361 * @param unitSource the source of the compilation unit |
| 362 * @param library the library containing the compilation unit | 362 * @param library the library containing the compilation unit |
| 363 * @return a fully resolved AST for the compilation unit | 363 * @return a fully resolved AST for the compilation unit |
| 364 * @see #resolveCompilationUnit(Source,LibraryElement) | 364 * @see #resolveCompilationUnit(Source,LibraryElement) |
| 365 */ | 365 */ |
| 366 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary); | 366 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary); |
| 367 | 367 |
| 368 /** | 368 /** |
| 369 * Return a fully resolved AST for a single compilation unit within the given
library, or{@code null} if the resolved AST is not already computed. | 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. |
| 370 * @param unitSource the source of the compilation unit | 370 * @param unitSource the source of the compilation unit |
| 371 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 371 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
| 372 * compilation unit | 372 * compilation unit |
| 373 * @return a fully resolved AST for the compilation unit | 373 * @return a fully resolved AST for the compilation unit |
| 374 * @see #resolveCompilationUnit(Source,Source) | 374 * @see #resolveCompilationUnit(Source,Source) |
| 375 */ | 375 */ |
| 376 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource); | 376 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource); |
| 377 | 377 |
| 378 /** | 378 /** |
| 379 * Return the source factory used to create the sources that can be analyzed i
n this context. | 379 * Return the source factory used to create the sources that can be analyzed i
n this context. |
| 380 * @return the source factory used to create the sources that can be analyzed
in this context | 380 * @return the source factory used to create the sources that can be analyzed
in this context |
| 381 */ | 381 */ |
| 382 SourceFactory get sourceFactory; | 382 SourceFactory get sourceFactory; |
| 383 | 383 |
| 384 /** | 384 /** |
| 385 * Return {@code true} if the given source is known to be the defining compila
tion unit of a | 385 * 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). | 386 * library that can be run on a client (references 'dart:html', either directl
y or indirectly). |
| 387 * <p> | 387 * |
| 388 * <b>Note:</b> In addition to the expected case of returning {@code false} if
the source is known | 388 * <b>Note:</b> In addition to the expected case of returning `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 {@code false} if | 389 * 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. | 390 * the source is not known to be a library or if we do not know whether it can
be run on a client. |
| 391 * @param librarySource the source being tested | 391 * @param librarySource the source being tested |
| 392 * @return {@code true} if the given source is known to be a library that can
be run on a client | 392 * @return `true` if the given source is known to be a library that can be run
on a client |
| 393 */ | 393 */ |
| 394 bool isClientLibrary(Source librarySource); | 394 bool isClientLibrary(Source librarySource); |
| 395 | 395 |
| 396 /** | 396 /** |
| 397 * Return {@code true} if the given source is known to be the defining compila
tion unit of a | 397 * 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 | 398 * library that can be run on the server (does not reference 'dart:html', eith
er directly or |
| 399 * indirectly). | 399 * indirectly). |
| 400 * <p> | 400 * |
| 401 * <b>Note:</b> In addition to the expected case of returning {@code false} if
the source is known | 401 * <b>Note:</b> In addition to the expected case of returning `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 {@code false} if | 402 * 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 | 403 * the source is not known to be a library or if we do not know whether it can
be run on the |
| 404 * server. | 404 * server. |
| 405 * @param librarySource the source being tested | 405 * @param librarySource the source being tested |
| 406 * @return {@code true} if the given source is known to be a library that can
be run on the server | 406 * @return `true` if the given source is known to be a library that can be run
on the server |
| 407 */ | 407 */ |
| 408 bool isServerLibrary(Source librarySource); | 408 bool isServerLibrary(Source librarySource); |
| 409 | 409 |
| 410 /** | 410 /** |
| 411 * Add the sources contained in the specified context to this context's collec
tion of sources. | 411 * Add the sources contained in the specified context to this context's collec
tion of sources. |
| 412 * This method is called when an existing context's pubspec has been removed,
and the contained | 412 * This method is called when an existing context's pubspec has been removed,
and the contained |
| 413 * sources should be reanalyzed as part of this context. | 413 * sources should be reanalyzed as part of this context. |
| 414 * @param context the context being merged | 414 * @param context the context being merged |
| 415 */ | 415 */ |
| 416 void mergeContext(AnalysisContext context); | 416 void mergeContext(AnalysisContext context); |
| 417 | 417 |
| 418 /** | 418 /** |
| 419 * Parse a single source to produce an AST structure. The resulting AST struct
ure may or may not | 419 * Parse a single source to produce an AST structure. The resulting AST struct
ure may or may not |
| 420 * be resolved, and may have a slightly different structure depending upon whe
ther it is resolved. | 420 * be resolved, and may have a slightly different structure depending upon whe
ther it is resolved. |
| 421 * @param source the source to be parsed | 421 * @param source the source to be parsed |
| 422 * @return the AST structure representing the content of the source | 422 * @return the AST structure representing the content of the source |
| 423 * @throws AnalysisException if the analysis could not be performed | 423 * @throws AnalysisException if the analysis could not be performed |
| 424 */ | 424 */ |
| 425 CompilationUnit parseCompilationUnit(Source source); | 425 CompilationUnit parseCompilationUnit(Source source); |
| 426 | 426 |
| 427 /** | 427 /** |
| 428 * Parse a single HTML source to produce an AST structure. The resulting HTML
AST structure may or | 428 * Parse a single HTML source to produce an AST structure. The resulting HTML
AST structure may or |
| 429 * may not be resolved, and may have a slightly different structure depending
upon whether it is | 429 * may not be resolved, and may have a slightly different structure depending
upon whether it is |
| 430 * resolved. | 430 * resolved. |
| 431 * @param source the HTML source to be parsed | 431 * @param source the HTML source to be parsed |
| 432 * @return the parse result (not {@code null}) | 432 * @return the parse result (not `null`) |
| 433 * @throws AnalysisException if the analysis could not be performed | 433 * @throws AnalysisException if the analysis could not be performed |
| 434 */ | 434 */ |
| 435 HtmlUnit parseHtmlUnit(Source source); | 435 HtmlUnit parseHtmlUnit(Source source); |
| 436 | 436 |
| 437 /** | 437 /** |
| 438 * Perform the next unit of work required to keep the analysis results up-to-d
ate and return | 438 * Perform the next unit of work required to keep the analysis results up-to-d
ate and return |
| 439 * information about the consequent changes to the analysis results. If there
were no results the | 439 * information about the consequent changes to the analysis results. If there
were no results the |
| 440 * returned array will be empty. If there are no more units of work required,
then this method | 440 * returned array will be empty. If there are no more units of work required,
then this method |
| 441 * returns {@code null}. This method can be long running. | 441 * returns `null`. This method can be long running. |
| 442 * @return an array containing notices of changes to the analysis results | 442 * @return an array containing notices of changes to the analysis results |
| 443 */ | 443 */ |
| 444 List<ChangeNotice> performAnalysisTask(); | 444 List<ChangeNotice> performAnalysisTask(); |
| 445 | 445 |
| 446 /** | 446 /** |
| 447 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 447 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
| 448 * @param unitSource the source to be parsed and resolved | 448 * @param unitSource the source to be parsed and resolved |
| 449 * @param library the library containing the source to be resolved | 449 * @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 | 450 * @return the result of resolving the AST structure representing the content
of the source in the |
| 451 * context of the given library | 451 * context of the given library |
| (...skipping 25 matching lines...) Expand all Loading... |
| 477 /** | 477 /** |
| 478 * Set the set of analysis options controlling the behavior of this context to
the given options. | 478 * Set the set of analysis options controlling the behavior of this context to
the given options. |
| 479 * Clients can safely assume that all necessary analysis results have been inv
alidated. | 479 * Clients can safely assume that all necessary analysis results have been inv
alidated. |
| 480 * @param options the set of analysis options that will control the behavior o
f this context | 480 * @param options the set of analysis options that will control the behavior o
f this context |
| 481 */ | 481 */ |
| 482 void set analysisOptions(AnalysisOptions options); | 482 void set analysisOptions(AnalysisOptions options); |
| 483 | 483 |
| 484 /** | 484 /** |
| 485 * Set the contents of the given source to the given contents and mark the sou
rce as having | 485 * Set the contents of the given source to the given contents and mark the sou
rce as having |
| 486 * changed. This has the effect of overriding the default contents of the sour
ce. If the contents | 486 * changed. This has the effect of overriding the default contents of the sour
ce. If the contents |
| 487 * are {@code null} the override is removed so that the default contents will
be returned. | 487 * are `null` the override is removed so that the default contents will be ret
urned. |
| 488 * @param source the source whose contents are being overridden | 488 * @param source the source whose contents are being overridden |
| 489 * @param contents the new contents of the source | 489 * @param contents the new contents of the source |
| 490 */ | 490 */ |
| 491 void setContents(Source source, String contents); | 491 void setContents(Source source, String contents); |
| 492 | 492 |
| 493 /** | 493 /** |
| 494 * Set the source factory used to create the sources that can be analyzed in t
his context to the | 494 * Set the source factory used to create the sources that can be analyzed in t
his context to the |
| 495 * given source factory. Clients can safely assume that all analysis results h
ave been | 495 * given source factory. Clients can safely assume that all analysis results h
ave been |
| 496 * invalidated. | 496 * invalidated. |
| 497 * @param factory the source factory used to create the sources that can be an
alyzed in this | 497 * @param factory the source factory used to create the sources that can be an
alyzed in this |
| 498 * context | 498 * context |
| 499 */ | 499 */ |
| 500 void set sourceFactory(SourceFactory factory); | 500 void set sourceFactory(SourceFactory factory); |
| 501 | 501 |
| 502 /** | 502 /** |
| 503 * Given a collection of sources with content that has changed, return an {@li
nk Iterable}identifying the sources that need to be resolved. | 503 * Given a collection of sources with content that has changed, return an [Ite
rable]identifying the sources that need to be resolved. |
| 504 * @param changedSources an array of sources (not {@code null}, contains no {@
code null}s) | 504 * @param changedSources an array of sources (not `null`, contains no `null`s) |
| 505 * @return An iterable returning the sources to be resolved | 505 * @return An iterable returning the sources to be resolved |
| 506 */ | 506 */ |
| 507 Iterable<Source> sourcesToResolve(List<Source> changedSources); | 507 Iterable<Source> sourcesToResolve(List<Source> changedSources); |
| 508 } | 508 } |
| 509 /** | 509 /** |
| 510 * The interface {@code AnalysisErrorInfo} contains the analysis errors and line
information for the | 510 * The interface `AnalysisErrorInfo` contains the analysis errors and line infor
mation for the |
| 511 * errors. | 511 * errors. |
| 512 */ | 512 */ |
| 513 abstract class AnalysisErrorInfo { | 513 abstract class AnalysisErrorInfo { |
| 514 | 514 |
| 515 /** | 515 /** |
| 516 * Return the errors that as a result of the analysis, or {@code null} if ther
e were no errors. | 516 * Return the errors that as a result of the analysis, or `null` if there were
no errors. |
| 517 * @return the errors as a result of the analysis | 517 * @return the errors as a result of the analysis |
| 518 */ | 518 */ |
| 519 List<AnalysisError> get errors; | 519 List<AnalysisError> get errors; |
| 520 | 520 |
| 521 /** | 521 /** |
| 522 * Return the line information associated with the errors, or {@code null} if
there were no | 522 * Return the line information associated with the errors, or `null` if there
were no |
| 523 * errors. | 523 * errors. |
| 524 * @return the line information associated with the errors | 524 * @return the line information associated with the errors |
| 525 */ | 525 */ |
| 526 LineInfo get lineInfo; | 526 LineInfo get lineInfo; |
| 527 } | 527 } |
| 528 /** | 528 /** |
| 529 * Instances of the class {@code AnalysisException} represent an exception that
occurred during the | 529 * Instances of the class `AnalysisException` represent an exception that occurr
ed during the |
| 530 * analysis of one or more sources. | 530 * analysis of one or more sources. |
| 531 * @coverage dart.engine | 531 * @coverage dart.engine |
| 532 */ | 532 */ |
| 533 class AnalysisException extends JavaException { | 533 class AnalysisException extends JavaException { |
| 534 | 534 |
| 535 /** | 535 /** |
| 536 * Initialize a newly created exception. | 536 * Initialize a newly created exception. |
| 537 */ | 537 */ |
| 538 AnalysisException() : super() { | 538 AnalysisException() : super() { |
| 539 _jtd_constructor_125_impl(); | 539 _jtd_constructor_125_impl(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 566 * Initialize a newly created exception to have the given cause. | 566 * Initialize a newly created exception to have the given cause. |
| 567 * @param cause the underlying exception that caused this exception | 567 * @param cause the underlying exception that caused this exception |
| 568 */ | 568 */ |
| 569 AnalysisException.con3(Exception cause) : super.withCause(cause) { | 569 AnalysisException.con3(Exception cause) : super.withCause(cause) { |
| 570 _jtd_constructor_128_impl(cause); | 570 _jtd_constructor_128_impl(cause); |
| 571 } | 571 } |
| 572 _jtd_constructor_128_impl(Exception cause) { | 572 _jtd_constructor_128_impl(Exception cause) { |
| 573 } | 573 } |
| 574 } | 574 } |
| 575 /** | 575 /** |
| 576 * The interface {@code AnalysisOptions} defines the behavior of objects that pr
ovide access to a | 576 * 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. | 577 * set of analysis options used to control the behavior of an analysis context. |
| 578 */ | 578 */ |
| 579 abstract class AnalysisOptions { | 579 abstract class AnalysisOptions { |
| 580 | 580 |
| 581 /** | 581 /** |
| 582 * Return {@code true} if analysis is to use strict mode. In strict mode, erro
r reporting is based | 582 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based |
| 583 * exclusively on the static type information. | 583 * exclusively on the static type information. |
| 584 * @return {@code true} if analysis is to use strict mode | 584 * @return `true` if analysis is to use strict mode |
| 585 */ | 585 */ |
| 586 bool get strictMode; | 586 bool get strictMode; |
| 587 } | 587 } |
| 588 /** | 588 /** |
| 589 * The interface {@code ChangeNotice} defines the behavior of objects that repre
sent a change to the | 589 * The interface `ChangeNotice` defines the behavior of objects that represent a
change to the |
| 590 * analysis results associated with a given source. | 590 * analysis results associated with a given source. |
| 591 * @coverage dart.engine | 591 * @coverage dart.engine |
| 592 */ | 592 */ |
| 593 abstract class ChangeNotice implements AnalysisErrorInfo { | 593 abstract class ChangeNotice implements AnalysisErrorInfo { |
| 594 | 594 |
| 595 /** | 595 /** |
| 596 * Return the fully resolved AST that changed as a result of the analysis, or
{@code null} if the | 596 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the |
| 597 * AST was not changed. | 597 * AST was not changed. |
| 598 * @return the fully resolved AST that changed as a result of the analysis | 598 * @return the fully resolved AST that changed as a result of the analysis |
| 599 */ | 599 */ |
| 600 CompilationUnit get compilationUnit; | 600 CompilationUnit get compilationUnit; |
| 601 | 601 |
| 602 /** | 602 /** |
| 603 * Return the source for which the result is being reported. | 603 * Return the source for which the result is being reported. |
| 604 * @return the source for which the result is being reported | 604 * @return the source for which the result is being reported |
| 605 */ | 605 */ |
| 606 Source get source; | 606 Source get source; |
| 607 } | 607 } |
| 608 /** | 608 /** |
| 609 * Instances of the class {@code ChangeSet} indicate what sources have been adde
d, changed, or | 609 * Instances of the class `ChangeSet` indicate what sources have been added, cha
nged, or |
| 610 * removed. | 610 * removed. |
| 611 * @coverage dart.engine | 611 * @coverage dart.engine |
| 612 */ | 612 */ |
| 613 class ChangeSet { | 613 class ChangeSet { |
| 614 | 614 |
| 615 /** | 615 /** |
| 616 * A list containing the sources that have been added. | 616 * A list containing the sources that have been added. |
| 617 */ | 617 */ |
| 618 List<Source> _added2 = new List<Source>(); | 618 List<Source> _added2 = new List<Source>(); |
| 619 | 619 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 */ | 668 */ |
| 669 List<Source> get removed => _removed2; | 669 List<Source> get removed => _removed2; |
| 670 | 670 |
| 671 /** | 671 /** |
| 672 * Return a list containing the source containers that were removed. | 672 * Return a list containing the source containers that were removed. |
| 673 * @return a list containing the source containers that were removed | 673 * @return a list containing the source containers that were removed |
| 674 */ | 674 */ |
| 675 List<SourceContainer> get removedContainers => _removedContainers; | 675 List<SourceContainer> get removedContainers => _removedContainers; |
| 676 | 676 |
| 677 /** | 677 /** |
| 678 * Return {@code true} if this change set does not contain any changes. | 678 * Return `true` if this change set does not contain any changes. |
| 679 * @return {@code true} if this change set does not contain any changes | 679 * @return `true` if this change set does not contain any changes |
| 680 */ | 680 */ |
| 681 bool isEmpty() => _added2.isEmpty && _changed2.isEmpty && _removed2.isEmpty &&
_removedContainers.isEmpty; | 681 bool isEmpty() => _added2.isEmpty && _changed2.isEmpty && _removed2.isEmpty &&
_removedContainers.isEmpty; |
| 682 | 682 |
| 683 /** | 683 /** |
| 684 * Record that the specified source has been removed. | 684 * Record that the specified source has been removed. |
| 685 * @param source the source that was removed | 685 * @param source the source that was removed |
| 686 */ | 686 */ |
| 687 void removed3(Source source) { | 687 void removed3(Source source) { |
| 688 if (source != null) { | 688 if (source != null) { |
| 689 _removed2.add(source); | 689 _removed2.add(source); |
| 690 } | 690 } |
| 691 } | 691 } |
| 692 | 692 |
| 693 /** | 693 /** |
| 694 * Record that the specified source container has been removed. | 694 * Record that the specified source container has been removed. |
| 695 * @param container the source container that was removed | 695 * @param container the source container that was removed |
| 696 */ | 696 */ |
| 697 void removedContainer(SourceContainer container) { | 697 void removedContainer(SourceContainer container) { |
| 698 if (container != null) { | 698 if (container != null) { |
| 699 _removedContainers.add(container); | 699 _removedContainers.add(container); |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 /** | 703 /** |
| 704 * The interface {@code DartEntry} defines the behavior of objects that maintain
the information | 704 * The interface `DartEntry` defines the behavior of objects that maintain the i
nformation |
| 705 * cached by an analysis context about an individual Dart file. | 705 * cached by an analysis context about an individual Dart file. |
| 706 * @coverage dart.engine | 706 * @coverage dart.engine |
| 707 */ | 707 */ |
| 708 abstract class DartEntry implements SourceEntry { | 708 abstract class DartEntry implements SourceEntry { |
| 709 | 709 |
| 710 /** | 710 /** |
| 711 * The data descriptor representing the library element for the library. This
data is only | 711 * The data descriptor representing the library element for the library. This
data is only |
| 712 * available for Dart files that are the defining compilation unit of a librar
y. | 712 * available for Dart files that are the defining compilation unit of a librar
y. |
| 713 */ | 713 */ |
| 714 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra
ryElement>("DartEntry.ELEMENT"); | 714 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra
ryElement>("DartEntry.ELEMENT"); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 static final DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<Sourc
eKind>("DartEntry.SOURCE_KIND"); | 769 static final DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<Sourc
eKind>("DartEntry.SOURCE_KIND"); |
| 770 | 770 |
| 771 /** | 771 /** |
| 772 * Return all of the errors associated with the compilation unit that are curr
ently cached. | 772 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 773 * @return all of the errors associated with the compilation unit | 773 * @return all of the errors associated with the compilation unit |
| 774 */ | 774 */ |
| 775 List<AnalysisError> get allErrors; | 775 List<AnalysisError> get allErrors; |
| 776 | 776 |
| 777 /** | 777 /** |
| 778 * Return a valid parsed compilation unit, either an unresolved AST structure
or the result of | 778 * Return a valid parsed compilation unit, either an unresolved AST structure
or the result of |
| 779 * resolving the AST structure in the context of some library, or {@code null}
if there is no | 779 * resolving the AST structure in the context of some library, or `null` if th
ere is no |
| 780 * parsed compilation unit available. | 780 * parsed compilation unit available. |
| 781 * @return a valid parsed compilation unit | 781 * @return a valid parsed compilation unit |
| 782 */ | 782 */ |
| 783 CompilationUnit get anyParsedCompilationUnit; | 783 CompilationUnit get anyParsedCompilationUnit; |
| 784 | 784 |
| 785 /** | 785 /** |
| 786 * Return the result of resolving the compilation unit as part of any library,
or {@code null} if | 786 * Return the result of resolving the compilation unit as part of any library,
or `null` if |
| 787 * there is no cached resolved compilation unit. | 787 * there is no cached resolved compilation unit. |
| 788 * @return any resolved compilation unit | 788 * @return any resolved compilation unit |
| 789 */ | 789 */ |
| 790 CompilationUnit get anyResolvedCompilationUnit; | 790 CompilationUnit get anyResolvedCompilationUnit; |
| 791 | 791 |
| 792 /** | 792 /** |
| 793 * Return the state of the data represented by the given descriptor in the con
text of the given | 793 * Return the state of the data represented by the given descriptor in the con
text of the given |
| 794 * library. | 794 * library. |
| 795 * @param descriptor the descriptor representing the data whose state is to be
returned | 795 * @param descriptor the descriptor representing the data whose state is to be
returned |
| 796 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 796 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 797 * context for the data | 797 * context for the data |
| 798 * @return the value of the data represented by the given descriptor and libra
ry | 798 * @return the value of the data represented by the given descriptor and libra
ry |
| 799 */ | 799 */ |
| 800 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource); | 800 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource); |
| 801 | 801 |
| 802 /** | 802 /** |
| 803 * Return the value of the data represented by the given descriptor in the con
text of the given | 803 * Return the value of the data represented by the given descriptor in the con
text of the given |
| 804 * library, or {@code null} if the data represented by the descriptor is not i
n the cache. | 804 * library, or `null` if the data represented by the descriptor is not in the
cache. |
| 805 * @param descriptor the descriptor representing which data is to be returned | 805 * @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 | 806 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 807 * context for the data | 807 * context for the data |
| 808 * @return the value of the data represented by the given descriptor and libra
ry | 808 * @return the value of the data represented by the given descriptor and libra
ry |
| 809 */ | 809 */ |
| 810 Object getValue2(DataDescriptor descriptor, Source librarySource); | 810 Object getValue2(DataDescriptor descriptor, Source librarySource); |
| 811 DartEntryImpl get writableCopy; | 811 DartEntryImpl get writableCopy; |
| 812 } | 812 } |
| 813 /** | 813 /** |
| 814 * Instances of the class {@code DartEntryImpl} implement a {@link DartEntry}. | 814 * Instances of the class `DartEntryImpl` implement a [DartEntry]. |
| 815 * @coverage dart.engine | 815 * @coverage dart.engine |
| 816 */ | 816 */ |
| 817 class DartEntryImpl extends SourceEntryImpl implements DartEntry { | 817 class DartEntryImpl extends SourceEntryImpl implements DartEntry { |
| 818 | 818 |
| 819 /** | 819 /** |
| 820 * The state of the cached source kind. | 820 * The state of the cached source kind. |
| 821 */ | 821 */ |
| 822 CacheState _sourceKindState = CacheState.INVALID; | 822 CacheState _sourceKindState = CacheState.INVALID; |
| 823 | 823 |
| 824 /** | 824 /** |
| 825 * The kind of this source. | 825 * The kind of this source. |
| 826 */ | 826 */ |
| 827 SourceKind _sourceKind = SourceKind.UNKNOWN; | 827 SourceKind _sourceKind = SourceKind.UNKNOWN; |
| 828 | 828 |
| 829 /** | 829 /** |
| 830 * The state of the cached parsed compilation unit. | 830 * The state of the cached parsed compilation unit. |
| 831 */ | 831 */ |
| 832 CacheState _parsedUnitState = CacheState.INVALID; | 832 CacheState _parsedUnitState = CacheState.INVALID; |
| 833 | 833 |
| 834 /** | 834 /** |
| 835 * The parsed compilation unit, or {@code null} if the parsed compilation unit
is not currently | 835 * The parsed compilation unit, or `null` if the parsed compilation unit is no
t currently |
| 836 * cached. | 836 * cached. |
| 837 */ | 837 */ |
| 838 CompilationUnit _parsedUnit; | 838 CompilationUnit _parsedUnit; |
| 839 | 839 |
| 840 /** | 840 /** |
| 841 * The state of the cached parse errors. | 841 * The state of the cached parse errors. |
| 842 */ | 842 */ |
| 843 CacheState _parseErrorsState = CacheState.INVALID; | 843 CacheState _parseErrorsState = CacheState.INVALID; |
| 844 | 844 |
| 845 /** | 845 /** |
| 846 * The errors produced while scanning and parsing the compilation unit, or {@c
ode null} if the | 846 * The errors produced while scanning and parsing the compilation unit, or `nu
ll` if the |
| 847 * errors are not currently cached. | 847 * errors are not currently cached. |
| 848 */ | 848 */ |
| 849 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; | 849 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; |
| 850 | 850 |
| 851 /** | 851 /** |
| 852 * The state of the cached list of included parts. | 852 * The state of the cached list of included parts. |
| 853 */ | 853 */ |
| 854 CacheState _includedPartsState = CacheState.INVALID; | 854 CacheState _includedPartsState = CacheState.INVALID; |
| 855 | 855 |
| 856 /** | 856 /** |
| 857 * The list of parts included in the library, or an empty array if the list is
not currently | 857 * The list of parts included in the library, or an empty array if the list is
not currently |
| 858 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. | 858 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. |
| 859 */ | 859 */ |
| 860 List<Source> _includedParts = Source.EMPTY_ARRAY; | 860 List<Source> _includedParts = Source.EMPTY_ARRAY; |
| 861 | 861 |
| 862 /** | 862 /** |
| 863 * The state of the cached list of referenced libraries. | 863 * The state of the cached list of referenced libraries. |
| 864 */ | 864 */ |
| 865 CacheState _referencedLibrariesState = CacheState.INVALID; | 865 CacheState _referencedLibrariesState = CacheState.INVALID; |
| 866 | 866 |
| 867 /** | 867 /** |
| 868 * The list of libraries referenced (imported or exported) by the library, or
an empty array if | 868 * The list of libraries referenced (imported or exported) by the library, or
an empty array if |
| 869 * the list is not currently cached. The list will be empty if the Dart file i
s a part rather than | 869 * the list is not currently cached. The list will be empty if the Dart file i
s a part rather than |
| 870 * a library. | 870 * a library. |
| 871 */ | 871 */ |
| 872 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; | 872 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; |
| 873 | 873 |
| 874 /** | 874 /** |
| 875 * The information known as a result of resolving this compilation unit as par
t of the library | 875 * The information known as a result of resolving this compilation unit as par
t of the library |
| 876 * that contains this unit. This field will never be {@code null}. | 876 * that contains this unit. This field will never be `null`. |
| 877 */ | 877 */ |
| 878 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); | 878 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); |
| 879 | 879 |
| 880 /** | 880 /** |
| 881 * The state of the cached library element. | 881 * The state of the cached library element. |
| 882 */ | 882 */ |
| 883 CacheState _elementState = CacheState.INVALID; | 883 CacheState _elementState = CacheState.INVALID; |
| 884 | 884 |
| 885 /** | 885 /** |
| 886 * The element representing the library, or {@code null} if the element is not
currently cached. | 886 * The element representing the library, or `null` if the element is not curre
ntly cached. |
| 887 */ | 887 */ |
| 888 LibraryElement _element; | 888 LibraryElement _element; |
| 889 | 889 |
| 890 /** | 890 /** |
| 891 * The state of the cached public namespace. | 891 * The state of the cached public namespace. |
| 892 */ | 892 */ |
| 893 CacheState _publicNamespaceState = CacheState.INVALID; | 893 CacheState _publicNamespaceState = CacheState.INVALID; |
| 894 | 894 |
| 895 /** | 895 /** |
| 896 * The public namespace of the library, or {@code null} if the namespace is no
t currently cached. | 896 * The public namespace of the library, or `null` if the namespace is not curr
ently cached. |
| 897 */ | 897 */ |
| 898 Namespace _publicNamespace; | 898 Namespace _publicNamespace; |
| 899 | 899 |
| 900 /** | 900 /** |
| 901 * The state of the cached client/ server flag. | 901 * The state of the cached client/ server flag. |
| 902 */ | 902 */ |
| 903 CacheState _clientServerState = CacheState.INVALID; | 903 CacheState _clientServerState = CacheState.INVALID; |
| 904 | 904 |
| 905 /** | 905 /** |
| 906 * The state of the cached launchable flag. | 906 * The state of the cached launchable flag. |
| 907 */ | 907 */ |
| 908 CacheState _launchableState = CacheState.INVALID; | 908 CacheState _launchableState = CacheState.INVALID; |
| 909 | 909 |
| 910 /** | 910 /** |
| 911 * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT
_CODE}. | 911 * An integer holding bit masks such as [LAUNCHABLE] and [CLIENT_CODE]. |
| 912 */ | 912 */ |
| 913 int _bitmask = 0; | 913 int _bitmask = 0; |
| 914 | 914 |
| 915 /** | 915 /** |
| 916 * Mask indicating that this library is launchable: that the file has a main m
ethod. | 916 * Mask indicating that this library is launchable: that the file has a main m
ethod. |
| 917 */ | 917 */ |
| 918 static int _LAUNCHABLE = 1 << 1; | 918 static int _LAUNCHABLE = 1 << 1; |
| 919 | 919 |
| 920 /** | 920 /** |
| 921 * Mask indicating that the library is client code: that the library depends o
n the html library. | 921 * Mask indicating that the library is client code: that the library depends o
n the html library. |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1273 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 1274 _sourceKind = value as SourceKind; | 1274 _sourceKind = value as SourceKind; |
| 1275 _sourceKindState = CacheState.VALID; | 1275 _sourceKindState = CacheState.VALID; |
| 1276 } else { | 1276 } else { |
| 1277 super.setValue(descriptor, value); | 1277 super.setValue(descriptor, value); |
| 1278 } | 1278 } |
| 1279 } | 1279 } |
| 1280 | 1280 |
| 1281 /** | 1281 /** |
| 1282 * Set the value of the data represented by the given descriptor in the contex
t of the given | 1282 * Set the value of the data represented by the given descriptor in the contex
t of the given |
| 1283 * library to the given value, and set the state of that data to {@link CacheS
tate#VALID}. | 1283 * library to the given value, and set the state of that data to [CacheState#V
ALID]. |
| 1284 * @param descriptor the descriptor representing which data is to have its val
ue set | 1284 * @param descriptor the descriptor representing which data is to have its val
ue set |
| 1285 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 1285 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 1286 * context for the data | 1286 * context for the data |
| 1287 * @param value the new value of the data represented by the given descriptor
and library | 1287 * @param value the new value of the data represented by the given descriptor
and library |
| 1288 */ | 1288 */ |
| 1289 void setValue2(DataDescriptor descriptor, Source librarySource, Object value)
{ | 1289 void setValue2(DataDescriptor descriptor, Source librarySource, Object value)
{ |
| 1290 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); | 1290 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); |
| 1291 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1291 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1292 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); | 1292 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); |
| 1293 state._resolutionErrorsState = CacheState.VALID; | 1293 state._resolutionErrorsState = CacheState.VALID; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1314 _element = other._element; | 1314 _element = other._element; |
| 1315 _publicNamespaceState = other._publicNamespaceState; | 1315 _publicNamespaceState = other._publicNamespaceState; |
| 1316 _publicNamespace = other._publicNamespace; | 1316 _publicNamespace = other._publicNamespace; |
| 1317 _clientServerState = other._clientServerState; | 1317 _clientServerState = other._clientServerState; |
| 1318 _launchableState = other._launchableState; | 1318 _launchableState = other._launchableState; |
| 1319 _bitmask = other._bitmask; | 1319 _bitmask = other._bitmask; |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 /** | 1322 /** |
| 1323 * Return a resolution state for the specified library, creating one as necess
ary. | 1323 * Return a resolution state for the specified library, creating one as necess
ary. |
| 1324 * @param librarySource the library source (not {@code null}) | 1324 * @param librarySource the library source (not `null`) |
| 1325 * @return the resolution state (not {@code null}) | 1325 * @return the resolution state (not `null`) |
| 1326 */ | 1326 */ |
| 1327 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2
) { | 1327 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2
) { |
| 1328 DartEntryImpl_ResolutionState state = _resolutionState; | 1328 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1329 if (state._librarySource == null) { | 1329 if (state._librarySource == null) { |
| 1330 state._librarySource = librarySource2; | 1330 state._librarySource = librarySource2; |
| 1331 return state; | 1331 return state; |
| 1332 } | 1332 } |
| 1333 while (state._librarySource != librarySource2) { | 1333 while (state._librarySource != librarySource2) { |
| 1334 if (state._nextState == null) { | 1334 if (state._nextState == null) { |
| 1335 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); | 1335 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1353 int updatedValue2(CacheState state, int currentValue, int bitMask) { | 1353 int updatedValue2(CacheState state, int currentValue, int bitMask) { |
| 1354 if (identical(state, CacheState.VALID)) { | 1354 if (identical(state, CacheState.VALID)) { |
| 1355 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 1355 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 1356 } else if (identical(state, CacheState.IN_PROCESS)) { | 1356 } else if (identical(state, CacheState.IN_PROCESS)) { |
| 1357 return currentValue; | 1357 return currentValue; |
| 1358 } | 1358 } |
| 1359 return currentValue &= ~bitMask; | 1359 return currentValue &= ~bitMask; |
| 1360 } | 1360 } |
| 1361 } | 1361 } |
| 1362 /** | 1362 /** |
| 1363 * Instances of the class {@code ResolutionState} represent the information prod
uced by resolving | 1363 * Instances of the class `ResolutionState` represent the information produced b
y resolving |
| 1364 * a compilation unit as part of a specific library. | 1364 * a compilation unit as part of a specific library. |
| 1365 */ | 1365 */ |
| 1366 class DartEntryImpl_ResolutionState { | 1366 class DartEntryImpl_ResolutionState { |
| 1367 | 1367 |
| 1368 /** | 1368 /** |
| 1369 * The next resolution state or {@code null} if none. | 1369 * The next resolution state or `null` if none. |
| 1370 */ | 1370 */ |
| 1371 DartEntryImpl_ResolutionState _nextState; | 1371 DartEntryImpl_ResolutionState _nextState; |
| 1372 | 1372 |
| 1373 /** | 1373 /** |
| 1374 * The source for the defining compilation unit of the library that contains t
his unit. If this | 1374 * The source for the defining compilation unit of the library that contains t
his unit. If this |
| 1375 * unit is the defining compilation unit for it's library, then this will be t
he source for this | 1375 * unit is the defining compilation unit for it's library, then this will be t
he source for this |
| 1376 * unit. | 1376 * unit. |
| 1377 */ | 1377 */ |
| 1378 Source _librarySource; | 1378 Source _librarySource; |
| 1379 | 1379 |
| 1380 /** | 1380 /** |
| 1381 * The state of the cached resolved compilation unit. | 1381 * The state of the cached resolved compilation unit. |
| 1382 */ | 1382 */ |
| 1383 CacheState _resolvedUnitState = CacheState.INVALID; | 1383 CacheState _resolvedUnitState = CacheState.INVALID; |
| 1384 | 1384 |
| 1385 /** | 1385 /** |
| 1386 * The resolved compilation unit, or {@code null} if the resolved compilation
unit is not | 1386 * The resolved compilation unit, or `null` if the resolved compilation unit i
s not |
| 1387 * currently cached. | 1387 * currently cached. |
| 1388 */ | 1388 */ |
| 1389 CompilationUnit _resolvedUnit; | 1389 CompilationUnit _resolvedUnit; |
| 1390 | 1390 |
| 1391 /** | 1391 /** |
| 1392 * The state of the cached resolution errors. | 1392 * The state of the cached resolution errors. |
| 1393 */ | 1393 */ |
| 1394 CacheState _resolutionErrorsState = CacheState.INVALID; | 1394 CacheState _resolutionErrorsState = CacheState.INVALID; |
| 1395 | 1395 |
| 1396 /** | 1396 /** |
| 1397 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are | 1397 * The errors produced while resolving the compilation unit, or `null` if the
errors are |
| 1398 * not currently cached. | 1398 * not currently cached. |
| 1399 */ | 1399 */ |
| 1400 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 1400 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1401 | 1401 |
| 1402 /** | 1402 /** |
| 1403 * Set this state to be exactly like the given state, recursively copying the
next state as | 1403 * Set this state to be exactly like the given state, recursively copying the
next state as |
| 1404 * necessary. | 1404 * necessary. |
| 1405 * @param other the state to be copied | 1405 * @param other the state to be copied |
| 1406 */ | 1406 */ |
| 1407 void copyFrom(DartEntryImpl_ResolutionState other) { | 1407 void copyFrom(DartEntryImpl_ResolutionState other) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1436 void recordResolutionError() { | 1436 void recordResolutionError() { |
| 1437 _nextState = null; | 1437 _nextState = null; |
| 1438 _librarySource = null; | 1438 _librarySource = null; |
| 1439 _resolvedUnitState = CacheState.ERROR; | 1439 _resolvedUnitState = CacheState.ERROR; |
| 1440 _resolvedUnit = null; | 1440 _resolvedUnit = null; |
| 1441 _resolutionErrorsState = CacheState.ERROR; | 1441 _resolutionErrorsState = CacheState.ERROR; |
| 1442 _resolutionErrors = AnalysisError.NO_ERRORS; | 1442 _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1443 } | 1443 } |
| 1444 } | 1444 } |
| 1445 /** | 1445 /** |
| 1446 * Instances of the class {@code DataDescriptor} are immutable constants represe
nting data that can | 1446 * Instances of the class `DataDescriptor` are immutable constants representing
data that can |
| 1447 * be stored in the cache. | 1447 * be stored in the cache. |
| 1448 */ | 1448 */ |
| 1449 class DataDescriptor<E> { | 1449 class DataDescriptor<E> { |
| 1450 | 1450 |
| 1451 /** | 1451 /** |
| 1452 * The name of the descriptor, used for debugging purposes. | 1452 * The name of the descriptor, used for debugging purposes. |
| 1453 */ | 1453 */ |
| 1454 String _name; | 1454 String _name; |
| 1455 | 1455 |
| 1456 /** | 1456 /** |
| 1457 * Initialize a newly created descriptor to have the given name. | 1457 * Initialize a newly created descriptor to have the given name. |
| 1458 * @param name the name of the descriptor | 1458 * @param name the name of the descriptor |
| 1459 */ | 1459 */ |
| 1460 DataDescriptor(String name) { | 1460 DataDescriptor(String name) { |
| 1461 this._name = name; | 1461 this._name = name; |
| 1462 } | 1462 } |
| 1463 String toString() => _name; | 1463 String toString() => _name; |
| 1464 } | 1464 } |
| 1465 /** | 1465 /** |
| 1466 * The interface {@code HtmlEntry} defines the behavior of objects that maintain
the information | 1466 * The interface `HtmlEntry` defines the behavior of objects that maintain the i
nformation |
| 1467 * cached by an analysis context about an individual HTML file. | 1467 * cached by an analysis context about an individual HTML file. |
| 1468 * @coverage dart.engine | 1468 * @coverage dart.engine |
| 1469 */ | 1469 */ |
| 1470 abstract class HtmlEntry implements SourceEntry { | 1470 abstract class HtmlEntry implements SourceEntry { |
| 1471 | 1471 |
| 1472 /** | 1472 /** |
| 1473 * The data descriptor representing the HTML element. | 1473 * The data descriptor representing the HTML element. |
| 1474 */ | 1474 */ |
| 1475 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem
ent>("HtmlEntry.ELEMENT"); | 1475 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem
ent>("HtmlEntry.ELEMENT"); |
| 1476 | 1476 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1495 static final DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlU
nit>("HtmlEntry.RESOLVED_UNIT"); | 1495 static final DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlU
nit>("HtmlEntry.RESOLVED_UNIT"); |
| 1496 | 1496 |
| 1497 /** | 1497 /** |
| 1498 * Return all of the errors associated with the compilation unit that are curr
ently cached. | 1498 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 1499 * @return all of the errors associated with the compilation unit | 1499 * @return all of the errors associated with the compilation unit |
| 1500 */ | 1500 */ |
| 1501 List<AnalysisError> get allErrors; | 1501 List<AnalysisError> get allErrors; |
| 1502 HtmlEntryImpl get writableCopy; | 1502 HtmlEntryImpl get writableCopy; |
| 1503 } | 1503 } |
| 1504 /** | 1504 /** |
| 1505 * Instances of the class {@code HtmlEntryImpl} implement an {@link HtmlEntry}. | 1505 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. |
| 1506 * @coverage dart.engine | 1506 * @coverage dart.engine |
| 1507 */ | 1507 */ |
| 1508 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { | 1508 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { |
| 1509 | 1509 |
| 1510 /** | 1510 /** |
| 1511 * The state of the cached parsed (but not resolved) HTML unit. | 1511 * The state of the cached parsed (but not resolved) HTML unit. |
| 1512 */ | 1512 */ |
| 1513 CacheState _parsedUnitState = CacheState.INVALID; | 1513 CacheState _parsedUnitState = CacheState.INVALID; |
| 1514 | 1514 |
| 1515 /** | 1515 /** |
| 1516 * The parsed HTML unit, or {@code null} if the parsed HTML unit is not curren
tly cached. | 1516 * The parsed HTML unit, or `null` if the parsed HTML unit is not currently ca
ched. |
| 1517 */ | 1517 */ |
| 1518 HtmlUnit _parsedUnit; | 1518 HtmlUnit _parsedUnit; |
| 1519 | 1519 |
| 1520 /** | 1520 /** |
| 1521 * The state of the cached resolution errors. | 1521 * The state of the cached resolution errors. |
| 1522 */ | 1522 */ |
| 1523 CacheState _resolutionErrorsState = CacheState.INVALID; | 1523 CacheState _resolutionErrorsState = CacheState.INVALID; |
| 1524 | 1524 |
| 1525 /** | 1525 /** |
| 1526 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are not | 1526 * The errors produced while resolving the compilation unit, or `null` if the
errors are not |
| 1527 * currently cached. | 1527 * currently cached. |
| 1528 */ | 1528 */ |
| 1529 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 1529 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1530 | 1530 |
| 1531 /** | 1531 /** |
| 1532 * The state of the cached parsed and resolved HTML unit. | 1532 * The state of the cached parsed and resolved HTML unit. |
| 1533 */ | 1533 */ |
| 1534 CacheState _resolvedUnitState = CacheState.INVALID; | 1534 CacheState _resolvedUnitState = CacheState.INVALID; |
| 1535 | 1535 |
| 1536 /** | 1536 /** |
| 1537 * The resolved HTML unit, or {@code null} if the resolved HTML unit is not cu
rrently cached. | 1537 * The resolved HTML unit, or `null` if the resolved HTML unit is not currentl
y cached. |
| 1538 */ | 1538 */ |
| 1539 HtmlUnit _resolvedUnit; | 1539 HtmlUnit _resolvedUnit; |
| 1540 | 1540 |
| 1541 /** | 1541 /** |
| 1542 * The state of the cached list of referenced libraries. | 1542 * The state of the cached list of referenced libraries. |
| 1543 */ | 1543 */ |
| 1544 CacheState _referencedLibrariesState = CacheState.INVALID; | 1544 CacheState _referencedLibrariesState = CacheState.INVALID; |
| 1545 | 1545 |
| 1546 /** | 1546 /** |
| 1547 * The list of libraries referenced in the HTML, or {@code null} if the list i
s not currently | 1547 * The list of libraries referenced in the HTML, or `null` if the list is not
currently |
| 1548 * cached. Note that this list does not include libraries defined directly wit
hin the HTML file. | 1548 * cached. Note that this list does not include libraries defined directly wit
hin the HTML file. |
| 1549 */ | 1549 */ |
| 1550 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; | 1550 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; |
| 1551 | 1551 |
| 1552 /** | 1552 /** |
| 1553 * The state of the cached HTML element. | 1553 * The state of the cached HTML element. |
| 1554 */ | 1554 */ |
| 1555 CacheState _elementState = CacheState.INVALID; | 1555 CacheState _elementState = CacheState.INVALID; |
| 1556 | 1556 |
| 1557 /** | 1557 /** |
| 1558 * The element representing the HTML file, or {@code null} if the element is n
ot currently cached. | 1558 * The element representing the HTML file, or `null` if the element is not cur
rently cached. |
| 1559 */ | 1559 */ |
| 1560 HtmlElement _element; | 1560 HtmlElement _element; |
| 1561 List<AnalysisError> get allErrors { | 1561 List<AnalysisError> get allErrors { |
| 1562 List<AnalysisError> errors = new List<AnalysisError>(); | 1562 List<AnalysisError> errors = new List<AnalysisError>(); |
| 1563 for (AnalysisError error in _resolutionErrors) { | 1563 for (AnalysisError error in _resolutionErrors) { |
| 1564 errors.add(error); | 1564 errors.add(error); |
| 1565 } | 1565 } |
| 1566 if (errors.length == 0) { | 1566 if (errors.length == 0) { |
| 1567 return AnalysisError.NO_ERRORS; | 1567 return AnalysisError.NO_ERRORS; |
| 1568 } | 1568 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 _referencedLibraries = other._referencedLibraries; | 1651 _referencedLibraries = other._referencedLibraries; |
| 1652 _resolutionErrors = other._resolutionErrors; | 1652 _resolutionErrors = other._resolutionErrors; |
| 1653 _resolutionErrorsState = other._resolutionErrorsState; | 1653 _resolutionErrorsState = other._resolutionErrorsState; |
| 1654 _resolvedUnitState = other._resolvedUnitState; | 1654 _resolvedUnitState = other._resolvedUnitState; |
| 1655 _resolvedUnit = other._resolvedUnit; | 1655 _resolvedUnit = other._resolvedUnit; |
| 1656 _elementState = other._elementState; | 1656 _elementState = other._elementState; |
| 1657 _element = other._element; | 1657 _element = other._element; |
| 1658 } | 1658 } |
| 1659 } | 1659 } |
| 1660 /** | 1660 /** |
| 1661 * The interface {@code SourceEntry} defines the behavior of objects that mainta
in the information | 1661 * 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. | 1662 * cached by an analysis context about an individual source, no matter what kind
of source it is. |
| 1663 * <p> | 1663 * |
| 1664 * Source entries should be treated as if they were immutable unless a writable
copy of the entry | 1664 * Source entries should be treated as if they were immutable unless a writable
copy of the entry |
| 1665 * has been obtained and has not yet been made visible to other threads. | 1665 * has been obtained and has not yet been made visible to other threads. |
| 1666 * @coverage dart.engine | 1666 * @coverage dart.engine |
| 1667 */ | 1667 */ |
| 1668 abstract class SourceEntry { | 1668 abstract class SourceEntry { |
| 1669 | 1669 |
| 1670 /** | 1670 /** |
| 1671 * The data descriptor representing the line information. | 1671 * The data descriptor representing the line information. |
| 1672 */ | 1672 */ |
| 1673 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>
("SourceEntry.LINE_INFO"); | 1673 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>
("SourceEntry.LINE_INFO"); |
| 1674 | 1674 |
| 1675 /** | 1675 /** |
| 1676 * Return the kind of the source, or {@code null} if the kind is not currently
cached. | 1676 * Return the kind of the source, or `null` if the kind is not currently cache
d. |
| 1677 * @return the kind of the source | 1677 * @return the kind of the source |
| 1678 */ | 1678 */ |
| 1679 SourceKind get kind; | 1679 SourceKind get kind; |
| 1680 | 1680 |
| 1681 /** | 1681 /** |
| 1682 * Return the most recent time at which the state of the source matched the st
ate represented by | 1682 * Return the most recent time at which the state of the source matched the st
ate represented by |
| 1683 * this entry. | 1683 * this entry. |
| 1684 * @return the modification time of this entry | 1684 * @return the modification time of this entry |
| 1685 */ | 1685 */ |
| 1686 int get modificationTime; | 1686 int get modificationTime; |
| 1687 | 1687 |
| 1688 /** | 1688 /** |
| 1689 * Return the state of the data represented by the given descriptor. | 1689 * Return the state of the data represented by the given descriptor. |
| 1690 * @param descriptor the descriptor representing the data whose state is to be
returned | 1690 * @param descriptor the descriptor representing the data whose state is to be
returned |
| 1691 * @return the state of the data represented by the given descriptor | 1691 * @return the state of the data represented by the given descriptor |
| 1692 */ | 1692 */ |
| 1693 CacheState getState(DataDescriptor<Object> descriptor); | 1693 CacheState getState(DataDescriptor<Object> descriptor); |
| 1694 | 1694 |
| 1695 /** | 1695 /** |
| 1696 * Return the value of the data represented by the given descriptor, or {@code
null} if the data | 1696 * Return the value of the data represented by the given descriptor, or `null`
if the data |
| 1697 * represented by the descriptor is not in the cache. | 1697 * represented by the descriptor is not in the cache. |
| 1698 * @param descriptor the descriptor representing which data is to be returned | 1698 * @param descriptor the descriptor representing which data is to be returned |
| 1699 * @return the value of the data represented by the given descriptor | 1699 * @return the value of the data represented by the given descriptor |
| 1700 */ | 1700 */ |
| 1701 Object getValue(DataDescriptor descriptor); | 1701 Object getValue(DataDescriptor descriptor); |
| 1702 | 1702 |
| 1703 /** | 1703 /** |
| 1704 * Return a new entry that is initialized to the same state as this entry but
that can be | 1704 * Return a new entry that is initialized to the same state as this entry but
that can be |
| 1705 * modified. | 1705 * modified. |
| 1706 * @return a writable copy of this entry | 1706 * @return a writable copy of this entry |
| 1707 */ | 1707 */ |
| 1708 SourceEntryImpl get writableCopy; | 1708 SourceEntryImpl get writableCopy; |
| 1709 } | 1709 } |
| 1710 /** | 1710 /** |
| 1711 * Instances of the abstract class {@code SourceEntryImpl} implement the behavio
r common to all{@link SourceEntry source entries}. | 1711 * Instances of the abstract class `SourceEntryImpl` implement the behavior comm
on to all[SourceEntry source entries]. |
| 1712 * @coverage dart.engine | 1712 * @coverage dart.engine |
| 1713 */ | 1713 */ |
| 1714 abstract class SourceEntryImpl implements SourceEntry { | 1714 abstract class SourceEntryImpl implements SourceEntry { |
| 1715 | 1715 |
| 1716 /** | 1716 /** |
| 1717 * The most recent time at which the state of the source matched the state rep
resented by this | 1717 * The most recent time at which the state of the source matched the state rep
resented by this |
| 1718 * entry. | 1718 * entry. |
| 1719 */ | 1719 */ |
| 1720 int _modificationTime = 0; | 1720 int _modificationTime = 0; |
| 1721 | 1721 |
| 1722 /** | 1722 /** |
| 1723 * The state of the cached line information. | 1723 * The state of the cached line information. |
| 1724 */ | 1724 */ |
| 1725 CacheState _lineInfoState = CacheState.INVALID; | 1725 CacheState _lineInfoState = CacheState.INVALID; |
| 1726 | 1726 |
| 1727 /** | 1727 /** |
| 1728 * The line information computed for the source, or {@code null} if the line i
nformation is not | 1728 * The line information computed for the source, or `null` if the line informa
tion is not |
| 1729 * currently cached. | 1729 * currently cached. |
| 1730 */ | 1730 */ |
| 1731 LineInfo _lineInfo; | 1731 LineInfo _lineInfo; |
| 1732 int get modificationTime => _modificationTime; | 1732 int get modificationTime => _modificationTime; |
| 1733 CacheState getState(DataDescriptor<Object> descriptor) { | 1733 CacheState getState(DataDescriptor<Object> descriptor) { |
| 1734 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 1734 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1735 return _lineInfoState; | 1735 return _lineInfoState; |
| 1736 } else { | 1736 } else { |
| 1737 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1737 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1738 } | 1738 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { | 1803 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { |
| 1804 if (identical(state, CacheState.VALID)) { | 1804 if (identical(state, CacheState.VALID)) { |
| 1805 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 1805 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 1806 } else if (identical(state, CacheState.IN_PROCESS)) { | 1806 } else if (identical(state, CacheState.IN_PROCESS)) { |
| 1807 return currentValue; | 1807 return currentValue; |
| 1808 } | 1808 } |
| 1809 return defaultValue; | 1809 return defaultValue; |
| 1810 } | 1810 } |
| 1811 } | 1811 } |
| 1812 /** | 1812 /** |
| 1813 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys
isContext analysis | 1813 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext an
alysis |
| 1814 * context}. | 1814 * context]. |
| 1815 * @coverage dart.engine | 1815 * @coverage dart.engine |
| 1816 */ | 1816 */ |
| 1817 class AnalysisContextImpl implements InternalAnalysisContext { | 1817 class AnalysisContextImpl implements InternalAnalysisContext { |
| 1818 | 1818 |
| 1819 /** | 1819 /** |
| 1820 * The set of analysis options controlling the behavior of this context. | 1820 * The set of analysis options controlling the behavior of this context. |
| 1821 */ | 1821 */ |
| 1822 AnalysisOptions _options = new AnalysisOptionsImpl(); | 1822 AnalysisOptions _options = new AnalysisOptionsImpl(); |
| 1823 | 1823 |
| 1824 /** | 1824 /** |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2489 List<Source> librarySources = new List<Source>(); | 2489 List<Source> librarySources = new List<Source>(); |
| 2490 for (Source source in changedSources) { | 2490 for (Source source in changedSources) { |
| 2491 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { | 2491 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { |
| 2492 librarySources.add(source); | 2492 librarySources.add(source); |
| 2493 } | 2493 } |
| 2494 } | 2494 } |
| 2495 return librarySources; | 2495 return librarySources; |
| 2496 } | 2496 } |
| 2497 | 2497 |
| 2498 /** | 2498 /** |
| 2499 * Return a list of the sources that would be processed by {@link #performAnal
ysisTask()}. This | 2499 * 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. | 2500 * method is intended to be used for testing purposes only. |
| 2501 * @return a list of the sources that would be processed by {@link #performAna
lysisTask()} | 2501 * @return a list of the sources that would be processed by [performAnalysisTa
sk] |
| 2502 */ | 2502 */ |
| 2503 List<Source> get sourcesNeedingProcessing { | 2503 List<Source> get sourcesNeedingProcessing { |
| 2504 List<Source> sources = new List<Source>(); | 2504 List<Source> sources = new List<Source>(); |
| 2505 { | 2505 { |
| 2506 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2506 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 2507 SourceEntry sourceEntry = entry.getValue(); | 2507 SourceEntry sourceEntry = entry.getValue(); |
| 2508 if (sourceEntry is DartEntry) { | 2508 if (sourceEntry is DartEntry) { |
| 2509 DartEntry dartEntry = sourceEntry as DartEntry; | 2509 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2510 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT)
; | 2510 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT)
; |
| 2511 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); | 2511 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
| 2512 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen
tState, CacheState.INVALID)) { | 2512 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen
tState, CacheState.INVALID)) { |
| 2513 sources.add(entry.getKey()); | 2513 sources.add(entry.getKey()); |
| 2514 } | 2514 } |
| 2515 } else if (sourceEntry is HtmlEntry) { | 2515 } else if (sourceEntry is HtmlEntry) { |
| 2516 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 2516 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 2517 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT)
; | 2517 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT)
; |
| 2518 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_U
NIT); | 2518 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_U
NIT); |
| 2519 if (identical(parsedUnitState, CacheState.INVALID) || identical(resolv
edUnitState, CacheState.INVALID)) { | 2519 if (identical(parsedUnitState, CacheState.INVALID) || identical(resolv
edUnitState, CacheState.INVALID)) { |
| 2520 sources.add(entry.getKey()); | 2520 sources.add(entry.getKey()); |
| 2521 } | 2521 } |
| 2522 } | 2522 } |
| 2523 } | 2523 } |
| 2524 } | 2524 } |
| 2525 return sources; | 2525 return sources; |
| 2526 } | 2526 } |
| 2527 | 2527 |
| 2528 /** | 2528 /** |
| 2529 * Record that the given source was just accessed for some unspecified purpose
. | 2529 * Record that the given source was just accessed for some unspecified purpose
. |
| 2530 * <p> | 2530 * |
| 2531 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. | 2531 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 2532 * @param source the source that was accessed | 2532 * @param source the source that was accessed |
| 2533 */ | 2533 */ |
| 2534 void accessed(Source source) { | 2534 void accessed(Source source) { |
| 2535 if (_recentlyUsed.contains(source)) { | 2535 if (_recentlyUsed.contains(source)) { |
| 2536 _recentlyUsed.remove(source); | 2536 _recentlyUsed.remove(source); |
| 2537 _recentlyUsed.add(source); | 2537 _recentlyUsed.add(source); |
| 2538 return; | 2538 return; |
| 2539 } | 2539 } |
| 2540 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { | 2540 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { |
| 2541 Source removedSource = _recentlyUsed.removeAt(0); | 2541 Source removedSource = _recentlyUsed.removeAt(0); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2552 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
FLUSHED); | 2552 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
FLUSHED); |
| 2553 } | 2553 } |
| 2554 _sourceMap[removedSource] = dartCopy; | 2554 _sourceMap[removedSource] = dartCopy; |
| 2555 } | 2555 } |
| 2556 } | 2556 } |
| 2557 _recentlyUsed.add(source); | 2557 _recentlyUsed.add(source); |
| 2558 } | 2558 } |
| 2559 | 2559 |
| 2560 /** | 2560 /** |
| 2561 * Add all of the sources contained in the given source container to the given
list of sources. | 2561 * Add all of the sources contained in the given source container to the given
list of sources. |
| 2562 * <p> | 2562 * |
| 2563 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. | 2563 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 2564 * @param sources the list to which sources are to be added | 2564 * @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 | 2565 * @param container the source container containing the sources to be added to
the list |
| 2566 */ | 2566 */ |
| 2567 void addSourcesInContainer(List<Source> sources, SourceContainer container) { | 2567 void addSourcesInContainer(List<Source> sources, SourceContainer container) { |
| 2568 for (Source source in _sourceMap.keys.toSet()) { | 2568 for (Source source in _sourceMap.keys.toSet()) { |
| 2569 if (container.contains(source)) { | 2569 if (container.contains(source)) { |
| 2570 sources.add(source); | 2570 sources.add(source); |
| 2571 } | 2571 } |
| 2572 } | 2572 } |
| 2573 } | 2573 } |
| 2574 | 2574 |
| 2575 /** | 2575 /** |
| 2576 * Return {@code true} if the given array of sources contains the given source
. | 2576 * Return `true` if the given array of sources contains the given source. |
| 2577 * @param sources the sources being searched | 2577 * @param sources the sources being searched |
| 2578 * @param targetSource the source being searched for | 2578 * @param targetSource the source being searched for |
| 2579 * @return {@code true} if the given source is in the array | 2579 * @return `true` if the given source is in the array |
| 2580 */ | 2580 */ |
| 2581 bool contains(List<Source> sources, Source targetSource) { | 2581 bool contains(List<Source> sources, Source targetSource) { |
| 2582 for (Source source in sources) { | 2582 for (Source source in sources) { |
| 2583 if (source == targetSource) { | 2583 if (source == targetSource) { |
| 2584 return true; | 2584 return true; |
| 2585 } | 2585 } |
| 2586 } | 2586 } |
| 2587 return false; | 2587 return false; |
| 2588 } | 2588 } |
| 2589 | 2589 |
| 2590 /** | 2590 /** |
| 2591 * Return {@code true} if the given array of sources contains any of the given
target sources. | 2591 * Return `true` if the given array of sources contains any of the given targe
t sources. |
| 2592 * @param sources the sources being searched | 2592 * @param sources the sources being searched |
| 2593 * @param targetSources the sources being searched for | 2593 * @param targetSources the sources being searched for |
| 2594 * @return {@code true} if any of the given target sources are in the array | 2594 * @return `true` if any of the given target sources are in the array |
| 2595 */ | 2595 */ |
| 2596 bool containsAny(List<Source> sources, List<Source> targetSources) { | 2596 bool containsAny(List<Source> sources, List<Source> targetSources) { |
| 2597 for (Source targetSource in targetSources) { | 2597 for (Source targetSource in targetSources) { |
| 2598 if (contains(sources, targetSource)) { | 2598 if (contains(sources, targetSource)) { |
| 2599 return true; | 2599 return true; |
| 2600 } | 2600 } |
| 2601 } | 2601 } |
| 2602 return false; | 2602 return false; |
| 2603 } | 2603 } |
| 2604 | 2604 |
| 2605 /** | 2605 /** |
| 2606 * Create a source information object suitable for the given source. Return th
e source information | 2606 * Create a source information object suitable for the given source. Return th
e source information |
| 2607 * object that was created, or {@code null} if the source should not be tracke
d by this context. | 2607 * object that was created, or `null` if the source should not be tracked by t
his context. |
| 2608 * @param source the source for which an information object is being created | 2608 * @param source the source for which an information object is being created |
| 2609 * @return the source information object that was created | 2609 * @return the source information object that was created |
| 2610 */ | 2610 */ |
| 2611 SourceEntry createSourceEntry(Source source) { | 2611 SourceEntry createSourceEntry(Source source) { |
| 2612 String name = source.shortName; | 2612 String name = source.shortName; |
| 2613 if (AnalysisEngine.isHtmlFileName(name)) { | 2613 if (AnalysisEngine.isHtmlFileName(name)) { |
| 2614 HtmlEntry htmlEntry = new HtmlEntryImpl(); | 2614 HtmlEntry htmlEntry = new HtmlEntryImpl(); |
| 2615 _sourceMap[source] = htmlEntry; | 2615 _sourceMap[source] = htmlEntry; |
| 2616 return htmlEntry; | 2616 return htmlEntry; |
| 2617 } else { | 2617 } else { |
| 2618 DartEntry dartEntry = new DartEntryImpl(); | 2618 DartEntry dartEntry = new DartEntryImpl(); |
| 2619 _sourceMap[source] = dartEntry; | 2619 _sourceMap[source] = dartEntry; |
| 2620 return dartEntry; | 2620 return dartEntry; |
| 2621 } | 2621 } |
| 2622 } | 2622 } |
| 2623 | 2623 |
| 2624 /** | 2624 /** |
| 2625 * Disable flushing information from the cache until {@link #enableCacheRemova
l()} has been | 2625 * Disable flushing information from the cache until [enableCacheRemoval] has
been |
| 2626 * called. | 2626 * called. |
| 2627 */ | 2627 */ |
| 2628 void disableCacheRemoval() { | 2628 void disableCacheRemoval() { |
| 2629 _cacheRemovalCount++; | 2629 _cacheRemovalCount++; |
| 2630 } | 2630 } |
| 2631 | 2631 |
| 2632 /** | 2632 /** |
| 2633 * Re-enable flushing information from the cache. | 2633 * Re-enable flushing information from the cache. |
| 2634 */ | 2634 */ |
| 2635 void enableCacheRemoval() { | 2635 void enableCacheRemoval() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2652 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat
e.FLUSHED); | 2652 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat
e.FLUSHED); |
| 2653 } | 2653 } |
| 2654 _sourceMap[removedSource] = dartCopy; | 2654 _sourceMap[removedSource] = dartCopy; |
| 2655 } | 2655 } |
| 2656 } | 2656 } |
| 2657 } | 2657 } |
| 2658 } | 2658 } |
| 2659 | 2659 |
| 2660 /** | 2660 /** |
| 2661 * Search the compilation units that are part of the given library and return
the element | 2661 * 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 {@code null
} if there is no | 2662 * representing the compilation unit with the given source. Return `null` if t
here is no |
| 2663 * such compilation unit. | 2663 * such compilation unit. |
| 2664 * @param libraryElement the element representing the library being searched t
hrough | 2664 * @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 | 2665 * @param unitSource the source for the compilation unit whose element is to b
e returned |
| 2666 * @return the element representing the compilation unit | 2666 * @return the element representing the compilation unit |
| 2667 */ | 2667 */ |
| 2668 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ | 2668 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ |
| 2669 CompilationUnitElement element = libraryElement.definingCompilationUnit; | 2669 CompilationUnitElement element = libraryElement.definingCompilationUnit; |
| 2670 if (element.source == unitSource) { | 2670 if (element.source == unitSource) { |
| 2671 return element; | 2671 return element; |
| 2672 } | 2672 } |
| 2673 for (CompilationUnitElement partElement in libraryElement.parts) { | 2673 for (CompilationUnitElement partElement in libraryElement.parts) { |
| 2674 if (partElement.source == unitSource) { | 2674 if (partElement.source == unitSource) { |
| 2675 return partElement; | 2675 return partElement; |
| 2676 } | 2676 } |
| 2677 } | 2677 } |
| 2678 return null; | 2678 return null; |
| 2679 } | 2679 } |
| 2680 | 2680 |
| 2681 /** | 2681 /** |
| 2682 * Return the compilation unit information associated with the given source, o
r {@code null} if | 2682 * 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 | 2683 * 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 | 2684 * 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 | 2685 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when |
| 2686 * first accessed. | 2686 * first accessed. |
| 2687 * <p> | 2687 * |
| 2688 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2688 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 2689 * @param source the source for which information is being sought | 2689 * @param source the source for which information is being sought |
| 2690 * @return the compilation unit information associated with the given source | 2690 * @return the compilation unit information associated with the given source |
| 2691 */ | 2691 */ |
| 2692 DartEntry getDartEntry(Source source) { | 2692 DartEntry getDartEntry(Source source) { |
| 2693 SourceEntry sourceEntry = getSourceEntry(source); | 2693 SourceEntry sourceEntry = getSourceEntry(source); |
| 2694 if (sourceEntry == null) { | 2694 if (sourceEntry == null) { |
| 2695 sourceEntry = new DartEntryImpl(); | 2695 sourceEntry = new DartEntryImpl(); |
| 2696 _sourceMap[source] = sourceEntry; | 2696 _sourceMap[source] = sourceEntry; |
| 2697 return sourceEntry as DartEntry; | 2697 return sourceEntry as DartEntry; |
| 2698 } else if (sourceEntry is DartEntry) { | 2698 } else if (sourceEntry is DartEntry) { |
| 2699 return sourceEntry as DartEntry; | 2699 return sourceEntry as DartEntry; |
| 2700 } | 2700 } |
| 2701 return null; | 2701 return null; |
| 2702 } | 2702 } |
| 2703 | 2703 |
| 2704 /** | 2704 /** |
| 2705 * Return the HTML unit information associated with the given source, or {@cod
e null} if the | 2705 * 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 | 2706 * 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 | 2707 * 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 | 2708 * implicitly part of every analysis context and are therefore only added to t
he map when first |
| 2709 * accessed. | 2709 * accessed. |
| 2710 * <p> | 2710 * |
| 2711 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2711 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 2712 * @param source the source for which information is being sought | 2712 * @param source the source for which information is being sought |
| 2713 * @return the HTML unit information associated with the given source | 2713 * @return the HTML unit information associated with the given source |
| 2714 */ | 2714 */ |
| 2715 HtmlEntry getHtmlEntry(Source source) { | 2715 HtmlEntry getHtmlEntry(Source source) { |
| 2716 SourceEntry sourceEntry = getSourceEntry(source); | 2716 SourceEntry sourceEntry = getSourceEntry(source); |
| 2717 if (sourceEntry == null) { | 2717 if (sourceEntry == null) { |
| 2718 sourceEntry = new HtmlEntryImpl(); | 2718 sourceEntry = new HtmlEntryImpl(); |
| 2719 _sourceMap[source] = sourceEntry; | 2719 _sourceMap[source] = sourceEntry; |
| 2720 return sourceEntry as HtmlEntry; | 2720 return sourceEntry as HtmlEntry; |
| 2721 } else if (sourceEntry is HtmlEntry) { | 2721 } else if (sourceEntry is HtmlEntry) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2747 ChangeNoticeImpl getNotice(Source source) { | 2747 ChangeNoticeImpl getNotice(Source source) { |
| 2748 ChangeNoticeImpl notice = _pendingNotices[source]; | 2748 ChangeNoticeImpl notice = _pendingNotices[source]; |
| 2749 if (notice == null) { | 2749 if (notice == null) { |
| 2750 notice = new ChangeNoticeImpl(source); | 2750 notice = new ChangeNoticeImpl(source); |
| 2751 _pendingNotices[source] = notice; | 2751 _pendingNotices[source] = notice; |
| 2752 } | 2752 } |
| 2753 return notice; | 2753 return notice; |
| 2754 } | 2754 } |
| 2755 | 2755 |
| 2756 /** | 2756 /** |
| 2757 * Return the cache entry associated with the given source, or {@code null} if
there is no entry | 2757 * Return the cache entry associated with the given source, or `null` if there
is no entry |
| 2758 * associated with the source. | 2758 * associated with the source. |
| 2759 * @param source the source for which a cache entry is being sought | 2759 * @param source the source for which a cache entry is being sought |
| 2760 * @return the source cache entry associated with the given source | 2760 * @return the source cache entry associated with the given source |
| 2761 */ | 2761 */ |
| 2762 SourceEntry getReadableSourceEntry(Source source) { | 2762 SourceEntry getReadableSourceEntry(Source source) { |
| 2763 { | 2763 { |
| 2764 return _sourceMap[source]; | 2764 return _sourceMap[source]; |
| 2765 } | 2765 } |
| 2766 } | 2766 } |
| 2767 | 2767 |
| 2768 /** | 2768 /** |
| 2769 * Return the source information associated with the given source, or {@code n
ull} if the source | 2769 * 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 | 2770 * 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 | 2771 * 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. | 2772 * every analysis context and are therefore only added to the map when first a
ccessed. |
| 2773 * <p> | 2773 * |
| 2774 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2774 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 2775 * @param source the source for which information is being sought | 2775 * @param source the source for which information is being sought |
| 2776 * @return the source information associated with the given source | 2776 * @return the source information associated with the given source |
| 2777 */ | 2777 */ |
| 2778 SourceEntry getSourceEntry(Source source) { | 2778 SourceEntry getSourceEntry(Source source) { |
| 2779 SourceEntry sourceEntry = _sourceMap[source]; | 2779 SourceEntry sourceEntry = _sourceMap[source]; |
| 2780 if (sourceEntry == null) { | 2780 if (sourceEntry == null) { |
| 2781 sourceEntry = createSourceEntry(source); | 2781 sourceEntry = createSourceEntry(source); |
| 2782 } | 2782 } |
| 2783 return sourceEntry; | 2783 return sourceEntry; |
| 2784 } | 2784 } |
| 2785 | 2785 |
| 2786 /** | 2786 /** |
| 2787 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 2787 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
| 2788 * @param kind the kind of sources to be returned | 2788 * @param kind the kind of sources to be returned |
| 2789 * @return all of the sources known to this context that have the given kind | 2789 * @return all of the sources known to this context that have the given kind |
| 2790 */ | 2790 */ |
| 2791 List<Source> getSources(SourceKind kind2) { | 2791 List<Source> getSources(SourceKind kind2) { |
| 2792 List<Source> sources = new List<Source>(); | 2792 List<Source> sources = new List<Source>(); |
| 2793 { | 2793 { |
| 2794 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2794 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 2795 if (identical(entry.getValue().kind, kind2)) { | 2795 if (identical(entry.getValue().kind, kind2)) { |
| 2796 sources.add(entry.getKey()); | 2796 sources.add(entry.getKey()); |
| 2797 } | 2797 } |
| 2798 } | 2798 } |
| 2799 } | 2799 } |
| 2800 return new List.from(sources); | 2800 return new List.from(sources); |
| 2801 } | 2801 } |
| 2802 | 2802 |
| 2803 /** | 2803 /** |
| 2804 * Return {@code true} if the given compilation unit has a part-of directive b
ut no library | 2804 * Return `true` if the given compilation unit has a part-of directive but no
library |
| 2805 * directive. | 2805 * directive. |
| 2806 * @param unit the compilation unit being tested | 2806 * @param unit the compilation unit being tested |
| 2807 * @return {@code true} if the compilation unit has a part-of directive | 2807 * @return `true` if the compilation unit has a part-of directive |
| 2808 */ | 2808 */ |
| 2809 bool hasPartOfDirective(CompilationUnit unit) { | 2809 bool hasPartOfDirective(CompilationUnit unit) { |
| 2810 bool hasPartOf = false; | 2810 bool hasPartOf = false; |
| 2811 for (Directive directive in unit.directives) { | 2811 for (Directive directive in unit.directives) { |
| 2812 if (directive is PartOfDirective) { | 2812 if (directive is PartOfDirective) { |
| 2813 hasPartOf = true; | 2813 hasPartOf = true; |
| 2814 } else if (directive is LibraryDirective) { | 2814 } else if (directive is LibraryDirective) { |
| 2815 return false; | 2815 return false; |
| 2816 } | 2816 } |
| 2817 } | 2817 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 try { | 2891 try { |
| 2892 source.getContents(receiver); | 2892 source.getContents(receiver); |
| 2893 } catch (exception) { | 2893 } catch (exception) { |
| 2894 throw new AnalysisException.con3(exception); | 2894 throw new AnalysisException.con3(exception); |
| 2895 } | 2895 } |
| 2896 return result; | 2896 return result; |
| 2897 } | 2897 } |
| 2898 | 2898 |
| 2899 /** | 2899 /** |
| 2900 * Invalidate all of the results computed by this context. | 2900 * Invalidate all of the results computed by this context. |
| 2901 * <p> | 2901 * |
| 2902 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2902 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 2903 */ | 2903 */ |
| 2904 void invalidateAllResults() { | 2904 void invalidateAllResults() { |
| 2905 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) { | 2905 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) { |
| 2906 SourceEntry sourceEntry = mapEntry.getValue(); | 2906 SourceEntry sourceEntry = mapEntry.getValue(); |
| 2907 if (sourceEntry is HtmlEntry) { | 2907 if (sourceEntry is HtmlEntry) { |
| 2908 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; | 2908 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 2909 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); | 2909 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); |
| 2910 mapEntry.setValue(htmlCopy); | 2910 mapEntry.setValue(htmlCopy); |
| 2911 } else if (sourceEntry is DartEntry) { | 2911 } else if (sourceEntry is DartEntry) { |
| 2912 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; | 2912 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2934 if (partEntry != null) { | 2934 if (partEntry != null) { |
| 2935 DartEntryImpl dartCopy = partEntry.writableCopy; | 2935 DartEntryImpl dartCopy = partEntry.writableCopy; |
| 2936 dartCopy.invalidateAllResolutionInformation(); | 2936 dartCopy.invalidateAllResolutionInformation(); |
| 2937 _sourceMap[unitSource] = dartCopy; | 2937 _sourceMap[unitSource] = dartCopy; |
| 2938 } | 2938 } |
| 2939 } | 2939 } |
| 2940 } | 2940 } |
| 2941 } | 2941 } |
| 2942 | 2942 |
| 2943 /** | 2943 /** |
| 2944 * Return {@code true} if this library is, or depends on, dart:html. | 2944 * Return `true` if this library is, or depends on, dart:html. |
| 2945 * @param library the library being tested | 2945 * @param library the library being tested |
| 2946 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent | 2946 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent |
| 2947 * infinite recursion | 2947 * infinite recursion |
| 2948 * @return {@code true} if this library is, or depends on, dart:html | 2948 * @return `true` if this library is, or depends on, dart:html |
| 2949 */ | 2949 */ |
| 2950 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { | 2950 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { |
| 2951 if (visitedLibraries.contains(library)) { | 2951 if (visitedLibraries.contains(library)) { |
| 2952 return false; | 2952 return false; |
| 2953 } | 2953 } |
| 2954 if (library.source == htmlSource) { | 2954 if (library.source == htmlSource) { |
| 2955 return true; | 2955 return true; |
| 2956 } | 2956 } |
| 2957 javaSetAdd(visitedLibraries, library); | 2957 javaSetAdd(visitedLibraries, library); |
| 2958 for (LibraryElement imported in library.importedLibraries) { | 2958 for (LibraryElement imported in library.importedLibraries) { |
| 2959 if (isClient(imported, htmlSource, visitedLibraries)) { | 2959 if (isClient(imported, htmlSource, visitedLibraries)) { |
| 2960 return true; | 2960 return true; |
| 2961 } | 2961 } |
| 2962 } | 2962 } |
| 2963 for (LibraryElement exported in library.exportedLibraries) { | 2963 for (LibraryElement exported in library.exportedLibraries) { |
| 2964 if (isClient(exported, htmlSource, visitedLibraries)) { | 2964 if (isClient(exported, htmlSource, visitedLibraries)) { |
| 2965 return true; | 2965 return true; |
| 2966 } | 2966 } |
| 2967 } | 2967 } |
| 2968 return false; | 2968 return false; |
| 2969 } | 2969 } |
| 2970 | 2970 |
| 2971 /** | 2971 /** |
| 2972 * Perform a single analysis task. | 2972 * Perform a single analysis task. |
| 2973 * <p> | 2973 * |
| 2974 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2974 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 2975 * @return {@code true} if work was done, implying that there might be more wo
rk to be done | 2975 * @return `true` if work was done, implying that there might be more work to
be done |
| 2976 */ | 2976 */ |
| 2977 bool performSingleAnalysisTask() { | 2977 bool performSingleAnalysisTask() { |
| 2978 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2978 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 2979 SourceEntry sourceEntry = entry.getValue(); | 2979 SourceEntry sourceEntry = entry.getValue(); |
| 2980 if (sourceEntry is DartEntry) { | 2980 if (sourceEntry is DartEntry) { |
| 2981 DartEntry dartEntry = sourceEntry as DartEntry; | 2981 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2982 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT); | 2982 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT); |
| 2983 if (identical(parsedUnitState, CacheState.INVALID)) { | 2983 if (identical(parsedUnitState, CacheState.INVALID)) { |
| 2984 try { | 2984 try { |
| 2985 parseCompilationUnit(entry.getKey()); | 2985 parseCompilationUnit(entry.getKey()); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3115 HtmlScanner scanner = new HtmlScanner(source); | 3115 HtmlScanner scanner = new HtmlScanner(source); |
| 3116 try { | 3116 try { |
| 3117 source.getContents(scanner); | 3117 source.getContents(scanner); |
| 3118 } catch (exception) { | 3118 } catch (exception) { |
| 3119 throw new AnalysisException.con3(exception); | 3119 throw new AnalysisException.con3(exception); |
| 3120 } | 3120 } |
| 3121 return scanner.result; | 3121 return scanner.result; |
| 3122 } | 3122 } |
| 3123 | 3123 |
| 3124 /** | 3124 /** |
| 3125 * Create an entry for the newly added source. Return {@code true} if the new
source is a Dart | 3125 * Create an entry for the newly added source. Return `true` if the new source
is a Dart |
| 3126 * file. | 3126 * file. |
| 3127 * <p> | 3127 * |
| 3128 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 3128 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3129 * @param source the source that has been added | 3129 * @param source the source that has been added |
| 3130 * @return {@code true} if the new source is a Dart file | 3130 * @return `true` if the new source is a Dart file |
| 3131 */ | 3131 */ |
| 3132 bool sourceAvailable(Source source) { | 3132 bool sourceAvailable(Source source) { |
| 3133 SourceEntry sourceEntry = _sourceMap[source]; | 3133 SourceEntry sourceEntry = _sourceMap[source]; |
| 3134 if (sourceEntry == null) { | 3134 if (sourceEntry == null) { |
| 3135 sourceEntry = createSourceEntry(source); | 3135 sourceEntry = createSourceEntry(source); |
| 3136 } | 3136 } |
| 3137 return sourceEntry is DartEntry; | 3137 return sourceEntry is DartEntry; |
| 3138 } | 3138 } |
| 3139 | 3139 |
| 3140 /** | 3140 /** |
| 3141 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 3141 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3142 * @param source the source that has been changed | 3142 * @param source the source that has been changed |
| 3143 */ | 3143 */ |
| 3144 void sourceChanged(Source source) { | 3144 void sourceChanged(Source source) { |
| 3145 SourceEntry sourceEntry = _sourceMap[source]; | 3145 SourceEntry sourceEntry = _sourceMap[source]; |
| 3146 if (sourceEntry is HtmlEntry) { | 3146 if (sourceEntry is HtmlEntry) { |
| 3147 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; | 3147 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 3148 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); | 3148 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
| 3149 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 3149 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 3150 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); | 3150 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); |
| 3151 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); | 3151 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); |
| 3152 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); | 3152 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); |
| 3153 _sourceMap[source] = htmlCopy; | 3153 _sourceMap[source] = htmlCopy; |
| 3154 } else if (sourceEntry is DartEntry) { | 3154 } else if (sourceEntry is DartEntry) { |
| 3155 Set<Source> librariesToInvalidate = new Set<Source>(); | |
| 3156 List<Source> containingLibraries = getLibrariesContaining(source); | 3155 List<Source> containingLibraries = getLibrariesContaining(source); |
| 3157 for (Source containingLibrary in containingLibraries) { | |
| 3158 javaSetAdd(librariesToInvalidate, containingLibrary); | |
| 3159 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { | |
| 3160 javaSetAdd(librariesToInvalidate, dependentLibrary); | |
| 3161 } | |
| 3162 } | |
| 3163 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; | 3156 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| 3164 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 3157 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 3165 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); | 3158 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); |
| 3166 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); | 3159 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); |
| 3167 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); | 3160 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); |
| 3168 _sourceMap[source] = dartCopy; | 3161 _sourceMap[source] = dartCopy; |
| 3169 for (Source library in librariesToInvalidate) { | 3162 for (Source library in containingLibraries) { |
| 3170 invalidateLibraryResolution(library); | 3163 invalidateLibraryResolution(library); |
| 3171 } | 3164 } |
| 3172 } | 3165 } |
| 3173 } | 3166 } |
| 3174 | 3167 |
| 3175 /** | 3168 /** |
| 3176 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 3169 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3177 * @param source the source that has been deleted | 3170 * @param source the source that has been deleted |
| 3178 */ | 3171 */ |
| 3179 void sourceRemoved(Source source) { | 3172 void sourceRemoved(Source source) { |
| 3180 DartEntry dartEntry = getDartEntry(source); | 3173 DartEntry dartEntry = getDartEntry(source); |
| 3181 if (dartEntry != null) { | 3174 if (dartEntry != null) { |
| 3182 Set<Source> libraries = new Set<Source>(); | 3175 Set<Source> libraries = new Set<Source>(); |
| 3183 for (Source librarySource in getLibrariesContaining(source)) { | 3176 for (Source librarySource in getLibrariesContaining(source)) { |
| 3184 javaSetAdd(libraries, librarySource); | 3177 javaSetAdd(libraries, librarySource); |
| 3185 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ | 3178 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ |
| 3186 javaSetAdd(libraries, dependentLibrary); | 3179 javaSetAdd(libraries, dependentLibrary); |
| 3187 } | 3180 } |
| 3188 } | 3181 } |
| 3189 for (Source librarySource in libraries) { | 3182 for (Source librarySource in libraries) { |
| 3190 invalidateLibraryResolution(librarySource); | 3183 invalidateLibraryResolution(librarySource); |
| 3191 } | 3184 } |
| 3192 } | 3185 } |
| 3193 _sourceMap.remove(source); | 3186 _sourceMap.remove(source); |
| 3194 } | 3187 } |
| 3195 } | 3188 } |
| 3196 /** | 3189 /** |
| 3197 * Instances of the class {@code ScanResult} represent the results of scanning a
source. | 3190 * Instances of the class `ScanResult` represent the results of scanning a sourc
e. |
| 3198 */ | 3191 */ |
| 3199 class AnalysisContextImpl_ScanResult { | 3192 class AnalysisContextImpl_ScanResult { |
| 3200 | 3193 |
| 3201 /** | 3194 /** |
| 3202 * The time at which the contents of the source were last set. | 3195 * The time at which the contents of the source were last set. |
| 3203 */ | 3196 */ |
| 3204 int _modificationTime = 0; | 3197 int _modificationTime = 0; |
| 3205 | 3198 |
| 3206 /** | 3199 /** |
| 3207 * The first token in the token stream. | 3200 * The first token in the token stream. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3259 result._lineStarts = scanner.lineStarts; | 3252 result._lineStarts = scanner.lineStarts; |
| 3260 } | 3253 } |
| 3261 void accept2(String contents, int modificationTime2) { | 3254 void accept2(String contents, int modificationTime2) { |
| 3262 StringScanner scanner = new StringScanner(source, contents, errorListener); | 3255 StringScanner scanner = new StringScanner(source, contents, errorListener); |
| 3263 result._modificationTime = modificationTime2; | 3256 result._modificationTime = modificationTime2; |
| 3264 result._token = scanner.tokenize(); | 3257 result._token = scanner.tokenize(); |
| 3265 result._lineStarts = scanner.lineStarts; | 3258 result._lineStarts = scanner.lineStarts; |
| 3266 } | 3259 } |
| 3267 } | 3260 } |
| 3268 /** | 3261 /** |
| 3269 * Instances of the class {@code AnalysisErrorInfoImpl} represent the analysis e
rrors and line info | 3262 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors
and line info |
| 3270 * associated with a source. | 3263 * associated with a source. |
| 3271 */ | 3264 */ |
| 3272 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { | 3265 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { |
| 3273 | 3266 |
| 3274 /** | 3267 /** |
| 3275 * The analysis errors associated with a source, or {@code null} if there are
no errors. | 3268 * The analysis errors associated with a source, or `null` if there are no err
ors. |
| 3276 */ | 3269 */ |
| 3277 List<AnalysisError> _errors; | 3270 List<AnalysisError> _errors; |
| 3278 | 3271 |
| 3279 /** | 3272 /** |
| 3280 * The line information associated with the errors, or {@code null} if there a
re no errors. | 3273 * The line information associated with the errors, or `null` if there are no
errors. |
| 3281 */ | 3274 */ |
| 3282 LineInfo _lineInfo; | 3275 LineInfo _lineInfo; |
| 3283 | 3276 |
| 3284 /** | 3277 /** |
| 3285 * Initialize an newly created error info with the errors and line information | 3278 * Initialize an newly created error info with the errors and line information |
| 3286 * @param errors the errors as a result of analysis | 3279 * @param errors the errors as a result of analysis |
| 3287 * @param lineinfo the line info for the errors | 3280 * @param lineinfo the line info for the errors |
| 3288 */ | 3281 */ |
| 3289 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { | 3282 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { |
| 3290 this._errors = errors; | 3283 this._errors = errors; |
| 3291 this._lineInfo = lineInfo; | 3284 this._lineInfo = lineInfo; |
| 3292 } | 3285 } |
| 3293 | 3286 |
| 3294 /** | 3287 /** |
| 3295 * Return the errors of analysis, or {@code null} if there were no errors. | 3288 * Return the errors of analysis, or `null` if there were no errors. |
| 3296 * @return the errors as a result of the analysis | 3289 * @return the errors as a result of the analysis |
| 3297 */ | 3290 */ |
| 3298 List<AnalysisError> get errors => _errors; | 3291 List<AnalysisError> get errors => _errors; |
| 3299 | 3292 |
| 3300 /** | 3293 /** |
| 3301 * Return the line information associated with the errors, or {@code null} if
there were no | 3294 * Return the line information associated with the errors, or `null` if there
were no |
| 3302 * errors. | 3295 * errors. |
| 3303 * @return the line information associated with the errors | 3296 * @return the line information associated with the errors |
| 3304 */ | 3297 */ |
| 3305 LineInfo get lineInfo => _lineInfo; | 3298 LineInfo get lineInfo => _lineInfo; |
| 3306 } | 3299 } |
| 3307 /** | 3300 /** |
| 3308 * Instances of the class {@code AnalysisOptions} represent a set of analysis op
tions used to | 3301 * Instances of the class `AnalysisOptions` represent a set of analysis options
used to |
| 3309 * control the behavior of an analysis context. | 3302 * control the behavior of an analysis context. |
| 3310 */ | 3303 */ |
| 3311 class AnalysisOptionsImpl implements AnalysisOptions { | 3304 class AnalysisOptionsImpl implements AnalysisOptions { |
| 3312 | 3305 |
| 3313 /** | 3306 /** |
| 3314 * A flag indicating whether analysis is to use strict mode. In strict mode, e
rror reporting is | 3307 * A flag indicating whether analysis is to use strict mode. In strict mode, e
rror reporting is |
| 3315 * based exclusively on the static type information. | 3308 * based exclusively on the static type information. |
| 3316 */ | 3309 */ |
| 3317 bool _strictMode = false; | 3310 bool _strictMode = false; |
| 3318 | 3311 |
| 3319 /** | 3312 /** |
| 3320 * Return {@code true} if analysis is to use strict mode. In strict mode, erro
r reporting is based | 3313 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based |
| 3321 * exclusively on the static type information. | 3314 * exclusively on the static type information. |
| 3322 * @return {@code true} if analysis is to use strict mode | 3315 * @return `true` if analysis is to use strict mode |
| 3323 */ | 3316 */ |
| 3324 bool get strictMode => _strictMode; | 3317 bool get strictMode => _strictMode; |
| 3325 | 3318 |
| 3326 /** | 3319 /** |
| 3327 * Set whether analysis is to use strict mode to the given value. In strict mo
de, error reporting | 3320 * Set whether analysis is to use strict mode to the given value. In strict mo
de, error reporting |
| 3328 * is based exclusively on the static type information. | 3321 * is based exclusively on the static type information. |
| 3329 * @param isStrict {@code true} if analysis is to use strict mode | 3322 * @param isStrict `true` if analysis is to use strict mode |
| 3330 */ | 3323 */ |
| 3331 void set strictMode(bool isStrict) { | 3324 void set strictMode(bool isStrict) { |
| 3332 _strictMode = isStrict; | 3325 _strictMode = isStrict; |
| 3333 } | 3326 } |
| 3334 } | 3327 } |
| 3335 /** | 3328 /** |
| 3336 * The enumeration {@code CacheState} defines the possible states of cached data
. | 3329 * The enumeration `CacheState` defines the possible states of cached data. |
| 3337 */ | 3330 */ |
| 3338 class CacheState implements Comparable<CacheState> { | 3331 class CacheState implements Comparable<CacheState> { |
| 3339 | 3332 |
| 3340 /** | 3333 /** |
| 3341 * The data is not in the cache and the last time an attempt was made to compu
te the data an | 3334 * The data is not in the cache and the last time an attempt was made to compu
te the data an |
| 3342 * exception occurred, making it pointless to attempt. | 3335 * exception occurred, making it pointless to attempt. |
| 3343 * <p> | 3336 * |
| 3344 * Valid Transitions: | 3337 * Valid Transitions: |
| 3345 * <ul> | 3338 * |
| 3346 * <li>{@link #INVALID} if a source was modified that might cause the data to
be computable</li> | 3339 * * [INVALID] if a source was modified that might cause the data to be comput
able |
| 3347 * </ul> | 3340 * |
| 3348 */ | 3341 */ |
| 3349 static final CacheState ERROR = new CacheState('ERROR', 0); | 3342 static final CacheState ERROR = new CacheState('ERROR', 0); |
| 3350 | 3343 |
| 3351 /** | 3344 /** |
| 3352 * The data is not in the cache because it was flushed from the cache in order
to control memory | 3345 * The data is not in the cache because it was flushed from the cache in order
to control memory |
| 3353 * usage. If the data is recomputed, results do not need to be reported. | 3346 * usage. If the data is recomputed, results do not need to be reported. |
| 3354 * <p> | 3347 * |
| 3355 * Valid Transitions: | 3348 * Valid Transitions: |
| 3356 * <ul> | 3349 * |
| 3357 * <li>{@link #IN_PROCESS} if the data is being recomputed</li> | 3350 * * [IN_PROCESS] if the data is being recomputed |
| 3358 * <li>{@link #INVALID} if a source was modified that causes the data to need
to be recomputed</li> | 3351 * * [INVALID] if a source was modified that causes the data to need to be rec
omputed |
| 3359 * </ul> | 3352 * |
| 3360 */ | 3353 */ |
| 3361 static final CacheState FLUSHED = new CacheState('FLUSHED', 1); | 3354 static final CacheState FLUSHED = new CacheState('FLUSHED', 1); |
| 3362 | 3355 |
| 3363 /** | 3356 /** |
| 3364 * The data might or might not be in the cache but is in the process of being
recomputed. | 3357 * The data might or might not be in the cache but is in the process of being
recomputed. |
| 3365 * <p> | 3358 * |
| 3366 * Valid Transitions: | 3359 * Valid Transitions: |
| 3367 * <ul> | 3360 * |
| 3368 * <li>{@link #ERROR} if an exception occurred while trying to compute the dat
a</li> | 3361 * * [ERROR] if an exception occurred while trying to compute the data |
| 3369 * <li>{@link #VALID} if the data was successfully computed and stored in the
cache</li> | 3362 * * [VALID] if the data was successfully computed and stored in the cache |
| 3370 * </ul> | 3363 * |
| 3371 */ | 3364 */ |
| 3372 static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2); | 3365 static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2); |
| 3373 | 3366 |
| 3374 /** | 3367 /** |
| 3375 * The data is not in the cache and needs to be recomputed so that results can
be reported. | 3368 * The data is not in the cache and needs to be recomputed so that results can
be reported. |
| 3376 * <p> | 3369 * |
| 3377 * Valid Transitions: | 3370 * Valid Transitions: |
| 3378 * <ul> | 3371 * |
| 3379 * <li>{@link #IN_PROCESS} if an attempt is being made to recompute the data</
li> | 3372 * * [IN_PROCESS] if an attempt is being made to recompute the data |
| 3380 * </ul> | 3373 * |
| 3381 */ | 3374 */ |
| 3382 static final CacheState INVALID = new CacheState('INVALID', 3); | 3375 static final CacheState INVALID = new CacheState('INVALID', 3); |
| 3383 | 3376 |
| 3384 /** | 3377 /** |
| 3385 * The data is in the cache and up-to-date. | 3378 * The data is in the cache and up-to-date. |
| 3386 * <p> | 3379 * |
| 3387 * Valid Transitions: | 3380 * Valid Transitions: |
| 3388 * <ul> | 3381 * |
| 3389 * <li>{@link #FLUSHED} if the data is removed in order to manage memory usage
</li> | 3382 * * [FLUSHED] if the data is removed in order to manage memory usage |
| 3390 * <li>{@link #INVALID} if a source was modified in such a way as to invalidat
e the previous data</li> | 3383 * * [INVALID] if a source was modified in such a way as to invalidate the pre
vious data |
| 3391 * </ul> | 3384 * |
| 3392 */ | 3385 */ |
| 3393 static final CacheState VALID = new CacheState('VALID', 4); | 3386 static final CacheState VALID = new CacheState('VALID', 4); |
| 3394 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V
ALID]; | 3387 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V
ALID]; |
| 3395 | 3388 |
| 3396 /// The name of this enum constant, as declared in the enum declaration. | 3389 /// The name of this enum constant, as declared in the enum declaration. |
| 3397 final String name; | 3390 final String name; |
| 3398 | 3391 |
| 3399 /// The position in the enum declaration. | 3392 /// The position in the enum declaration. |
| 3400 final int ordinal; | 3393 final int ordinal; |
| 3401 CacheState(this.name, this.ordinal) { | 3394 CacheState(this.name, this.ordinal) { |
| 3402 } | 3395 } |
| 3403 int compareTo(CacheState other) => ordinal - other.ordinal; | 3396 int compareTo(CacheState other) => ordinal - other.ordinal; |
| 3404 int get hashCode => ordinal; | 3397 int get hashCode => ordinal; |
| 3405 String toString() => name; | 3398 String toString() => name; |
| 3406 } | 3399 } |
| 3407 /** | 3400 /** |
| 3408 * Instances of the class {@code ChangeNoticeImpl} represent a change to the ana
lysis results | 3401 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results |
| 3409 * associated with a given source. | 3402 * associated with a given source. |
| 3410 * @coverage dart.engine | 3403 * @coverage dart.engine |
| 3411 */ | 3404 */ |
| 3412 class ChangeNoticeImpl implements ChangeNotice { | 3405 class ChangeNoticeImpl implements ChangeNotice { |
| 3413 | 3406 |
| 3414 /** | 3407 /** |
| 3415 * The source for which the result is being reported. | 3408 * The source for which the result is being reported. |
| 3416 */ | 3409 */ |
| 3417 Source _source; | 3410 Source _source; |
| 3418 | 3411 |
| 3419 /** | 3412 /** |
| 3420 * The fully resolved AST that changed as a result of the analysis, or {@code
null} if the AST was | 3413 * The fully resolved AST that changed as a result of the analysis, or `null`
if the AST was |
| 3421 * not changed. | 3414 * not changed. |
| 3422 */ | 3415 */ |
| 3423 CompilationUnit _compilationUnit; | 3416 CompilationUnit _compilationUnit; |
| 3424 | 3417 |
| 3425 /** | 3418 /** |
| 3426 * The errors that changed as a result of the analysis, or {@code null} if err
ors were not | 3419 * The errors that changed as a result of the analysis, or `null` if errors we
re not |
| 3427 * changed. | 3420 * changed. |
| 3428 */ | 3421 */ |
| 3429 List<AnalysisError> _errors; | 3422 List<AnalysisError> _errors; |
| 3430 | 3423 |
| 3431 /** | 3424 /** |
| 3432 * The line information associated with the source, or {@code null} if errors
were not changed. | 3425 * The line information associated with the source, or `null` if errors were n
ot changed. |
| 3433 */ | 3426 */ |
| 3434 LineInfo _lineInfo; | 3427 LineInfo _lineInfo; |
| 3435 | 3428 |
| 3436 /** | 3429 /** |
| 3437 * An empty array of change notices. | 3430 * An empty array of change notices. |
| 3438 */ | 3431 */ |
| 3439 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); | 3432 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); |
| 3440 | 3433 |
| 3441 /** | 3434 /** |
| 3442 * Initialize a newly created notice associated with the given source. | 3435 * Initialize a newly created notice associated with the given source. |
| 3443 * @param source the source for which the change is being reported | 3436 * @param source the source for which the change is being reported |
| 3444 */ | 3437 */ |
| 3445 ChangeNoticeImpl(Source source) { | 3438 ChangeNoticeImpl(Source source) { |
| 3446 this._source = source; | 3439 this._source = source; |
| 3447 } | 3440 } |
| 3448 | 3441 |
| 3449 /** | 3442 /** |
| 3450 * Return the fully resolved AST that changed as a result of the analysis, or
{@code null} if the | 3443 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the |
| 3451 * AST was not changed. | 3444 * AST was not changed. |
| 3452 * @return the fully resolved AST that changed as a result of the analysis | 3445 * @return the fully resolved AST that changed as a result of the analysis |
| 3453 */ | 3446 */ |
| 3454 CompilationUnit get compilationUnit => _compilationUnit; | 3447 CompilationUnit get compilationUnit => _compilationUnit; |
| 3455 | 3448 |
| 3456 /** | 3449 /** |
| 3457 * Return the errors that changed as a result of the analysis, or {@code null}
if errors were not | 3450 * Return the errors that changed as a result of the analysis, or `null` if er
rors were not |
| 3458 * changed. | 3451 * changed. |
| 3459 * @return the errors that changed as a result of the analysis | 3452 * @return the errors that changed as a result of the analysis |
| 3460 */ | 3453 */ |
| 3461 List<AnalysisError> get errors => _errors; | 3454 List<AnalysisError> get errors => _errors; |
| 3462 | 3455 |
| 3463 /** | 3456 /** |
| 3464 * Return the line information associated with the source, or {@code null} if
errors were not | 3457 * Return the line information associated with the source, or `null` if errors
were not |
| 3465 * changed. | 3458 * changed. |
| 3466 * @return the line information associated with the source | 3459 * @return the line information associated with the source |
| 3467 */ | 3460 */ |
| 3468 LineInfo get lineInfo => _lineInfo; | 3461 LineInfo get lineInfo => _lineInfo; |
| 3469 | 3462 |
| 3470 /** | 3463 /** |
| 3471 * Return the source for which the result is being reported. | 3464 * Return the source for which the result is being reported. |
| 3472 * @return the source for which the result is being reported | 3465 * @return the source for which the result is being reported |
| 3473 */ | 3466 */ |
| 3474 Source get source => _source; | 3467 Source get source => _source; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3486 * information to the given line information. | 3479 * information to the given line information. |
| 3487 * @param errors the errors that changed as a result of the analysis | 3480 * @param errors the errors that changed as a result of the analysis |
| 3488 * @param lineInfo the line information associated with the source | 3481 * @param lineInfo the line information associated with the source |
| 3489 */ | 3482 */ |
| 3490 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { | 3483 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { |
| 3491 this._errors = errors2; | 3484 this._errors = errors2; |
| 3492 this._lineInfo = lineInfo2; | 3485 this._lineInfo = lineInfo2; |
| 3493 } | 3486 } |
| 3494 } | 3487 } |
| 3495 /** | 3488 /** |
| 3496 * Instances of the class {@code DelegatingAnalysisContextImpl} extend {@link An
alysisContextImplanalysis context} to delegate sources to the appropriate analys
is context. For instance, if the | 3489 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex
tImplanalysis context] to delegate sources to the appropriate analysis context.
For instance, if the |
| 3497 * source is in a system library then the analysis context from the {@link DartS
dk} is used. | 3490 * source is in a system library then the analysis context from the [DartSdk] is
used. |
| 3498 * @coverage dart.engine | 3491 * @coverage dart.engine |
| 3499 */ | 3492 */ |
| 3500 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { | 3493 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { |
| 3501 | 3494 |
| 3502 /** | 3495 /** |
| 3503 * This references the {@link InternalAnalysisContext} held onto by the {@link
DartSdk} which is | 3496 * This references the [InternalAnalysisContext] held onto by the [DartSdk] wh
ich is |
| 3504 * used (instead of this {@link AnalysisContext}) for SDK sources. This field
is set when | 3497 * used (instead of this [AnalysisContext]) for SDK sources. This field is set
when |
| 3505 * #setSourceFactory(SourceFactory) is called, and references the analysis con
text in the{@link DartUriResolver} in the {@link SourceFactory}, this analysis c
ontext assumes that there | 3498 * #setSourceFactory(SourceFactory) is called, and references the analysis con
text in the[DartUriResolver] in the [SourceFactory], this analysis context assum
es that there |
| 3506 * will be such a resolver. | 3499 * will be such a resolver. |
| 3507 */ | 3500 */ |
| 3508 InternalAnalysisContext _sdkAnalysisContext; | 3501 InternalAnalysisContext _sdkAnalysisContext; |
| 3509 void addSourceInfo(Source source, SourceEntry info) { | 3502 void addSourceInfo(Source source, SourceEntry info) { |
| 3510 if (source.isInSystemLibrary()) { | 3503 if (source.isInSystemLibrary()) { |
| 3511 _sdkAnalysisContext.addSourceInfo(source, info); | 3504 _sdkAnalysisContext.addSourceInfo(source, info); |
| 3512 } else { | 3505 } else { |
| 3513 super.addSourceInfo(source, info); | 3506 super.addSourceInfo(source, info); |
| 3514 } | 3507 } |
| 3515 } | 3508 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3716 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { | 3709 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { |
| 3717 _sdkAnalysisContext = null; | 3710 _sdkAnalysisContext = null; |
| 3718 throw new IllegalStateException("The context provided by an SDK cannot i
tself be a delegating analysis context"); | 3711 throw new IllegalStateException("The context provided by an SDK cannot i
tself be a delegating analysis context"); |
| 3719 } | 3712 } |
| 3720 } else { | 3713 } else { |
| 3721 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal
ysisContextImpls must have a DartSdk associated with the provided SourceFactory.
"); | 3714 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal
ysisContextImpls must have a DartSdk associated with the provided SourceFactory.
"); |
| 3722 } | 3715 } |
| 3723 } | 3716 } |
| 3724 } | 3717 } |
| 3725 /** | 3718 /** |
| 3726 * Instances of the class {@code InstrumentedAnalysisContextImpl} implement an{@
link AnalysisContext analysis context} by recording instrumentation data and del
egating to | 3719 * Instances of the class `InstrumentedAnalysisContextImpl` implement an[Analysi
sContext analysis context] by recording instrumentation data and delegating to |
| 3727 * another analysis context to do the non-instrumentation work. | 3720 * another analysis context to do the non-instrumentation work. |
| 3728 * @coverage dart.engine | 3721 * @coverage dart.engine |
| 3729 */ | 3722 */ |
| 3730 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { | 3723 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { |
| 3731 | 3724 |
| 3732 /** | 3725 /** |
| 3733 * Record an exception that was thrown during analysis. | 3726 * Record an exception that was thrown during analysis. |
| 3734 * @param instrumentation the instrumentation builder being used to record the
exception | 3727 * @param instrumentation the instrumentation builder being used to record the
exception |
| 3735 * @param exception the exception being reported | 3728 * @param exception the exception being reported |
| 3736 */ | 3729 */ |
| 3737 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { | 3730 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { |
| 3738 instrumentation.record(exception); | 3731 instrumentation.record(exception); |
| 3739 } | 3732 } |
| 3740 | 3733 |
| 3741 /** | 3734 /** |
| 3742 * The unique identifier used to identify this analysis context in the instrum
entation data. | 3735 * The unique identifier used to identify this analysis context in the instrum
entation data. |
| 3743 */ | 3736 */ |
| 3744 String _contextId = UUID.randomUUID().toString(); | 3737 String _contextId = UUID.randomUUID().toString(); |
| 3745 | 3738 |
| 3746 /** | 3739 /** |
| 3747 * The analysis context to which all of the non-instrumentation work is delega
ted. | 3740 * The analysis context to which all of the non-instrumentation work is delega
ted. |
| 3748 */ | 3741 */ |
| 3749 InternalAnalysisContext _basis; | 3742 InternalAnalysisContext _basis; |
| 3750 | 3743 |
| 3751 /** | 3744 /** |
| 3752 * Create a new {@link InstrumentedAnalysisContextImpl} which wraps a new{@lin
k AnalysisContextImpl} as the basis context. | 3745 * Create a new [InstrumentedAnalysisContextImpl] which wraps a new[AnalysisCo
ntextImpl] as the basis context. |
| 3753 */ | 3746 */ |
| 3754 InstrumentedAnalysisContextImpl() { | 3747 InstrumentedAnalysisContextImpl() { |
| 3755 _jtd_constructor_183_impl(); | 3748 _jtd_constructor_183_impl(); |
| 3756 } | 3749 } |
| 3757 _jtd_constructor_183_impl() { | 3750 _jtd_constructor_183_impl() { |
| 3758 _jtd_constructor_184_impl(new AnalysisContextImpl()); | 3751 _jtd_constructor_184_impl(new AnalysisContextImpl()); |
| 3759 } | 3752 } |
| 3760 | 3753 |
| 3761 /** | 3754 /** |
| 3762 * Create a new {@link InstrumentedAnalysisContextImpl} with a specified basis
context, aka the | 3755 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte
xt, aka the |
| 3763 * context to wrap and instrument. | 3756 * context to wrap and instrument. |
| 3764 * @param context some {@link InstrumentedAnalysisContext} to wrap and instrum
ent | 3757 * @param context some [InstrumentedAnalysisContext] to wrap and instrument |
| 3765 */ | 3758 */ |
| 3766 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { | 3759 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { |
| 3767 _jtd_constructor_184_impl(context); | 3760 _jtd_constructor_184_impl(context); |
| 3768 } | 3761 } |
| 3769 _jtd_constructor_184_impl(InternalAnalysisContext context) { | 3762 _jtd_constructor_184_impl(InternalAnalysisContext context) { |
| 3770 _basis = context; | 3763 _basis = context; |
| 3771 } | 3764 } |
| 3772 void addSourceInfo(Source source, SourceEntry info) { | 3765 void addSourceInfo(Source source, SourceEntry info) { |
| 3773 _basis.addSourceInfo(source, info); | 3766 _basis.addSourceInfo(source, info); |
| 3774 } | 3767 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3863 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getAnalysisOptions"); | 3856 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getAnalysisOptions"); |
| 3864 try { | 3857 try { |
| 3865 instrumentation.metric3("contextId", _contextId); | 3858 instrumentation.metric3("contextId", _contextId); |
| 3866 return _basis.analysisOptions; | 3859 return _basis.analysisOptions; |
| 3867 } finally { | 3860 } finally { |
| 3868 instrumentation.log(); | 3861 instrumentation.log(); |
| 3869 } | 3862 } |
| 3870 } | 3863 } |
| 3871 | 3864 |
| 3872 /** | 3865 /** |
| 3873 * @return the underlying {@link AnalysisContext}. | 3866 * @return the underlying [AnalysisContext]. |
| 3874 */ | 3867 */ |
| 3875 AnalysisContext get basis => _basis; | 3868 AnalysisContext get basis => _basis; |
| 3876 Element getElement(ElementLocation location) { | 3869 Element getElement(ElementLocation location) { |
| 3877 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getElement"); | 3870 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getElement"); |
| 3878 try { | 3871 try { |
| 3879 instrumentation.metric3("contextId", _contextId); | 3872 instrumentation.metric3("contextId", _contextId); |
| 3880 return _basis.getElement(location); | 3873 return _basis.getElement(location); |
| 3881 } finally { | 3874 } finally { |
| 3882 instrumentation.log(); | 3875 instrumentation.log(); |
| 3883 } | 3876 } |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4188 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
sourcesToResolve"); | 4181 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
sourcesToResolve"); |
| 4189 try { | 4182 try { |
| 4190 instrumentation.metric3("contextId", _contextId); | 4183 instrumentation.metric3("contextId", _contextId); |
| 4191 return _basis.sourcesToResolve(changedSources); | 4184 return _basis.sourcesToResolve(changedSources); |
| 4192 } finally { | 4185 } finally { |
| 4193 instrumentation.log(); | 4186 instrumentation.log(); |
| 4194 } | 4187 } |
| 4195 } | 4188 } |
| 4196 } | 4189 } |
| 4197 /** | 4190 /** |
| 4198 * The interface {@code InternalAnalysisContext} defines additional behavior for
an analysis context | 4191 * The interface `InternalAnalysisContext` defines additional behavior for an an
alysis context |
| 4199 * that is required by internal users of the context. | 4192 * that is required by internal users of the context. |
| 4200 */ | 4193 */ |
| 4201 abstract class InternalAnalysisContext implements AnalysisContext { | 4194 abstract class InternalAnalysisContext implements AnalysisContext { |
| 4202 | 4195 |
| 4203 /** | 4196 /** |
| 4204 * Add the given source with the given information to this context. | 4197 * Add the given source with the given information to this context. |
| 4205 * @param source the source to be added | 4198 * @param source the source to be added |
| 4206 * @param info the information about the source | 4199 * @param info the information about the source |
| 4207 */ | 4200 */ |
| 4208 void addSourceInfo(Source source, SourceEntry info); | 4201 void addSourceInfo(Source source, SourceEntry info); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4246 | 4239 |
| 4247 /** | 4240 /** |
| 4248 * Given a table mapping the source for the libraries represented by the corre
sponding elements to | 4241 * Given a table mapping the source for the libraries represented by the corre
sponding elements to |
| 4249 * the elements representing the libraries, record those mappings. | 4242 * the elements representing the libraries, record those mappings. |
| 4250 * @param elementMap a table mapping the source for the libraries represented
by the elements to | 4243 * @param elementMap a table mapping the source for the libraries represented
by the elements to |
| 4251 * the elements representing the libraries | 4244 * the elements representing the libraries |
| 4252 */ | 4245 */ |
| 4253 void recordLibraryElements(Map<Source, LibraryElement> elementMap); | 4246 void recordLibraryElements(Map<Source, LibraryElement> elementMap); |
| 4254 } | 4247 } |
| 4255 /** | 4248 /** |
| 4256 * Instances of the class {@code RecordingErrorListener} implement an error list
ener that will | 4249 * Instances of the class `RecordingErrorListener` implement an error listener t
hat will |
| 4257 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors | 4250 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors |
| 4258 * within an analysis context. | 4251 * within an analysis context. |
| 4259 * @coverage dart.engine | 4252 * @coverage dart.engine |
| 4260 */ | 4253 */ |
| 4261 class RecordingErrorListener implements AnalysisErrorListener { | 4254 class RecordingErrorListener implements AnalysisErrorListener { |
| 4262 | 4255 |
| 4263 /** | 4256 /** |
| 4264 * A HashMap of lists containing the errors that were collected, keyed by each
{@link Source}. | 4257 * A HashMap of lists containing the errors that were collected, keyed by each
[Source]. |
| 4265 */ | 4258 */ |
| 4266 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError>
>(); | 4259 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError>
>(); |
| 4267 | 4260 |
| 4268 /** | 4261 /** |
| 4269 * Add all of the errors recorded by the given listener to this listener. | 4262 * Add all of the errors recorded by the given listener to this listener. |
| 4270 * @param listener the listener that has recorded the errors to be added | 4263 * @param listener the listener that has recorded the errors to be added |
| 4271 */ | 4264 */ |
| 4272 void addAll(RecordingErrorListener listener) { | 4265 void addAll(RecordingErrorListener listener) { |
| 4273 for (AnalysisError error in listener.errors) { | 4266 for (AnalysisError error in listener.errors) { |
| 4274 onError(error); | 4267 onError(error); |
| 4275 } | 4268 } |
| 4276 } | 4269 } |
| 4277 | 4270 |
| 4278 /** | 4271 /** |
| 4279 * Answer the errors collected by the listener. | 4272 * Answer the errors collected by the listener. |
| 4280 * @return an array of errors (not {@code null}, contains no {@code null}s) | 4273 * @return an array of errors (not `null`, contains no `null`s) |
| 4281 */ | 4274 */ |
| 4282 List<AnalysisError> get errors { | 4275 List<AnalysisError> get errors { |
| 4283 Iterable<MapEntry<Source, List<AnalysisError>>> entrySet = getMapEntrySet(_e
rrors); | 4276 Iterable<MapEntry<Source, List<AnalysisError>>> entrySet = getMapEntrySet(_e
rrors); |
| 4284 int numEntries = entrySet.length; | 4277 int numEntries = entrySet.length; |
| 4285 if (numEntries == 0) { | 4278 if (numEntries == 0) { |
| 4286 return AnalysisError.NO_ERRORS; | 4279 return AnalysisError.NO_ERRORS; |
| 4287 } | 4280 } |
| 4288 List<AnalysisError> resultList = new List<AnalysisError>(); | 4281 List<AnalysisError> resultList = new List<AnalysisError>(); |
| 4289 for (MapEntry<Source, List<AnalysisError>> entry in entrySet) { | 4282 for (MapEntry<Source, List<AnalysisError>> entry in entrySet) { |
| 4290 resultList.addAll(entry.getValue()); | 4283 resultList.addAll(entry.getValue()); |
| 4291 } | 4284 } |
| 4292 return new List.from(resultList); | 4285 return new List.from(resultList); |
| 4293 } | 4286 } |
| 4294 | 4287 |
| 4295 /** | 4288 /** |
| 4296 * Answer the errors collected by the listener for some passed {@link Source}. | 4289 * Answer the errors collected by the listener for some passed [Source]. |
| 4297 * @param source some {@link Source} for which the caller wants the set of {@l
ink AnalysisError}s | 4290 * @param source some [Source] for which the caller wants the set of [Analysis
Error]s |
| 4298 * collected by this listener | 4291 * collected by this listener |
| 4299 * @return the errors collected by the listener for the passed {@link Source} | 4292 * @return the errors collected by the listener for the passed [Source] |
| 4300 */ | 4293 */ |
| 4301 List<AnalysisError> getErrors2(Source source) { | 4294 List<AnalysisError> getErrors2(Source source) { |
| 4302 List<AnalysisError> errorsForSource = _errors[source]; | 4295 List<AnalysisError> errorsForSource = _errors[source]; |
| 4303 if (errorsForSource == null) { | 4296 if (errorsForSource == null) { |
| 4304 return AnalysisError.NO_ERRORS; | 4297 return AnalysisError.NO_ERRORS; |
| 4305 } else { | 4298 } else { |
| 4306 return new List.from(errorsForSource); | 4299 return new List.from(errorsForSource); |
| 4307 } | 4300 } |
| 4308 } | 4301 } |
| 4309 void onError(AnalysisError event) { | 4302 void onError(AnalysisError event) { |
| 4310 Source source = event.source; | 4303 Source source = event.source; |
| 4311 List<AnalysisError> errorsForSource = _errors[source]; | 4304 List<AnalysisError> errorsForSource = _errors[source]; |
| 4312 if (_errors[source] == null) { | 4305 if (_errors[source] == null) { |
| 4313 errorsForSource = new List<AnalysisError>(); | 4306 errorsForSource = new List<AnalysisError>(); |
| 4314 _errors[source] = errorsForSource; | 4307 _errors[source] = errorsForSource; |
| 4315 } | 4308 } |
| 4316 errorsForSource.add(event); | 4309 errorsForSource.add(event); |
| 4317 } | 4310 } |
| 4318 } | 4311 } |
| 4319 /** | 4312 /** |
| 4320 * Instances of the class {@code ResolutionEraser} remove any resolution informa
tion from an AST | 4313 * Instances of the class `ResolutionEraser` remove any resolution information f
rom an AST |
| 4321 * structure when used to visit that structure. | 4314 * structure when used to visit that structure. |
| 4322 */ | 4315 */ |
| 4323 class ResolutionEraser extends GeneralizingASTVisitor<Object> { | 4316 class ResolutionEraser extends GeneralizingASTVisitor<Object> { |
| 4324 Object visitAssignmentExpression(AssignmentExpression node) { | 4317 Object visitAssignmentExpression(AssignmentExpression node) { |
| 4325 node.element = null; | 4318 node.element = null; |
| 4326 return super.visitAssignmentExpression(node); | 4319 return super.visitAssignmentExpression(node); |
| 4327 } | 4320 } |
| 4328 Object visitBinaryExpression(BinaryExpression node) { | 4321 Object visitBinaryExpression(BinaryExpression node) { |
| 4329 node.element = null; | 4322 node.element = null; |
| 4330 return super.visitBinaryExpression(node); | 4323 return super.visitBinaryExpression(node); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4381 Object visitSimpleIdentifier(SimpleIdentifier node) { | 4374 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 4382 node.element = null; | 4375 node.element = null; |
| 4383 return super.visitSimpleIdentifier(node); | 4376 return super.visitSimpleIdentifier(node); |
| 4384 } | 4377 } |
| 4385 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 4378 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 4386 node.element = null; | 4379 node.element = null; |
| 4387 return super.visitSuperConstructorInvocation(node); | 4380 return super.visitSuperConstructorInvocation(node); |
| 4388 } | 4381 } |
| 4389 } | 4382 } |
| 4390 /** | 4383 /** |
| 4391 * The interface {@code Logger} defines the behavior of objects that can be used
to receive | 4384 * The interface `Logger` defines the behavior of objects that can be used to re
ceive |
| 4392 * information about errors within the analysis engine. Implementations usually
write this | 4385 * information about errors within the analysis engine. Implementations usually
write this |
| 4393 * information to a file, but can also record the information for later use (suc
h as during testing) | 4386 * information to a file, but can also record the information for later use (suc
h as during testing) |
| 4394 * or even ignore the information. | 4387 * or even ignore the information. |
| 4395 * @coverage dart.engine.utilities | 4388 * @coverage dart.engine.utilities |
| 4396 */ | 4389 */ |
| 4397 abstract class Logger { | 4390 abstract class Logger { |
| 4398 static final Logger NULL = new Logger_NullLogger(); | 4391 static final Logger NULL = new Logger_NullLogger(); |
| 4399 | 4392 |
| 4400 /** | 4393 /** |
| 4401 * Log the given message as an error. | 4394 * Log the given message as an error. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4424 void logInformation(String message); | 4417 void logInformation(String message); |
| 4425 | 4418 |
| 4426 /** | 4419 /** |
| 4427 * Log the given exception as one representing an informational message. | 4420 * Log the given exception as one representing an informational message. |
| 4428 * @param message an explanation of why the error occurred or what it means | 4421 * @param message an explanation of why the error occurred or what it means |
| 4429 * @param exception the exception being logged | 4422 * @param exception the exception being logged |
| 4430 */ | 4423 */ |
| 4431 void logInformation2(String message, Exception exception); | 4424 void logInformation2(String message, Exception exception); |
| 4432 } | 4425 } |
| 4433 /** | 4426 /** |
| 4434 * Implementation of {@link Logger} that does nothing. | 4427 * Implementation of [Logger] that does nothing. |
| 4435 */ | 4428 */ |
| 4436 class Logger_NullLogger implements Logger { | 4429 class Logger_NullLogger implements Logger { |
| 4437 void logError(String message) { | 4430 void logError(String message) { |
| 4438 } | 4431 } |
| 4439 void logError2(String message, Exception exception) { | 4432 void logError2(String message, Exception exception) { |
| 4440 } | 4433 } |
| 4441 void logError3(Exception exception) { | 4434 void logError3(Exception exception) { |
| 4442 } | 4435 } |
| 4443 void logInformation(String message) { | 4436 void logInformation(String message) { |
| 4444 } | 4437 } |
| 4445 void logInformation2(String message, Exception exception) { | 4438 void logInformation2(String message, Exception exception) { |
| 4446 } | 4439 } |
| 4447 } | 4440 } |
| OLD | NEW |