| 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 | 3 |
| 4 library engine; | 4 library engine; |
| 5 | 5 |
| 6 import 'dart:collection' show HasNextIterator; | 6 import 'dart:collection' show HasNextIterator; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'java_engine.dart'; | 8 import 'java_engine.dart'; |
| 9 import 'instrumentation.dart'; | 9 import 'instrumentation.dart'; |
| 10 import 'error.dart'; | 10 import 'error.dart'; |
| 11 import 'source.dart'; | 11 import 'source.dart'; |
| 12 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; | 12 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; |
| 13 import 'ast.dart'; | 13 import 'ast.dart'; |
| 14 import 'parser.dart' show Parser; | 14 import 'parser.dart' show Parser; |
| 15 import 'sdk.dart' show DartSdk; | 15 import 'sdk.dart' show DartSdk; |
| 16 import 'element.dart'; | 16 import 'element.dart'; |
| 17 import 'resolver.dart'; | 17 import 'resolver.dart'; |
| 18 import 'html.dart' show XmlTagNode, XmlAttributeNode, RecursiveXmlVisitor, HtmlS
canner, HtmlScanResult, HtmlParser, HtmlParseResult, HtmlUnit; | 18 import 'html.dart' show XmlTagNode, XmlAttributeNode, RecursiveXmlVisitor, HtmlS
canner, HtmlScanResult, HtmlParser, HtmlParseResult, HtmlUnit; |
| 19 | 19 |
| 20 |
| 20 /** | 21 /** |
| 21 * The unique instance of the class {@code AnalysisEngine} serves as the entry p
oint for the | 22 * The unique instance of the class {@code AnalysisEngine} serves as the entry p
oint for the |
| 22 * functionality provided by the analysis engine. | 23 * functionality provided by the analysis engine. |
| 23 * @coverage dart.engine | 24 * @coverage dart.engine |
| 24 */ | 25 */ |
| 25 class AnalysisEngine { | 26 class AnalysisEngine { |
| 27 |
| 26 /** | 28 /** |
| 27 * The suffix used for Dart source files. | 29 * The suffix used for Dart source files. |
| 28 */ | 30 */ |
| 29 static String SUFFIX_DART = "dart"; | 31 static String SUFFIX_DART = "dart"; |
| 32 |
| 30 /** | 33 /** |
| 31 * The short suffix used for HTML files. | 34 * The short suffix used for HTML files. |
| 32 */ | 35 */ |
| 33 static String SUFFIX_HTM = "htm"; | 36 static String SUFFIX_HTM = "htm"; |
| 37 |
| 34 /** | 38 /** |
| 35 * The long suffix used for HTML files. | 39 * The long suffix used for HTML files. |
| 36 */ | 40 */ |
| 37 static String SUFFIX_HTML = "html"; | 41 static String SUFFIX_HTML = "html"; |
| 42 |
| 38 /** | 43 /** |
| 39 * The unique instance of this class. | 44 * The unique instance of this class. |
| 40 */ | 45 */ |
| 41 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); | 46 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); |
| 47 |
| 42 /** | 48 /** |
| 43 * Return the unique instance of this class. | 49 * Return the unique instance of this class. |
| 44 * @return the unique instance of this class | 50 * @return the unique instance of this class |
| 45 */ | 51 */ |
| 46 static AnalysisEngine get instance => _UniqueInstance; | 52 static AnalysisEngine get instance => _UniqueInstance; |
| 53 |
| 47 /** | 54 /** |
| 48 * Return {@code true} if the given file name is assumed to contain Dart sourc
e code. | 55 * Return {@code true} if the given file name is assumed to contain Dart sourc
e code. |
| 49 * @param fileName the name of the file being tested | 56 * @param fileName the name of the file being tested |
| 50 * @return {@code true} if the given file name is assumed to contain Dart sour
ce code | 57 * @return {@code true} if the given file name is assumed to contain Dart sour
ce code |
| 51 */ | 58 */ |
| 52 static bool isDartFileName(String fileName) { | 59 static bool isDartFileName(String fileName) { |
| 53 if (fileName == null) { | 60 if (fileName == null) { |
| 54 return false; | 61 return false; |
| 55 } | 62 } |
| 56 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName),
SUFFIX_DART); | 63 return javaStringEqualsIgnoreCase(FileNameUtilities.getExtension(fileName),
SUFFIX_DART); |
| 57 } | 64 } |
| 65 |
| 58 /** | 66 /** |
| 59 * Return {@code true} if the given file name is assumed to contain HTML. | 67 * Return {@code true} if the given file name is assumed to contain HTML. |
| 60 * @param fileName the name of the file being tested | 68 * @param fileName the name of the file being tested |
| 61 * @return {@code true} if the given file name is assumed to contain HTML | 69 * @return {@code true} if the given file name is assumed to contain HTML |
| 62 */ | 70 */ |
| 63 static bool isHtmlFileName(String fileName) { | 71 static bool isHtmlFileName(String fileName) { |
| 64 if (fileName == null) { | 72 if (fileName == null) { |
| 65 return false; | 73 return false; |
| 66 } | 74 } |
| 67 String extension = FileNameUtilities.getExtension(fileName); | 75 String extension = FileNameUtilities.getExtension(fileName); |
| 68 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual
sIgnoreCase(extension, SUFFIX_HTM); | 76 return javaStringEqualsIgnoreCase(extension, SUFFIX_HTML) || javaStringEqual
sIgnoreCase(extension, SUFFIX_HTM); |
| 69 } | 77 } |
| 78 |
| 70 /** | 79 /** |
| 71 * The logger that should receive information about errors within the analysis
engine. | 80 * The logger that should receive information about errors within the analysis
engine. |
| 72 */ | 81 */ |
| 73 Logger _logger = Logger.NULL; | 82 Logger _logger = Logger.NULL; |
| 74 /** | 83 |
| 75 * Prevent the creation of instances of this class. | |
| 76 */ | |
| 77 AnalysisEngine() : super() { | |
| 78 } | |
| 79 /** | 84 /** |
| 80 * Create a new context in which analysis can be performed. | 85 * Create a new context in which analysis can be performed. |
| 81 * @return the analysis context that was created | 86 * @return the analysis context that was created |
| 82 */ | 87 */ |
| 83 AnalysisContext createAnalysisContext() { | 88 AnalysisContext createAnalysisContext() { |
| 84 if (Instrumentation.isNullLogger()) { | 89 if (Instrumentation.isNullLogger()) { |
| 85 return new DelegatingAnalysisContextImpl(); | 90 return new DelegatingAnalysisContextImpl(); |
| 86 } else { | 91 } else { |
| 87 return new InstrumentedAnalysisContextImpl.con1(new DelegatingAnalysisCont
extImpl()); | 92 return new InstrumentedAnalysisContextImpl.con1(new DelegatingAnalysisCont
extImpl()); |
| 88 } | 93 } |
| 89 } | 94 } |
| 95 |
| 90 /** | 96 /** |
| 91 * Return the logger that should receive information about errors within the a
nalysis engine. | 97 * Return the logger that should receive information about errors within the a
nalysis engine. |
| 92 * @return the logger that should receive information about errors within the
analysis engine | 98 * @return the logger that should receive information about errors within the
analysis engine |
| 93 */ | 99 */ |
| 94 Logger get logger => _logger; | 100 Logger get logger => _logger; |
| 101 |
| 95 /** | 102 /** |
| 96 * Set the logger that should receive information about errors within the anal
ysis engine to the | 103 * Set the logger that should receive information about errors within the anal
ysis engine to the |
| 97 * given logger. | 104 * given logger. |
| 98 * @param logger the logger that should receive information about errors withi
n the analysis | 105 * @param logger the logger that should receive information about errors withi
n the analysis |
| 99 * engine | 106 * engine |
| 100 */ | 107 */ |
| 101 void set logger(Logger logger2) { | 108 void set logger(Logger logger2) { |
| 102 this._logger = logger2 == null ? Logger.NULL : logger2; | 109 this._logger = logger2 == null ? Logger.NULL : logger2; |
| 103 } | 110 } |
| 104 } | 111 } |
| 112 |
| 105 /** | 113 /** |
| 106 * The interface {@code AnalysisContext} defines the behavior of objects that re
present a context in | 114 * The interface {@code AnalysisContext} defines the behavior of objects that re
present a context in |
| 107 * which a single analysis can be performed and incrementally maintained. The co
ntext includes such | 115 * which a single analysis can be performed and incrementally maintained. The co
ntext includes such |
| 108 * information as the version of the SDK being analyzed against as well as the p
ackage-root used to | 116 * information as the version of the SDK being analyzed against as well as the p
ackage-root used to |
| 109 * resolve 'package:' URI's. (Both of which are known indirectly through the {@l
ink SourceFactorysource factory}.) | 117 * resolve 'package:' URI's. (Both of which are known indirectly through the {@l
ink SourceFactorysource factory}.) |
| 110 * <p> | 118 * <p> |
| 111 * An analysis context also represents the state of the analysis, which includes
knowing which | 119 * An analysis context also represents the state of the analysis, which includes
knowing which |
| 112 * sources have been included in the analysis (either directly or indirectly) an
d the results of the | 120 * sources have been included in the analysis (either directly or indirectly) an
d the results of the |
| 113 * 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 | 121 * analysis. Sources must be added and removed from the context using the method
{@link #applyChanges(ChangeSet)}, which is also used to notify the context when
sources have been |
| 114 * modified and, consequently, previously known results might have been invalida
ted. | 122 * modified and, consequently, previously known results might have been invalida
ted. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 128 * up-to-date. For such clients there is a mechanism that allows them to increme
ntally perform | 136 * up-to-date. For such clients there is a mechanism that allows them to increme
ntally perform |
| 129 * needed analysis and get notified of the consequent changes to the analysis re
sults. This | 137 * needed analysis and get notified of the consequent changes to the analysis re
sults. This |
| 130 * mechanism is realized by the method {@link #performAnalysisTask()}. | 138 * mechanism is realized by the method {@link #performAnalysisTask()}. |
| 131 * <p> | 139 * <p> |
| 132 * Analysis engine allows for having more than one context. This can be used, fo
r example, to | 140 * Analysis engine allows for having more than one context. This can be used, fo
r example, to |
| 133 * perform one analysis based on the state of files on disk and a separate analy
sis based on the | 141 * perform one analysis based on the state of files on disk and a separate analy
sis based on the |
| 134 * state of those files in open editors. It can also be used to perform an analy
sis based on a | 142 * state of those files in open editors. It can also be used to perform an analy
sis based on a |
| 135 * proposed future state, such as the state after a refactoring. | 143 * proposed future state, such as the state after a refactoring. |
| 136 */ | 144 */ |
| 137 abstract class AnalysisContext { | 145 abstract class AnalysisContext { |
| 146 |
| 138 /** | 147 /** |
| 139 * Apply the changes specified by the given change set to this context. Any an
alysis results that | 148 * Apply the changes specified by the given change set to this context. Any an
alysis results that |
| 140 * have been invalidated by these changes will be removed. | 149 * have been invalidated by these changes will be removed. |
| 141 * @param changeSet a description of the changes that are to be applied | 150 * @param changeSet a description of the changes that are to be applied |
| 142 */ | 151 */ |
| 143 void applyChanges(ChangeSet changeSet); | 152 void applyChanges(ChangeSet changeSet); |
| 153 |
| 144 /** | 154 /** |
| 145 * Return the documentation comment for the given element as it appears in the
original source | 155 * Return the documentation comment for the given element as it appears in the
original source |
| 146 * (complete with the beginning and ending delimiters), or {@code null} if the
element does not | 156 * (complete with the beginning and ending delimiters), or {@code null} if the
element does not |
| 147 * have a documentation comment associated with it. This can be a long-running
operation if the | 157 * have a documentation comment associated with it. This can be a long-running
operation if the |
| 148 * information needed to access the comment is not cached. | 158 * information needed to access the comment is not cached. |
| 149 * @param element the element whose documentation comment is to be returned | 159 * @param element the element whose documentation comment is to be returned |
| 150 * @return the element's documentation comment | 160 * @return the element's documentation comment |
| 151 * @throws AnalysisException if the documentation comment could not be determi
ned because the | 161 * @throws AnalysisException if the documentation comment could not be determi
ned because the |
| 152 * analysis could not be performed | 162 * analysis could not be performed |
| 153 */ | 163 */ |
| 154 String computeDocumentationComment(Element element); | 164 String computeDocumentationComment(Element element); |
| 165 |
| 155 /** | 166 /** |
| 156 * Return an array containing all of the errors associated with the given sour
ce. If the errors | 167 * Return an array containing all of the errors associated with the given sour
ce. If the errors |
| 157 * are not already known then the source will be analyzed in order to determin
e the errors | 168 * are not already known then the source will be analyzed in order to determin
e the errors |
| 158 * associated with it. | 169 * associated with it. |
| 159 * @param source the source whose errors are to be returned | 170 * @param source the source whose errors are to be returned |
| 160 * @return all of the errors associated with the given source | 171 * @return all of the errors associated with the given source |
| 161 * @throws AnalysisException if the errors could not be determined because the
analysis could not | 172 * @throws AnalysisException if the errors could not be determined because the
analysis could not |
| 162 * be performed | 173 * be performed |
| 163 * @see #getErrors(Source) | 174 * @see #getErrors(Source) |
| 164 */ | 175 */ |
| 165 List<AnalysisError> computeErrors(Source source); | 176 List<AnalysisError> computeErrors(Source source); |
| 177 |
| 166 /** | 178 /** |
| 167 * Return the element model corresponding to the HTML file defined by the give
n source. If the | 179 * Return the element model corresponding to the HTML file defined by the give
n source. If the |
| 168 * element model does not yet exist it will be created. The process of creatin
g an element model | 180 * element model does not yet exist it will be created. The process of creatin
g an element model |
| 169 * for an HTML file can long-running, depending on the size of the file and th
e number of | 181 * for an HTML file can long-running, depending on the size of the file and th
e number of |
| 170 * libraries that are defined in it (via script tags) that also need to have a
model built for | 182 * libraries that are defined in it (via script tags) that also need to have a
model built for |
| 171 * them. | 183 * them. |
| 172 * @param source the source defining the HTML file whose element model is to b
e returned | 184 * @param source the source defining the HTML file whose element model is to b
e returned |
| 173 * @return the element model corresponding to the HTML file defined by the giv
en source | 185 * @return the element model corresponding to the HTML file defined by the giv
en source |
| 174 * @throws AnalysisException if the element model could not be determined beca
use the analysis | 186 * @throws AnalysisException if the element model could not be determined beca
use the analysis |
| 175 * could not be performed | 187 * could not be performed |
| 176 * @see #getHtmlElement(Source) | 188 * @see #getHtmlElement(Source) |
| 177 */ | 189 */ |
| 178 HtmlElement computeHtmlElement(Source source); | 190 HtmlElement computeHtmlElement(Source source); |
| 191 |
| 179 /** | 192 /** |
| 180 * 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. | 193 * Return the kind of the given source, computing it's kind if it is not alrea
dy known. Return{@link SourceKind#UNKNOWN} if the source is not contained in thi
s context. |
| 181 * @param source the source whose kind is to be returned | 194 * @param source the source whose kind is to be returned |
| 182 * @return the kind of the given source | 195 * @return the kind of the given source |
| 183 * @see #getKindOf(Source) | 196 * @see #getKindOf(Source) |
| 184 */ | 197 */ |
| 185 SourceKind computeKindOf(Source source); | 198 SourceKind computeKindOf(Source source); |
| 199 |
| 186 /** | 200 /** |
| 187 * Return the element model corresponding to the library defined by the given
source. If the | 201 * Return the element model corresponding to the library defined by the given
source. If the |
| 188 * element model does not yet exist it will be created. The process of creatin
g an element model | 202 * element model does not yet exist it will be created. The process of creatin
g an element model |
| 189 * for a library can long-running, depending on the size of the library and th
e number of | 203 * for a library can long-running, depending on the size of the library and th
e number of |
| 190 * libraries that are imported into it that also need to have a model built fo
r them. | 204 * libraries that are imported into it that also need to have a model built fo
r them. |
| 191 * @param source the source defining the library whose element model is to be
returned | 205 * @param source the source defining the library whose element model is to be
returned |
| 192 * @return the element model corresponding to the library defined by the given
source | 206 * @return the element model corresponding to the library defined by the given
source |
| 193 * @throws AnalysisException if the element model could not be determined beca
use the analysis | 207 * @throws AnalysisException if the element model could not be determined beca
use the analysis |
| 194 * could not be performed | 208 * could not be performed |
| 195 * @see #getLibraryElement(Source) | 209 * @see #getLibraryElement(Source) |
| 196 */ | 210 */ |
| 197 LibraryElement computeLibraryElement(Source source); | 211 LibraryElement computeLibraryElement(Source source); |
| 212 |
| 198 /** | 213 /** |
| 199 * Return the line information for the given source, or {@code null} if the so
urce is not of a | 214 * Return the line information for the given source, or {@code null} if the so
urce is not of a |
| 200 * recognized kind (neither a Dart nor HTML file). If the line information was
not previously | 215 * recognized kind (neither a Dart nor HTML file). If the line information was
not previously |
| 201 * known it will be created. The line information is used to map offsets from
the beginning of the | 216 * known it will be created. The line information is used to map offsets from
the beginning of the |
| 202 * source to line and column pairs. | 217 * source to line and column pairs. |
| 203 * @param source the source whose line information is to be returned | 218 * @param source the source whose line information is to be returned |
| 204 * @return the line information for the given source | 219 * @return the line information for the given source |
| 205 * @throws AnalysisException if the line information could not be determined b
ecause the analysis | 220 * @throws AnalysisException if the line information could not be determined b
ecause the analysis |
| 206 * could not be performed | 221 * could not be performed |
| 207 * @see #getLineInfo(Source) | 222 * @see #getLineInfo(Source) |
| 208 */ | 223 */ |
| 209 LineInfo computeLineInfo(Source source); | 224 LineInfo computeLineInfo(Source source); |
| 225 |
| 210 /** | 226 /** |
| 211 * Create a new context in which analysis can be performed. Any sources in the
specified container | 227 * Create a new context in which analysis can be performed. Any sources in the
specified container |
| 212 * will be removed from this context and added to the newly created context. | 228 * will be removed from this context and added to the newly created context. |
| 213 * @param container the container containing sources that should be removed fr
om this context and | 229 * @param container the container containing sources that should be removed fr
om this context and |
| 214 * added to the returned context | 230 * added to the returned context |
| 215 * @return the analysis context that was created | 231 * @return the analysis context that was created |
| 216 */ | 232 */ |
| 217 AnalysisContext extractContext(SourceContainer container); | 233 AnalysisContext extractContext(SourceContainer container); |
| 234 |
| 235 /** |
| 236 * Return the set of analysis options controlling the behavior of this context
. |
| 237 * @return the set of analysis options controlling the behavior of this contex
t |
| 238 */ |
| 239 AnalysisOptions get analysisOptions; |
| 240 |
| 218 /** | 241 /** |
| 219 * Return the element referenced by the given location, or {@code null} if the
element is not | 242 * Return the element referenced by the given location, or {@code null} if the
element is not |
| 220 * immediately available or if there is no element with the given location. Th
e latter condition | 243 * immediately available or if there is no element with the given location. Th
e latter condition |
| 221 * can occur, for example, if the location describes an element from a differe
nt context or if the | 244 * can occur, for example, if the location describes an element from a differe
nt context or if the |
| 222 * element has been removed from this context as a result of some change since
it was originally | 245 * element has been removed from this context as a result of some change since
it was originally |
| 223 * obtained. | 246 * obtained. |
| 224 * @param location the reference describing the element to be returned | 247 * @param location the reference describing the element to be returned |
| 225 * @return the element referenced by the given location | 248 * @return the element referenced by the given location |
| 226 */ | 249 */ |
| 227 Element getElement(ElementLocation location); | 250 Element getElement(ElementLocation location); |
| 251 |
| 228 /** | 252 /** |
| 229 * Return an analysis error info containing the array of all of the errors and
the line info | 253 * Return an analysis error info containing the array of all of the errors and
the line info |
| 230 * associated with the given source. The array of errors will be empty if the
source is not known | 254 * associated with the given source. The array of errors will be empty if the
source is not known |
| 231 * to this context or if there are no errors in the source. The errors contain
ed in the array can | 255 * to this context or if there are no errors in the source. The errors contain
ed in the array can |
| 232 * be incomplete. | 256 * be incomplete. |
| 233 * @param source the source whose errors are to be returned | 257 * @param source the source whose errors are to be returned |
| 234 * @return all of the errors associated with the given source and the line inf
o | 258 * @return all of the errors associated with the given source and the line inf
o |
| 235 * @see #computeErrors(Source) | 259 * @see #computeErrors(Source) |
| 236 */ | 260 */ |
| 237 AnalysisErrorInfo getErrors(Source source); | 261 AnalysisErrorInfo getErrors(Source source); |
| 262 |
| 238 /** | 263 /** |
| 239 * 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 | 264 * Return the element model corresponding to the HTML file defined by the give
n source, or{@code null} if the source does not represent an HTML file, the elem
ent representing the file |
| 240 * has not yet been created, or the analysis of the HTML file failed for some
reason. | 265 * has not yet been created, or the analysis of the HTML file failed for some
reason. |
| 241 * @param source the source defining the HTML file whose element model is to b
e returned | 266 * @param source the source defining the HTML file whose element model is to b
e returned |
| 242 * @return the element model corresponding to the HTML file defined by the giv
en source | 267 * @return the element model corresponding to the HTML file defined by the giv
en source |
| 243 * @see #computeHtmlElement(Source) | 268 * @see #computeHtmlElement(Source) |
| 244 */ | 269 */ |
| 245 HtmlElement getHtmlElement(Source source); | 270 HtmlElement getHtmlElement(Source source); |
| 271 |
| 246 /** | 272 /** |
| 247 * Return the sources for the HTML files that reference the given compilation
unit. If the source | 273 * Return the sources for the HTML files that reference the given compilation
unit. If the source |
| 248 * does not represent a Dart source or is not known to this context, the retur
ned array will be | 274 * does not represent a Dart source or is not known to this context, the retur
ned array will be |
| 249 * empty. The contents of the array can be incomplete. | 275 * empty. The contents of the array can be incomplete. |
| 250 * @param source the source referenced by the returned HTML files | 276 * @param source the source referenced by the returned HTML files |
| 251 * @return the sources for the HTML files that reference the given compilation
unit | 277 * @return the sources for the HTML files that reference the given compilation
unit |
| 252 */ | 278 */ |
| 253 List<Source> getHtmlFilesReferencing(Source source); | 279 List<Source> getHtmlFilesReferencing(Source source); |
| 280 |
| 254 /** | 281 /** |
| 255 * Return an array containing all of the sources known to this context that re
present HTML files. | 282 * Return an array containing all of the sources known to this context that re
present HTML files. |
| 256 * The contents of the array can be incomplete. | 283 * The contents of the array can be incomplete. |
| 257 * @return the sources known to this context that represent HTML files | 284 * @return the sources known to this context that represent HTML files |
| 258 */ | 285 */ |
| 259 List<Source> get htmlSources; | 286 List<Source> get htmlSources; |
| 287 |
| 260 /** | 288 /** |
| 261 * Return the kind of the given source, or {@code null} if the kind is not kno
wn to this context. | 289 * Return the kind of the given source, or {@code null} if the kind is not kno
wn to this context. |
| 262 * @param source the source whose kind is to be returned | 290 * @param source the source whose kind is to be returned |
| 263 * @return the kind of the given source | 291 * @return the kind of the given source |
| 264 * @see #computeKindOf(Source) | 292 * @see #computeKindOf(Source) |
| 265 */ | 293 */ |
| 266 SourceKind getKindOf(Source source); | 294 SourceKind getKindOf(Source source); |
| 295 |
| 267 /** | 296 /** |
| 268 * Return an array containing all of the sources known to this context that re
present the defining | 297 * Return an array containing all of the sources known to this context that re
present the defining |
| 269 * compilation unit of a library that can be run within a browser. The sources
that are returned | 298 * compilation unit of a library that can be run within a browser. The sources
that are returned |
| 270 * represent libraries that have a 'main' method and are either referenced by
an HTML file or | 299 * represent libraries that have a 'main' method and are either referenced by
an HTML file or |
| 271 * import, directly or indirectly, a client-only library. The contents of the
array can be | 300 * import, directly or indirectly, a client-only library. The contents of the
array can be |
| 272 * incomplete. | 301 * incomplete. |
| 273 * @return the sources known to this context that represent the defining compi
lation unit of a | 302 * @return the sources known to this context that represent the defining compi
lation unit of a |
| 274 * library that can be run within a browser | 303 * library that can be run within a browser |
| 275 */ | 304 */ |
| 276 List<Source> get launchableClientLibrarySources; | 305 List<Source> get launchableClientLibrarySources; |
| 306 |
| 277 /** | 307 /** |
| 278 * Return an array containing all of the sources known to this context that re
present the defining | 308 * Return an array containing all of the sources known to this context that re
present the defining |
| 279 * compilation unit of a library that can be run outside of a browser. The con
tents of the array | 309 * compilation unit of a library that can be run outside of a browser. The con
tents of the array |
| 280 * can be incomplete. | 310 * can be incomplete. |
| 281 * @return the sources known to this context that represent the defining compi
lation unit of a | 311 * @return the sources known to this context that represent the defining compi
lation unit of a |
| 282 * library that can be run outside of a browser | 312 * library that can be run outside of a browser |
| 283 */ | 313 */ |
| 284 List<Source> get launchableServerLibrarySources; | 314 List<Source> get launchableServerLibrarySources; |
| 315 |
| 285 /** | 316 /** |
| 286 * Return the sources for the defining compilation units of any libraries of w
hich the given | 317 * Return the sources for the defining compilation units of any libraries of w
hich the given |
| 287 * source is a part. The array will normally contain a single library because
most Dart sources | 318 * source is a part. The array will normally contain a single library because
most Dart sources |
| 288 * are only included in a single library, but it is possible to have a part th
at is contained in | 319 * are only included in a single library, but it is possible to have a part th
at is contained in |
| 289 * multiple identically named libraries. If the source represents the defining
compilation unit of | 320 * multiple identically named libraries. If the source represents the defining
compilation unit of |
| 290 * a library, then the returned array will contain the given source as its onl
y element. If the | 321 * a library, then the returned array will contain the given source as its onl
y element. If the |
| 291 * source does not represent a Dart source or is not known to this context, th
e returned array | 322 * source does not represent a Dart source or is not known to this context, th
e returned array |
| 292 * will be empty. The contents of the array can be incomplete. | 323 * will be empty. The contents of the array can be incomplete. |
| 293 * @param source the source contained in the returned libraries | 324 * @param source the source contained in the returned libraries |
| 294 * @return the sources for the libraries containing the given source | 325 * @return the sources for the libraries containing the given source |
| 295 */ | 326 */ |
| 296 List<Source> getLibrariesContaining(Source source); | 327 List<Source> getLibrariesContaining(Source source); |
| 328 |
| 329 /** |
| 330 * Return the sources for the defining compilation units of any libraries that
depend on the given |
| 331 * library. One library depends on another if it either imports or exports tha
t library. |
| 332 * @param librarySource the source for the defining compilation unit of the li
brary being depended |
| 333 * on |
| 334 * @return the sources for the libraries that depend on the given library |
| 335 */ |
| 336 List<Source> getLibrariesDependingOn(Source librarySource); |
| 337 |
| 297 /** | 338 /** |
| 298 * 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 | 339 * Return the element model corresponding to the library defined by the given
source, or{@code null} if the element model does not currently exist or if the l
ibrary cannot be analyzed |
| 299 * for some reason. | 340 * for some reason. |
| 300 * @param source the source defining the library whose element model is to be
returned | 341 * @param source the source defining the library whose element model is to be
returned |
| 301 * @return the element model corresponding to the library defined by the given
source | 342 * @return the element model corresponding to the library defined by the given
source |
| 302 */ | 343 */ |
| 303 LibraryElement getLibraryElement(Source source); | 344 LibraryElement getLibraryElement(Source source); |
| 345 |
| 304 /** | 346 /** |
| 305 * Return an array containing all of the sources known to this context that re
present the defining | 347 * Return an array containing all of the sources known to this context that re
present the defining |
| 306 * compilation unit of a library. The contents of the array can be incomplete. | 348 * compilation unit of a library. The contents of the array can be incomplete. |
| 307 * @return the sources known to this context that represent the defining compi
lation unit of a | 349 * @return the sources known to this context that represent the defining compi
lation unit of a |
| 308 * library | 350 * library |
| 309 */ | 351 */ |
| 310 List<Source> get librarySources; | 352 List<Source> get librarySources; |
| 353 |
| 311 /** | 354 /** |
| 312 * Return the line information for the given source, or {@code null} if the li
ne information is | 355 * Return the line information for the given source, or {@code null} if the li
ne information is |
| 313 * not known. The line information is used to map offsets from the beginning o
f the source to line | 356 * not known. The line information is used to map offsets from the beginning o
f the source to line |
| 314 * and column pairs. | 357 * and column pairs. |
| 315 * @param source the source whose line information is to be returned | 358 * @param source the source whose line information is to be returned |
| 316 * @return the line information for the given source | 359 * @return the line information for the given source |
| 317 * @see #computeLineInfo(Source) | 360 * @see #computeLineInfo(Source) |
| 318 */ | 361 */ |
| 319 LineInfo getLineInfo(Source source); | 362 LineInfo getLineInfo(Source source); |
| 363 |
| 320 /** | 364 /** |
| 321 * 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. | 365 * Return a fully resolved AST for a single compilation unit within the given
library, or{@code null} if the resolved AST is not already computed. |
| 322 * @param unitSource the source of the compilation unit | 366 * @param unitSource the source of the compilation unit |
| 323 * @param library the library containing the compilation unit | 367 * @param library the library containing the compilation unit |
| 324 * @return a fully resolved AST for the compilation unit | 368 * @return a fully resolved AST for the compilation unit |
| 325 * @see #resolveCompilationUnit(Source,LibraryElement) | 369 * @see #resolveCompilationUnit(Source,LibraryElement) |
| 326 */ | 370 */ |
| 327 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary); | 371 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary); |
| 372 |
| 328 /** | 373 /** |
| 329 * 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. | 374 * Return a fully resolved AST for a single compilation unit within the given
library, or{@code null} if the resolved AST is not already computed. |
| 330 * @param unitSource the source of the compilation unit | 375 * @param unitSource the source of the compilation unit |
| 331 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 376 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
| 332 * compilation unit | 377 * compilation unit |
| 333 * @return a fully resolved AST for the compilation unit | 378 * @return a fully resolved AST for the compilation unit |
| 334 * @see #resolveCompilationUnit(Source,Source) | 379 * @see #resolveCompilationUnit(Source,Source) |
| 335 */ | 380 */ |
| 336 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource); | 381 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource); |
| 382 |
| 337 /** | 383 /** |
| 338 * Return the source factory used to create the sources that can be analyzed i
n this context. | 384 * Return the source factory used to create the sources that can be analyzed i
n this context. |
| 339 * @return the source factory used to create the sources that can be analyzed
in this context | 385 * @return the source factory used to create the sources that can be analyzed
in this context |
| 340 */ | 386 */ |
| 341 SourceFactory get sourceFactory; | 387 SourceFactory get sourceFactory; |
| 388 |
| 342 /** | 389 /** |
| 343 * Return {@code true} if the given source is known to be the defining compila
tion unit of a | 390 * Return {@code true} if the given source is known to be the defining compila
tion unit of a |
| 344 * library that can be run on a client (references 'dart:html', either directl
y or indirectly). | 391 * library that can be run on a client (references 'dart:html', either directl
y or indirectly). |
| 345 * <p> | 392 * <p> |
| 346 * <b>Note:</b> In addition to the expected case of returning {@code false} if
the source is known | 393 * <b>Note:</b> In addition to the expected case of returning {@code false} if
the source is known |
| 347 * to be a library that cannot be run on a client, this method will also retur
n {@code false} if | 394 * to be a library that cannot be run on a client, this method will also retur
n {@code false} if |
| 348 * the source is not known to be a library or if we do not know whether it can
be run on a client. | 395 * the source is not known to be a library or if we do not know whether it can
be run on a client. |
| 349 * @param librarySource the source being tested | 396 * @param librarySource the source being tested |
| 350 * @return {@code true} if the given source is known to be a library that can
be run on a client | 397 * @return {@code true} if the given source is known to be a library that can
be run on a client |
| 351 */ | 398 */ |
| 352 bool isClientLibrary(Source librarySource); | 399 bool isClientLibrary(Source librarySource); |
| 400 |
| 353 /** | 401 /** |
| 354 * Return {@code true} if the given source is known to be the defining compila
tion unit of a | 402 * Return {@code true} if the given source is known to be the defining compila
tion unit of a |
| 355 * library that can be run on the server (does not reference 'dart:html', eith
er directly or | 403 * library that can be run on the server (does not reference 'dart:html', eith
er directly or |
| 356 * indirectly). | 404 * indirectly). |
| 357 * <p> | 405 * <p> |
| 358 * <b>Note:</b> In addition to the expected case of returning {@code false} if
the source is known | 406 * <b>Note:</b> In addition to the expected case of returning {@code false} if
the source is known |
| 359 * to be a library that cannot be run on the server, this method will also ret
urn {@code false} if | 407 * to be a library that cannot be run on the server, this method will also ret
urn {@code false} if |
| 360 * the source is not known to be a library or if we do not know whether it can
be run on the | 408 * the source is not known to be a library or if we do not know whether it can
be run on the |
| 361 * server. | 409 * server. |
| 362 * @param librarySource the source being tested | 410 * @param librarySource the source being tested |
| 363 * @return {@code true} if the given source is known to be a library that can
be run on the server | 411 * @return {@code true} if the given source is known to be a library that can
be run on the server |
| 364 */ | 412 */ |
| 365 bool isServerLibrary(Source librarySource); | 413 bool isServerLibrary(Source librarySource); |
| 414 |
| 366 /** | 415 /** |
| 367 * Add the sources contained in the specified context to this context's collec
tion of sources. | 416 * Add the sources contained in the specified context to this context's collec
tion of sources. |
| 368 * This method is called when an existing context's pubspec has been removed,
and the contained | 417 * This method is called when an existing context's pubspec has been removed,
and the contained |
| 369 * sources should be reanalyzed as part of this context. | 418 * sources should be reanalyzed as part of this context. |
| 370 * @param context the context being merged | 419 * @param context the context being merged |
| 371 */ | 420 */ |
| 372 void mergeContext(AnalysisContext context); | 421 void mergeContext(AnalysisContext context); |
| 422 |
| 373 /** | 423 /** |
| 374 * Parse a single source to produce an AST structure. The resulting AST struct
ure may or may not | 424 * Parse a single source to produce an AST structure. The resulting AST struct
ure may or may not |
| 375 * be resolved, and may have a slightly different structure depending upon whe
ther it is resolved. | 425 * be resolved, and may have a slightly different structure depending upon whe
ther it is resolved. |
| 376 * @param source the source to be parsed | 426 * @param source the source to be parsed |
| 377 * @return the AST structure representing the content of the source | 427 * @return the AST structure representing the content of the source |
| 378 * @throws AnalysisException if the analysis could not be performed | 428 * @throws AnalysisException if the analysis could not be performed |
| 379 */ | 429 */ |
| 380 CompilationUnit parseCompilationUnit(Source source); | 430 CompilationUnit parseCompilationUnit(Source source); |
| 431 |
| 381 /** | 432 /** |
| 382 * Parse a single HTML source to produce an AST structure. The resulting HTML
AST structure may or | 433 * Parse a single HTML source to produce an AST structure. The resulting HTML
AST structure may or |
| 383 * may not be resolved, and may have a slightly different structure depending
upon whether it is | 434 * may not be resolved, and may have a slightly different structure depending
upon whether it is |
| 384 * resolved. | 435 * resolved. |
| 385 * @param source the HTML source to be parsed | 436 * @param source the HTML source to be parsed |
| 386 * @return the parse result (not {@code null}) | 437 * @return the parse result (not {@code null}) |
| 387 * @throws AnalysisException if the analysis could not be performed | 438 * @throws AnalysisException if the analysis could not be performed |
| 388 */ | 439 */ |
| 389 HtmlUnit parseHtmlUnit(Source source); | 440 HtmlUnit parseHtmlUnit(Source source); |
| 441 |
| 390 /** | 442 /** |
| 391 * Perform the next unit of work required to keep the analysis results up-to-d
ate and return | 443 * Perform the next unit of work required to keep the analysis results up-to-d
ate and return |
| 392 * information about the consequent changes to the analysis results. If there
were no results the | 444 * information about the consequent changes to the analysis results. If there
were no results the |
| 393 * returned array will be empty. If there are no more units of work required,
then this method | 445 * returned array will be empty. If there are no more units of work required,
then this method |
| 394 * returns {@code null}. This method can be long running. | 446 * returns {@code null}. This method can be long running. |
| 395 * @return an array containing notices of changes to the analysis results | 447 * @return an array containing notices of changes to the analysis results |
| 396 */ | 448 */ |
| 397 List<ChangeNotice> performAnalysisTask(); | 449 List<ChangeNotice> performAnalysisTask(); |
| 450 |
| 398 /** | 451 /** |
| 399 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 452 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
| 400 * @param unitSource the source to be parsed and resolved | 453 * @param unitSource the source to be parsed and resolved |
| 401 * @param library the library containing the source to be resolved | 454 * @param library the library containing the source to be resolved |
| 402 * @return the result of resolving the AST structure representing the content
of the source in the | 455 * @return the result of resolving the AST structure representing the content
of the source in the |
| 403 * context of the given library | 456 * context of the given library |
| 404 * @throws AnalysisException if the analysis could not be performed | 457 * @throws AnalysisException if the analysis could not be performed |
| 405 * @see #getResolvedCompilationUnit(Source,LibraryElement) | 458 * @see #getResolvedCompilationUnit(Source,LibraryElement) |
| 406 */ | 459 */ |
| 407 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry); | 460 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry); |
| 461 |
| 408 /** | 462 /** |
| 409 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 463 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
| 410 * @param unitSource the source to be parsed and resolved | 464 * @param unitSource the source to be parsed and resolved |
| 411 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 465 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
| 412 * source to be resolved | 466 * source to be resolved |
| 413 * @return the result of resolving the AST structure representing the content
of the source in the | 467 * @return the result of resolving the AST structure representing the content
of the source in the |
| 414 * context of the given library | 468 * context of the given library |
| 415 * @throws AnalysisException if the analysis could not be performed | 469 * @throws AnalysisException if the analysis could not be performed |
| 416 * @see #getResolvedCompilationUnit(Source,Source) | 470 * @see #getResolvedCompilationUnit(Source,Source) |
| 417 */ | 471 */ |
| 418 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e); | 472 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e); |
| 473 |
| 419 /** | 474 /** |
| 420 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 475 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
| 421 * @param htmlSource the source to be parsed and resolved | 476 * @param htmlSource the source to be parsed and resolved |
| 422 * @return the result of resolving the AST structure representing the content
of the source | 477 * @return the result of resolving the AST structure representing the content
of the source |
| 423 * @throws AnalysisException if the analysis could not be performed | 478 * @throws AnalysisException if the analysis could not be performed |
| 424 */ | 479 */ |
| 425 HtmlUnit resolveHtmlUnit(Source htmlSource); | 480 HtmlUnit resolveHtmlUnit(Source htmlSource); |
| 481 |
| 482 /** |
| 483 * Set the set of analysis options controlling the behavior of this context to
the given options. |
| 484 * Clients can safely assume that all necessary analysis results have been inv
alidated. |
| 485 * @param options the set of analysis options that will control the behavior o
f this context |
| 486 */ |
| 487 void set analysisOptions(AnalysisOptions options); |
| 488 |
| 426 /** | 489 /** |
| 427 * Set the contents of the given source to the given contents and mark the sou
rce as having | 490 * Set the contents of the given source to the given contents and mark the sou
rce as having |
| 428 * changed. This has the effect of overriding the default contents of the sour
ce. If the contents | 491 * changed. This has the effect of overriding the default contents of the sour
ce. If the contents |
| 429 * are {@code null} the override is removed so that the default contents will
be returned. | 492 * are {@code null} the override is removed so that the default contents will
be returned. |
| 430 * @param source the source whose contents are being overridden | 493 * @param source the source whose contents are being overridden |
| 431 * @param contents the new contents of the source | 494 * @param contents the new contents of the source |
| 432 */ | 495 */ |
| 433 void setContents(Source source, String contents); | 496 void setContents(Source source, String contents); |
| 497 |
| 434 /** | 498 /** |
| 435 * Set the source factory used to create the sources that can be analyzed in t
his context to the | 499 * Set the source factory used to create the sources that can be analyzed in t
his context to the |
| 436 * given source factory. Clients can safely assume that all analysis results h
ave been | 500 * given source factory. Clients can safely assume that all analysis results h
ave been |
| 437 * invalidated. | 501 * invalidated. |
| 438 * @param factory the source factory used to create the sources that can be an
alyzed in this | 502 * @param factory the source factory used to create the sources that can be an
alyzed in this |
| 439 * context | 503 * context |
| 440 */ | 504 */ |
| 441 void set sourceFactory(SourceFactory factory); | 505 void set sourceFactory(SourceFactory factory); |
| 506 |
| 442 /** | 507 /** |
| 443 * Given a collection of sources with content that has changed, return an {@li
nk Iterable}identifying the sources that need to be resolved. | 508 * Given a collection of sources with content that has changed, return an {@li
nk Iterable}identifying the sources that need to be resolved. |
| 444 * @param changedSources an array of sources (not {@code null}, contains no {@
code null}s) | 509 * @param changedSources an array of sources (not {@code null}, contains no {@
code null}s) |
| 445 * @return An iterable returning the sources to be resolved | 510 * @return An iterable returning the sources to be resolved |
| 446 */ | 511 */ |
| 447 Iterable<Source> sourcesToResolve(List<Source> changedSources); | 512 Iterable<Source> sourcesToResolve(List<Source> changedSources); |
| 448 } | 513 } |
| 514 |
| 449 /** | 515 /** |
| 450 * The interface {@code AnalysisErrorInfo} contains the analysis errors and line
information for the | 516 * The interface {@code AnalysisErrorInfo} contains the analysis errors and line
information for the |
| 451 * errors. | 517 * errors. |
| 452 */ | 518 */ |
| 453 abstract class AnalysisErrorInfo { | 519 abstract class AnalysisErrorInfo { |
| 520 |
| 454 /** | 521 /** |
| 455 * Return the errors that as a result of the analysis, or {@code null} if ther
e were no errors. | 522 * Return the errors that as a result of the analysis, or {@code null} if ther
e were no errors. |
| 456 * @return the errors as a result of the analysis | 523 * @return the errors as a result of the analysis |
| 457 */ | 524 */ |
| 458 List<AnalysisError> get errors; | 525 List<AnalysisError> get errors; |
| 526 |
| 459 /** | 527 /** |
| 460 * Return the line information associated with the errors, or {@code null} if
there were no | 528 * Return the line information associated with the errors, or {@code null} if
there were no |
| 461 * errors. | 529 * errors. |
| 462 * @return the line information associated with the errors | 530 * @return the line information associated with the errors |
| 463 */ | 531 */ |
| 464 LineInfo get lineInfo; | 532 LineInfo get lineInfo; |
| 465 } | 533 } |
| 534 |
| 466 /** | 535 /** |
| 467 * Instances of the class {@code AnalysisException} represent an exception that
occurred during the | 536 * Instances of the class {@code AnalysisException} represent an exception that
occurred during the |
| 468 * analysis of one or more sources. | 537 * analysis of one or more sources. |
| 469 * @coverage dart.engine | 538 * @coverage dart.engine |
| 470 */ | 539 */ |
| 471 class AnalysisException extends JavaException { | 540 class AnalysisException extends JavaException { |
| 541 |
| 472 /** | 542 /** |
| 473 * Initialize a newly created exception. | 543 * Initialize a newly created exception. |
| 474 */ | 544 */ |
| 475 AnalysisException() : super() { | 545 AnalysisException() : super() { |
| 476 _jtd_constructor_125_impl(); | 546 _jtd_constructor_125_impl(); |
| 477 } | 547 } |
| 478 _jtd_constructor_125_impl() { | 548 _jtd_constructor_125_impl() { |
| 479 } | 549 } |
| 550 |
| 480 /** | 551 /** |
| 481 * Initialize a newly created exception to have the given message. | 552 * Initialize a newly created exception to have the given message. |
| 482 * @param message the message associated with the exception | 553 * @param message the message associated with the exception |
| 483 */ | 554 */ |
| 484 AnalysisException.con1(String message) : super(message) { | 555 AnalysisException.con1(String message) : super(message) { |
| 485 _jtd_constructor_126_impl(message); | 556 _jtd_constructor_126_impl(message); |
| 486 } | 557 } |
| 487 _jtd_constructor_126_impl(String message) { | 558 _jtd_constructor_126_impl(String message) { |
| 488 } | 559 } |
| 560 |
| 489 /** | 561 /** |
| 490 * Initialize a newly created exception to have the given message and cause. | 562 * Initialize a newly created exception to have the given message and cause. |
| 491 * @param message the message associated with the exception | 563 * @param message the message associated with the exception |
| 492 * @param cause the underlying exception that caused this exception | 564 * @param cause the underlying exception that caused this exception |
| 493 */ | 565 */ |
| 494 AnalysisException.con2(String message, Exception cause) : super(message, cause
) { | 566 AnalysisException.con2(String message, Exception cause) : super(message, cause
) { |
| 495 _jtd_constructor_127_impl(message, cause); | 567 _jtd_constructor_127_impl(message, cause); |
| 496 } | 568 } |
| 497 _jtd_constructor_127_impl(String message, Exception cause) { | 569 _jtd_constructor_127_impl(String message, Exception cause) { |
| 498 } | 570 } |
| 571 |
| 499 /** | 572 /** |
| 500 * Initialize a newly created exception to have the given cause. | 573 * Initialize a newly created exception to have the given cause. |
| 501 * @param cause the underlying exception that caused this exception | 574 * @param cause the underlying exception that caused this exception |
| 502 */ | 575 */ |
| 503 AnalysisException.con3(Exception cause) : super.withCause(cause) { | 576 AnalysisException.con3(Exception cause) : super.withCause(cause) { |
| 504 _jtd_constructor_128_impl(cause); | 577 _jtd_constructor_128_impl(cause); |
| 505 } | 578 } |
| 506 _jtd_constructor_128_impl(Exception cause) { | 579 _jtd_constructor_128_impl(Exception cause) { |
| 507 } | 580 } |
| 508 } | 581 } |
| 582 |
| 583 /** |
| 584 * The interface {@code AnalysisOptions} defines the behavior of objects that pr
ovide access to a |
| 585 * set of analysis options used to control the behavior of an analysis context. |
| 586 */ |
| 587 abstract class AnalysisOptions { |
| 588 |
| 589 /** |
| 590 * Return {@code true} if analysis is to use strict mode. In strict mode, erro
r reporting is based |
| 591 * exclusively on the static type information. |
| 592 * @return {@code true} if analysis is to use strict mode |
| 593 */ |
| 594 bool get strictMode; |
| 595 } |
| 596 |
| 509 /** | 597 /** |
| 510 * The interface {@code ChangeNotice} defines the behavior of objects that repre
sent a change to the | 598 * The interface {@code ChangeNotice} defines the behavior of objects that repre
sent a change to the |
| 511 * analysis results associated with a given source. | 599 * analysis results associated with a given source. |
| 512 * @coverage dart.engine | 600 * @coverage dart.engine |
| 513 */ | 601 */ |
| 514 abstract class ChangeNotice implements AnalysisErrorInfo { | 602 abstract class ChangeNotice implements AnalysisErrorInfo { |
| 603 |
| 515 /** | 604 /** |
| 516 * Return the fully resolved AST that changed as a result of the analysis, or
{@code null} if the | 605 * Return the fully resolved AST that changed as a result of the analysis, or
{@code null} if the |
| 517 * AST was not changed. | 606 * AST was not changed. |
| 518 * @return the fully resolved AST that changed as a result of the analysis | 607 * @return the fully resolved AST that changed as a result of the analysis |
| 519 */ | 608 */ |
| 520 CompilationUnit get compilationUnit; | 609 CompilationUnit get compilationUnit; |
| 610 |
| 521 /** | 611 /** |
| 522 * Return the source for which the result is being reported. | 612 * Return the source for which the result is being reported. |
| 523 * @return the source for which the result is being reported | 613 * @return the source for which the result is being reported |
| 524 */ | 614 */ |
| 525 Source get source; | 615 Source get source; |
| 526 } | 616 } |
| 617 |
| 527 /** | 618 /** |
| 528 * Instances of the class {@code ChangeSet} indicate what sources have been adde
d, changed, or | 619 * Instances of the class {@code ChangeSet} indicate what sources have been adde
d, changed, or |
| 529 * removed. | 620 * removed. |
| 530 * @coverage dart.engine | 621 * @coverage dart.engine |
| 531 */ | 622 */ |
| 532 class ChangeSet { | 623 class ChangeSet { |
| 624 |
| 533 /** | 625 /** |
| 534 * A list containing the sources that have been added. | 626 * A list containing the sources that have been added. |
| 535 */ | 627 */ |
| 536 List<Source> _added2 = new List<Source>(); | 628 List<Source> _added2 = new List<Source>(); |
| 629 |
| 537 /** | 630 /** |
| 538 * A list containing the sources that have been changed. | 631 * A list containing the sources that have been changed. |
| 539 */ | 632 */ |
| 540 List<Source> _changed2 = new List<Source>(); | 633 List<Source> _changed2 = new List<Source>(); |
| 634 |
| 541 /** | 635 /** |
| 542 * A list containing the sources that have been removed. | 636 * A list containing the sources that have been removed. |
| 543 */ | 637 */ |
| 544 List<Source> _removed2 = new List<Source>(); | 638 List<Source> _removed2 = new List<Source>(); |
| 639 |
| 545 /** | 640 /** |
| 546 * A list containing the source containers specifying additional sources that
have been removed. | 641 * A list containing the source containers specifying additional sources that
have been removed. |
| 547 */ | 642 */ |
| 548 List<SourceContainer> _removedContainers = new List<SourceContainer>(); | 643 List<SourceContainer> _removedContainers = new List<SourceContainer>(); |
| 549 /** | 644 |
| 550 * Initialize a newly created change set to be empty. | |
| 551 */ | |
| 552 ChangeSet() : super() { | |
| 553 } | |
| 554 /** | 645 /** |
| 555 * Record that the specified source has been added and that it's content is th
e default contents | 646 * Record that the specified source has been added and that it's content is th
e default contents |
| 556 * of the source. | 647 * of the source. |
| 557 * @param source the source that was added | 648 * @param source the source that was added |
| 558 */ | 649 */ |
| 559 void added(Source source) { | 650 void added(Source source) { |
| 560 _added2.add(source); | 651 _added2.add(source); |
| 561 } | 652 } |
| 653 |
| 562 /** | 654 /** |
| 563 * Record that the specified source has been changed and that it's content is
the default contents | 655 * Record that the specified source has been changed and that it's content is
the default contents |
| 564 * of the source. | 656 * of the source. |
| 565 * @param source the source that was changed | 657 * @param source the source that was changed |
| 566 */ | 658 */ |
| 567 void changed(Source source) { | 659 void changed(Source source) { |
| 568 _changed2.add(source); | 660 _changed2.add(source); |
| 569 } | 661 } |
| 662 |
| 570 /** | 663 /** |
| 571 * Return a collection of the sources that have been added. | 664 * Return a collection of the sources that have been added. |
| 572 * @return a collection of the sources that have been added | 665 * @return a collection of the sources that have been added |
| 573 */ | 666 */ |
| 574 List<Source> get added3 => _added2; | 667 List<Source> get added3 => _added2; |
| 668 |
| 575 /** | 669 /** |
| 576 * Return a collection of sources that have been changed. | 670 * Return a collection of sources that have been changed. |
| 577 * @return a collection of sources that have been changed | 671 * @return a collection of sources that have been changed |
| 578 */ | 672 */ |
| 579 List<Source> get changed3 => _changed2; | 673 List<Source> get changed3 => _changed2; |
| 674 |
| 580 /** | 675 /** |
| 581 * Return a list containing the sources that were removed. | 676 * Return a list containing the sources that were removed. |
| 582 * @return a list containing the sources that were removed | 677 * @return a list containing the sources that were removed |
| 583 */ | 678 */ |
| 584 List<Source> get removed => _removed2; | 679 List<Source> get removed => _removed2; |
| 680 |
| 585 /** | 681 /** |
| 586 * Return a list containing the source containers that were removed. | 682 * Return a list containing the source containers that were removed. |
| 587 * @return a list containing the source containers that were removed | 683 * @return a list containing the source containers that were removed |
| 588 */ | 684 */ |
| 589 List<SourceContainer> get removedContainers => _removedContainers; | 685 List<SourceContainer> get removedContainers => _removedContainers; |
| 686 |
| 590 /** | 687 /** |
| 591 * Return {@code true} if this change set does not contain any changes. | 688 * Return {@code true} if this change set does not contain any changes. |
| 592 * @return {@code true} if this change set does not contain any changes | 689 * @return {@code true} if this change set does not contain any changes |
| 593 */ | 690 */ |
| 594 bool isEmpty() => _added2.isEmpty && _changed2.isEmpty && _removed2.isEmpty &&
_removedContainers.isEmpty; | 691 bool isEmpty() => _added2.isEmpty && _changed2.isEmpty && _removed2.isEmpty &&
_removedContainers.isEmpty; |
| 692 |
| 595 /** | 693 /** |
| 596 * Record that the specified source has been removed. | 694 * Record that the specified source has been removed. |
| 597 * @param source the source that was removed | 695 * @param source the source that was removed |
| 598 */ | 696 */ |
| 599 void removed3(Source source) { | 697 void removed3(Source source) { |
| 600 if (source != null) { | 698 if (source != null) { |
| 601 _removed2.add(source); | 699 _removed2.add(source); |
| 602 } | 700 } |
| 603 } | 701 } |
| 702 |
| 604 /** | 703 /** |
| 605 * Record that the specified source container has been removed. | 704 * Record that the specified source container has been removed. |
| 606 * @param container the source container that was removed | 705 * @param container the source container that was removed |
| 607 */ | 706 */ |
| 608 void removedContainer(SourceContainer container) { | 707 void removedContainer(SourceContainer container) { |
| 609 if (container != null) { | 708 if (container != null) { |
| 610 _removedContainers.add(container); | 709 _removedContainers.add(container); |
| 611 } | 710 } |
| 612 } | 711 } |
| 613 } | 712 } |
| 713 |
| 614 /** | 714 /** |
| 615 * The interface {@code DartEntry} defines the behavior of objects that maintain
the information | 715 * The interface {@code DartEntry} defines the behavior of objects that maintain
the information |
| 616 * cached by an analysis context about an individual Dart file. | 716 * cached by an analysis context about an individual Dart file. |
| 617 * @coverage dart.engine | 717 * @coverage dart.engine |
| 618 */ | 718 */ |
| 619 abstract class DartEntry implements SourceEntry { | 719 abstract class DartEntry implements SourceEntry { |
| 720 |
| 620 /** | 721 /** |
| 621 * The data descriptor representing the library element for the library. This
data is only | 722 * The data descriptor representing the library element for the library. This
data is only |
| 622 * available for Dart files that are the defining compilation unit of a librar
y. | 723 * available for Dart files that are the defining compilation unit of a librar
y. |
| 623 */ | 724 */ |
| 624 static DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<LibraryElem
ent>("DartEntry.ELEMENT"); | 725 static DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<LibraryElem
ent>("DartEntry.ELEMENT"); |
| 726 |
| 727 /** |
| 728 * The data descriptor representing the list of referenced libraries. This dat
a is only available |
| 729 * for Dart files that are the defining compilation unit of a library. |
| 730 */ |
| 731 static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor<
List<Source>>("DartEntry.REFERENCED_LIBRARIES"); |
| 732 |
| 625 /** | 733 /** |
| 626 * The data descriptor representing the list of included parts. This data is o
nly available for | 734 * The data descriptor representing the list of included parts. This data is o
nly available for |
| 627 * Dart files that are the defining compilation unit of a library. | 735 * Dart files that are the defining compilation unit of a library. |
| 628 */ | 736 */ |
| 629 static DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<List<S
ource>>("DartEntry.INCLUDED_PARTS"); | 737 static DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<List<S
ource>>("DartEntry.INCLUDED_PARTS"); |
| 738 |
| 630 /** | 739 /** |
| 631 * The data descriptor representing the client flag. This data is only availab
le for Dart files | 740 * The data descriptor representing the client flag. This data is only availab
le for Dart files |
| 632 * that are the defining compilation unit of a library. | 741 * that are the defining compilation unit of a library. |
| 633 */ | 742 */ |
| 634 static DataDescriptor<bool> IS_CLIENT = new DataDescriptor<bool>("DartEntry.IS
_CLIENT"); | 743 static DataDescriptor<bool> IS_CLIENT = new DataDescriptor<bool>("DartEntry.IS
_CLIENT"); |
| 744 |
| 635 /** | 745 /** |
| 636 * The data descriptor representing the launchable flag. This data is only ava
ilable for Dart | 746 * The data descriptor representing the launchable flag. This data is only ava
ilable for Dart |
| 637 * files that are the defining compilation unit of a library. | 747 * files that are the defining compilation unit of a library. |
| 638 */ | 748 */ |
| 639 static DataDescriptor<bool> IS_LAUNCHABLE = new DataDescriptor<bool>("DartEntr
y.IS_LAUNCHABLE"); | 749 static DataDescriptor<bool> IS_LAUNCHABLE = new DataDescriptor<bool>("DartEntr
y.IS_LAUNCHABLE"); |
| 750 |
| 640 /** | 751 /** |
| 641 * The data descriptor representing the errors resulting from parsing the sour
ce. | 752 * The data descriptor representing the errors resulting from parsing the sour
ce. |
| 642 */ | 753 */ |
| 643 static DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescriptor<L
ist<AnalysisError>>("DartEntry.PARSE_ERRORS"); | 754 static DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescriptor<L
ist<AnalysisError>>("DartEntry.PARSE_ERRORS"); |
| 755 |
| 644 /** | 756 /** |
| 645 * The data descriptor representing the parsed AST structure. | 757 * The data descriptor representing the parsed AST structure. |
| 646 */ | 758 */ |
| 647 static DataDescriptor<CompilationUnit> PARSED_UNIT = new DataDescriptor<Compil
ationUnit>("DartEntry.PARSED_UNIT"); | 759 static DataDescriptor<CompilationUnit> PARSED_UNIT = new DataDescriptor<Compil
ationUnit>("DartEntry.PARSED_UNIT"); |
| 760 |
| 648 /** | 761 /** |
| 649 * The data descriptor representing the public namespace of the library. This
data is only | 762 * The data descriptor representing the public namespace of the library. This
data is only |
| 650 * available for Dart files that are the defining compilation unit of a librar
y. | 763 * available for Dart files that are the defining compilation unit of a librar
y. |
| 651 */ | 764 */ |
| 652 static DataDescriptor<Namespace> PUBLIC_NAMESPACE = new DataDescriptor<Namespa
ce>("DartEntry.PUBLIC_NAMESPACE"); | 765 static DataDescriptor<Namespace> PUBLIC_NAMESPACE = new DataDescriptor<Namespa
ce>("DartEntry.PUBLIC_NAMESPACE"); |
| 766 |
| 653 /** | 767 /** |
| 654 * The data descriptor representing the errors resulting from resolving the so
urce. | 768 * The data descriptor representing the errors resulting from resolving the so
urce. |
| 655 */ | 769 */ |
| 656 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip
tor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS"); | 770 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip
tor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS"); |
| 771 |
| 657 /** | 772 /** |
| 658 * The data descriptor representing the resolved AST structure. | 773 * The data descriptor representing the resolved AST structure. |
| 659 */ | 774 */ |
| 660 static DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescriptor<Comp
ilationUnit>("DartEntry.RESOLVED_UNIT"); | 775 static DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescriptor<Comp
ilationUnit>("DartEntry.RESOLVED_UNIT"); |
| 776 |
| 661 /** | 777 /** |
| 662 * The data descriptor representing the source kind. | 778 * The data descriptor representing the source kind. |
| 663 */ | 779 */ |
| 664 static DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<SourceKind>
("DartEntry.SOURCE_KIND"); | 780 static DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<SourceKind>
("DartEntry.SOURCE_KIND"); |
| 781 |
| 665 /** | 782 /** |
| 666 * Return all of the errors associated with the compilation unit that are curr
ently cached. | 783 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 667 * @return all of the errors associated with the compilation unit | 784 * @return all of the errors associated with the compilation unit |
| 668 */ | 785 */ |
| 669 List<AnalysisError> get allErrors; | 786 List<AnalysisError> get allErrors; |
| 787 |
| 670 /** | 788 /** |
| 671 * Return a valid parsed compilation unit, either an unresolved AST structure
or the result of | 789 * Return a valid parsed compilation unit, either an unresolved AST structure
or the result of |
| 672 * resolving the AST structure in the context of some library, or {@code null}
if there is no | 790 * resolving the AST structure in the context of some library, or {@code null}
if there is no |
| 673 * parsed compilation unit available. | 791 * parsed compilation unit available. |
| 674 * @return a valid parsed compilation unit | 792 * @return a valid parsed compilation unit |
| 675 */ | 793 */ |
| 676 CompilationUnit get anyParsedCompilationUnit; | 794 CompilationUnit get anyParsedCompilationUnit; |
| 795 |
| 677 /** | 796 /** |
| 678 * Return the result of resolving the compilation unit as part of any library,
or {@code null} if | 797 * Return the result of resolving the compilation unit as part of any library,
or {@code null} if |
| 679 * there is no cached resolved compilation unit. | 798 * there is no cached resolved compilation unit. |
| 680 * @return any resolved compilation unit | 799 * @return any resolved compilation unit |
| 681 */ | 800 */ |
| 682 CompilationUnit get anyResolvedCompilationUnit; | 801 CompilationUnit get anyResolvedCompilationUnit; |
| 802 |
| 683 /** | 803 /** |
| 684 * Return the state of the data represented by the given descriptor in the con
text of the given | 804 * Return the state of the data represented by the given descriptor in the con
text of the given |
| 685 * library. | 805 * library. |
| 686 * @param descriptor the descriptor representing the data whose state is to be
returned | 806 * @param descriptor the descriptor representing the data whose state is to be
returned |
| 687 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 807 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 688 * context for the data | 808 * context for the data |
| 689 * @return the value of the data represented by the given descriptor and libra
ry | 809 * @return the value of the data represented by the given descriptor and libra
ry |
| 690 */ | 810 */ |
| 691 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource); | 811 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource); |
| 812 |
| 692 /** | 813 /** |
| 693 * Return the value of the data represented by the given descriptor in the con
text of the given | 814 * Return the value of the data represented by the given descriptor in the con
text of the given |
| 694 * library, or {@code null} if the data represented by the descriptor is not i
n the cache. | 815 * library, or {@code null} if the data represented by the descriptor is not i
n the cache. |
| 695 * @param descriptor the descriptor representing which data is to be returned | 816 * @param descriptor the descriptor representing which data is to be returned |
| 696 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 817 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 697 * context for the data | 818 * context for the data |
| 698 * @return the value of the data represented by the given descriptor and libra
ry | 819 * @return the value of the data represented by the given descriptor and libra
ry |
| 699 */ | 820 */ |
| 700 Object getValue2(DataDescriptor descriptor, Source librarySource); | 821 Object getValue2(DataDescriptor descriptor, Source librarySource); |
| 701 DartEntryImpl get writableCopy; | 822 DartEntryImpl get writableCopy; |
| 702 } | 823 } |
| 824 |
| 703 /** | 825 /** |
| 704 * Instances of the class {@code DartEntryImpl} implement a {@link DartEntry}. | 826 * Instances of the class {@code DartEntryImpl} implement a {@link DartEntry}. |
| 705 * @coverage dart.engine | 827 * @coverage dart.engine |
| 706 */ | 828 */ |
| 707 class DartEntryImpl extends SourceEntryImpl implements DartEntry { | 829 class DartEntryImpl extends SourceEntryImpl implements DartEntry { |
| 830 |
| 708 /** | 831 /** |
| 709 * The state of the cached source kind. | 832 * The state of the cached source kind. |
| 710 */ | 833 */ |
| 711 CacheState _sourceKindState = CacheState.INVALID; | 834 CacheState _sourceKindState = CacheState.INVALID; |
| 835 |
| 712 /** | 836 /** |
| 713 * The kind of this source. | 837 * The kind of this source. |
| 714 */ | 838 */ |
| 715 SourceKind _sourceKind = SourceKind.UNKNOWN; | 839 SourceKind _sourceKind = SourceKind.UNKNOWN; |
| 840 |
| 716 /** | 841 /** |
| 717 * The state of the cached parsed compilation unit. | 842 * The state of the cached parsed compilation unit. |
| 718 */ | 843 */ |
| 719 CacheState _parsedUnitState = CacheState.INVALID; | 844 CacheState _parsedUnitState = CacheState.INVALID; |
| 845 |
| 720 /** | 846 /** |
| 721 * The parsed compilation unit, or {@code null} if the parsed compilation unit
is not currently | 847 * The parsed compilation unit, or {@code null} if the parsed compilation unit
is not currently |
| 722 * cached. | 848 * cached. |
| 723 */ | 849 */ |
| 724 CompilationUnit _parsedUnit; | 850 CompilationUnit _parsedUnit; |
| 851 |
| 725 /** | 852 /** |
| 726 * The state of the cached parse errors. | 853 * The state of the cached parse errors. |
| 727 */ | 854 */ |
| 728 CacheState _parseErrorsState = CacheState.INVALID; | 855 CacheState _parseErrorsState = CacheState.INVALID; |
| 856 |
| 729 /** | 857 /** |
| 730 * The errors produced while scanning and parsing the compilation unit, or {@c
ode null} if the | 858 * The errors produced while scanning and parsing the compilation unit, or {@c
ode null} if the |
| 731 * errors are not currently cached. | 859 * errors are not currently cached. |
| 732 */ | 860 */ |
| 733 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; | 861 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; |
| 862 |
| 734 /** | 863 /** |
| 735 * The state of the cached list of included parts. | 864 * The state of the cached list of included parts. |
| 736 */ | 865 */ |
| 737 CacheState _includedPartsState = CacheState.INVALID; | 866 CacheState _includedPartsState = CacheState.INVALID; |
| 867 |
| 738 /** | 868 /** |
| 739 * The list of parts included in the library, or {@code null} if the list is n
ot currently cached. | 869 * The list of parts included in the library, or an empty array if the list is
not currently |
| 740 * The list will be empty if the Dart file is a part rather than a library. | 870 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. |
| 741 */ | 871 */ |
| 742 List<Source> _includedParts = Source.EMPTY_ARRAY; | 872 List<Source> _includedParts = Source.EMPTY_ARRAY; |
| 873 |
| 743 /** | 874 /** |
| 744 * The source for the defining compilation unit of the library that contains t
his unit, or{@code null} if this unit is contained in multiple libraries. (If th
is unit is the defining | 875 * The state of the cached list of referenced libraries. |
| 745 * compilation unit for it's library, then this will be the source for this un
it.) | |
| 746 */ | 876 */ |
| 747 Source _librarySource; | 877 CacheState _referencedLibrariesState = CacheState.INVALID; |
| 878 |
| 879 /** |
| 880 * The list of libraries referenced (imported or exported) by the library, or
an empty array if |
| 881 * the list is not currently cached. The list will be empty if the Dart file i
s a part rather than |
| 882 * a library. |
| 883 */ |
| 884 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; |
| 885 |
| 748 /** | 886 /** |
| 749 * The information known as a result of resolving this compilation unit as par
t of the library | 887 * The information known as a result of resolving this compilation unit as par
t of the library |
| 750 * that contains this unit, or {@code null} if this unit is contained in multi
ple libraries. | 888 * that contains this unit. This field will never be {@code null}. |
| 751 */ | 889 */ |
| 752 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); | 890 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); |
| 753 /** | 891 |
| 754 * A table mapping the sources of the libraries containing this compilation un
it to the | |
| 755 * information known as a result of resolving this compilation unit as part of
the library, or{@code null} if this unit is contained in a single library. | |
| 756 */ | |
| 757 Map<Source, DartEntryImpl_ResolutionState> _resolutionMap; | |
| 758 /** | 892 /** |
| 759 * The state of the cached library element. | 893 * The state of the cached library element. |
| 760 */ | 894 */ |
| 761 CacheState _elementState = CacheState.INVALID; | 895 CacheState _elementState = CacheState.INVALID; |
| 896 |
| 762 /** | 897 /** |
| 763 * The element representing the library, or {@code null} if the element is not
currently cached. | 898 * The element representing the library, or {@code null} if the element is not
currently cached. |
| 764 */ | 899 */ |
| 765 LibraryElement _element; | 900 LibraryElement _element; |
| 901 |
| 766 /** | 902 /** |
| 767 * The state of the cached public namespace. | 903 * The state of the cached public namespace. |
| 768 */ | 904 */ |
| 769 CacheState _publicNamespaceState = CacheState.INVALID; | 905 CacheState _publicNamespaceState = CacheState.INVALID; |
| 906 |
| 770 /** | 907 /** |
| 771 * The public namespace of the library, or {@code null} if the namespace is no
t currently cached. | 908 * The public namespace of the library, or {@code null} if the namespace is no
t currently cached. |
| 772 */ | 909 */ |
| 773 Namespace _publicNamespace; | 910 Namespace _publicNamespace; |
| 911 |
| 774 /** | 912 /** |
| 775 * The state of the cached client/ server flag. | 913 * The state of the cached client/ server flag. |
| 776 */ | 914 */ |
| 777 CacheState _clientServerState = CacheState.INVALID; | 915 CacheState _clientServerState = CacheState.INVALID; |
| 916 |
| 778 /** | 917 /** |
| 779 * The state of the cached launchable flag. | 918 * The state of the cached launchable flag. |
| 780 */ | 919 */ |
| 781 CacheState _launchableState = CacheState.INVALID; | 920 CacheState _launchableState = CacheState.INVALID; |
| 921 |
| 782 /** | 922 /** |
| 783 * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT
_CODE}. | 923 * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT
_CODE}. |
| 784 */ | 924 */ |
| 785 int _bitmask = 0; | 925 int _bitmask = 0; |
| 926 |
| 786 /** | 927 /** |
| 787 * Mask indicating that this library is launchable: that the file has a main m
ethod. | 928 * Mask indicating that this library is launchable: that the file has a main m
ethod. |
| 788 */ | 929 */ |
| 789 static int _LAUNCHABLE = 1 << 1; | 930 static int _LAUNCHABLE = 1 << 1; |
| 931 |
| 790 /** | 932 /** |
| 791 * Mask indicating that the library is client code: that the library depends o
n the html library. | 933 * Mask indicating that the library is client code: that the library depends o
n the html library. |
| 792 * If the library is not "client code", then it is referenced as "server code"
. | 934 * If the library is not "client code", then it is referenced as "server code"
. |
| 793 */ | 935 */ |
| 794 static int _CLIENT_CODE = 1 << 2; | 936 static int _CLIENT_CODE = 1 << 2; |
| 795 /** | |
| 796 * Initialize a newly created cache entry to be empty. | |
| 797 */ | |
| 798 DartEntryImpl() : super() { | |
| 799 } | |
| 800 /** | |
| 801 * Record the fact that we are about to parse the compilation unit by marking
the results of | |
| 802 * parsing as being in progress. | |
| 803 */ | |
| 804 void aboutToParse() { | |
| 805 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS); | |
| 806 _parsedUnitState = CacheState.IN_PROCESS; | |
| 807 _parseErrorsState = CacheState.IN_PROCESS; | |
| 808 } | |
| 809 List<AnalysisError> get allErrors { | 937 List<AnalysisError> get allErrors { |
| 810 List<AnalysisError> errors = new List<AnalysisError>(); | 938 List<AnalysisError> errors = new List<AnalysisError>(); |
| 811 for (AnalysisError error in _parseErrors) { | 939 for (AnalysisError error in _parseErrors) { |
| 812 errors.add(error); | 940 errors.add(error); |
| 813 } | 941 } |
| 814 if (_resolutionMap == null) { | 942 DartEntryImpl_ResolutionState state = _resolutionState; |
| 815 for (AnalysisError error in _resolutionState._resolutionErrors) { | 943 while (state != null) { |
| 944 for (AnalysisError error in state._resolutionErrors) { |
| 816 errors.add(error); | 945 errors.add(error); |
| 817 } | 946 } |
| 818 } else { | 947 state = state._nextState; |
| 819 for (DartEntryImpl_ResolutionState state in _resolutionMap.values) { | |
| 820 for (AnalysisError error in state._resolutionErrors) { | |
| 821 errors.add(error); | |
| 822 } | |
| 823 } | |
| 824 } | 948 } |
| 949 ; |
| 825 if (errors.length == 0) { | 950 if (errors.length == 0) { |
| 826 return AnalysisError.NO_ERRORS; | 951 return AnalysisError.NO_ERRORS; |
| 827 } | 952 } |
| 828 return new List.from(errors); | 953 return new List.from(errors); |
| 829 } | 954 } |
| 830 CompilationUnit get anyParsedCompilationUnit { | 955 CompilationUnit get anyParsedCompilationUnit { |
| 831 if (identical(_parsedUnitState, CacheState.VALID)) { | 956 if (identical(_parsedUnitState, CacheState.VALID)) { |
| 832 return _parsedUnit; | 957 return _parsedUnit; |
| 833 } | 958 } |
| 834 if (_resolutionMap == null) { | 959 return anyResolvedCompilationUnit; |
| 835 return _resolutionState._resolvedUnit; | |
| 836 } else { | |
| 837 for (DartEntryImpl_ResolutionState state in _resolutionMap.values) { | |
| 838 if (identical(state._resolvedUnitState, CacheState.VALID)) { | |
| 839 return state._resolvedUnit; | |
| 840 } | |
| 841 } | |
| 842 } | |
| 843 return null; | |
| 844 } | 960 } |
| 845 CompilationUnit get anyResolvedCompilationUnit { | 961 CompilationUnit get anyResolvedCompilationUnit { |
| 846 for (DartEntryImpl_ResolutionState state in _resolutionMap.values) { | 962 DartEntryImpl_ResolutionState state = _resolutionState; |
| 963 while (state != null) { |
| 847 if (identical(state._resolvedUnitState, CacheState.VALID)) { | 964 if (identical(state._resolvedUnitState, CacheState.VALID)) { |
| 848 return state._resolvedUnit; | 965 return state._resolvedUnit; |
| 849 } | 966 } |
| 967 state = state._nextState; |
| 850 } | 968 } |
| 969 ; |
| 851 return null; | 970 return null; |
| 852 } | 971 } |
| 853 SourceKind get kind => _sourceKind; | 972 SourceKind get kind => _sourceKind; |
| 854 CacheState getState(DataDescriptor<Object> descriptor) { | 973 CacheState getState(DataDescriptor<Object> descriptor) { |
| 855 if (identical(descriptor, DartEntry.ELEMENT)) { | 974 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 856 return _elementState; | 975 return _elementState; |
| 857 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 976 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 858 return _includedPartsState; | 977 return _includedPartsState; |
| 859 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 978 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 860 return _clientServerState; | 979 return _clientServerState; |
| 861 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 980 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 862 return _launchableState; | 981 return _launchableState; |
| 863 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 982 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 864 return _parseErrorsState; | 983 return _parseErrorsState; |
| 865 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 984 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 866 return _parsedUnitState; | 985 return _parsedUnitState; |
| 867 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 986 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 868 return _publicNamespaceState; | 987 return _publicNamespaceState; |
| 988 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { |
| 989 return _referencedLibrariesState; |
| 869 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 990 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 870 return _sourceKindState; | 991 return _sourceKindState; |
| 871 } else { | 992 } else { |
| 872 return super.getState(descriptor); | 993 return super.getState(descriptor); |
| 873 } | 994 } |
| 874 } | 995 } |
| 875 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource)
{ | 996 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource2)
{ |
| 876 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 997 DartEntryImpl_ResolutionState state = _resolutionState; |
| 877 if (_resolutionMap == null) { | 998 while (state != null) { |
| 878 return _resolutionState._resolutionErrorsState; | 999 if (librarySource2 == state._librarySource) { |
| 879 } else { | 1000 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 880 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource]; | 1001 return _resolutionState._resolutionErrorsState; |
| 881 if (state != null) { | 1002 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 882 return state._resolutionErrorsState; | 1003 return _resolutionState._resolvedUnitState; |
| 1004 } else { |
| 1005 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); |
| 883 } | 1006 } |
| 884 } | 1007 } |
| 885 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1008 state = state._nextState; |
| 886 if (_resolutionMap == null) { | |
| 887 return _resolutionState._resolvedUnitState; | |
| 888 } else { | |
| 889 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource]; | |
| 890 if (state != null) { | |
| 891 return state._resolvedUnitState; | |
| 892 } | |
| 893 } | |
| 894 } else { | |
| 895 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | |
| 896 } | 1009 } |
| 1010 ; |
| 897 return CacheState.INVALID; | 1011 return CacheState.INVALID; |
| 898 } | 1012 } |
| 899 Object getValue(DataDescriptor descriptor) { | 1013 Object getValue(DataDescriptor descriptor) { |
| 900 if (identical(descriptor, DartEntry.ELEMENT)) { | 1014 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 901 return _element as Object; | 1015 return _element as Object; |
| 902 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1016 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 903 return _includedParts as Object; | 1017 return _includedParts as Object; |
| 904 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1018 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 905 return ((_bitmask & _CLIENT_CODE) != 0 ? true : false) as Object; | 1019 return ((_bitmask & _CLIENT_CODE) != 0 ? true : false) as Object; |
| 906 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 1020 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 907 return ((_bitmask & _LAUNCHABLE) != 0 ? true : false) as Object; | 1021 return ((_bitmask & _LAUNCHABLE) != 0 ? true : false) as Object; |
| 908 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1022 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 909 return _parseErrors as Object; | 1023 return _parseErrors as Object; |
| 910 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1024 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 911 return _parsedUnit as Object; | 1025 return _parsedUnit as Object; |
| 912 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1026 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 913 return _publicNamespace as Object; | 1027 return _publicNamespace as Object; |
| 1028 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { |
| 1029 return _referencedLibraries as Object; |
| 914 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1030 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 915 return _sourceKind as Object; | 1031 return _sourceKind as Object; |
| 916 } | 1032 } |
| 917 return super.getValue(descriptor); | 1033 return super.getValue(descriptor); |
| 918 } | 1034 } |
| 919 Object getValue2(DataDescriptor descriptor, Source librarySource2) { | 1035 Object getValue2(DataDescriptor descriptor, Source librarySource2) { |
| 920 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1036 DartEntryImpl_ResolutionState state = _resolutionState; |
| 921 if (_resolutionMap == null) { | 1037 while (state != null) { |
| 922 if (librarySource2 == this._librarySource) { | 1038 if (librarySource2 == state._librarySource) { |
| 923 return _resolutionState._resolutionErrors as Object; | 1039 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1040 return state._resolutionErrors as Object; |
| 1041 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1042 return state._resolvedUnit as Object; |
| 924 } else { | 1043 } else { |
| 925 return AnalysisError.NO_ERRORS as Object; | 1044 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); |
| 926 } | |
| 927 } else { | |
| 928 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2]; | |
| 929 if (state != null) { | |
| 930 return state._resolutionErrors as Object; | |
| 931 } | 1045 } |
| 932 } | 1046 } |
| 1047 state = state._nextState; |
| 1048 } |
| 1049 ; |
| 1050 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1051 return AnalysisError.NO_ERRORS as Object; |
| 933 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1052 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 934 if (_resolutionMap == null) { | 1053 return null; |
| 935 if (librarySource2 == this._librarySource) { | |
| 936 return _resolutionState._resolvedUnit as Object; | |
| 937 } else { | |
| 938 return null; | |
| 939 } | |
| 940 } else { | |
| 941 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2]; | |
| 942 if (state != null) { | |
| 943 return state._resolvedUnit as Object; | |
| 944 } | |
| 945 } | |
| 946 } else { | 1054 } else { |
| 947 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1055 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 948 } | 1056 } |
| 949 return null; | |
| 950 } | 1057 } |
| 951 DartEntryImpl get writableCopy { | 1058 DartEntryImpl get writableCopy { |
| 952 DartEntryImpl copy = new DartEntryImpl(); | 1059 DartEntryImpl copy = new DartEntryImpl(); |
| 953 copy.copyFrom(this); | 1060 copy.copyFrom(this); |
| 954 return copy; | 1061 return copy; |
| 955 } | 1062 } |
| 1063 |
| 1064 /** |
| 1065 * Invalidate all of the information associated with the compilation unit. |
| 1066 */ |
| 1067 void invalidateAllInformation() { |
| 1068 setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 1069 _sourceKind = SourceKind.UNKNOWN; |
| 1070 _sourceKindState = CacheState.INVALID; |
| 1071 _parseErrors = AnalysisError.NO_ERRORS; |
| 1072 _parseErrorsState = CacheState.INVALID; |
| 1073 _parsedUnit = null; |
| 1074 _parsedUnitState = CacheState.INVALID; |
| 1075 invalidateAllResolutionInformation(); |
| 1076 } |
| 1077 |
| 956 /** | 1078 /** |
| 957 * Invalidate all of the resolution information associated with the compilatio
n unit. | 1079 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 958 */ | 1080 */ |
| 959 void invalidateAllResolutionInformation() { | 1081 void invalidateAllResolutionInformation() { |
| 960 if (_resolutionMap == null) { | 1082 _element = null; |
| 961 _resolutionState.invalidateAllResolutionInformation(); | 1083 _elementState = CacheState.INVALID; |
| 962 } else { | 1084 _includedParts = Source.EMPTY_ARRAY; |
| 963 for (DartEntryImpl_ResolutionState state in _resolutionMap.values) { | 1085 _includedPartsState = CacheState.INVALID; |
| 964 state.invalidateAllResolutionInformation(); | 1086 _referencedLibraries = Source.EMPTY_ARRAY; |
| 965 } | 1087 _referencedLibrariesState = CacheState.INVALID; |
| 1088 _bitmask = 0; |
| 1089 _clientServerState = CacheState.INVALID; |
| 1090 _launchableState = CacheState.INVALID; |
| 1091 _publicNamespace = null; |
| 1092 _publicNamespaceState = CacheState.INVALID; |
| 1093 _resolutionState.invalidateAllResolutionInformation(); |
| 1094 } |
| 1095 |
| 1096 /** |
| 1097 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 1098 * entry. This will set the state of all information, including any resolution
-based information, |
| 1099 * as being in error. |
| 1100 */ |
| 1101 void recordParseError() { |
| 1102 setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 1103 _sourceKind = SourceKind.UNKNOWN; |
| 1104 _sourceKindState = CacheState.ERROR; |
| 1105 _parseErrors = AnalysisError.NO_ERRORS; |
| 1106 _parseErrorsState = CacheState.ERROR; |
| 1107 _parsedUnit = null; |
| 1108 _parsedUnitState = CacheState.ERROR; |
| 1109 recordResolutionError(); |
| 1110 } |
| 1111 |
| 1112 /** |
| 1113 * Record that the parse-related information for the associated source is abou
t to be computed by |
| 1114 * the current thread. |
| 1115 */ |
| 1116 void recordParseInProcess() { |
| 1117 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { |
| 1118 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS); |
| 966 } | 1119 } |
| 967 _elementState = CacheState.INVALID; | 1120 if (_sourceKindState != CacheState.VALID) { |
| 1121 _sourceKindState = CacheState.IN_PROCESS; |
| 1122 } |
| 1123 if (_parseErrorsState != CacheState.VALID) { |
| 1124 _parseErrorsState = CacheState.IN_PROCESS; |
| 1125 } |
| 1126 if (_parsedUnitState != CacheState.VALID) { |
| 1127 _parsedUnitState = CacheState.IN_PROCESS; |
| 1128 } |
| 1129 } |
| 1130 |
| 1131 /** |
| 1132 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 1133 * entry. This will set the state of all resolution-based information as being
in error, but will |
| 1134 * not change the state of any parse results. |
| 1135 */ |
| 1136 void recordResolutionError() { |
| 968 _element = null; | 1137 _element = null; |
| 969 _publicNamespaceState = CacheState.INVALID; | 1138 _elementState = CacheState.ERROR; |
| 1139 _includedParts = Source.EMPTY_ARRAY; |
| 1140 _includedPartsState = CacheState.ERROR; |
| 1141 _referencedLibraries = Source.EMPTY_ARRAY; |
| 1142 _referencedLibrariesState = CacheState.ERROR; |
| 1143 _bitmask = 0; |
| 1144 _clientServerState = CacheState.ERROR; |
| 1145 _launchableState = CacheState.ERROR; |
| 970 _publicNamespace = null; | 1146 _publicNamespace = null; |
| 971 _launchableState = CacheState.INVALID; | 1147 _publicNamespaceState = CacheState.ERROR; |
| 972 _clientServerState = CacheState.INVALID; | 1148 _resolutionState.recordResolutionError(); |
| 973 _bitmask = 0; | |
| 974 } | 1149 } |
| 1150 |
| 975 /** | 1151 /** |
| 976 * Remove any resolution information associated with this compilation unit bei
ng part of the given | 1152 * Remove any resolution information associated with this compilation unit bei
ng part of the given |
| 977 * library, presumably because it is no longer part of the library. | 1153 * library, presumably because it is no longer part of the library. |
| 978 * @param librarySource the source of the defining compilation unit of the lib
rary that used to | 1154 * @param librarySource the source of the defining compilation unit of the lib
rary that used to |
| 979 * contain this part but no longer does | 1155 * contain this part but no longer does |
| 980 */ | 1156 */ |
| 981 void removeResolution(Source librarySource2) { | 1157 void removeResolution(Source librarySource2) { |
| 982 if (_resolutionMap == null) { | 1158 if (librarySource2 != null) { |
| 983 if (librarySource2 == this._librarySource) { | 1159 if (librarySource2 == _resolutionState._librarySource) { |
| 984 _resolutionState.invalidateAllResolutionInformation(); | 1160 if (_resolutionState._nextState == null) { |
| 985 this._librarySource = null; | 1161 _resolutionState.invalidateAllResolutionInformation(); |
| 986 } | 1162 } else { |
| 987 } else { | 1163 _resolutionState = _resolutionState._nextState; |
| 988 _resolutionMap.remove(librarySource2); | 1164 } |
| 989 if (_resolutionMap.length == 1) { | 1165 } else { |
| 990 MapEntry<Source, DartEntryImpl_ResolutionState> entry = new JavaIterator
(getMapEntrySet(_resolutionMap)).next(); | 1166 DartEntryImpl_ResolutionState priorState = _resolutionState; |
| 991 this._librarySource = entry.getKey(); | 1167 DartEntryImpl_ResolutionState state = _resolutionState._nextState; |
| 992 _resolutionState = entry.getValue(); | 1168 while (state != null) { |
| 993 _resolutionMap = null; | 1169 if (librarySource2 == state._librarySource) { |
| 1170 priorState._nextState = state._nextState; |
| 1171 break; |
| 1172 } |
| 1173 priorState = state; |
| 1174 state = state._nextState; |
| 1175 } |
| 994 } | 1176 } |
| 995 } | 1177 } |
| 996 } | 1178 } |
| 1179 |
| 997 /** | 1180 /** |
| 998 * Set the results of parsing the compilation unit at the given time to the gi
ven values. | 1181 * Set the results of parsing the compilation unit at the given time to the gi
ven values. |
| 999 * @param modificationStamp the earliest time at which the source was last mod
ified before the | 1182 * @param modificationStamp the earliest time at which the source was last mod
ified before the |
| 1000 * parsing was started | 1183 * parsing was started |
| 1001 * @param lineInfo the line information resulting from parsing the compilation
unit | 1184 * @param lineInfo the line information resulting from parsing the compilation
unit |
| 1002 * @param unit the AST structure resulting from parsing the compilation unit | 1185 * @param unit the AST structure resulting from parsing the compilation unit |
| 1003 * @param errors the parse errors resulting from parsing the compilation unit | 1186 * @param errors the parse errors resulting from parsing the compilation unit |
| 1004 */ | 1187 */ |
| 1005 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit
unit, List<AnalysisError> errors) { | 1188 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit
unit, List<AnalysisError> errors) { |
| 1006 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { | 1189 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1028 _launchableState = state; | 1211 _launchableState = state; |
| 1029 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1212 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 1030 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); | 1213 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); |
| 1031 _parseErrorsState = state; | 1214 _parseErrorsState = state; |
| 1032 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1215 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 1033 _parsedUnit = updatedValue(state, _parsedUnit, null); | 1216 _parsedUnit = updatedValue(state, _parsedUnit, null); |
| 1034 _parsedUnitState = state; | 1217 _parsedUnitState = state; |
| 1035 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1218 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 1036 _publicNamespace = updatedValue(state, _publicNamespace, null); | 1219 _publicNamespace = updatedValue(state, _publicNamespace, null); |
| 1037 _publicNamespaceState = state; | 1220 _publicNamespaceState = state; |
| 1221 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { |
| 1222 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM
PTY_ARRAY); |
| 1223 _referencedLibrariesState = state; |
| 1038 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1224 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 1039 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN); | 1225 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN); |
| 1040 _sourceKindState = state; | 1226 _sourceKindState = state; |
| 1041 } else { | 1227 } else { |
| 1042 super.setState(descriptor, state); | 1228 super.setState(descriptor, state); |
| 1043 } | 1229 } |
| 1044 } | 1230 } |
| 1231 |
| 1045 /** | 1232 /** |
| 1046 * Set the state of the data represented by the given descriptor in the contex
t of the given | 1233 * Set the state of the data represented by the given descriptor in the contex
t of the given |
| 1047 * library to the given state. | 1234 * library to the given state. |
| 1048 * @param descriptor the descriptor representing the data whose state is to be
set | 1235 * @param descriptor the descriptor representing the data whose state is to be
set |
| 1049 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 1236 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 1050 * context for the data | 1237 * context for the data |
| 1051 * @param state the new state of the data represented by the given descriptor | 1238 * @param cacheState the new state of the data represented by the given descri
ptor |
| 1052 */ | 1239 */ |
| 1053 void setState2(DataDescriptor<Object> descriptor, Source librarySource2, Cache
State state) { | 1240 void setState2(DataDescriptor<Object> descriptor, Source librarySource, CacheS
tate cacheState) { |
| 1054 if (_resolutionMap == null && this._librarySource != librarySource2) { | 1241 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); |
| 1055 _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>(); | |
| 1056 _resolutionMap[this._librarySource] = _resolutionState; | |
| 1057 this._librarySource = null; | |
| 1058 _resolutionState = null; | |
| 1059 } | |
| 1060 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1242 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1061 if (_resolutionMap == null) { | 1243 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors
, AnalysisError.NO_ERRORS); |
| 1062 _resolutionState._resolutionErrors = updatedValue(state, _resolutionStat
e._resolutionErrors, AnalysisError.NO_ERRORS); | 1244 state._resolutionErrorsState = cacheState; |
| 1063 _resolutionState._resolutionErrorsState = state; | |
| 1064 } else { | |
| 1065 DartEntryImpl_ResolutionState resolutionState = _resolutionMap[librarySo
urce2]; | |
| 1066 if (resolutionState == null) { | |
| 1067 resolutionState = new DartEntryImpl_ResolutionState(); | |
| 1068 _resolutionMap[librarySource2] = resolutionState; | |
| 1069 } | |
| 1070 resolutionState._resolutionErrors = updatedValue(state, resolutionState.
_resolutionErrors, AnalysisError.NO_ERRORS); | |
| 1071 resolutionState._resolutionErrorsState = state; | |
| 1072 } | |
| 1073 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1245 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1074 if (_resolutionMap == null) { | 1246 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); |
| 1075 _resolutionState._resolvedUnit = updatedValue(state, _resolutionState._r
esolvedUnit, null); | 1247 state._resolvedUnitState = cacheState; |
| 1076 _resolutionState._resolvedUnitState = state; | |
| 1077 } else { | |
| 1078 DartEntryImpl_ResolutionState resolutionState = _resolutionMap[librarySo
urce2]; | |
| 1079 if (resolutionState == null) { | |
| 1080 resolutionState = new DartEntryImpl_ResolutionState(); | |
| 1081 _resolutionMap[librarySource2] = resolutionState; | |
| 1082 } | |
| 1083 resolutionState._resolvedUnit = updatedValue(state, resolutionState._res
olvedUnit, null); | |
| 1084 resolutionState._resolvedUnitState = state; | |
| 1085 } | |
| 1086 } else { | 1248 } else { |
| 1087 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1249 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1088 } | 1250 } |
| 1089 } | 1251 } |
| 1090 void setValue(DataDescriptor descriptor, Object value) { | 1252 void setValue(DataDescriptor descriptor, Object value) { |
| 1091 if (identical(descriptor, DartEntry.ELEMENT)) { | 1253 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 1092 _element = value as LibraryElement; | 1254 _element = value as LibraryElement; |
| 1093 _elementState = CacheState.VALID; | 1255 _elementState = CacheState.VALID; |
| 1094 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1256 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 1095 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); | 1257 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1110 _launchableState = CacheState.VALID; | 1272 _launchableState = CacheState.VALID; |
| 1111 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1273 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 1112 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); | 1274 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); |
| 1113 _parseErrorsState = CacheState.VALID; | 1275 _parseErrorsState = CacheState.VALID; |
| 1114 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1276 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 1115 _parsedUnit = value as CompilationUnit; | 1277 _parsedUnit = value as CompilationUnit; |
| 1116 _parsedUnitState = CacheState.VALID; | 1278 _parsedUnitState = CacheState.VALID; |
| 1117 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1279 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 1118 _publicNamespace = value as Namespace; | 1280 _publicNamespace = value as Namespace; |
| 1119 _publicNamespaceState = CacheState.VALID; | 1281 _publicNamespaceState = CacheState.VALID; |
| 1282 } else if (identical(descriptor, DartEntry.REFERENCED_LIBRARIES)) { |
| 1283 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List
<Source>); |
| 1284 _referencedLibrariesState = CacheState.VALID; |
| 1120 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1285 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 1121 _sourceKind = value as SourceKind; | 1286 _sourceKind = value as SourceKind; |
| 1122 _sourceKindState = CacheState.VALID; | 1287 _sourceKindState = CacheState.VALID; |
| 1123 } else { | 1288 } else { |
| 1124 super.setValue(descriptor, value); | 1289 super.setValue(descriptor, value); |
| 1125 } | 1290 } |
| 1126 } | 1291 } |
| 1292 |
| 1127 /** | 1293 /** |
| 1128 * Set the value of the data represented by the given descriptor in the contex
t of the given | 1294 * Set the value of the data represented by the given descriptor in the contex
t of the given |
| 1129 * library to the given value, and set the state of that data to {@link CacheS
tate#VALID}. | 1295 * library to the given value, and set the state of that data to {@link CacheS
tate#VALID}. |
| 1130 * @param descriptor the descriptor representing which data is to have its val
ue set | 1296 * @param descriptor the descriptor representing which data is to have its val
ue set |
| 1131 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 1297 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 1132 * context for the data | 1298 * context for the data |
| 1133 * @param value the new value of the data represented by the given descriptor
and library | 1299 * @param value the new value of the data represented by the given descriptor
and library |
| 1134 */ | 1300 */ |
| 1135 void setValue2(DataDescriptor descriptor, Source librarySource2, Object value)
{ | 1301 void setValue2(DataDescriptor descriptor, Source librarySource, Object value)
{ |
| 1136 if (_resolutionMap == null) { | 1302 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); |
| 1137 if (this._librarySource == null) { | |
| 1138 this._librarySource = librarySource2; | |
| 1139 } else if (librarySource2 != this._librarySource) { | |
| 1140 _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>(); | |
| 1141 _resolutionMap[this._librarySource] = _resolutionState; | |
| 1142 this._librarySource = null; | |
| 1143 _resolutionState = null; | |
| 1144 } | |
| 1145 } | |
| 1146 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1303 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1147 if (_resolutionMap == null) { | 1304 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); |
| 1148 _resolutionState._resolutionErrors = value == null ? AnalysisError.NO_ER
RORS : (value as List<AnalysisError>); | 1305 state._resolutionErrorsState = CacheState.VALID; |
| 1149 _resolutionState._resolutionErrorsState = CacheState.VALID; | |
| 1150 } else { | |
| 1151 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2]; | |
| 1152 if (state != null) { | |
| 1153 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (v
alue as List<AnalysisError>); | |
| 1154 state._resolutionErrorsState = CacheState.VALID; | |
| 1155 } | |
| 1156 } | |
| 1157 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1306 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1158 if (_resolutionMap == null) { | 1307 state._resolvedUnit = value as CompilationUnit; |
| 1159 _resolutionState._resolvedUnit = value as CompilationUnit; | 1308 state._resolvedUnitState = CacheState.VALID; |
| 1160 _resolutionState._resolvedUnitState = CacheState.VALID; | |
| 1161 } else { | |
| 1162 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2]; | |
| 1163 if (state != null) { | |
| 1164 state._resolvedUnit = value as CompilationUnit; | |
| 1165 state._resolvedUnitState = CacheState.VALID; | |
| 1166 } | |
| 1167 } | |
| 1168 } | 1309 } |
| 1169 } | 1310 } |
| 1170 void copyFrom(SourceEntryImpl entry) { | 1311 void copyFrom(SourceEntryImpl entry) { |
| 1171 super.copyFrom(entry); | 1312 super.copyFrom(entry); |
| 1172 DartEntryImpl other = entry as DartEntryImpl; | 1313 DartEntryImpl other = entry as DartEntryImpl; |
| 1173 _sourceKindState = other._sourceKindState; | 1314 _sourceKindState = other._sourceKindState; |
| 1174 _sourceKind = other._sourceKind; | 1315 _sourceKind = other._sourceKind; |
| 1175 _parsedUnitState = other._parsedUnitState; | 1316 _parsedUnitState = other._parsedUnitState; |
| 1176 _parsedUnit = other._parsedUnit; | 1317 _parsedUnit = other._parsedUnit; |
| 1177 _parseErrorsState = other._parseErrorsState; | 1318 _parseErrorsState = other._parseErrorsState; |
| 1178 _parseErrors = other._parseErrors; | 1319 _parseErrors = other._parseErrors; |
| 1179 _includedPartsState = other._includedPartsState; | 1320 _includedPartsState = other._includedPartsState; |
| 1180 _includedParts = other._includedParts; | 1321 _includedParts = other._includedParts; |
| 1181 if (other._resolutionMap == null) { | 1322 _referencedLibrariesState = other._referencedLibrariesState; |
| 1182 _librarySource = other._librarySource; | 1323 _referencedLibraries = other._referencedLibraries; |
| 1183 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionState
(); | 1324 _resolutionState.copyFrom(other._resolutionState); |
| 1184 newState.copyFrom(_resolutionState); | |
| 1185 _resolutionState = newState; | |
| 1186 } else { | |
| 1187 _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>(); | |
| 1188 for (MapEntry<Source, DartEntryImpl_ResolutionState> mapEntry in getMapEnt
rySet(other._resolutionMap)) { | |
| 1189 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); | |
| 1190 newState.copyFrom(mapEntry.getValue()); | |
| 1191 _resolutionMap[mapEntry.getKey()] = newState; | |
| 1192 } | |
| 1193 } | |
| 1194 _elementState = other._elementState; | 1325 _elementState = other._elementState; |
| 1195 _element = other._element; | 1326 _element = other._element; |
| 1196 _publicNamespaceState = other._publicNamespaceState; | 1327 _publicNamespaceState = other._publicNamespaceState; |
| 1197 _publicNamespace = other._publicNamespace; | 1328 _publicNamespace = other._publicNamespace; |
| 1198 _clientServerState = other._clientServerState; | 1329 _clientServerState = other._clientServerState; |
| 1199 _launchableState = other._launchableState; | 1330 _launchableState = other._launchableState; |
| 1200 _bitmask = other._bitmask; | 1331 _bitmask = other._bitmask; |
| 1201 } | 1332 } |
| 1333 |
| 1334 /** |
| 1335 * Return a resolution state for the specified library, creating one as necess
ary. |
| 1336 * @param librarySource the library source (not {@code null}) |
| 1337 * @return the resolution state (not {@code null}) |
| 1338 */ |
| 1339 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2
) { |
| 1340 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1341 if (state._librarySource == null) { |
| 1342 state._librarySource = librarySource2; |
| 1343 return state; |
| 1344 } |
| 1345 while (state._librarySource != librarySource2) { |
| 1346 if (state._nextState == null) { |
| 1347 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); |
| 1348 newState._librarySource = librarySource2; |
| 1349 state._nextState = newState; |
| 1350 return newState; |
| 1351 } |
| 1352 state = state._nextState; |
| 1353 } |
| 1354 return state; |
| 1355 } |
| 1356 |
| 1202 /** | 1357 /** |
| 1203 * Given that one of the flags is being transitioned to the given state, retur
n the value of the | 1358 * Given that one of the flags is being transitioned to the given state, retur
n the value of the |
| 1204 * flags that should be kept in the cache. | 1359 * flags that should be kept in the cache. |
| 1205 * @param state the state to which the data is being transitioned | 1360 * @param state the state to which the data is being transitioned |
| 1206 * @param currentValue the value of the flags before the transition | 1361 * @param currentValue the value of the flags before the transition |
| 1207 * @param bitMask the mask used to access the bit whose state is being set | 1362 * @param bitMask the mask used to access the bit whose state is being set |
| 1208 * @return the value of the data that should be kept in the cache | 1363 * @return the value of the data that should be kept in the cache |
| 1209 */ | 1364 */ |
| 1210 int updatedValue2(CacheState state, int currentValue, int bitMask) { | 1365 int updatedValue2(CacheState state, int currentValue, int bitMask) { |
| 1211 if (identical(state, CacheState.VALID)) { | 1366 if (identical(state, CacheState.VALID)) { |
| 1212 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 1367 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 1213 } else if (identical(state, CacheState.IN_PROCESS)) { | 1368 } else if (identical(state, CacheState.IN_PROCESS)) { |
| 1214 return currentValue; | 1369 return currentValue; |
| 1215 } | 1370 } |
| 1216 return currentValue &= ~bitMask; | 1371 return currentValue &= ~bitMask; |
| 1217 } | 1372 } |
| 1218 } | 1373 } |
| 1374 |
| 1219 /** | 1375 /** |
| 1220 * Instances of the class {@code ResolutionState} represent the information prod
uced by resolving | 1376 * Instances of the class {@code ResolutionState} represent the information prod
uced by resolving |
| 1221 * a compilation unit as part of a specific library. | 1377 * a compilation unit as part of a specific library. |
| 1222 */ | 1378 */ |
| 1223 class DartEntryImpl_ResolutionState { | 1379 class DartEntryImpl_ResolutionState { |
| 1380 |
| 1381 /** |
| 1382 * The next resolution state or {@code null} if none. |
| 1383 */ |
| 1384 DartEntryImpl_ResolutionState _nextState; |
| 1385 |
| 1386 /** |
| 1387 * The source for the defining compilation unit of the library that contains t
his unit. If this |
| 1388 * unit is the defining compilation unit for it's library, then this will be t
he source for this |
| 1389 * unit. |
| 1390 */ |
| 1391 Source _librarySource; |
| 1392 |
| 1224 /** | 1393 /** |
| 1225 * The state of the cached resolved compilation unit. | 1394 * The state of the cached resolved compilation unit. |
| 1226 */ | 1395 */ |
| 1227 CacheState _resolvedUnitState = CacheState.INVALID; | 1396 CacheState _resolvedUnitState = CacheState.INVALID; |
| 1397 |
| 1228 /** | 1398 /** |
| 1229 * The resolved compilation unit, or {@code null} if the resolved compilation
unit is not | 1399 * The resolved compilation unit, or {@code null} if the resolved compilation
unit is not |
| 1230 * currently cached. | 1400 * currently cached. |
| 1231 */ | 1401 */ |
| 1232 CompilationUnit _resolvedUnit; | 1402 CompilationUnit _resolvedUnit; |
| 1403 |
| 1233 /** | 1404 /** |
| 1234 * The state of the cached resolution errors. | 1405 * The state of the cached resolution errors. |
| 1235 */ | 1406 */ |
| 1236 CacheState _resolutionErrorsState = CacheState.INVALID; | 1407 CacheState _resolutionErrorsState = CacheState.INVALID; |
| 1408 |
| 1237 /** | 1409 /** |
| 1238 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are | 1410 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are |
| 1239 * not currently cached. | 1411 * not currently cached. |
| 1240 */ | 1412 */ |
| 1241 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 1413 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1414 |
| 1242 /** | 1415 /** |
| 1243 * Initialize a newly created resolution state. | 1416 * Set this state to be exactly like the given state, recursively copying the
next state as |
| 1244 */ | 1417 * necessary. |
| 1245 DartEntryImpl_ResolutionState() : super() { | |
| 1246 } | |
| 1247 /** | |
| 1248 * Set this state to be exactly like the given state. | |
| 1249 * @param other the state to be copied | 1418 * @param other the state to be copied |
| 1250 */ | 1419 */ |
| 1251 void copyFrom(DartEntryImpl_ResolutionState other) { | 1420 void copyFrom(DartEntryImpl_ResolutionState other) { |
| 1421 _librarySource = other._librarySource; |
| 1252 _resolvedUnitState = other._resolvedUnitState; | 1422 _resolvedUnitState = other._resolvedUnitState; |
| 1253 _resolvedUnit = other._resolvedUnit; | 1423 _resolvedUnit = other._resolvedUnit; |
| 1254 _resolutionErrorsState = other._resolutionErrorsState; | 1424 _resolutionErrorsState = other._resolutionErrorsState; |
| 1255 _resolutionErrors = other._resolutionErrors; | 1425 _resolutionErrors = other._resolutionErrors; |
| 1426 if (other._nextState != null) { |
| 1427 _nextState = new DartEntryImpl_ResolutionState(); |
| 1428 _nextState.copyFrom(other._nextState); |
| 1429 } |
| 1256 } | 1430 } |
| 1431 |
| 1257 /** | 1432 /** |
| 1258 * Invalidate all of the resolution information associated with the compilatio
n unit. | 1433 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 1259 */ | 1434 */ |
| 1260 void invalidateAllResolutionInformation() { | 1435 void invalidateAllResolutionInformation() { |
| 1436 _nextState = null; |
| 1437 _librarySource = null; |
| 1261 _resolvedUnitState = CacheState.INVALID; | 1438 _resolvedUnitState = CacheState.INVALID; |
| 1262 _resolvedUnit = null; | 1439 _resolvedUnit = null; |
| 1263 _resolutionErrorsState = CacheState.INVALID; | 1440 _resolutionErrorsState = CacheState.INVALID; |
| 1264 _resolutionErrors = AnalysisError.NO_ERRORS; | 1441 _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1265 } | 1442 } |
| 1443 |
| 1444 /** |
| 1445 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 1446 * entry. This will set the state of all resolution-based information as being
in error, but |
| 1447 * will not change the state of any parse results. |
| 1448 */ |
| 1449 void recordResolutionError() { |
| 1450 _nextState = null; |
| 1451 _librarySource = null; |
| 1452 _resolvedUnitState = CacheState.ERROR; |
| 1453 _resolvedUnit = null; |
| 1454 _resolutionErrorsState = CacheState.ERROR; |
| 1455 _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1456 } |
| 1266 } | 1457 } |
| 1458 |
| 1267 /** | 1459 /** |
| 1268 * Instances of the class {@code DataDescriptor} are immutable constants represe
nting data that can | 1460 * Instances of the class {@code DataDescriptor} are immutable constants represe
nting data that can |
| 1269 * be stored in the cache. | 1461 * be stored in the cache. |
| 1270 */ | 1462 */ |
| 1271 class DataDescriptor<E> { | 1463 class DataDescriptor<E> { |
| 1464 |
| 1272 /** | 1465 /** |
| 1273 * The name of the descriptor, used for debugging purposes. | 1466 * The name of the descriptor, used for debugging purposes. |
| 1274 */ | 1467 */ |
| 1275 String _name; | 1468 String _name; |
| 1469 |
| 1276 /** | 1470 /** |
| 1277 * Initialize a newly created descriptor to have the given name. | 1471 * Initialize a newly created descriptor to have the given name. |
| 1278 * @param name the name of the descriptor | 1472 * @param name the name of the descriptor |
| 1279 */ | 1473 */ |
| 1280 DataDescriptor(String name) { | 1474 DataDescriptor(String name) { |
| 1281 this._name = name; | 1475 this._name = name; |
| 1282 } | 1476 } |
| 1283 String toString() => _name; | 1477 String toString() => _name; |
| 1284 } | 1478 } |
| 1479 |
| 1285 /** | 1480 /** |
| 1286 * The interface {@code HtmlEntry} defines the behavior of objects that maintain
the information | 1481 * The interface {@code HtmlEntry} defines the behavior of objects that maintain
the information |
| 1287 * cached by an analysis context about an individual HTML file. | 1482 * cached by an analysis context about an individual HTML file. |
| 1288 * @coverage dart.engine | 1483 * @coverage dart.engine |
| 1289 */ | 1484 */ |
| 1290 abstract class HtmlEntry implements SourceEntry { | 1485 abstract class HtmlEntry implements SourceEntry { |
| 1486 |
| 1291 /** | 1487 /** |
| 1292 * The data descriptor representing the HTML element. | 1488 * The data descriptor representing the HTML element. |
| 1293 */ | 1489 */ |
| 1294 static DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElement>("
HtmlEntry.ELEMENT"); | 1490 static DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElement>("
HtmlEntry.ELEMENT"); |
| 1491 |
| 1295 /** | 1492 /** |
| 1296 * The data descriptor representing the parsed AST structure. | 1493 * The data descriptor representing the parsed AST structure. |
| 1297 */ | 1494 */ |
| 1298 static DataDescriptor<HtmlUnit> PARSED_UNIT = new DataDescriptor<HtmlUnit>("Ht
mlEntry.PARSED_UNIT"); | 1495 static DataDescriptor<HtmlUnit> PARSED_UNIT = new DataDescriptor<HtmlUnit>("Ht
mlEntry.PARSED_UNIT"); |
| 1496 |
| 1299 /** | 1497 /** |
| 1300 * The data descriptor representing the list of referenced libraries. | 1498 * The data descriptor representing the list of referenced libraries. |
| 1301 */ | 1499 */ |
| 1302 static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor<
List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); | 1500 static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor<
List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); |
| 1501 |
| 1303 /** | 1502 /** |
| 1304 * The data descriptor representing the errors resulting from resolving the so
urce. | 1503 * The data descriptor representing the errors resulting from resolving the so
urce. |
| 1305 */ | 1504 */ |
| 1306 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip
tor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); | 1505 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip
tor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); |
| 1506 |
| 1307 /** | 1507 /** |
| 1308 * The data descriptor representing the resolved AST structure. | 1508 * The data descriptor representing the resolved AST structure. |
| 1309 */ | 1509 */ |
| 1310 static DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlUnit>("
HtmlEntry.RESOLVED_UNIT"); | 1510 static DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlUnit>("
HtmlEntry.RESOLVED_UNIT"); |
| 1511 |
| 1512 /** |
| 1513 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 1514 * @return all of the errors associated with the compilation unit |
| 1515 */ |
| 1516 List<AnalysisError> get allErrors; |
| 1311 HtmlEntryImpl get writableCopy; | 1517 HtmlEntryImpl get writableCopy; |
| 1312 } | 1518 } |
| 1519 |
| 1313 /** | 1520 /** |
| 1314 * Instances of the class {@code HtmlEntryImpl} implement an {@link HtmlEntry}. | 1521 * Instances of the class {@code HtmlEntryImpl} implement an {@link HtmlEntry}. |
| 1315 * @coverage dart.engine | 1522 * @coverage dart.engine |
| 1316 */ | 1523 */ |
| 1317 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { | 1524 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { |
| 1525 |
| 1318 /** | 1526 /** |
| 1319 * The state of the cached parsed (but not resolved) HTML unit. | 1527 * The state of the cached parsed (but not resolved) HTML unit. |
| 1320 */ | 1528 */ |
| 1321 CacheState _parsedUnitState = CacheState.INVALID; | 1529 CacheState _parsedUnitState = CacheState.INVALID; |
| 1530 |
| 1322 /** | 1531 /** |
| 1323 * The parsed HTML unit, or {@code null} if the parsed HTML unit is not curren
tly cached. | 1532 * The parsed HTML unit, or {@code null} if the parsed HTML unit is not curren
tly cached. |
| 1324 */ | 1533 */ |
| 1325 HtmlUnit _parsedUnit; | 1534 HtmlUnit _parsedUnit; |
| 1535 |
| 1326 /** | 1536 /** |
| 1327 * The state of the cached resolution errors. | 1537 * The state of the cached resolution errors. |
| 1328 */ | 1538 */ |
| 1329 CacheState _resolutionErrorsState = CacheState.INVALID; | 1539 CacheState _resolutionErrorsState = CacheState.INVALID; |
| 1540 |
| 1330 /** | 1541 /** |
| 1331 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are not | 1542 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are not |
| 1332 * currently cached. | 1543 * currently cached. |
| 1333 */ | 1544 */ |
| 1334 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 1545 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1546 |
| 1335 /** | 1547 /** |
| 1336 * The state of the cached parsed and resolved HTML unit. | 1548 * The state of the cached parsed and resolved HTML unit. |
| 1337 */ | 1549 */ |
| 1338 CacheState _resolvedUnitState = CacheState.INVALID; | 1550 CacheState _resolvedUnitState = CacheState.INVALID; |
| 1551 |
| 1339 /** | 1552 /** |
| 1340 * The resolved HTML unit, or {@code null} if the resolved HTML unit is not cu
rrently cached. | 1553 * The resolved HTML unit, or {@code null} if the resolved HTML unit is not cu
rrently cached. |
| 1341 */ | 1554 */ |
| 1342 HtmlUnit _resolvedUnit; | 1555 HtmlUnit _resolvedUnit; |
| 1556 |
| 1343 /** | 1557 /** |
| 1344 * The state of the cached list of referenced libraries. | 1558 * The state of the cached list of referenced libraries. |
| 1345 */ | 1559 */ |
| 1346 CacheState _referencedLibrariesState = CacheState.INVALID; | 1560 CacheState _referencedLibrariesState = CacheState.INVALID; |
| 1561 |
| 1347 /** | 1562 /** |
| 1348 * The list of libraries referenced in the HTML, or {@code null} if the list i
s not currently | 1563 * The list of libraries referenced in the HTML, or {@code null} if the list i
s not currently |
| 1349 * cached. Note that this list does not include libraries defined directly wit
hin the HTML file. | 1564 * cached. Note that this list does not include libraries defined directly wit
hin the HTML file. |
| 1350 */ | 1565 */ |
| 1351 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; | 1566 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; |
| 1567 |
| 1352 /** | 1568 /** |
| 1353 * The state of the cached HTML element. | 1569 * The state of the cached HTML element. |
| 1354 */ | 1570 */ |
| 1355 CacheState _elementState = CacheState.INVALID; | 1571 CacheState _elementState = CacheState.INVALID; |
| 1572 |
| 1356 /** | 1573 /** |
| 1357 * The element representing the HTML file, or {@code null} if the element is n
ot currently cached. | 1574 * The element representing the HTML file, or {@code null} if the element is n
ot currently cached. |
| 1358 */ | 1575 */ |
| 1359 HtmlElement _element; | 1576 HtmlElement _element; |
| 1360 /** | 1577 List<AnalysisError> get allErrors { |
| 1361 * Initialize a newly created cache entry to be empty. | 1578 List<AnalysisError> errors = new List<AnalysisError>(); |
| 1362 */ | 1579 for (AnalysisError error in _resolutionErrors) { |
| 1363 HtmlEntryImpl() : super() { | 1580 errors.add(error); |
| 1581 } |
| 1582 if (errors.length == 0) { |
| 1583 return AnalysisError.NO_ERRORS; |
| 1584 } |
| 1585 return new List.from(errors); |
| 1364 } | 1586 } |
| 1365 SourceKind get kind => SourceKind.HTML; | 1587 SourceKind get kind => SourceKind.HTML; |
| 1366 CacheState getState(DataDescriptor<Object> descriptor) { | 1588 CacheState getState(DataDescriptor<Object> descriptor) { |
| 1367 if (identical(descriptor, HtmlEntry.ELEMENT)) { | 1589 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1368 return _elementState; | 1590 return _elementState; |
| 1369 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 1591 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1370 return _parsedUnitState; | 1592 return _parsedUnitState; |
| 1371 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 1593 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1372 return _referencedLibrariesState; | 1594 return _referencedLibrariesState; |
| 1373 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 1595 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 _referencedLibrariesState = other._referencedLibrariesState; | 1666 _referencedLibrariesState = other._referencedLibrariesState; |
| 1445 _referencedLibraries = other._referencedLibraries; | 1667 _referencedLibraries = other._referencedLibraries; |
| 1446 _resolutionErrors = other._resolutionErrors; | 1668 _resolutionErrors = other._resolutionErrors; |
| 1447 _resolutionErrorsState = other._resolutionErrorsState; | 1669 _resolutionErrorsState = other._resolutionErrorsState; |
| 1448 _resolvedUnitState = other._resolvedUnitState; | 1670 _resolvedUnitState = other._resolvedUnitState; |
| 1449 _resolvedUnit = other._resolvedUnit; | 1671 _resolvedUnit = other._resolvedUnit; |
| 1450 _elementState = other._elementState; | 1672 _elementState = other._elementState; |
| 1451 _element = other._element; | 1673 _element = other._element; |
| 1452 } | 1674 } |
| 1453 } | 1675 } |
| 1676 |
| 1454 /** | 1677 /** |
| 1455 * The interface {@code SourceEntry} defines the behavior of objects that mainta
in the information | 1678 * The interface {@code SourceEntry} defines the behavior of objects that mainta
in the information |
| 1456 * cached by an analysis context about an individual source, no matter what kind
of source it is. | 1679 * cached by an analysis context about an individual source, no matter what kind
of source it is. |
| 1457 * <p> | 1680 * <p> |
| 1458 * Source entries should be treated as if they were immutable unless a writable
copy of the entry | 1681 * Source entries should be treated as if they were immutable unless a writable
copy of the entry |
| 1459 * has been obtained and has not yet been made visible to other threads. | 1682 * has been obtained and has not yet been made visible to other threads. |
| 1460 * @coverage dart.engine | 1683 * @coverage dart.engine |
| 1461 */ | 1684 */ |
| 1462 abstract class SourceEntry { | 1685 abstract class SourceEntry { |
| 1686 |
| 1463 /** | 1687 /** |
| 1464 * The data descriptor representing the line information. | 1688 * The data descriptor representing the line information. |
| 1465 */ | 1689 */ |
| 1466 static DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>("Sour
ceEntry.LINE_INFO"); | 1690 static DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>("Sour
ceEntry.LINE_INFO"); |
| 1691 |
| 1467 /** | 1692 /** |
| 1468 * Return the kind of the source, or {@code null} if the kind is not currently
cached. | 1693 * Return the kind of the source, or {@code null} if the kind is not currently
cached. |
| 1469 * @return the kind of the source | 1694 * @return the kind of the source |
| 1470 */ | 1695 */ |
| 1471 SourceKind get kind; | 1696 SourceKind get kind; |
| 1697 |
| 1472 /** | 1698 /** |
| 1473 * Return the most recent time at which the state of the source matched the st
ate represented by | 1699 * Return the most recent time at which the state of the source matched the st
ate represented by |
| 1474 * this entry. | 1700 * this entry. |
| 1475 * @return the modification time of this entry | 1701 * @return the modification time of this entry |
| 1476 */ | 1702 */ |
| 1477 int get modificationTime; | 1703 int get modificationTime; |
| 1704 |
| 1478 /** | 1705 /** |
| 1479 * Return the state of the data represented by the given descriptor. | 1706 * Return the state of the data represented by the given descriptor. |
| 1480 * @param descriptor the descriptor representing the data whose state is to be
returned | 1707 * @param descriptor the descriptor representing the data whose state is to be
returned |
| 1481 * @return the state of the data represented by the given descriptor | 1708 * @return the state of the data represented by the given descriptor |
| 1482 */ | 1709 */ |
| 1483 CacheState getState(DataDescriptor<Object> descriptor); | 1710 CacheState getState(DataDescriptor<Object> descriptor); |
| 1711 |
| 1484 /** | 1712 /** |
| 1485 * Return the value of the data represented by the given descriptor, or {@code
null} if the data | 1713 * Return the value of the data represented by the given descriptor, or {@code
null} if the data |
| 1486 * represented by the descriptor is not in the cache. | 1714 * represented by the descriptor is not in the cache. |
| 1487 * @param descriptor the descriptor representing which data is to be returned | 1715 * @param descriptor the descriptor representing which data is to be returned |
| 1488 * @return the value of the data represented by the given descriptor | 1716 * @return the value of the data represented by the given descriptor |
| 1489 */ | 1717 */ |
| 1490 Object getValue(DataDescriptor descriptor); | 1718 Object getValue(DataDescriptor descriptor); |
| 1719 |
| 1491 /** | 1720 /** |
| 1492 * Return a new entry that is initialized to the same state as this entry but
that can be | 1721 * Return a new entry that is initialized to the same state as this entry but
that can be |
| 1493 * modified. | 1722 * modified. |
| 1494 * @return a writable copy of this entry | 1723 * @return a writable copy of this entry |
| 1495 */ | 1724 */ |
| 1496 SourceEntryImpl get writableCopy; | 1725 SourceEntryImpl get writableCopy; |
| 1497 } | 1726 } |
| 1727 |
| 1498 /** | 1728 /** |
| 1499 * Instances of the abstract class {@code SourceEntryImpl} implement the behavio
r common to all{@link SourceEntry source entries}. | 1729 * Instances of the abstract class {@code SourceEntryImpl} implement the behavio
r common to all{@link SourceEntry source entries}. |
| 1500 * @coverage dart.engine | 1730 * @coverage dart.engine |
| 1501 */ | 1731 */ |
| 1502 abstract class SourceEntryImpl implements SourceEntry { | 1732 abstract class SourceEntryImpl implements SourceEntry { |
| 1733 |
| 1503 /** | 1734 /** |
| 1504 * The most recent time at which the state of the source matched the state rep
resented by this | 1735 * The most recent time at which the state of the source matched the state rep
resented by this |
| 1505 * entry. | 1736 * entry. |
| 1506 */ | 1737 */ |
| 1507 int _modificationTime = 0; | 1738 int _modificationTime = 0; |
| 1739 |
| 1508 /** | 1740 /** |
| 1509 * The state of the cached line information. | 1741 * The state of the cached line information. |
| 1510 */ | 1742 */ |
| 1511 CacheState _lineInfoState = CacheState.INVALID; | 1743 CacheState _lineInfoState = CacheState.INVALID; |
| 1744 |
| 1512 /** | 1745 /** |
| 1513 * The line information computed for the source, or {@code null} if the line i
nformation is not | 1746 * The line information computed for the source, or {@code null} if the line i
nformation is not |
| 1514 * currently cached. | 1747 * currently cached. |
| 1515 */ | 1748 */ |
| 1516 LineInfo _lineInfo; | 1749 LineInfo _lineInfo; |
| 1517 /** | |
| 1518 * Initialize a newly created cache entry to be empty. | |
| 1519 */ | |
| 1520 SourceEntryImpl() : super() { | |
| 1521 } | |
| 1522 int get modificationTime => _modificationTime; | 1750 int get modificationTime => _modificationTime; |
| 1523 CacheState getState(DataDescriptor<Object> descriptor) { | 1751 CacheState getState(DataDescriptor<Object> descriptor) { |
| 1524 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 1752 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1525 return _lineInfoState; | 1753 return _lineInfoState; |
| 1526 } else { | 1754 } else { |
| 1527 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1755 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1528 } | 1756 } |
| 1529 } | 1757 } |
| 1530 Object getValue(DataDescriptor descriptor) { | 1758 Object getValue(DataDescriptor descriptor) { |
| 1531 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 1759 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1532 return _lineInfo as Object; | 1760 return _lineInfo as Object; |
| 1533 } else { | 1761 } else { |
| 1534 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1762 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1535 } | 1763 } |
| 1536 } | 1764 } |
| 1765 |
| 1537 /** | 1766 /** |
| 1538 * Set the most recent time at which the state of the source matched the state
represented by this | 1767 * Set the most recent time at which the state of the source matched the state
represented by this |
| 1539 * entry to the given time. | 1768 * entry to the given time. |
| 1540 * @param time the new modification time of this entry | 1769 * @param time the new modification time of this entry |
| 1541 */ | 1770 */ |
| 1542 void set modificationTime(int time) { | 1771 void set modificationTime(int time) { |
| 1543 _modificationTime = time; | 1772 _modificationTime = time; |
| 1544 } | 1773 } |
| 1774 |
| 1545 /** | 1775 /** |
| 1546 * Set the state of the data represented by the given descriptor to the given
state. | 1776 * Set the state of the data represented by the given descriptor to the given
state. |
| 1547 * @param descriptor the descriptor representing the data whose state is to be
set | 1777 * @param descriptor the descriptor representing the data whose state is to be
set |
| 1548 * @param the new state of the data represented by the given descriptor | 1778 * @param the new state of the data represented by the given descriptor |
| 1549 */ | 1779 */ |
| 1550 void setState(DataDescriptor<Object> descriptor, CacheState state) { | 1780 void setState(DataDescriptor<Object> descriptor, CacheState state) { |
| 1551 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 1781 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1552 _lineInfo = updatedValue(state, _lineInfo, null); | 1782 _lineInfo = updatedValue(state, _lineInfo, null); |
| 1553 _lineInfoState = state; | 1783 _lineInfoState = state; |
| 1554 } else { | 1784 } else { |
| 1555 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1785 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1556 } | 1786 } |
| 1557 } | 1787 } |
| 1788 |
| 1558 /** | 1789 /** |
| 1559 * Set the value of the data represented by the given descriptor to the given
value. | 1790 * Set the value of the data represented by the given descriptor to the given
value. |
| 1560 * @param descriptor the descriptor representing the data whose value is to be
set | 1791 * @param descriptor the descriptor representing the data whose value is to be
set |
| 1561 * @param value the new value of the data represented by the given descriptor | 1792 * @param value the new value of the data represented by the given descriptor |
| 1562 */ | 1793 */ |
| 1563 void setValue(DataDescriptor descriptor, Object value) { | 1794 void setValue(DataDescriptor descriptor, Object value) { |
| 1564 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 1795 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1565 _lineInfo = value as LineInfo; | 1796 _lineInfo = value as LineInfo; |
| 1566 _lineInfoState = CacheState.VALID; | 1797 _lineInfoState = CacheState.VALID; |
| 1567 } else { | 1798 } else { |
| 1568 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1799 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1569 } | 1800 } |
| 1570 } | 1801 } |
| 1802 |
| 1571 /** | 1803 /** |
| 1572 * Copy the information from the given cache entry. | 1804 * Copy the information from the given cache entry. |
| 1573 * @param entry the cache entry from which information will be copied | 1805 * @param entry the cache entry from which information will be copied |
| 1574 */ | 1806 */ |
| 1575 void copyFrom(SourceEntryImpl entry) { | 1807 void copyFrom(SourceEntryImpl entry) { |
| 1576 _modificationTime = entry._modificationTime; | 1808 _modificationTime = entry._modificationTime; |
| 1577 _lineInfoState = entry._lineInfoState; | 1809 _lineInfoState = entry._lineInfoState; |
| 1578 _lineInfo = entry._lineInfo; | 1810 _lineInfo = entry._lineInfo; |
| 1579 } | 1811 } |
| 1812 |
| 1580 /** | 1813 /** |
| 1581 * Given that some data is being transitioned to the given state, return the v
alue that should be | 1814 * Given that some data is being transitioned to the given state, return the v
alue that should be |
| 1582 * kept in the cache. | 1815 * kept in the cache. |
| 1583 * @param state the state to which the data is being transitioned | 1816 * @param state the state to which the data is being transitioned |
| 1584 * @param currentValue the value of the data before the transition | 1817 * @param currentValue the value of the data before the transition |
| 1585 * @param defaultValue the value to be used if the current value is to be remo
ved from the cache | 1818 * @param defaultValue the value to be used if the current value is to be remo
ved from the cache |
| 1586 * @return the value of the data that should be kept in the cache | 1819 * @return the value of the data that should be kept in the cache |
| 1587 */ | 1820 */ |
| 1588 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { | 1821 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { |
| 1589 if (identical(state, CacheState.VALID)) { | 1822 if (identical(state, CacheState.VALID)) { |
| 1590 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 1823 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 1591 } else if (identical(state, CacheState.IN_PROCESS)) { | 1824 } else if (identical(state, CacheState.IN_PROCESS)) { |
| 1592 return currentValue; | 1825 return currentValue; |
| 1593 } | 1826 } |
| 1594 return defaultValue; | 1827 return defaultValue; |
| 1595 } | 1828 } |
| 1596 } | 1829 } |
| 1830 |
| 1597 /** | 1831 /** |
| 1598 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys
isContext analysis | 1832 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys
isContext analysis |
| 1599 * context}. | 1833 * context}. |
| 1600 * @coverage dart.engine | 1834 * @coverage dart.engine |
| 1601 */ | 1835 */ |
| 1602 class AnalysisContextImpl implements InternalAnalysisContext { | 1836 class AnalysisContextImpl implements InternalAnalysisContext { |
| 1837 |
| 1838 /** |
| 1839 * The set of analysis options controlling the behavior of this context. |
| 1840 */ |
| 1841 AnalysisOptions _options = new AnalysisOptionsImpl(); |
| 1842 |
| 1603 /** | 1843 /** |
| 1604 * The source factory used to create the sources that can be analyzed in this
context. | 1844 * The source factory used to create the sources that can be analyzed in this
context. |
| 1605 */ | 1845 */ |
| 1606 SourceFactory _sourceFactory; | 1846 SourceFactory _sourceFactory; |
| 1847 |
| 1607 /** | 1848 /** |
| 1608 * A table mapping the sources known to the context to the information known a
bout the source. | 1849 * A table mapping the sources known to the context to the information known a
bout the source. |
| 1609 */ | 1850 */ |
| 1610 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); | 1851 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); |
| 1852 |
| 1611 /** | 1853 /** |
| 1612 * A table mapping sources to the change notices that are waiting to be return
ed related to that | 1854 * A table mapping sources to the change notices that are waiting to be return
ed related to that |
| 1613 * source. | 1855 * source. |
| 1614 */ | 1856 */ |
| 1615 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); | 1857 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); |
| 1858 |
| 1616 /** | 1859 /** |
| 1617 * A list containing the most recently accessed sources with the most recently
used at the end of | 1860 * A list containing the most recently accessed sources with the most recently
used at the end of |
| 1618 * the list. When more sources are added than the maximum allowed then the lea
st recently used | 1861 * the list. When more sources are added than the maximum allowed then the lea
st recently used |
| 1619 * source will be removed and will have it's cached AST structure flushed. | 1862 * source will be removed and will have it's cached AST structure flushed. |
| 1620 */ | 1863 */ |
| 1621 List<Source> _recentlyUsed = new List<Source>(); | 1864 List<Source> _recentlyUsed = new List<Source>(); |
| 1865 |
| 1622 /** | 1866 /** |
| 1623 * The object used to synchronize access to all of the caches. | 1867 * The object used to synchronize access to all of the caches. |
| 1624 */ | 1868 */ |
| 1625 Object _cacheLock = new Object(); | 1869 Object _cacheLock = new Object(); |
| 1870 |
| 1626 /** | 1871 /** |
| 1627 * The maximum number of sources for which data should be kept in the cache. | 1872 * The maximum number of sources for which data should be kept in the cache. |
| 1628 */ | 1873 */ |
| 1629 static int _MAX_CACHE_SIZE = 64; | 1874 static int _MAX_CACHE_SIZE = 64; |
| 1875 |
| 1630 /** | 1876 /** |
| 1631 * The name of the 'src' attribute in a HTML tag. | 1877 * The name of the 'src' attribute in a HTML tag. |
| 1632 */ | 1878 */ |
| 1633 static String _ATTRIBUTE_SRC = "src"; | 1879 static String _ATTRIBUTE_SRC = "src"; |
| 1880 |
| 1634 /** | 1881 /** |
| 1635 * The name of the 'script' tag in an HTML file. | 1882 * The name of the 'script' tag in an HTML file. |
| 1636 */ | 1883 */ |
| 1637 static String _TAG_SCRIPT = "script"; | 1884 static String _TAG_SCRIPT = "script"; |
| 1885 |
| 1638 /** | 1886 /** |
| 1639 * The number of times that the flushing of information from the cache has bee
n disabled without | 1887 * The number of times that the flushing of information from the cache has bee
n disabled without |
| 1640 * being re-enabled. | 1888 * being re-enabled. |
| 1641 */ | 1889 */ |
| 1642 int _cacheRemovalCount = 0; | 1890 int _cacheRemovalCount = 0; |
| 1643 /** | |
| 1644 * Initialize a newly created analysis context. | |
| 1645 */ | |
| 1646 AnalysisContextImpl() : super() { | |
| 1647 } | |
| 1648 void addSourceInfo(Source source, SourceEntry info) { | 1891 void addSourceInfo(Source source, SourceEntry info) { |
| 1649 _sourceMap[source] = info; | 1892 _sourceMap[source] = info; |
| 1650 } | 1893 } |
| 1651 void applyChanges(ChangeSet changeSet) { | 1894 void applyChanges(ChangeSet changeSet) { |
| 1652 if (changeSet.isEmpty()) { | 1895 if (changeSet.isEmpty()) { |
| 1653 return; | 1896 return; |
| 1654 } | 1897 } |
| 1655 { | 1898 { |
| 1656 List<Source> removedSources = new List<Source>.from(changeSet.removed); | 1899 List<Source> removedSources = new List<Source>.from(changeSet.removed); |
| 1657 for (SourceContainer container in changeSet.removedContainers) { | 1900 for (SourceContainer container in changeSet.removedContainers) { |
| 1658 addSourcesInContainer(removedSources, container); | 1901 addSourcesInContainer(removedSources, container); |
| 1659 } | 1902 } |
| 1660 bool addedDartSource = false; | 1903 bool addedDartSource = false; |
| 1661 for (Source source in changeSet.added3) { | 1904 for (Source source in changeSet.added3) { |
| 1662 if (sourceAvailable(source)) { | 1905 if (sourceAvailable(source)) { |
| 1663 addedDartSource = true; | 1906 addedDartSource = true; |
| 1664 } | 1907 } |
| 1665 } | 1908 } |
| 1666 for (Source source in changeSet.changed3) { | 1909 for (Source source in changeSet.changed3) { |
| 1667 sourceChanged(source); | 1910 sourceChanged(source); |
| 1668 } | 1911 } |
| 1669 for (Source source in removedSources) { | 1912 for (Source source in removedSources) { |
| 1670 sourceRemoved(source); | 1913 sourceRemoved(source); |
| 1671 } | 1914 } |
| 1672 if (addedDartSource) { | 1915 if (addedDartSource) { |
| 1673 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap
)) { | 1916 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap
)) { |
| 1674 if (!mapEntry.getKey().isInSystemLibrary() && mapEntry.getValue() is D
artEntry) { | 1917 if (!mapEntry.getKey().isInSystemLibrary() && mapEntry.getValue() is D
artEntry) { |
| 1675 ((mapEntry.getValue() as DartEntryImpl)).invalidateAllResolutionInfo
rmation(); | 1918 DartEntryImpl dartCopy = ((mapEntry.getValue() as DartEntry)).writab
leCopy; |
| 1919 dartCopy.invalidateAllResolutionInformation(); |
| 1920 mapEntry.setValue(dartCopy); |
| 1676 } | 1921 } |
| 1677 } | 1922 } |
| 1678 } | 1923 } |
| 1679 } | 1924 } |
| 1680 } | 1925 } |
| 1681 String computeDocumentationComment(Element element) { | 1926 String computeDocumentationComment(Element element) { |
| 1682 if (element == null) { | 1927 if (element == null) { |
| 1683 return null; | 1928 return null; |
| 1684 } | 1929 } |
| 1685 Source source2 = element.source; | 1930 Source source2 = element.source; |
| 1686 if (source2 == null) { | 1931 if (source2 == null) { |
| 1687 return null; | 1932 return null; |
| 1688 } | 1933 } |
| 1689 List<CharSequence> contentHolder = new List<CharSequence>(1); | 1934 List<CharSequence> contentHolder = new List<CharSequence>(1); |
| 1690 try { | 1935 try { |
| 1691 source2.getContents(new Source_ContentReceiver_5(contentHolder)); | 1936 source2.getContents(new Source_ContentReceiver_6(contentHolder)); |
| 1692 } catch (exception) { | 1937 } catch (exception) { |
| 1693 throw new AnalysisException.con2("Could not get contents of ${source2.full
Name}", exception); | 1938 throw new AnalysisException.con2("Could not get contents of ${source2.full
Name}", exception); |
| 1694 } | 1939 } |
| 1695 if (contentHolder[0] == null) { | 1940 if (contentHolder[0] == null) { |
| 1696 return null; | 1941 return null; |
| 1697 } | 1942 } |
| 1698 CompilationUnit unit = parseCompilationUnit(source2); | 1943 CompilationUnit unit = parseCompilationUnit(source2); |
| 1699 if (unit == null) { | 1944 if (unit == null) { |
| 1700 return null; | 1945 return null; |
| 1701 } | 1946 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1715 return null; | 1960 return null; |
| 1716 } | 1961 } |
| 1717 List<AnalysisError> computeErrors(Source source) { | 1962 List<AnalysisError> computeErrors(Source source) { |
| 1718 { | 1963 { |
| 1719 SourceEntry sourceEntry = getSourceEntry(source); | 1964 SourceEntry sourceEntry = getSourceEntry(source); |
| 1720 if (sourceEntry is DartEntry) { | 1965 if (sourceEntry is DartEntry) { |
| 1721 DartEntry dartEntry = sourceEntry as DartEntry; | 1966 DartEntry dartEntry = sourceEntry as DartEntry; |
| 1722 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS)
; | 1967 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS)
; |
| 1723 if (parseErrorsState != CacheState.VALID && parseErrorsState != CacheSta
te.ERROR) { | 1968 if (parseErrorsState != CacheState.VALID && parseErrorsState != CacheSta
te.ERROR) { |
| 1724 parseCompilationUnit(source); | 1969 parseCompilationUnit(source); |
| 1970 dartEntry = getSourceEntry(source) as DartEntry; |
| 1725 } | 1971 } |
| 1726 List<Source> libraries = getLibrariesContaining(source); | 1972 List<Source> libraries = getLibrariesContaining(source); |
| 1727 for (Source librarySource in libraries) { | 1973 for (Source librarySource in libraries) { |
| 1728 CacheState resolutionErrorsState = dartEntry.getState2(DartEntry.RESOL
UTION_ERRORS, librarySource); | 1974 CacheState resolutionErrorsState = dartEntry.getState2(DartEntry.RESOL
UTION_ERRORS, librarySource); |
| 1729 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState
!= CacheState.ERROR) { | 1975 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState
!= CacheState.ERROR) { |
| 1730 } | 1976 } |
| 1731 } | 1977 } |
| 1732 return dartEntry.allErrors; | 1978 return dartEntry.allErrors; |
| 1733 } else if (sourceEntry is HtmlEntry) { | 1979 } else if (sourceEntry is HtmlEntry) { |
| 1734 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 1980 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 1735 CacheState resolutionErrorsState = htmlEntry.getState(HtmlEntry.RESOLUTI
ON_ERRORS); | 1981 CacheState resolutionErrorsState = htmlEntry.getState(HtmlEntry.RESOLUTI
ON_ERRORS); |
| 1736 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState !
= CacheState.ERROR) { | 1982 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState !
= CacheState.ERROR) { |
| 1737 computeHtmlElement(source); | 1983 computeHtmlElement(source); |
| 1984 htmlEntry = getSourceEntry(source) as HtmlEntry; |
| 1738 } | 1985 } |
| 1739 return htmlEntry.getValue(HtmlEntry.RESOLUTION_ERRORS); | 1986 return htmlEntry.getValue(HtmlEntry.RESOLUTION_ERRORS); |
| 1740 } | 1987 } |
| 1741 return AnalysisError.NO_ERRORS; | 1988 return AnalysisError.NO_ERRORS; |
| 1742 } | 1989 } |
| 1743 } | 1990 } |
| 1744 HtmlElement computeHtmlElement(Source source) { | 1991 HtmlElement computeHtmlElement(Source source) { |
| 1745 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { | 1992 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { |
| 1746 return null; | 1993 return null; |
| 1747 } | 1994 } |
| 1748 { | 1995 { |
| 1749 HtmlEntry htmlEntry = getHtmlEntry(source); | 1996 HtmlEntry htmlEntry = getHtmlEntry(source); |
| 1750 if (htmlEntry == null) { | 1997 if (htmlEntry == null) { |
| 1751 return null; | 1998 return null; |
| 1752 } | 1999 } |
| 1753 HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT); | 2000 HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT); |
| 1754 if (element == null) { | 2001 if (element == null) { |
| 1755 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2002 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 1756 if (unit == null) { | 2003 if (unit == null) { |
| 1757 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); | 2004 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
| 1758 if (unit == null) { | 2005 if (unit == null) { |
| 1759 unit = parseHtmlUnit(source); | 2006 unit = parseHtmlUnit(source); |
| 1760 } | 2007 } |
| 1761 } | 2008 } |
| 1762 RecordingErrorListener listener = new RecordingErrorListener(); | 2009 HtmlUnitBuilder builder = new HtmlUnitBuilder(this); |
| 1763 HtmlUnitBuilder builder = new HtmlUnitBuilder(this, listener); | |
| 1764 element = builder.buildHtmlElement2(source, unit); | 2010 element = builder.buildHtmlElement2(source, unit); |
| 1765 List<AnalysisError> resolutionErrors = listener.getErrors2(source); | 2011 List<AnalysisError> resolutionErrors = builder.errorListener.getErrors2(
source); |
| 1766 HtmlEntryImpl htmlCopy = (htmlEntry as HtmlEntryImpl); | 2012 HtmlEntryImpl htmlCopy = getHtmlEntry(source).writableCopy; |
| 1767 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, unit); | 2013 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, unit); |
| 1768 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors); | 2014 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors); |
| 1769 htmlCopy.setValue(HtmlEntry.ELEMENT, element); | 2015 htmlCopy.setValue(HtmlEntry.ELEMENT, element); |
| 1770 getNotice(source).setErrors(resolutionErrors, htmlCopy.getValue(SourceEn
try.LINE_INFO)); | 2016 _sourceMap[source] = htmlCopy; |
| 2017 getNotice(source).setErrors(htmlCopy.allErrors, htmlCopy.getValue(Source
Entry.LINE_INFO)); |
| 1771 } | 2018 } |
| 1772 return element; | 2019 return element; |
| 1773 } | 2020 } |
| 1774 } | 2021 } |
| 1775 SourceKind computeKindOf(Source source) { | 2022 SourceKind computeKindOf(Source source) { |
| 1776 { | 2023 { |
| 1777 SourceEntry sourceEntry = getSourceEntry(source); | 2024 SourceEntry sourceEntry = getSourceEntry(source); |
| 1778 if (sourceEntry == null) { | 2025 if (sourceEntry == null) { |
| 1779 return SourceKind.UNKNOWN; | 2026 return SourceKind.UNKNOWN; |
| 1780 } else if (sourceEntry is DartEntry) { | 2027 } else if (sourceEntry is DartEntry) { |
| 1781 DartEntry dartEntry = sourceEntry as DartEntry; | 2028 DartEntry dartEntry = sourceEntry as DartEntry; |
| 1782 CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND); | 2029 CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND); |
| 1783 if (sourceKindState != CacheState.VALID && sourceKindState != CacheState
.ERROR) { | 2030 if (sourceKindState != CacheState.VALID && sourceKindState != CacheState
.ERROR) { |
| 1784 internalComputeKindOf(source); | 2031 internalComputeKindOf(source); |
| 2032 sourceEntry = getSourceEntry(source); |
| 1785 } | 2033 } |
| 1786 } | 2034 } |
| 1787 return sourceEntry.kind; | 2035 return sourceEntry.kind; |
| 1788 } | 2036 } |
| 1789 } | 2037 } |
| 1790 LibraryElement computeLibraryElement(Source source) { | 2038 LibraryElement computeLibraryElement(Source source) { |
| 1791 if (!AnalysisEngine.isDartFileName(source.shortName)) { | 2039 if (!AnalysisEngine.isDartFileName(source.shortName)) { |
| 1792 return null; | 2040 return null; |
| 1793 } | 2041 } |
| 1794 { | 2042 { |
| 1795 DartEntry dartEntry = getDartEntry(source); | 2043 DartEntry dartEntry = getDartEntry(source); |
| 1796 if (dartEntry == null) { | 2044 if (dartEntry == null) { |
| 1797 return null; | 2045 return null; |
| 1798 } | 2046 } |
| 1799 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT); | 2047 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT); |
| 1800 if (element == null) { | 2048 if (element == null) { |
| 1801 if (computeKindOf(source) != SourceKind.LIBRARY) { | 2049 LibraryResolver resolver = new LibraryResolver(this); |
| 1802 throw new AnalysisException.con1("Cannot compute library element for n
on-library: ${source.fullName}"); | |
| 1803 } | |
| 1804 LibraryResolver resolver = new LibraryResolver.con1(this); | |
| 1805 try { | 2050 try { |
| 1806 element = resolver.resolveLibrary(source, true); | 2051 element = resolver.resolveLibrary(source, true); |
| 1807 if (element != null) { | 2052 recordResolutionResults(resolver); |
| 1808 ((dartEntry as DartEntryImpl)).setValue(DartEntry.ELEMENT, element); | |
| 1809 } | |
| 1810 } on AnalysisException catch (exception) { | 2053 } on AnalysisException catch (exception) { |
| 2054 DartEntryImpl dartCopy = getDartEntry(source).writableCopy; |
| 2055 dartCopy.setState(DartEntry.ELEMENT, CacheState.ERROR); |
| 2056 _sourceMap[source] = dartCopy; |
| 1811 AnalysisEngine.instance.logger.logError2("Could not resolve the librar
y ${source.fullName}", exception); | 2057 AnalysisEngine.instance.logger.logError2("Could not resolve the librar
y ${source.fullName}", exception); |
| 1812 } | 2058 } |
| 1813 } | 2059 } |
| 1814 return element; | 2060 return element; |
| 1815 } | 2061 } |
| 1816 } | 2062 } |
| 1817 LineInfo computeLineInfo(Source source) { | 2063 LineInfo computeLineInfo(Source source) { |
| 1818 { | 2064 { |
| 1819 SourceEntry sourceEntry = getSourceEntry(source); | 2065 SourceEntry sourceEntry = getSourceEntry(source); |
| 1820 if (sourceEntry == null) { | 2066 if (sourceEntry == null) { |
| 1821 return null; | 2067 return null; |
| 1822 } | 2068 } |
| 1823 LineInfo lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO); | 2069 LineInfo lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 1824 if (lineInfo == null) { | 2070 if (lineInfo == null) { |
| 1825 if (sourceEntry is HtmlEntry) { | 2071 if (sourceEntry is HtmlEntry) { |
| 1826 parseHtmlUnit(source); | 2072 parseHtmlUnit(source); |
| 1827 lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO); | 2073 lineInfo = getSourceEntry(source).getValue(SourceEntry.LINE_INFO); |
| 1828 } else if (sourceEntry is DartEntry) { | 2074 } else if (sourceEntry is DartEntry) { |
| 1829 parseCompilationUnit(source); | 2075 parseCompilationUnit(source); |
| 1830 lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO); | 2076 lineInfo = getSourceEntry(source).getValue(SourceEntry.LINE_INFO); |
| 1831 } | 2077 } |
| 1832 } | 2078 } |
| 1833 return lineInfo; | 2079 return lineInfo; |
| 1834 } | 2080 } |
| 1835 } | 2081 } |
| 1836 CompilationUnit computeResolvableCompilationUnit(Source source) { | 2082 CompilationUnit computeResolvableCompilationUnit(Source source) { |
| 1837 { | 2083 { |
| 1838 DartEntry dartEntry = getDartEntry(source); | 2084 DartEntry dartEntry = getDartEntry(source); |
| 1839 if (dartEntry == null) { | 2085 if (dartEntry == null) { |
| 1840 return null; | 2086 return null; |
| 1841 } | 2087 } |
| 1842 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; | 2088 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; |
| 1843 if (unit != null) { | 2089 if (unit != null) { |
| 1844 return unit.accept(new ASTCloner()) as CompilationUnit; | 2090 return unit.accept(new ASTCloner()) as CompilationUnit; |
| 1845 } | 2091 } |
| 1846 unit = internalParseCompilationUnit(((dartEntry as DartEntryImpl)), source
); | 2092 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 1847 ((dartEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, CacheState.
FLUSHED); | 2093 unit = internalParseCompilationUnit(dartCopy, source); |
| 2094 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 2095 _sourceMap[source] = dartCopy; |
| 1848 return unit; | 2096 return unit; |
| 1849 } | 2097 } |
| 1850 } | 2098 } |
| 1851 AnalysisContext extractContext(SourceContainer container) => extractContextInt
o(container, (AnalysisEngine.instance.createAnalysisContext() as AnalysisContext
Impl)); | 2099 AnalysisContext extractContext(SourceContainer container) => extractContextInt
o(container, (AnalysisEngine.instance.createAnalysisContext() as InternalAnalysi
sContext)); |
| 1852 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) { | 2100 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) { |
| 1853 List<Source> sourcesToRemove = new List<Source>(); | 2101 List<Source> sourcesToRemove = new List<Source>(); |
| 1854 { | 2102 { |
| 1855 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2103 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 1856 Source source = entry.getKey(); | 2104 Source source = entry.getKey(); |
| 1857 if (container.contains(source)) { | 2105 if (container.contains(source)) { |
| 1858 sourcesToRemove.add(source); | 2106 sourcesToRemove.add(source); |
| 1859 newContext.addSourceInfo(source, entry.getValue().writableCopy); | 2107 newContext.addSourceInfo(source, entry.getValue().writableCopy); |
| 1860 } | 2108 } |
| 1861 } | 2109 } |
| 1862 } | 2110 } |
| 1863 return newContext; | 2111 return newContext; |
| 1864 } | 2112 } |
| 2113 AnalysisOptions get analysisOptions => _options; |
| 1865 Element getElement(ElementLocation location) { | 2114 Element getElement(ElementLocation location) { |
| 1866 List<String> components2 = ((location as ElementLocationImpl)).components; | 2115 List<String> components2 = ((location as ElementLocationImpl)).components; |
| 1867 ElementImpl element; | 2116 ElementImpl element; |
| 1868 { | 2117 { |
| 1869 Source librarySource = _sourceFactory.fromEncoding(components2[0]); | 2118 Source librarySource = _sourceFactory.fromEncoding(components2[0]); |
| 1870 try { | 2119 try { |
| 1871 element = computeLibraryElement(librarySource) as ElementImpl; | 2120 element = computeLibraryElement(librarySource) as ElementImpl; |
| 1872 } on AnalysisException catch (exception) { | 2121 } on AnalysisException catch (exception) { |
| 1873 return null; | 2122 return null; |
| 1874 } | 2123 } |
| 1875 } | 2124 } |
| 1876 for (int i = 1; i < components2.length; i++) { | 2125 for (int i = 1; i < components2.length; i++) { |
| 1877 if (element == null) { | 2126 if (element == null) { |
| 1878 return null; | 2127 return null; |
| 1879 } | 2128 } |
| 1880 element = element.getChild(components2[i]); | 2129 element = element.getChild(components2[i]); |
| 1881 } | 2130 } |
| 1882 return element; | 2131 return element; |
| 1883 } | 2132 } |
| 1884 AnalysisErrorInfo getErrors(Source source) { | 2133 AnalysisErrorInfo getErrors(Source source) { |
| 1885 { | 2134 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 1886 SourceEntry sourceEntry = getSourceEntry(source); | 2135 if (sourceEntry is DartEntry) { |
| 1887 if (sourceEntry is DartEntry) { | 2136 DartEntry dartEntry = sourceEntry as DartEntry; |
| 1888 DartEntry dartEntry = sourceEntry as DartEntry; | 2137 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue(S
ourceEntry.LINE_INFO)); |
| 1889 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue
(SourceEntry.LINE_INFO)); | 2138 } else if (sourceEntry is HtmlEntry) { |
| 1890 } else if (sourceEntry is HtmlEntry) { | 2139 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 1891 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 2140 return new AnalysisErrorInfoImpl(htmlEntry.allErrors, htmlEntry.getValue(S
ourceEntry.LINE_INFO)); |
| 1892 return new AnalysisErrorInfoImpl(htmlEntry.getValue(HtmlEntry.RESOLUTION
_ERRORS), htmlEntry.getValue(SourceEntry.LINE_INFO)); | |
| 1893 } | |
| 1894 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, sourceEntry.getV
alue(SourceEntry.LINE_INFO)); | |
| 1895 } | 2141 } |
| 2142 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); |
| 1896 } | 2143 } |
| 1897 HtmlElement getHtmlElement(Source source) { | 2144 HtmlElement getHtmlElement(Source source) { |
| 1898 { | 2145 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 1899 SourceEntry sourceEntry = getSourceEntry(source); | 2146 if (sourceEntry is HtmlEntry) { |
| 1900 if (sourceEntry is HtmlEntry) { | 2147 return ((sourceEntry as HtmlEntry)).getValue(HtmlEntry.ELEMENT); |
| 1901 return ((sourceEntry as HtmlEntry)).getValue(HtmlEntry.ELEMENT); | |
| 1902 } | |
| 1903 return null; | |
| 1904 } | 2148 } |
| 2149 return null; |
| 1905 } | 2150 } |
| 1906 List<Source> getHtmlFilesReferencing(Source source) { | 2151 List<Source> getHtmlFilesReferencing(Source source) { |
| 1907 { | 2152 { |
| 1908 List<Source> htmlSources = new List<Source>(); | 2153 List<Source> htmlSources = new List<Source>(); |
| 1909 while (true) { | 2154 while (true) { |
| 1910 if (getKindOf(source) == SourceKind.LIBRARY) { | 2155 if (getKindOf(source) == SourceKind.LIBRARY) { |
| 1911 } else if (getKindOf(source) == SourceKind.PART) { | 2156 } else if (getKindOf(source) == SourceKind.PART) { |
| 1912 List<Source> librarySources = getLibrariesContaining(source); | 2157 List<Source> librarySources = getLibrariesContaining(source); |
| 1913 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)
) { | 2158 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)
) { |
| 1914 if (identical(entry.getValue().kind, SourceKind.HTML)) { | 2159 if (identical(entry.getValue().kind, SourceKind.HTML)) { |
| 1915 List<Source> referencedLibraries = ((entry.getValue() as HtmlEntry
)).getValue(HtmlEntry.REFERENCED_LIBRARIES); | 2160 List<Source> referencedLibraries = ((entry.getValue() as HtmlEntry
)).getValue(HtmlEntry.REFERENCED_LIBRARIES); |
| 1916 if (containsAny(referencedLibraries, librarySources)) { | 2161 if (containsAny(referencedLibraries, librarySources)) { |
| 1917 htmlSources.add(entry.getKey()); | 2162 htmlSources.add(entry.getKey()); |
| 1918 } | 2163 } |
| 1919 } | 2164 } |
| 1920 } | 2165 } |
| 1921 } | 2166 } |
| 1922 break; | 2167 break; |
| 1923 } | 2168 } |
| 1924 if (htmlSources.isEmpty) { | 2169 if (htmlSources.isEmpty) { |
| 1925 return Source.EMPTY_ARRAY; | 2170 return Source.EMPTY_ARRAY; |
| 1926 } | 2171 } |
| 1927 return new List.from(htmlSources); | 2172 return new List.from(htmlSources); |
| 1928 } | 2173 } |
| 1929 } | 2174 } |
| 1930 List<Source> get htmlSources => getSources(SourceKind.HTML); | 2175 List<Source> get htmlSources => getSources(SourceKind.HTML); |
| 1931 SourceKind getKindOf(Source source) { | 2176 SourceKind getKindOf(Source source) { |
| 1932 { | 2177 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 1933 SourceEntry sourceEntry = getSourceEntry(source); | 2178 if (sourceEntry == null) { |
| 1934 if (sourceEntry == null) { | 2179 if (AnalysisEngine.isHtmlFileName(source.shortName)) { |
| 1935 return SourceKind.UNKNOWN; | 2180 return SourceKind.HTML; |
| 1936 } | 2181 } |
| 1937 return sourceEntry.kind; | 2182 return SourceKind.UNKNOWN; |
| 1938 } | 2183 } |
| 2184 return sourceEntry.kind; |
| 1939 } | 2185 } |
| 1940 List<Source> get launchableClientLibrarySources { | 2186 List<Source> get launchableClientLibrarySources { |
| 1941 List<Source> sources = new List<Source>(); | 2187 List<Source> sources = new List<Source>(); |
| 1942 { | 2188 { |
| 1943 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2189 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 1944 Source source = entry.getKey(); | 2190 Source source = entry.getKey(); |
| 1945 SourceEntry sourceEntry = entry.getValue(); | 2191 SourceEntry sourceEntry = entry.getValue(); |
| 1946 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste
mLibrary()) { | 2192 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste
mLibrary()) { |
| 1947 sources.add(source); | 2193 sources.add(source); |
| 1948 } | 2194 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1972 librarySources.add(entry.getKey()); | 2218 librarySources.add(entry.getKey()); |
| 1973 } | 2219 } |
| 1974 } | 2220 } |
| 1975 } | 2221 } |
| 1976 if (librarySources.isEmpty) { | 2222 if (librarySources.isEmpty) { |
| 1977 return Source.EMPTY_ARRAY; | 2223 return Source.EMPTY_ARRAY; |
| 1978 } | 2224 } |
| 1979 return new List.from(librarySources); | 2225 return new List.from(librarySources); |
| 1980 } | 2226 } |
| 1981 } | 2227 } |
| 2228 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 2229 { |
| 2230 List<Source> dependentLibraries = new List<Source>(); |
| 2231 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 2232 if (identical(entry.getValue().kind, SourceKind.LIBRARY)) { |
| 2233 if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.REFE
RENCED_LIBRARIES), librarySource)) { |
| 2234 dependentLibraries.add(entry.getKey()); |
| 2235 } |
| 2236 } |
| 2237 } |
| 2238 if (dependentLibraries.isEmpty) { |
| 2239 return Source.EMPTY_ARRAY; |
| 2240 } |
| 2241 return new List.from(dependentLibraries); |
| 2242 } |
| 2243 } |
| 1982 LibraryElement getLibraryElement(Source source) { | 2244 LibraryElement getLibraryElement(Source source) { |
| 1983 { | 2245 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 1984 SourceEntry sourceEntry = getSourceEntry(source); | 2246 if (sourceEntry is DartEntry) { |
| 1985 if (sourceEntry is DartEntry) { | 2247 return ((sourceEntry as DartEntry)).getValue(DartEntry.ELEMENT); |
| 1986 return ((sourceEntry as DartEntry)).getValue(DartEntry.ELEMENT); | |
| 1987 } | |
| 1988 return null; | |
| 1989 } | 2248 } |
| 2249 return null; |
| 1990 } | 2250 } |
| 1991 List<Source> get librarySources => getSources(SourceKind.LIBRARY); | 2251 List<Source> get librarySources => getSources(SourceKind.LIBRARY); |
| 1992 LineInfo getLineInfo(Source source) { | 2252 LineInfo getLineInfo(Source source) { |
| 1993 { | 2253 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 1994 SourceEntry sourceEntry = getSourceEntry(source); | 2254 if (sourceEntry != null) { |
| 1995 if (sourceEntry != null) { | 2255 return sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 1996 return sourceEntry.getValue(SourceEntry.LINE_INFO); | |
| 1997 } | |
| 1998 return null; | |
| 1999 } | 2256 } |
| 2257 return null; |
| 2000 } | 2258 } |
| 2001 Namespace getPublicNamespace(LibraryElement library) { | 2259 Namespace getPublicNamespace(LibraryElement library) { |
| 2002 Source source2 = library.definingCompilationUnit.source; | 2260 Source source2 = library.definingCompilationUnit.source; |
| 2003 { | 2261 { |
| 2004 DartEntry dartEntry = getDartEntry(source2); | 2262 DartEntry dartEntry = getDartEntry(source2); |
| 2005 if (dartEntry == null) { | 2263 if (dartEntry == null) { |
| 2006 return null; | 2264 return null; |
| 2007 } | 2265 } |
| 2008 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 2266 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 2009 if (namespace == null) { | 2267 if (namespace == null) { |
| 2010 NamespaceBuilder builder = new NamespaceBuilder(); | 2268 NamespaceBuilder builder = new NamespaceBuilder(); |
| 2011 namespace = builder.createPublicNamespace(library); | 2269 namespace = builder.createPublicNamespace(library); |
| 2012 ((dartEntry as DartEntryImpl)).setValue(DartEntry.PUBLIC_NAMESPACE, name
space); | 2270 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 2271 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 2272 _sourceMap[source2] = dartCopy; |
| 2013 } | 2273 } |
| 2014 return namespace; | 2274 return namespace; |
| 2015 } | 2275 } |
| 2016 } | 2276 } |
| 2017 Namespace getPublicNamespace2(Source source) { | 2277 Namespace getPublicNamespace2(Source source) { |
| 2018 { | 2278 { |
| 2019 DartEntry dartEntry = getDartEntry(source); | 2279 DartEntry dartEntry = getDartEntry(source); |
| 2020 if (dartEntry == null) { | 2280 if (dartEntry == null) { |
| 2021 return null; | 2281 return null; |
| 2022 } | 2282 } |
| 2023 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 2283 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 2024 if (namespace == null) { | 2284 if (namespace == null) { |
| 2025 LibraryElement library = computeLibraryElement(source); | 2285 LibraryElement library = computeLibraryElement(source); |
| 2026 if (library == null) { | 2286 if (library == null) { |
| 2027 return null; | 2287 return null; |
| 2028 } | 2288 } |
| 2029 NamespaceBuilder builder = new NamespaceBuilder(); | 2289 NamespaceBuilder builder = new NamespaceBuilder(); |
| 2030 namespace = builder.createPublicNamespace(library); | 2290 namespace = builder.createPublicNamespace(library); |
| 2031 ((dartEntry as DartEntryImpl)).setValue(DartEntry.PUBLIC_NAMESPACE, name
space); | 2291 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 2292 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 2293 _sourceMap[source] = dartCopy; |
| 2032 } | 2294 } |
| 2033 return namespace; | 2295 return namespace; |
| 2034 } | 2296 } |
| 2035 } | 2297 } |
| 2036 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { | 2298 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { |
| 2037 if (library == null) { | 2299 if (library == null) { |
| 2038 return null; | 2300 return null; |
| 2039 } | 2301 } |
| 2040 return getResolvedCompilationUnit2(unitSource, library.source); | 2302 return getResolvedCompilationUnit2(unitSource, library.source); |
| 2041 } | 2303 } |
| 2042 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource) { | 2304 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource) { |
| 2043 { | 2305 SourceEntry sourceEntry = getReadableSourceEntry(unitSource); |
| 2044 accessed(unitSource); | 2306 if (sourceEntry is DartEntry) { |
| 2045 DartEntry dartEntry = getDartEntry(unitSource); | 2307 return ((sourceEntry as DartEntry)).getValue2(DartEntry.RESOLVED_UNIT, lib
rarySource); |
| 2046 if (dartEntry == null) { | |
| 2047 return null; | |
| 2048 } | |
| 2049 return dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource); | |
| 2050 } | 2308 } |
| 2309 return null; |
| 2051 } | 2310 } |
| 2052 SourceFactory get sourceFactory => _sourceFactory; | 2311 SourceFactory get sourceFactory => _sourceFactory; |
| 2053 bool isClientLibrary(Source librarySource) { | 2312 bool isClientLibrary(Source librarySource) { |
| 2054 SourceEntry sourceEntry = getSourceEntry(librarySource); | 2313 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); |
| 2055 if (sourceEntry is DartEntry) { | 2314 if (sourceEntry is DartEntry) { |
| 2056 DartEntry dartEntry = sourceEntry as DartEntry; | 2315 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2057 CacheState isClientState = dartEntry.getState(DartEntry.IS_CLIENT); | |
| 2058 CacheState isLaunchableState = dartEntry.getState(DartEntry.IS_LAUNCHABLE)
; | |
| 2059 if (identical(isClientState, CacheState.INVALID) || identical(isClientStat
e, CacheState.ERROR) || identical(isLaunchableState, CacheState.INVALID) || iden
tical(isLaunchableState, CacheState.ERROR)) { | |
| 2060 return false; | |
| 2061 } | |
| 2062 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE
ntry.IS_LAUNCHABLE); | 2316 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE
ntry.IS_LAUNCHABLE); |
| 2063 } | 2317 } |
| 2064 return false; | 2318 return false; |
| 2065 } | 2319 } |
| 2066 bool isServerLibrary(Source librarySource) { | 2320 bool isServerLibrary(Source librarySource) { |
| 2067 SourceEntry sourceEntry = getSourceEntry(librarySource); | 2321 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); |
| 2068 if (sourceEntry is DartEntry) { | 2322 if (sourceEntry is DartEntry) { |
| 2069 DartEntry dartEntry = sourceEntry as DartEntry; | 2323 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2070 CacheState isClientState = dartEntry.getState(DartEntry.IS_CLIENT); | |
| 2071 CacheState isLaunchableState = dartEntry.getState(DartEntry.IS_LAUNCHABLE)
; | |
| 2072 if (identical(isClientState, CacheState.INVALID) || identical(isClientStat
e, CacheState.ERROR) || identical(isLaunchableState, CacheState.INVALID) || iden
tical(isLaunchableState, CacheState.ERROR)) { | |
| 2073 return false; | |
| 2074 } | |
| 2075 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart
Entry.IS_LAUNCHABLE); | 2324 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart
Entry.IS_LAUNCHABLE); |
| 2076 } | 2325 } |
| 2077 return false; | 2326 return false; |
| 2078 } | 2327 } |
| 2079 void mergeContext(AnalysisContext context) { | 2328 void mergeContext(AnalysisContext context) { |
| 2080 { | 2329 { |
| 2081 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(((context as An
alysisContextImpl))._sourceMap)) { | 2330 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(((context as An
alysisContextImpl))._sourceMap)) { |
| 2082 Source newSource = entry.getKey(); | 2331 Source newSource = entry.getKey(); |
| 2083 SourceEntry existingEntry = getSourceEntry(newSource); | 2332 SourceEntry existingEntry = getSourceEntry(newSource); |
| 2084 if (existingEntry == null) { | 2333 if (existingEntry == null) { |
| 2085 _sourceMap[newSource] = entry.getValue().writableCopy; | 2334 _sourceMap[newSource] = entry.getValue().writableCopy; |
| 2086 } else { | 2335 } else { |
| 2087 } | 2336 } |
| 2088 } | 2337 } |
| 2089 } | 2338 } |
| 2090 } | 2339 } |
| 2091 CompilationUnit parseCompilationUnit(Source source) { | 2340 CompilationUnit parseCompilationUnit(Source source) { |
| 2092 { | 2341 { |
| 2093 accessed(source); | 2342 accessed(source); |
| 2094 DartEntry dartEntry = getDartEntry(source); | 2343 DartEntry dartEntry = getDartEntry(source); |
| 2095 if (dartEntry == null) { | 2344 if (dartEntry == null) { |
| 2096 return null; | 2345 return null; |
| 2097 } | 2346 } |
| 2098 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; | 2347 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; |
| 2099 if (unit == null) { | 2348 if (unit == null) { |
| 2100 unit = internalParseCompilationUnit((dartEntry as DartEntryImpl), source
); | 2349 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 2350 unit = internalParseCompilationUnit(dartCopy, source); |
| 2351 _sourceMap[source] = dartCopy; |
| 2101 } | 2352 } |
| 2102 return unit; | 2353 return unit; |
| 2103 } | 2354 } |
| 2104 } | 2355 } |
| 2105 HtmlUnit parseHtmlUnit(Source source) { | 2356 HtmlUnit parseHtmlUnit(Source source) { |
| 2106 { | 2357 { |
| 2107 accessed(source); | 2358 accessed(source); |
| 2108 HtmlEntry htmlEntry = getHtmlEntry(source); | 2359 HtmlEntry htmlEntry = getHtmlEntry(source); |
| 2109 if (htmlEntry == null) { | 2360 if (htmlEntry == null) { |
| 2110 return null; | 2361 return null; |
| 2111 } | 2362 } |
| 2112 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2363 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 2113 if (unit == null) { | 2364 if (unit == null) { |
| 2114 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); | 2365 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
| 2115 if (unit == null) { | 2366 if (unit == null) { |
| 2116 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(source)
); | 2367 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(source)
); |
| 2117 unit = result.htmlUnit; | 2368 unit = result.htmlUnit; |
| 2118 ((htmlEntry as HtmlEntryImpl)).setValue(SourceEntry.LINE_INFO, new Lin
eInfo(result.lineStarts)); | 2369 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 2119 ((htmlEntry as HtmlEntryImpl)).setValue(HtmlEntry.PARSED_UNIT, unit); | 2370 htmlCopy.setValue(SourceEntry.LINE_INFO, new LineInfo(result.lineStart
s)); |
| 2120 ((htmlEntry as HtmlEntryImpl)).setValue(HtmlEntry.REFERENCED_LIBRARIES
, getLibrarySources2(source, unit)); | 2371 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); |
| 2372 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2(s
ource, unit)); |
| 2373 _sourceMap[source] = htmlCopy; |
| 2121 } | 2374 } |
| 2122 } | 2375 } |
| 2123 return unit; | 2376 return unit; |
| 2124 } | 2377 } |
| 2125 } | 2378 } |
| 2126 List<ChangeNotice> performAnalysisTask() { | 2379 List<ChangeNotice> performAnalysisTask() { |
| 2127 { | 2380 { |
| 2128 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { | 2381 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { |
| 2129 return null; | 2382 return null; |
| 2130 } | 2383 } |
| 2131 if (_pendingNotices.isEmpty) { | 2384 if (_pendingNotices.isEmpty) { |
| 2132 return ChangeNoticeImpl.EMPTY_ARRAY; | 2385 return ChangeNoticeImpl.EMPTY_ARRAY; |
| 2133 } | 2386 } |
| 2134 List<ChangeNotice> notices = new List.from(_pendingNotices.values); | 2387 List<ChangeNotice> notices = new List.from(_pendingNotices.values); |
| 2135 _pendingNotices.clear(); | 2388 _pendingNotices.clear(); |
| 2136 return notices; | 2389 return notices; |
| 2137 } | 2390 } |
| 2138 } | 2391 } |
| 2139 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 2392 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 2140 Source htmlSource = _sourceFactory.forUri("dart:html"); | 2393 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
| 2141 { | 2394 { |
| 2142 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ | 2395 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ |
| 2143 Source librarySource = entry.getKey(); | 2396 Source librarySource = entry.getKey(); |
| 2144 LibraryElement library = entry.getValue(); | 2397 LibraryElement library = entry.getValue(); |
| 2145 DartEntryImpl dartEntry = getDartEntry(librarySource) as DartEntryImpl; | 2398 DartEntry dartEntry = getDartEntry(librarySource); |
| 2146 if (dartEntry != null) { | 2399 if (dartEntry != null) { |
| 2147 dartEntry.setValue(DartEntry.ELEMENT, library); | 2400 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 2148 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null
); | 2401 recordElementData(dartCopy, library, htmlSource); |
| 2149 dartEntry.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource,
new Set<LibraryElement>())); | 2402 _sourceMap[librarySource] = dartCopy; |
| 2150 List<Source> unitSources = new List<Source>(); | |
| 2151 unitSources.add(librarySource); | |
| 2152 for (CompilationUnitElement part in library.parts) { | |
| 2153 Source partSource = part.source; | |
| 2154 unitSources.add(partSource); | |
| 2155 } | |
| 2156 dartEntry.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources
)); | |
| 2157 } | 2403 } |
| 2158 } | 2404 } |
| 2159 } | 2405 } |
| 2160 } | 2406 } |
| 2161 void recordResolutionErrors(Source source, Source librarySource, List<Analysis
Error> errors, LineInfo lineInfo) { | |
| 2162 { | |
| 2163 DartEntryImpl dartEntry = getDartEntry(source) as DartEntryImpl; | |
| 2164 if (dartEntry != null) { | |
| 2165 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | |
| 2166 dartEntry.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, errors); | |
| 2167 } | |
| 2168 getNotice(source).setErrors(dartEntry.allErrors, lineInfo); | |
| 2169 } | |
| 2170 } | |
| 2171 void recordResolvedCompilationUnit(Source source, Source librarySource, Compil
ationUnit unit) { | |
| 2172 { | |
| 2173 DartEntryImpl dartEntry = getDartEntry(source) as DartEntryImpl; | |
| 2174 if (dartEntry != null) { | |
| 2175 dartEntry.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit); | |
| 2176 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | |
| 2177 getNotice(source).compilationUnit = unit; | |
| 2178 } | |
| 2179 } | |
| 2180 } | |
| 2181 CompilationUnit resolveCompilationUnit(Source source2, LibraryElement library)
{ | 2407 CompilationUnit resolveCompilationUnit(Source source2, LibraryElement library)
{ |
| 2182 if (library == null) { | 2408 if (library == null) { |
| 2183 return null; | 2409 return null; |
| 2184 } | 2410 } |
| 2185 return resolveCompilationUnit2(source2, library.source); | 2411 return resolveCompilationUnit2(source2, library.source); |
| 2186 } | 2412 } |
| 2187 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { | 2413 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { |
| 2188 { | 2414 { |
| 2189 accessed(unitSource); | 2415 accessed(unitSource); |
| 2190 DartEntry dartEntry = getDartEntry(unitSource); | 2416 DartEntry dartEntry = getDartEntry(unitSource); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2202 LibraryElement coreElement = computeLibraryElement(coreLibrarySource
); | 2428 LibraryElement coreElement = computeLibraryElement(coreLibrarySource
); |
| 2203 TypeProvider typeProvider = new TypeProviderImpl(coreElement); | 2429 TypeProvider typeProvider = new TypeProviderImpl(coreElement); |
| 2204 CompilationUnit unitAST = computeResolvableCompilationUnit(unitSourc
e); | 2430 CompilationUnit unitAST = computeResolvableCompilationUnit(unitSourc
e); |
| 2205 new DeclarationResolver().resolve(unitAST, find(libraryElement, unit
Source)); | 2431 new DeclarationResolver().resolve(unitAST, find(libraryElement, unit
Source)); |
| 2206 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2432 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 2207 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.co
n2(libraryElement, unitSource, typeProvider, errorListener); | 2433 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.co
n2(libraryElement, unitSource, typeProvider, errorListener); |
| 2208 unitAST.accept(typeResolverVisitor); | 2434 unitAST.accept(typeResolverVisitor); |
| 2209 ResolverVisitor resolverVisitor = new ResolverVisitor.con2(libraryEl
ement, unitSource, typeProvider, errorListener); | 2435 ResolverVisitor resolverVisitor = new ResolverVisitor.con2(libraryEl
ement, unitSource, typeProvider, errorListener); |
| 2210 unitAST.accept(resolverVisitor); | 2436 unitAST.accept(resolverVisitor); |
| 2211 ErrorReporter errorReporter = new ErrorReporter(errorListener, unitS
ource); | 2437 ErrorReporter errorReporter = new ErrorReporter(errorListener, unitS
ource); |
| 2212 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libra
ryElement, typeProvider); | 2438 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libra
ryElement, typeProvider, new InheritanceManager(libraryElement)); |
| 2213 unitAST.accept(errorVerifier); | 2439 unitAST.accept(errorVerifier); |
| 2214 ConstantVerifier constantVerifier = new ConstantVerifier(errorReport
er); | 2440 ConstantVerifier constantVerifier = new ConstantVerifier(errorReport
er, typeProvider); |
| 2215 unitAST.accept(constantVerifier); | 2441 unitAST.accept(constantVerifier); |
| 2216 unitAST.resolutionErrors = errorListener.errors; | 2442 unitAST.resolutionErrors = errorListener.errors; |
| 2217 ((dartEntry as DartEntryImpl)).setValue2(DartEntry.RESOLVED_UNIT, li
brarySource, unitAST); | 2443 DartEntryImpl dartCopy = getDartEntry(unitSource).writableCopy; |
| 2444 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unitAST); |
| 2445 _sourceMap[unitSource] = dartCopy; |
| 2218 unit = unitAST; | 2446 unit = unitAST; |
| 2219 } | 2447 } |
| 2220 } finally { | 2448 } finally { |
| 2221 enableCacheRemoval(); | 2449 enableCacheRemoval(); |
| 2222 } | 2450 } |
| 2223 } | 2451 } |
| 2224 return unit; | 2452 return unit; |
| 2225 } | 2453 } |
| 2226 } | 2454 } |
| 2227 HtmlUnit resolveHtmlUnit(Source unitSource) { | 2455 HtmlUnit resolveHtmlUnit(Source unitSource) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2240 if (unit == null) { | 2468 if (unit == null) { |
| 2241 unit = parseHtmlUnit(unitSource); | 2469 unit = parseHtmlUnit(unitSource); |
| 2242 } | 2470 } |
| 2243 } finally { | 2471 } finally { |
| 2244 enableCacheRemoval(); | 2472 enableCacheRemoval(); |
| 2245 } | 2473 } |
| 2246 } | 2474 } |
| 2247 return unit; | 2475 return unit; |
| 2248 } | 2476 } |
| 2249 } | 2477 } |
| 2478 void set analysisOptions(AnalysisOptions options2) { |
| 2479 { |
| 2480 this._options = options2; |
| 2481 invalidateAllResults(); |
| 2482 } |
| 2483 } |
| 2250 void setContents(Source source, String contents) { | 2484 void setContents(Source source, String contents) { |
| 2251 { | 2485 { |
| 2252 _sourceFactory.setContents(source, contents); | 2486 _sourceFactory.setContents(source, contents); |
| 2253 sourceChanged(source); | 2487 sourceChanged(source); |
| 2254 } | 2488 } |
| 2255 } | 2489 } |
| 2256 void set sourceFactory(SourceFactory factory) { | 2490 void set sourceFactory(SourceFactory factory) { |
| 2257 if (identical(_sourceFactory, factory)) { | 2491 if (identical(_sourceFactory, factory)) { |
| 2258 return; | 2492 return; |
| 2259 } else if (factory.context != null) { | 2493 } else if (factory.context != null) { |
| 2260 throw new IllegalStateException("Source factories cannot be shared between
contexts"); | 2494 throw new IllegalStateException("Source factories cannot be shared between
contexts"); |
| 2261 } | 2495 } |
| 2262 { | 2496 { |
| 2263 if (_sourceFactory != null) { | 2497 if (_sourceFactory != null) { |
| 2264 _sourceFactory.context = null; | 2498 _sourceFactory.context = null; |
| 2265 } | 2499 } |
| 2266 factory.context = this; | 2500 factory.context = this; |
| 2267 _sourceFactory = factory; | 2501 _sourceFactory = factory; |
| 2268 for (SourceEntry sourceEntry in _sourceMap.values) { | 2502 invalidateAllResults(); |
| 2269 if (sourceEntry is HtmlEntry) { | |
| 2270 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, Cac
heState.INVALID); | |
| 2271 } else if (sourceEntry is DartEntry) { | |
| 2272 ((sourceEntry as DartEntryImpl)).invalidateAllResolutionInformation(); | |
| 2273 } | |
| 2274 } | |
| 2275 } | 2503 } |
| 2276 } | 2504 } |
| 2277 Iterable<Source> sourcesToResolve(List<Source> changedSources) { | 2505 Iterable<Source> sourcesToResolve(List<Source> changedSources) { |
| 2278 List<Source> librarySources = new List<Source>(); | 2506 List<Source> librarySources = new List<Source>(); |
| 2279 for (Source source in changedSources) { | 2507 for (Source source in changedSources) { |
| 2280 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { | 2508 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { |
| 2281 librarySources.add(source); | 2509 librarySources.add(source); |
| 2282 } | 2510 } |
| 2283 } | 2511 } |
| 2284 return librarySources; | 2512 return librarySources; |
| 2285 } | 2513 } |
| 2514 |
| 2515 /** |
| 2516 * Return a list of the sources that would be processed by {@link #performAnal
ysisTask()}. This |
| 2517 * method is intended to be used for testing purposes only. |
| 2518 * @return a list of the sources that would be processed by {@link #performAna
lysisTask()} |
| 2519 */ |
| 2520 List<Source> get sourcesNeedingProcessing { |
| 2521 List<Source> sources = new List<Source>(); |
| 2522 { |
| 2523 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 2524 SourceEntry sourceEntry = entry.getValue(); |
| 2525 if (sourceEntry is DartEntry) { |
| 2526 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2527 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT)
; |
| 2528 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
| 2529 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen
tState, CacheState.INVALID)) { |
| 2530 sources.add(entry.getKey()); |
| 2531 } |
| 2532 } else if (sourceEntry is HtmlEntry) { |
| 2533 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 2534 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT)
; |
| 2535 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_U
NIT); |
| 2536 if (identical(parsedUnitState, CacheState.INVALID) || identical(resolv
edUnitState, CacheState.INVALID)) { |
| 2537 sources.add(entry.getKey()); |
| 2538 } |
| 2539 } |
| 2540 } |
| 2541 } |
| 2542 return sources; |
| 2543 } |
| 2544 |
| 2286 /** | 2545 /** |
| 2287 * Record that the given source was just accessed for some unspecified purpose
. | 2546 * Record that the given source was just accessed for some unspecified purpose
. |
| 2288 * <p> | 2547 * <p> |
| 2289 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. | 2548 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. |
| 2290 * @param source the source that was accessed | 2549 * @param source the source that was accessed |
| 2291 */ | 2550 */ |
| 2292 void accessed(Source source) { | 2551 void accessed(Source source) { |
| 2293 if (_recentlyUsed.contains(source)) { | 2552 if (_recentlyUsed.contains(source)) { |
| 2294 _recentlyUsed.remove(source); | 2553 _recentlyUsed.remove(source); |
| 2295 _recentlyUsed.add(source); | 2554 _recentlyUsed.add(source); |
| 2296 return; | 2555 return; |
| 2297 } | 2556 } |
| 2298 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { | 2557 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { |
| 2299 Source removedSource = _recentlyUsed.removeAt(0); | 2558 Source removedSource = _recentlyUsed.removeAt(0); |
| 2300 SourceEntry sourceEntry = _sourceMap[removedSource]; | 2559 SourceEntry sourceEntry = _sourceMap[removedSource]; |
| 2301 if (sourceEntry is HtmlEntry) { | 2560 if (sourceEntry is HtmlEntry) { |
| 2302 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, CacheSt
ate.FLUSHED); | 2561 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 2303 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, Cache
State.FLUSHED); | 2562 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 2563 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.FLUSHED); |
| 2564 _sourceMap[removedSource] = htmlCopy; |
| 2304 } else if (sourceEntry is DartEntry) { | 2565 } else if (sourceEntry is DartEntry) { |
| 2305 ((sourceEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, CacheSt
ate.FLUSHED); | 2566 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| 2567 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 2306 for (Source librarySource in getLibrariesContaining(source)) { | 2568 for (Source librarySource in getLibrariesContaining(source)) { |
| 2307 ((sourceEntry as DartEntryImpl)).setState2(DartEntry.RESOLVED_UNIT, li
brarySource, CacheState.FLUSHED); | 2569 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
FLUSHED); |
| 2308 } | 2570 } |
| 2571 _sourceMap[removedSource] = dartCopy; |
| 2309 } | 2572 } |
| 2310 } | 2573 } |
| 2311 _recentlyUsed.add(source); | 2574 _recentlyUsed.add(source); |
| 2312 } | 2575 } |
| 2576 |
| 2313 /** | 2577 /** |
| 2314 * Add all of the sources contained in the given source container to the given
list of sources. | 2578 * Add all of the sources contained in the given source container to the given
list of sources. |
| 2315 * <p> | 2579 * <p> |
| 2316 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. | 2580 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. |
| 2317 * @param sources the list to which sources are to be added | 2581 * @param sources the list to which sources are to be added |
| 2318 * @param container the source container containing the sources to be added to
the list | 2582 * @param container the source container containing the sources to be added to
the list |
| 2319 */ | 2583 */ |
| 2320 void addSourcesInContainer(List<Source> sources, SourceContainer container) { | 2584 void addSourcesInContainer(List<Source> sources, SourceContainer container) { |
| 2321 for (Source source in _sourceMap.keys.toSet()) { | 2585 for (Source source in _sourceMap.keys.toSet()) { |
| 2322 if (container.contains(source)) { | 2586 if (container.contains(source)) { |
| 2323 sources.add(source); | 2587 sources.add(source); |
| 2324 } | 2588 } |
| 2325 } | 2589 } |
| 2326 } | 2590 } |
| 2591 |
| 2327 /** | 2592 /** |
| 2328 * Return {@code true} if the given array of sources contains the given source
. | 2593 * Return {@code true} if the given array of sources contains the given source
. |
| 2329 * @param sources the sources being searched | 2594 * @param sources the sources being searched |
| 2330 * @param targetSource the source being searched for | 2595 * @param targetSource the source being searched for |
| 2331 * @return {@code true} if the given source is in the array | 2596 * @return {@code true} if the given source is in the array |
| 2332 */ | 2597 */ |
| 2333 bool contains(List<Source> sources, Source targetSource) { | 2598 bool contains(List<Source> sources, Source targetSource) { |
| 2334 for (Source source in sources) { | 2599 for (Source source in sources) { |
| 2335 if (source == targetSource) { | 2600 if (source == targetSource) { |
| 2336 return true; | 2601 return true; |
| 2337 } | 2602 } |
| 2338 } | 2603 } |
| 2339 return false; | 2604 return false; |
| 2340 } | 2605 } |
| 2606 |
| 2341 /** | 2607 /** |
| 2342 * Return {@code true} if the given array of sources contains any of the given
target sources. | 2608 * Return {@code true} if the given array of sources contains any of the given
target sources. |
| 2343 * @param sources the sources being searched | 2609 * @param sources the sources being searched |
| 2344 * @param targetSources the sources being searched for | 2610 * @param targetSources the sources being searched for |
| 2345 * @return {@code true} if any of the given target sources are in the array | 2611 * @return {@code true} if any of the given target sources are in the array |
| 2346 */ | 2612 */ |
| 2347 bool containsAny(List<Source> sources, List<Source> targetSources) { | 2613 bool containsAny(List<Source> sources, List<Source> targetSources) { |
| 2348 for (Source targetSource in targetSources) { | 2614 for (Source targetSource in targetSources) { |
| 2349 if (contains(sources, targetSource)) { | 2615 if (contains(sources, targetSource)) { |
| 2350 return true; | 2616 return true; |
| 2351 } | 2617 } |
| 2352 } | 2618 } |
| 2353 return false; | 2619 return false; |
| 2354 } | 2620 } |
| 2621 |
| 2355 /** | 2622 /** |
| 2356 * Create a source information object suitable for the given source. Return th
e source information | 2623 * Create a source information object suitable for the given source. Return th
e source information |
| 2357 * object that was created, or {@code null} if the source should not be tracke
d by this context. | 2624 * object that was created, or {@code null} if the source should not be tracke
d by this context. |
| 2358 * @param source the source for which an information object is being created | 2625 * @param source the source for which an information object is being created |
| 2359 * @return the source information object that was created | 2626 * @return the source information object that was created |
| 2360 */ | 2627 */ |
| 2361 SourceEntry createSourceEntry(Source source) { | 2628 SourceEntry createSourceEntry(Source source) { |
| 2362 String name = source.shortName; | 2629 String name = source.shortName; |
| 2363 if (AnalysisEngine.isHtmlFileName(name)) { | 2630 if (AnalysisEngine.isHtmlFileName(name)) { |
| 2364 HtmlEntry htmlEntry = new HtmlEntryImpl(); | 2631 HtmlEntry htmlEntry = new HtmlEntryImpl(); |
| 2365 _sourceMap[source] = htmlEntry; | 2632 _sourceMap[source] = htmlEntry; |
| 2366 return htmlEntry; | 2633 return htmlEntry; |
| 2367 } else if (AnalysisEngine.isDartFileName(name)) { | 2634 } else if (AnalysisEngine.isDartFileName(name)) { |
| 2368 DartEntry dartEntry = new DartEntryImpl(); | 2635 DartEntry dartEntry = new DartEntryImpl(); |
| 2369 _sourceMap[source] = dartEntry; | 2636 _sourceMap[source] = dartEntry; |
| 2370 return dartEntry; | 2637 return dartEntry; |
| 2371 } | 2638 } |
| 2372 return null; | 2639 return null; |
| 2373 } | 2640 } |
| 2641 |
| 2374 /** | 2642 /** |
| 2375 * Disable flushing information from the cache until {@link #enableCacheRemova
l()} has been | 2643 * Disable flushing information from the cache until {@link #enableCacheRemova
l()} has been |
| 2376 * called. | 2644 * called. |
| 2377 */ | 2645 */ |
| 2378 void disableCacheRemoval() { | 2646 void disableCacheRemoval() { |
| 2379 _cacheRemovalCount++; | 2647 _cacheRemovalCount++; |
| 2380 } | 2648 } |
| 2649 |
| 2381 /** | 2650 /** |
| 2382 * Re-enable flushing information from the cache. | 2651 * Re-enable flushing information from the cache. |
| 2383 */ | 2652 */ |
| 2384 void enableCacheRemoval() { | 2653 void enableCacheRemoval() { |
| 2385 if (_cacheRemovalCount > 0) { | 2654 if (_cacheRemovalCount > 0) { |
| 2386 _cacheRemovalCount--; | 2655 _cacheRemovalCount--; |
| 2387 } | 2656 } |
| 2388 if (_cacheRemovalCount == 0) { | 2657 if (_cacheRemovalCount == 0) { |
| 2389 while (_recentlyUsed.length >= _MAX_CACHE_SIZE) { | 2658 while (_recentlyUsed.length >= _MAX_CACHE_SIZE) { |
| 2390 Source removedSource = _recentlyUsed.removeAt(0); | 2659 Source removedSource = _recentlyUsed.removeAt(0); |
| 2391 SourceEntry sourceEntry = _sourceMap[removedSource]; | 2660 SourceEntry sourceEntry = _sourceMap[removedSource]; |
| 2392 if (sourceEntry is HtmlEntry) { | 2661 if (sourceEntry is HtmlEntry) { |
| 2393 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, Cache
State.FLUSHED); | 2662 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 2394 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, Cac
heState.FLUSHED); | 2663 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 2664 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.FLUSHED); |
| 2665 _sourceMap[removedSource] = htmlCopy; |
| 2395 } else if (sourceEntry is DartEntry) { | 2666 } else if (sourceEntry is DartEntry) { |
| 2396 ((sourceEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, Cache
State.FLUSHED); | 2667 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| 2668 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 2397 for (Source librarySource in getLibrariesContaining(removedSource)) { | 2669 for (Source librarySource in getLibrariesContaining(removedSource)) { |
| 2398 ((sourceEntry as DartEntryImpl)).setState2(DartEntry.RESOLVED_UNIT,
librarySource, CacheState.FLUSHED); | 2670 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat
e.FLUSHED); |
| 2399 } | 2671 } |
| 2672 _sourceMap[removedSource] = dartCopy; |
| 2400 } | 2673 } |
| 2401 } | 2674 } |
| 2402 } | 2675 } |
| 2403 } | 2676 } |
| 2677 |
| 2404 /** | 2678 /** |
| 2405 * Search the compilation units that are part of the given library and return
the element | 2679 * Search the compilation units that are part of the given library and return
the element |
| 2406 * representing the compilation unit with the given source. Return {@code null
} if there is no | 2680 * representing the compilation unit with the given source. Return {@code null
} if there is no |
| 2407 * such compilation unit. | 2681 * such compilation unit. |
| 2408 * @param libraryElement the element representing the library being searched t
hrough | 2682 * @param libraryElement the element representing the library being searched t
hrough |
| 2409 * @param unitSource the source for the compilation unit whose element is to b
e returned | 2683 * @param unitSource the source for the compilation unit whose element is to b
e returned |
| 2410 * @return the element representing the compilation unit | 2684 * @return the element representing the compilation unit |
| 2411 */ | 2685 */ |
| 2412 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ | 2686 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ |
| 2413 CompilationUnitElement element = libraryElement.definingCompilationUnit; | 2687 CompilationUnitElement element = libraryElement.definingCompilationUnit; |
| 2414 if (element.source == unitSource) { | 2688 if (element.source == unitSource) { |
| 2415 return element; | 2689 return element; |
| 2416 } | 2690 } |
| 2417 for (CompilationUnitElement partElement in libraryElement.parts) { | 2691 for (CompilationUnitElement partElement in libraryElement.parts) { |
| 2418 if (partElement.source == unitSource) { | 2692 if (partElement.source == unitSource) { |
| 2419 return partElement; | 2693 return partElement; |
| 2420 } | 2694 } |
| 2421 } | 2695 } |
| 2422 return null; | 2696 return null; |
| 2423 } | 2697 } |
| 2698 |
| 2424 /** | 2699 /** |
| 2425 * Return the compilation unit information associated with the given source, o
r {@code null} if | 2700 * Return the compilation unit information associated with the given source, o
r {@code null} if |
| 2426 * the source is not known to this context. This method should be used to acce
ss the compilation | 2701 * the source is not known to this context. This method should be used to acce
ss the compilation |
| 2427 * unit information rather than accessing the compilation unit map directly be
cause sources in the | 2702 * unit information rather than accessing the compilation unit map directly be
cause sources in the |
| 2428 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when | 2703 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when |
| 2429 * first accessed. | 2704 * first accessed. |
| 2430 * <p> | 2705 * <p> |
| 2431 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2706 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 2432 * @param source the source for which information is being sought | 2707 * @param source the source for which information is being sought |
| 2433 * @return the compilation unit information associated with the given source | 2708 * @return the compilation unit information associated with the given source |
| 2434 */ | 2709 */ |
| 2435 DartEntry getDartEntry(Source source) { | 2710 DartEntry getDartEntry(Source source) { |
| 2436 SourceEntry sourceEntry = getSourceEntry(source); | 2711 SourceEntry sourceEntry = getSourceEntry(source); |
| 2437 if (sourceEntry == null) { | 2712 if (sourceEntry == null) { |
| 2438 sourceEntry = new DartEntryImpl(); | 2713 sourceEntry = new DartEntryImpl(); |
| 2439 _sourceMap[source] = sourceEntry; | 2714 _sourceMap[source] = sourceEntry; |
| 2440 return sourceEntry as DartEntry; | 2715 return sourceEntry as DartEntry; |
| 2441 } else if (sourceEntry is DartEntry) { | 2716 } else if (sourceEntry is DartEntry) { |
| 2442 return sourceEntry as DartEntry; | 2717 return sourceEntry as DartEntry; |
| 2443 } | 2718 } |
| 2444 return null; | 2719 return null; |
| 2445 } | 2720 } |
| 2721 |
| 2446 /** | 2722 /** |
| 2447 * Return the HTML unit information associated with the given source, or {@cod
e null} if the | 2723 * Return the HTML unit information associated with the given source, or {@cod
e null} if the |
| 2448 * source is not known to this context. This method should be used to access t
he HTML unit | 2724 * source is not known to this context. This method should be used to access t
he HTML unit |
| 2449 * information rather than accessing the HTML unit map directly because source
s in the SDK are | 2725 * information rather than accessing the HTML unit map directly because source
s in the SDK are |
| 2450 * implicitly part of every analysis context and are therefore only added to t
he map when first | 2726 * implicitly part of every analysis context and are therefore only added to t
he map when first |
| 2451 * accessed. | 2727 * accessed. |
| 2452 * <p> | 2728 * <p> |
| 2453 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2729 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 2454 * @param source the source for which information is being sought | 2730 * @param source the source for which information is being sought |
| 2455 * @return the HTML unit information associated with the given source | 2731 * @return the HTML unit information associated with the given source |
| 2456 */ | 2732 */ |
| 2457 HtmlEntry getHtmlEntry(Source source) { | 2733 HtmlEntry getHtmlEntry(Source source) { |
| 2458 SourceEntry sourceEntry = getSourceEntry(source); | 2734 SourceEntry sourceEntry = getSourceEntry(source); |
| 2459 if (sourceEntry == null) { | 2735 if (sourceEntry == null) { |
| 2460 sourceEntry = new HtmlEntryImpl(); | 2736 sourceEntry = new HtmlEntryImpl(); |
| 2461 _sourceMap[source] = sourceEntry; | 2737 _sourceMap[source] = sourceEntry; |
| 2462 return sourceEntry as HtmlEntry; | 2738 return sourceEntry as HtmlEntry; |
| 2463 } else if (sourceEntry is HtmlEntry) { | 2739 } else if (sourceEntry is HtmlEntry) { |
| 2464 return sourceEntry as HtmlEntry; | 2740 return sourceEntry as HtmlEntry; |
| 2465 } | 2741 } |
| 2466 return null; | 2742 return null; |
| 2467 } | 2743 } |
| 2744 |
| 2468 /** | 2745 /** |
| 2469 * Return the sources of libraries that are referenced in the specified HTML f
ile. | 2746 * Return the sources of libraries that are referenced in the specified HTML f
ile. |
| 2470 * @param htmlSource the source of the HTML file being analyzed | 2747 * @param htmlSource the source of the HTML file being analyzed |
| 2471 * @param htmlUnit the AST for the HTML file being analyzed | 2748 * @param htmlUnit the AST for the HTML file being analyzed |
| 2472 * @return the sources of libraries that are referenced in the HTML file | 2749 * @return the sources of libraries that are referenced in the HTML file |
| 2473 */ | 2750 */ |
| 2474 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) { | 2751 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) { |
| 2475 List<Source> libraries = new List<Source>(); | 2752 List<Source> libraries = new List<Source>(); |
| 2476 htmlUnit.accept(new RecursiveXmlVisitor_6(this, htmlSource, libraries)); | 2753 htmlUnit.accept(new RecursiveXmlVisitor_7(this, htmlSource, libraries)); |
| 2477 if (libraries.isEmpty) { | 2754 if (libraries.isEmpty) { |
| 2478 return Source.EMPTY_ARRAY; | 2755 return Source.EMPTY_ARRAY; |
| 2479 } | 2756 } |
| 2480 return new List.from(libraries); | 2757 return new List.from(libraries); |
| 2481 } | 2758 } |
| 2759 |
| 2482 /** | 2760 /** |
| 2483 * Return a change notice for the given source, creating one if one does not a
lready exist. | 2761 * Return a change notice for the given source, creating one if one does not a
lready exist. |
| 2484 * @param source the source for which changes are being reported | 2762 * @param source the source for which changes are being reported |
| 2485 * @return a change notice for the given source | 2763 * @return a change notice for the given source |
| 2486 */ | 2764 */ |
| 2487 ChangeNoticeImpl getNotice(Source source) { | 2765 ChangeNoticeImpl getNotice(Source source) { |
| 2488 ChangeNoticeImpl notice = _pendingNotices[source]; | 2766 ChangeNoticeImpl notice = _pendingNotices[source]; |
| 2489 if (notice == null) { | 2767 if (notice == null) { |
| 2490 notice = new ChangeNoticeImpl(source); | 2768 notice = new ChangeNoticeImpl(source); |
| 2491 _pendingNotices[source] = notice; | 2769 _pendingNotices[source] = notice; |
| 2492 } | 2770 } |
| 2493 return notice; | 2771 return notice; |
| 2494 } | 2772 } |
| 2773 |
| 2774 /** |
| 2775 * Return the cache entry associated with the given source, or {@code null} if
there is no entry |
| 2776 * associated with the source. |
| 2777 * @param source the source for which a cache entry is being sought |
| 2778 * @return the source cache entry associated with the given source |
| 2779 */ |
| 2780 SourceEntry getReadableSourceEntry(Source source) { |
| 2781 { |
| 2782 return _sourceMap[source]; |
| 2783 } |
| 2784 } |
| 2785 |
| 2495 /** | 2786 /** |
| 2496 * Return the source information associated with the given source, or {@code n
ull} if the source | 2787 * Return the source information associated with the given source, or {@code n
ull} if the source |
| 2497 * is not known to this context. This method should be used to access the sour
ce information | 2788 * is not known to this context. This method should be used to access the sour
ce information |
| 2498 * rather than accessing the source map directly because sources in the SDK ar
e implicitly part of | 2789 * rather than accessing the source map directly because sources in the SDK ar
e implicitly part of |
| 2499 * every analysis context and are therefore only added to the map when first a
ccessed. | 2790 * every analysis context and are therefore only added to the map when first a
ccessed. |
| 2500 * <p> | 2791 * <p> |
| 2501 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2792 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 2502 * @param source the source for which information is being sought | 2793 * @param source the source for which information is being sought |
| 2503 * @return the source information associated with the given source | 2794 * @return the source information associated with the given source |
| 2504 */ | 2795 */ |
| 2505 SourceEntry getSourceEntry(Source source) { | 2796 SourceEntry getSourceEntry(Source source) { |
| 2506 SourceEntry sourceEntry = _sourceMap[source]; | 2797 SourceEntry sourceEntry = _sourceMap[source]; |
| 2507 if (sourceEntry == null) { | 2798 if (sourceEntry == null) { |
| 2508 sourceEntry = createSourceEntry(source); | 2799 sourceEntry = createSourceEntry(source); |
| 2509 } | 2800 } |
| 2510 return sourceEntry; | 2801 return sourceEntry; |
| 2511 } | 2802 } |
| 2803 |
| 2512 /** | 2804 /** |
| 2513 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 2805 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
| 2514 * @param kind the kind of sources to be returned | 2806 * @param kind the kind of sources to be returned |
| 2515 * @return all of the sources known to this context that have the given kind | 2807 * @return all of the sources known to this context that have the given kind |
| 2516 */ | 2808 */ |
| 2517 List<Source> getSources(SourceKind kind2) { | 2809 List<Source> getSources(SourceKind kind2) { |
| 2518 List<Source> sources = new List<Source>(); | 2810 List<Source> sources = new List<Source>(); |
| 2519 { | 2811 { |
| 2520 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2812 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 2521 if (identical(entry.getValue().kind, kind2)) { | 2813 if (identical(entry.getValue().kind, kind2)) { |
| 2522 sources.add(entry.getKey()); | 2814 sources.add(entry.getKey()); |
| 2523 } | 2815 } |
| 2524 } | 2816 } |
| 2525 } | 2817 } |
| 2526 return new List.from(sources); | 2818 return new List.from(sources); |
| 2527 } | 2819 } |
| 2820 |
| 2528 /** | 2821 /** |
| 2529 * Return {@code true} if the given compilation unit has a part-of directive b
ut no library | 2822 * Return {@code true} if the given compilation unit has a part-of directive b
ut no library |
| 2530 * directive. | 2823 * directive. |
| 2531 * @param unit the compilation unit being tested | 2824 * @param unit the compilation unit being tested |
| 2532 * @return {@code true} if the compilation unit has a part-of directive | 2825 * @return {@code true} if the compilation unit has a part-of directive |
| 2533 */ | 2826 */ |
| 2534 bool hasPartOfDirective(CompilationUnit unit) { | 2827 bool hasPartOfDirective(CompilationUnit unit) { |
| 2535 bool hasPartOf = false; | 2828 bool hasPartOf = false; |
| 2536 for (Directive directive in unit.directives) { | 2829 for (Directive directive in unit.directives) { |
| 2537 if (directive is PartOfDirective) { | 2830 if (directive is PartOfDirective) { |
| 2538 hasPartOf = true; | 2831 hasPartOf = true; |
| 2539 } else if (directive is LibraryDirective) { | 2832 } else if (directive is LibraryDirective) { |
| 2540 return false; | 2833 return false; |
| 2541 } | 2834 } |
| 2542 } | 2835 } |
| 2543 return hasPartOf; | 2836 return hasPartOf; |
| 2544 } | 2837 } |
| 2838 |
| 2545 /** | 2839 /** |
| 2546 * Compute the kind of the given source. This method should only be invoked wh
en the kind is not | 2840 * Compute the kind of the given source. This method should only be invoked wh
en the kind is not |
| 2547 * already known. | 2841 * already known. |
| 2548 * @param source the source for which a kind is to be computed | 2842 * @param source the source for which a kind is to be computed |
| 2549 * @return the new source info that was created to represent the source | 2843 * @return the new source info that was created to represent the source |
| 2550 */ | 2844 */ |
| 2551 DartEntry internalComputeKindOf(Source source) { | 2845 DartEntry internalComputeKindOf(Source source) { |
| 2552 try { | 2846 try { |
| 2553 accessed(source); | 2847 accessed(source); |
| 2554 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2848 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 2555 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); | 2849 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); |
| 2556 Parser parser = new Parser(source, errorListener); | 2850 Parser parser = new Parser(source, errorListener); |
| 2557 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); | 2851 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); |
| 2558 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); | 2852 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); |
| 2559 List<AnalysisError> errors = errorListener.getErrors2(source); | 2853 List<AnalysisError> errors = errorListener.getErrors2(source); |
| 2560 unit.parsingErrors = errors; | 2854 unit.parsingErrors = errors; |
| 2561 unit.lineInfo = lineInfo; | 2855 unit.lineInfo = lineInfo; |
| 2562 DartEntryImpl dartEntry = _sourceMap[source] as DartEntryImpl; | 2856 DartEntryImpl dartCopy = ((_sourceMap[source] as DartEntry)).writableCopy; |
| 2563 if (hasPartOfDirective(unit)) { | 2857 if (hasPartOfDirective(unit)) { |
| 2564 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 2858 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 2565 } else { | 2859 } else { |
| 2566 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 2860 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 2567 } | 2861 } |
| 2568 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | 2862 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 2569 dartEntry.setValue(DartEntry.PARSED_UNIT, unit); | 2863 dartCopy.setValue(DartEntry.PARSED_UNIT, unit); |
| 2570 dartEntry.setValue(DartEntry.PARSE_ERRORS, errors); | 2864 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors); |
| 2571 return dartEntry; | 2865 _sourceMap[source] = dartCopy; |
| 2866 return dartCopy; |
| 2572 } on AnalysisException catch (exception) { | 2867 } on AnalysisException catch (exception) { |
| 2573 DartEntryImpl dartEntry = _sourceMap[source] as DartEntryImpl; | 2868 DartEntryImpl dartCopy = ((_sourceMap[source] as DartEntry)).writableCopy; |
| 2574 dartEntry.setState(DartEntry.SOURCE_KIND, CacheState.ERROR); | 2869 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.ERROR); |
| 2575 dartEntry.setState(SourceEntry.LINE_INFO, CacheState.ERROR); | 2870 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 2576 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); | 2871 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); |
| 2577 dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR); | 2872 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR); |
| 2578 return dartEntry; | 2873 _sourceMap[source] = dartCopy; |
| 2874 return dartCopy; |
| 2579 } | 2875 } |
| 2580 } | 2876 } |
| 2581 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartEntry, Source s
ource) { | 2877 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartCopy, Source so
urce) { |
| 2582 accessed(source); | 2878 accessed(source); |
| 2583 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2879 try { |
| 2584 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorListen
er); | 2880 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 2585 Parser parser = new Parser(source, errorListener); | 2881 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); |
| 2586 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); | 2882 Parser parser = new Parser(source, errorListener); |
| 2587 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); | 2883 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); |
| 2588 List<AnalysisError> errors = errorListener.getErrors2(source); | 2884 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); |
| 2589 unit.parsingErrors = errors; | 2885 List<AnalysisError> errors = errorListener.getErrors2(source); |
| 2590 unit.lineInfo = lineInfo; | 2886 unit.parsingErrors = errors; |
| 2591 if (identical(dartEntry.getState(DartEntry.SOURCE_KIND), CacheState.INVALID)
) { | 2887 unit.lineInfo = lineInfo; |
| 2592 if (hasPartOfDirective(unit)) { | 2888 if (identical(dartCopy.getState(DartEntry.SOURCE_KIND), CacheState.INVALID
)) { |
| 2593 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 2889 if (hasPartOfDirective(unit)) { |
| 2594 } else { | 2890 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 2595 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 2891 } else { |
| 2892 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 2893 } |
| 2596 } | 2894 } |
| 2895 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 2896 dartCopy.setValue(DartEntry.PARSED_UNIT, unit); |
| 2897 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors); |
| 2898 return unit; |
| 2899 } on AnalysisException catch (exception) { |
| 2900 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 2901 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); |
| 2902 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR); |
| 2903 throw exception; |
| 2597 } | 2904 } |
| 2598 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | |
| 2599 dartEntry.setValue(DartEntry.PARSED_UNIT, unit); | |
| 2600 dartEntry.setValue(DartEntry.PARSE_ERRORS, errors); | |
| 2601 return unit; | |
| 2602 } | 2905 } |
| 2603 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen
er errorListener) { | 2906 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen
er errorListener) { |
| 2604 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult()
; | 2907 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult()
; |
| 2605 Source_ContentReceiver receiver = new Source_ContentReceiver_7(source, error
Listener, result); | 2908 Source_ContentReceiver receiver = new Source_ContentReceiver_8(source, error
Listener, result); |
| 2606 try { | 2909 try { |
| 2607 source.getContents(receiver); | 2910 source.getContents(receiver); |
| 2608 } catch (exception) { | 2911 } catch (exception) { |
| 2609 throw new AnalysisException.con3(exception); | 2912 throw new AnalysisException.con3(exception); |
| 2610 } | 2913 } |
| 2611 return result; | 2914 return result; |
| 2612 } | 2915 } |
| 2916 |
| 2917 /** |
| 2918 * Invalidate all of the results computed by this context. |
| 2919 * <p> |
| 2920 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 2921 */ |
| 2922 void invalidateAllResults() { |
| 2923 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) { |
| 2924 SourceEntry sourceEntry = mapEntry.getValue(); |
| 2925 if (sourceEntry is HtmlEntry) { |
| 2926 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 2927 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); |
| 2928 mapEntry.setValue(htmlCopy); |
| 2929 } else if (sourceEntry is DartEntry) { |
| 2930 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| 2931 dartCopy.invalidateAllResolutionInformation(); |
| 2932 mapEntry.setValue(dartCopy); |
| 2933 } |
| 2934 } |
| 2935 } |
| 2936 |
| 2613 /** | 2937 /** |
| 2614 * In response to a change to at least one of the compilation units in the giv
en library, | 2938 * In response to a change to at least one of the compilation units in the giv
en library, |
| 2615 * invalidate any results that are dependent on the result of resolving that l
ibrary. | 2939 * invalidate any results that are dependent on the result of resolving that l
ibrary. |
| 2616 * @param librarySource the source of the library being invalidated | 2940 * @param librarySource the source of the library being invalidated |
| 2617 * @param libraryEntry the cache entry for the library being invalidated | |
| 2618 */ | 2941 */ |
| 2619 void invalidateLibraryResolution(Source librarySource, DartEntryImpl libraryEn
try) { | 2942 void invalidateLibraryResolution(Source librarySource) { |
| 2943 DartEntry libraryEntry = getDartEntry(librarySource); |
| 2620 if (libraryEntry != null) { | 2944 if (libraryEntry != null) { |
| 2621 for (Source unitSource in libraryEntry.getValue(DartEntry.INCLUDED_PARTS))
{ | 2945 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); |
| 2622 DartEntryImpl partEntry = getDartEntry(unitSource) as DartEntryImpl; | 2946 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
| 2623 partEntry.invalidateAllResolutionInformation(); | 2947 libraryCopy.invalidateAllResolutionInformation(); |
| 2948 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); |
| 2949 _sourceMap[librarySource] = libraryCopy; |
| 2950 for (Source unitSource in includedParts) { |
| 2951 DartEntry partEntry = getDartEntry(unitSource); |
| 2952 if (partEntry != null) { |
| 2953 DartEntryImpl dartCopy = partEntry.writableCopy; |
| 2954 dartCopy.invalidateAllResolutionInformation(); |
| 2955 _sourceMap[unitSource] = dartCopy; |
| 2956 } |
| 2624 } | 2957 } |
| 2625 libraryEntry.invalidateAllResolutionInformation(); | |
| 2626 libraryEntry.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); | |
| 2627 } | 2958 } |
| 2628 } | 2959 } |
| 2960 |
| 2629 /** | 2961 /** |
| 2630 * Return {@code true} if this library is, or depends on, dart:html. | 2962 * Return {@code true} if this library is, or depends on, dart:html. |
| 2631 * @param library the library being tested | 2963 * @param library the library being tested |
| 2632 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent | 2964 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent |
| 2633 * infinite recursion | 2965 * infinite recursion |
| 2634 * @return {@code true} if this library is, or depends on, dart:html | 2966 * @return {@code true} if this library is, or depends on, dart:html |
| 2635 */ | 2967 */ |
| 2636 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { | 2968 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { |
| 2637 if (visitedLibraries.contains(library)) { | 2969 if (visitedLibraries.contains(library)) { |
| 2638 return false; | 2970 return false; |
| 2639 } | 2971 } |
| 2640 if (library.source == htmlSource) { | 2972 if (library.source == htmlSource) { |
| 2641 return true; | 2973 return true; |
| 2642 } | 2974 } |
| 2643 javaSetAdd(visitedLibraries, library); | 2975 javaSetAdd(visitedLibraries, library); |
| 2644 for (LibraryElement imported in library.importedLibraries) { | 2976 for (LibraryElement imported in library.importedLibraries) { |
| 2645 if (isClient(imported, htmlSource, visitedLibraries)) { | 2977 if (isClient(imported, htmlSource, visitedLibraries)) { |
| 2646 return true; | 2978 return true; |
| 2647 } | 2979 } |
| 2648 } | 2980 } |
| 2649 for (LibraryElement exported in library.exportedLibraries) { | 2981 for (LibraryElement exported in library.exportedLibraries) { |
| 2650 if (isClient(exported, htmlSource, visitedLibraries)) { | 2982 if (isClient(exported, htmlSource, visitedLibraries)) { |
| 2651 return true; | 2983 return true; |
| 2652 } | 2984 } |
| 2653 } | 2985 } |
| 2654 return false; | 2986 return false; |
| 2655 } | 2987 } |
| 2988 |
| 2656 /** | 2989 /** |
| 2657 * Perform a single analysis task. | 2990 * Perform a single analysis task. |
| 2658 * <p> | 2991 * <p> |
| 2659 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2992 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 2660 * @return {@code true} if work was done, implying that there might be more wo
rk to be done | 2993 * @return {@code true} if work was done, implying that there might be more wo
rk to be done |
| 2661 */ | 2994 */ |
| 2662 bool performSingleAnalysisTask() { | 2995 bool performSingleAnalysisTask() { |
| 2663 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 2996 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 2664 SourceEntry sourceEntry = entry.getValue(); | 2997 SourceEntry sourceEntry = entry.getValue(); |
| 2665 if (sourceEntry is DartEntry) { | 2998 if (sourceEntry is DartEntry) { |
| 2666 DartEntry dartEntry = sourceEntry as DartEntry; | 2999 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2667 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT); | 3000 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT); |
| 2668 if (identical(parsedUnitState, CacheState.INVALID)) { | 3001 if (identical(parsedUnitState, CacheState.INVALID)) { |
| 2669 try { | 3002 try { |
| 2670 parseCompilationUnit(entry.getKey()); | 3003 parseCompilationUnit(entry.getKey()); |
| 2671 } on AnalysisException catch (exception) { | 3004 } on AnalysisException catch (exception) { |
| 2672 ((dartEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, Cache
State.ERROR); | 3005 DartEntryImpl dartCopy = ((entry.getValue() as DartEntry)).writableC
opy; |
| 3006 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); |
| 3007 entry.setValue(dartCopy); |
| 2673 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); | 3008 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); |
| 2674 } | 3009 } |
| 2675 return true; | 3010 return true; |
| 2676 } | 3011 } |
| 2677 } else if (sourceEntry is HtmlEntry) { | 3012 } else if (sourceEntry is HtmlEntry) { |
| 2678 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 3013 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 2679 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); | 3014 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); |
| 2680 if (identical(parsedUnitState, CacheState.INVALID)) { | 3015 if (identical(parsedUnitState, CacheState.INVALID)) { |
| 2681 try { | 3016 try { |
| 2682 parseHtmlUnit(entry.getKey()); | 3017 parseHtmlUnit(entry.getKey()); |
| 2683 } on AnalysisException catch (exception) { | 3018 } on AnalysisException catch (exception) { |
| 2684 ((htmlEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, Cache
State.ERROR); | 3019 HtmlEntryImpl htmlCopy = ((entry.getValue() as HtmlEntry)).writableC
opy; |
| 3020 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); |
| 3021 entry.setValue(htmlCopy); |
| 2685 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); | 3022 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); |
| 2686 } | 3023 } |
| 2687 return true; | 3024 return true; |
| 2688 } | 3025 } |
| 2689 } | 3026 } |
| 2690 } | 3027 } |
| 2691 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 3028 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 2692 SourceEntry sourceEntry = entry.getValue(); | 3029 SourceEntry sourceEntry = entry.getValue(); |
| 2693 if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.LIB
RARY)) { | 3030 if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.LIB
RARY)) { |
| 2694 DartEntry dartEntry = sourceEntry as DartEntry; | 3031 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2695 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); | 3032 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
| 2696 if (identical(elementState, CacheState.INVALID)) { | 3033 if (identical(elementState, CacheState.INVALID)) { |
| 2697 try { | 3034 try { |
| 2698 computeLibraryElement(entry.getKey()); | 3035 computeLibraryElement(entry.getKey()); |
| 2699 } on AnalysisException catch (exception) { | 3036 } on AnalysisException catch (exception) { |
| 2700 ((dartEntry as DartEntryImpl)).setState(DartEntry.ELEMENT, CacheStat
e.ERROR); | 3037 DartEntryImpl dartCopy = ((entry.getValue() as DartEntry)).writableC
opy; |
| 3038 dartCopy.setState(DartEntry.ELEMENT, CacheState.ERROR); |
| 3039 entry.setValue(dartCopy); |
| 2701 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); | 3040 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); |
| 2702 } | 3041 } |
| 2703 return true; | 3042 return true; |
| 2704 } | 3043 } |
| 2705 } else if (sourceEntry is HtmlEntry) { | 3044 } else if (sourceEntry is HtmlEntry) { |
| 2706 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 3045 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 2707 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNI
T); | 3046 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNI
T); |
| 2708 if (identical(resolvedUnitState, CacheState.INVALID)) { | 3047 if (identical(resolvedUnitState, CacheState.INVALID)) { |
| 2709 try { | 3048 try { |
| 2710 resolveHtmlUnit(entry.getKey()); | 3049 resolveHtmlUnit(entry.getKey()); |
| 2711 } on AnalysisException catch (exception) { | 3050 } on AnalysisException catch (exception) { |
| 2712 ((htmlEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, Cac
heState.ERROR); | 3051 HtmlEntryImpl htmlCopy = ((entry.getValue() as HtmlEntry)).writableC
opy; |
| 3052 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); |
| 3053 entry.setValue(htmlCopy); |
| 2713 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); | 3054 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); |
| 2714 } | 3055 } |
| 2715 return true; | 3056 return true; |
| 2716 } | 3057 } |
| 2717 } | 3058 } |
| 2718 } | 3059 } |
| 2719 return false; | 3060 return false; |
| 2720 } | 3061 } |
| 3062 |
| 3063 /** |
| 3064 * Given a cache entry and a library element, record the library element and o
ther information |
| 3065 * gleaned from the element in the cache entry. |
| 3066 * @param dartCopy the cache entry in which data is to be recorded |
| 3067 * @param library the library element used to record information |
| 3068 * @param htmlSource the source for the HTML library |
| 3069 */ |
| 3070 void recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source
htmlSource) { |
| 3071 dartCopy.setValue(DartEntry.ELEMENT, library); |
| 3072 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); |
| 3073 dartCopy.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set
<LibraryElement>())); |
| 3074 List<Source> unitSources = new List<Source>(); |
| 3075 unitSources.add(library.definingCompilationUnit.source); |
| 3076 for (CompilationUnitElement part in library.parts) { |
| 3077 Source partSource = part.source; |
| 3078 unitSources.add(partSource); |
| 3079 } |
| 3080 dartCopy.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources)); |
| 3081 } |
| 3082 |
| 3083 /** |
| 3084 * Record the result of using the given resolver to resolve one or more librar
ies. |
| 3085 * @param resolver the resolver that has the needed results |
| 3086 * @throws AnalysisException if the results cannot be retrieved for some reaso
n |
| 3087 */ |
| 3088 void recordResolutionResults(LibraryResolver resolver) { |
| 3089 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
| 3090 RecordingErrorListener errorListener2 = resolver.errorListener; |
| 3091 for (Library library in resolver.resolvedLibraries) { |
| 3092 Source librarySource2 = library.librarySource; |
| 3093 Set<Source> referencedLibraries = new Set<Source>(); |
| 3094 for (Library referencedLibrary in library.exports) { |
| 3095 javaSetAdd(referencedLibraries, referencedLibrary.librarySource); |
| 3096 } |
| 3097 for (Library referencedLibrary in library.imports) { |
| 3098 javaSetAdd(referencedLibraries, referencedLibrary.librarySource); |
| 3099 } |
| 3100 for (Source source in library.compilationUnitSources) { |
| 3101 CompilationUnit unit = library.getAST(source); |
| 3102 List<AnalysisError> errors = errorListener2.getErrors2(source); |
| 3103 unit.resolutionErrors = errors; |
| 3104 LineInfo lineInfo2 = unit.lineInfo; |
| 3105 { |
| 3106 DartEntry dartEntry = getDartEntry(source); |
| 3107 if (dartEntry != null) { |
| 3108 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3109 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo2); |
| 3110 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 3111 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource2, unit); |
| 3112 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource2, erro
rs); |
| 3113 if (identical(source, librarySource2)) { |
| 3114 recordElementData(dartCopy, library.libraryElement, htmlSource); |
| 3115 List<Source> libraries; |
| 3116 if (referencedLibraries.isEmpty) { |
| 3117 libraries = Source.EMPTY_ARRAY; |
| 3118 } else { |
| 3119 libraries = new List.from(referencedLibraries); |
| 3120 } |
| 3121 dartCopy.setValue(DartEntry.REFERENCED_LIBRARIES, libraries); |
| 3122 } |
| 3123 _sourceMap[source] = dartCopy; |
| 3124 ChangeNoticeImpl notice = getNotice(source); |
| 3125 notice.compilationUnit = unit; |
| 3126 notice.setErrors(dartCopy.allErrors, lineInfo2); |
| 3127 } |
| 3128 } |
| 3129 } |
| 3130 } |
| 3131 } |
| 2721 HtmlScanResult scanHtml(Source source) { | 3132 HtmlScanResult scanHtml(Source source) { |
| 2722 HtmlScanner scanner = new HtmlScanner(source); | 3133 HtmlScanner scanner = new HtmlScanner(source); |
| 2723 try { | 3134 try { |
| 2724 source.getContents(scanner); | 3135 source.getContents(scanner); |
| 2725 } catch (exception) { | 3136 } catch (exception) { |
| 2726 throw new AnalysisException.con3(exception); | 3137 throw new AnalysisException.con3(exception); |
| 2727 } | 3138 } |
| 2728 return scanner.result; | 3139 return scanner.result; |
| 2729 } | 3140 } |
| 3141 |
| 2730 /** | 3142 /** |
| 2731 * Create an entry for the newly added source. Return {@code true} if the new
source is a Dart | 3143 * Create an entry for the newly added source. Return {@code true} if the new
source is a Dart |
| 2732 * file. | 3144 * file. |
| 2733 * <p> | 3145 * <p> |
| 2734 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 3146 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 2735 * @param source the source that has been added | 3147 * @param source the source that has been added |
| 2736 * @return {@code true} if the new source is a Dart file | 3148 * @return {@code true} if the new source is a Dart file |
| 2737 */ | 3149 */ |
| 2738 bool sourceAvailable(Source source) { | 3150 bool sourceAvailable(Source source) { |
| 2739 SourceEntry sourceEntry = _sourceMap[source]; | 3151 SourceEntry sourceEntry = _sourceMap[source]; |
| 2740 if (sourceEntry == null) { | 3152 if (sourceEntry == null) { |
| 2741 sourceEntry = createSourceEntry(source); | 3153 sourceEntry = createSourceEntry(source); |
| 2742 } | 3154 } |
| 2743 return sourceEntry is DartEntry; | 3155 return sourceEntry is DartEntry; |
| 2744 } | 3156 } |
| 3157 |
| 2745 /** | 3158 /** |
| 2746 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 3159 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 2747 * @param source the source that has been changed | 3160 * @param source the source that has been changed |
| 2748 */ | 3161 */ |
| 2749 void sourceChanged(Source source) { | 3162 void sourceChanged(Source source) { |
| 2750 SourceEntry sourceEntry = _sourceMap[source]; | 3163 SourceEntry sourceEntry = _sourceMap[source]; |
| 2751 if (sourceEntry is HtmlEntry) { | 3164 if (sourceEntry is HtmlEntry) { |
| 2752 HtmlEntryImpl htmlEntry = sourceEntry as HtmlEntryImpl; | 3165 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 2753 htmlEntry.setState(HtmlEntry.ELEMENT, CacheState.INVALID); | 3166 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
| 2754 htmlEntry.setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 3167 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 2755 htmlEntry.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); | 3168 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); |
| 2756 htmlEntry.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); | 3169 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); |
| 2757 htmlEntry.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); | 3170 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); |
| 3171 _sourceMap[source] = htmlCopy; |
| 2758 } else if (sourceEntry is DartEntry) { | 3172 } else if (sourceEntry is DartEntry) { |
| 2759 DartEntryImpl dartEntry = sourceEntry as DartEntryImpl; | |
| 2760 List<Source> containingLibraries = getLibrariesContaining(source); | 3173 List<Source> containingLibraries = getLibrariesContaining(source); |
| 2761 invalidateLibraryResolution(source, dartEntry); | 3174 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| 2762 dartEntry.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); | 3175 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 2763 dartEntry.setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 3176 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); |
| 2764 dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); | 3177 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); |
| 2765 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); | 3178 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); |
| 2766 dartEntry.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); | 3179 _sourceMap[source] = dartCopy; |
| 3180 invalidateLibraryResolution(source); |
| 2767 for (Source librarySource in containingLibraries) { | 3181 for (Source librarySource in containingLibraries) { |
| 2768 DartEntryImpl libraryEntry = getDartEntry(librarySource) as DartEntryImp
l; | 3182 invalidateLibraryResolution(librarySource); |
| 2769 invalidateLibraryResolution(librarySource, libraryEntry); | |
| 2770 } | 3183 } |
| 2771 } | 3184 } |
| 2772 } | 3185 } |
| 3186 |
| 2773 /** | 3187 /** |
| 2774 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 3188 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 2775 * @param source the source that has been deleted | 3189 * @param source the source that has been deleted |
| 2776 */ | 3190 */ |
| 2777 void sourceRemoved(Source source) { | 3191 void sourceRemoved(Source source) { |
| 2778 DartEntry dartEntry = getDartEntry(source); | 3192 DartEntry dartEntry = getDartEntry(source); |
| 2779 if (dartEntry != null) { | 3193 if (dartEntry != null) { |
| 3194 Set<Source> libraries = new Set<Source>(); |
| 2780 for (Source librarySource in getLibrariesContaining(source)) { | 3195 for (Source librarySource in getLibrariesContaining(source)) { |
| 2781 DartEntryImpl libraryEntry = getDartEntry(librarySource) as DartEntryImp
l; | 3196 javaSetAdd(libraries, librarySource); |
| 2782 invalidateLibraryResolution(librarySource, libraryEntry); | 3197 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ |
| 3198 javaSetAdd(libraries, dependentLibrary); |
| 3199 } |
| 3200 } |
| 3201 for (Source librarySource in libraries) { |
| 3202 invalidateLibraryResolution(librarySource); |
| 2783 } | 3203 } |
| 2784 } | 3204 } |
| 2785 _sourceMap.remove(source); | 3205 _sourceMap.remove(source); |
| 2786 } | 3206 } |
| 2787 } | 3207 } |
| 3208 |
| 2788 /** | 3209 /** |
| 2789 * Instances of the class {@code ScanResult} represent the results of scanning a
source. | 3210 * Instances of the class {@code ScanResult} represent the results of scanning a
source. |
| 2790 */ | 3211 */ |
| 2791 class AnalysisContextImpl_ScanResult { | 3212 class AnalysisContextImpl_ScanResult { |
| 3213 |
| 2792 /** | 3214 /** |
| 2793 * The time at which the contents of the source were last set. | 3215 * The time at which the contents of the source were last set. |
| 2794 */ | 3216 */ |
| 2795 int _modificationTime = 0; | 3217 int _modificationTime = 0; |
| 3218 |
| 2796 /** | 3219 /** |
| 2797 * The first token in the token stream. | 3220 * The first token in the token stream. |
| 2798 */ | 3221 */ |
| 2799 Token _token; | 3222 Token _token; |
| 3223 |
| 2800 /** | 3224 /** |
| 2801 * The line start information that was produced. | 3225 * The line start information that was produced. |
| 2802 */ | 3226 */ |
| 2803 List<int> _lineStarts; | 3227 List<int> _lineStarts; |
| 2804 /** | |
| 2805 * Initialize a newly created result object to be empty. | |
| 2806 */ | |
| 2807 AnalysisContextImpl_ScanResult() : super() { | |
| 2808 } | |
| 2809 } | 3228 } |
| 2810 class Source_ContentReceiver_5 implements Source_ContentReceiver { | 3229 class Source_ContentReceiver_6 implements Source_ContentReceiver { |
| 2811 List<CharSequence> contentHolder; | 3230 List<CharSequence> contentHolder; |
| 2812 Source_ContentReceiver_5(this.contentHolder); | 3231 Source_ContentReceiver_6(this.contentHolder); |
| 2813 void accept(CharBuffer contents, int modificationTime) { | 3232 void accept(CharBuffer contents, int modificationTime) { |
| 2814 contentHolder[0] = contents; | 3233 contentHolder[0] = contents; |
| 2815 } | 3234 } |
| 2816 void accept2(String contents, int modificationTime) { | 3235 void accept2(String contents, int modificationTime) { |
| 2817 contentHolder[0] = new CharSequence(contents); | 3236 contentHolder[0] = new CharSequence(contents); |
| 2818 } | 3237 } |
| 2819 } | 3238 } |
| 2820 class RecursiveXmlVisitor_6 extends RecursiveXmlVisitor<Object> { | 3239 class RecursiveXmlVisitor_7 extends RecursiveXmlVisitor<Object> { |
| 2821 final AnalysisContextImpl AnalysisContextImpl_this; | 3240 final AnalysisContextImpl AnalysisContextImpl_this; |
| 2822 Source htmlSource; | 3241 Source htmlSource; |
| 2823 List<Source> libraries; | 3242 List<Source> libraries; |
| 2824 RecursiveXmlVisitor_6(this.AnalysisContextImpl_this, this.htmlSource, this.lib
raries) : super(); | 3243 RecursiveXmlVisitor_7(this.AnalysisContextImpl_this, this.htmlSource, this.lib
raries) : super(); |
| 2825 Object visitXmlTagNode(XmlTagNode node) { | 3244 Object visitXmlTagNode(XmlTagNode node) { |
| 2826 if (javaStringEqualsIgnoreCase(node.tag.lexeme, AnalysisContextImpl._TAG_SCR
IPT)) { | 3245 if (javaStringEqualsIgnoreCase(node.tag.lexeme, AnalysisContextImpl._TAG_SCR
IPT)) { |
| 2827 for (XmlAttributeNode attribute in node.attributes) { | 3246 for (XmlAttributeNode attribute in node.attributes) { |
| 2828 if (javaStringEqualsIgnoreCase(attribute.name.lexeme, AnalysisContextImp
l._ATTRIBUTE_SRC)) { | 3247 if (javaStringEqualsIgnoreCase(attribute.name.lexeme, AnalysisContextImp
l._ATTRIBUTE_SRC)) { |
| 2829 try { | 3248 try { |
| 2830 Uri uri = new Uri(path: attribute.text); | 3249 Uri uri = new Uri(path: attribute.text); |
| 2831 String fileName = uri.path; | 3250 String fileName = uri.path; |
| 2832 if (AnalysisEngine.isDartFileName(fileName)) { | 3251 if (AnalysisEngine.isDartFileName(fileName)) { |
| 2833 Source librarySource = AnalysisContextImpl_this._sourceFactory.res
olveUri(htmlSource, fileName); | 3252 Source librarySource = AnalysisContextImpl_this._sourceFactory.res
olveUri(htmlSource, fileName); |
| 2834 if (librarySource.exists()) { | 3253 if (librarySource.exists()) { |
| 2835 libraries.add(librarySource); | 3254 libraries.add(librarySource); |
| 2836 } | 3255 } |
| 2837 } | 3256 } |
| 2838 } catch (exception) { | 3257 } catch (exception) { |
| 2839 AnalysisEngine.instance.logger.logError2("Invalid URL ('${attribute.
text}') in script tag in '${htmlSource.fullName}'", exception); | 3258 AnalysisEngine.instance.logger.logError2("Invalid URL ('${attribute.
text}') in script tag in '${htmlSource.fullName}'", exception); |
| 2840 } | 3259 } |
| 2841 } | 3260 } |
| 2842 } | 3261 } |
| 2843 } | 3262 } |
| 2844 return super.visitXmlTagNode(node); | 3263 return super.visitXmlTagNode(node); |
| 2845 } | 3264 } |
| 2846 } | 3265 } |
| 2847 class Source_ContentReceiver_7 implements Source_ContentReceiver { | 3266 class Source_ContentReceiver_8 implements Source_ContentReceiver { |
| 2848 Source source; | 3267 Source source; |
| 2849 AnalysisErrorListener errorListener; | 3268 AnalysisErrorListener errorListener; |
| 2850 AnalysisContextImpl_ScanResult result; | 3269 AnalysisContextImpl_ScanResult result; |
| 2851 Source_ContentReceiver_7(this.source, this.errorListener, this.result); | 3270 Source_ContentReceiver_8(this.source, this.errorListener, this.result); |
| 2852 void accept(CharBuffer contents, int modificationTime2) { | 3271 void accept(CharBuffer contents, int modificationTime2) { |
| 2853 CharBufferScanner scanner = new CharBufferScanner(source, contents, errorLis
tener); | 3272 CharBufferScanner scanner = new CharBufferScanner(source, contents, errorLis
tener); |
| 2854 result._modificationTime = modificationTime2; | 3273 result._modificationTime = modificationTime2; |
| 2855 result._token = scanner.tokenize(); | 3274 result._token = scanner.tokenize(); |
| 2856 result._lineStarts = scanner.lineStarts; | 3275 result._lineStarts = scanner.lineStarts; |
| 2857 } | 3276 } |
| 2858 void accept2(String contents, int modificationTime2) { | 3277 void accept2(String contents, int modificationTime2) { |
| 2859 StringScanner scanner = new StringScanner(source, contents, errorListener); | 3278 StringScanner scanner = new StringScanner(source, contents, errorListener); |
| 2860 result._modificationTime = modificationTime2; | 3279 result._modificationTime = modificationTime2; |
| 2861 result._token = scanner.tokenize(); | 3280 result._token = scanner.tokenize(); |
| 2862 result._lineStarts = scanner.lineStarts; | 3281 result._lineStarts = scanner.lineStarts; |
| 2863 } | 3282 } |
| 2864 } | 3283 } |
| 3284 |
| 2865 /** | 3285 /** |
| 2866 * Instances of the class {@code AnalysisErrorInfoImpl} represent the analysis e
rrors and line info | 3286 * Instances of the class {@code AnalysisErrorInfoImpl} represent the analysis e
rrors and line info |
| 2867 * associated with a source. | 3287 * associated with a source. |
| 2868 */ | 3288 */ |
| 2869 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { | 3289 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { |
| 3290 |
| 2870 /** | 3291 /** |
| 2871 * The analysis errors associated with a source, or {@code null} if there are
no errors. | 3292 * The analysis errors associated with a source, or {@code null} if there are
no errors. |
| 2872 */ | 3293 */ |
| 2873 List<AnalysisError> _errors; | 3294 List<AnalysisError> _errors; |
| 3295 |
| 2874 /** | 3296 /** |
| 2875 * The line information associated with the errors, or {@code null} if there a
re no errors. | 3297 * The line information associated with the errors, or {@code null} if there a
re no errors. |
| 2876 */ | 3298 */ |
| 2877 LineInfo _lineInfo; | 3299 LineInfo _lineInfo; |
| 3300 |
| 2878 /** | 3301 /** |
| 2879 * Initialize an newly created error info with the errors and line information | 3302 * Initialize an newly created error info with the errors and line information |
| 2880 * @param errors the errors as a result of analysis | 3303 * @param errors the errors as a result of analysis |
| 2881 * @param lineinfo the line info for the errors | 3304 * @param lineinfo the line info for the errors |
| 2882 */ | 3305 */ |
| 2883 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { | 3306 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { |
| 2884 this._errors = errors; | 3307 this._errors = errors; |
| 2885 this._lineInfo = lineInfo; | 3308 this._lineInfo = lineInfo; |
| 2886 } | 3309 } |
| 3310 |
| 2887 /** | 3311 /** |
| 2888 * Return the errors of analysis, or {@code null} if there were no errors. | 3312 * Return the errors of analysis, or {@code null} if there were no errors. |
| 2889 * @return the errors as a result of the analysis | 3313 * @return the errors as a result of the analysis |
| 2890 */ | 3314 */ |
| 2891 List<AnalysisError> get errors => _errors; | 3315 List<AnalysisError> get errors => _errors; |
| 3316 |
| 2892 /** | 3317 /** |
| 2893 * Return the line information associated with the errors, or {@code null} if
there were no | 3318 * Return the line information associated with the errors, or {@code null} if
there were no |
| 2894 * errors. | 3319 * errors. |
| 2895 * @return the line information associated with the errors | 3320 * @return the line information associated with the errors |
| 2896 */ | 3321 */ |
| 2897 LineInfo get lineInfo => _lineInfo; | 3322 LineInfo get lineInfo => _lineInfo; |
| 2898 } | 3323 } |
| 3324 |
| 3325 /** |
| 3326 * Instances of the class {@code AnalysisOptions} represent a set of analysis op
tions used to |
| 3327 * control the behavior of an analysis context. |
| 3328 */ |
| 3329 class AnalysisOptionsImpl implements AnalysisOptions { |
| 3330 |
| 3331 /** |
| 3332 * A flag indicating whether analysis is to use strict mode. In strict mode, e
rror reporting is |
| 3333 * based exclusively on the static type information. |
| 3334 */ |
| 3335 bool _strictMode = false; |
| 3336 |
| 3337 /** |
| 3338 * Return {@code true} if analysis is to use strict mode. In strict mode, erro
r reporting is based |
| 3339 * exclusively on the static type information. |
| 3340 * @return {@code true} if analysis is to use strict mode |
| 3341 */ |
| 3342 bool get strictMode => _strictMode; |
| 3343 |
| 3344 /** |
| 3345 * Set whether analysis is to use strict mode to the given value. In strict mo
de, error reporting |
| 3346 * is based exclusively on the static type information. |
| 3347 * @param isStrict {@code true} if analysis is to use strict mode |
| 3348 */ |
| 3349 void set strictMode(bool isStrict) { |
| 3350 _strictMode = isStrict; |
| 3351 } |
| 3352 } |
| 3353 |
| 2899 /** | 3354 /** |
| 2900 * The enumeration {@code CacheState} defines the possible states of cached data
. | 3355 * The enumeration {@code CacheState} defines the possible states of cached data
. |
| 2901 */ | 3356 */ |
| 2902 class CacheState implements Comparable<CacheState> { | 3357 class CacheState implements Comparable<CacheState> { |
| 3358 |
| 2903 /** | 3359 /** |
| 2904 * The data is not in the cache and the last time an attempt was made to compu
te the data an | 3360 * The data is not in the cache and the last time an attempt was made to compu
te the data an |
| 2905 * exception occurred, making it pointless to attempt. | 3361 * exception occurred, making it pointless to attempt. |
| 2906 * <p> | 3362 * <p> |
| 2907 * Valid Transitions: | 3363 * Valid Transitions: |
| 2908 * <ul> | 3364 * <ul> |
| 2909 * <li>{@link #INVALID} if a source was modified that might cause the data to
be computable</li> | 3365 * <li>{@link #INVALID} if a source was modified that might cause the data to
be computable</li> |
| 2910 * </ul> | 3366 * </ul> |
| 2911 */ | 3367 */ |
| 2912 static final CacheState ERROR = new CacheState('ERROR', 0); | 3368 static final CacheState ERROR = new CacheState('ERROR', 0); |
| 3369 |
| 2913 /** | 3370 /** |
| 2914 * The data is not in the cache because it was flushed from the cache in order
to control memory | 3371 * The data is not in the cache because it was flushed from the cache in order
to control memory |
| 2915 * usage. If the data is recomputed, results do not need to be reported. | 3372 * usage. If the data is recomputed, results do not need to be reported. |
| 2916 * <p> | 3373 * <p> |
| 2917 * Valid Transitions: | 3374 * Valid Transitions: |
| 2918 * <ul> | 3375 * <ul> |
| 2919 * <li>{@link #IN_PROCESS} if the data is being recomputed</li> | 3376 * <li>{@link #IN_PROCESS} if the data is being recomputed</li> |
| 2920 * <li>{@link #INVALID} if a source was modified that causes the data to need
to be recomputed</li> | 3377 * <li>{@link #INVALID} if a source was modified that causes the data to need
to be recomputed</li> |
| 2921 * </ul> | 3378 * </ul> |
| 2922 */ | 3379 */ |
| 2923 static final CacheState FLUSHED = new CacheState('FLUSHED', 1); | 3380 static final CacheState FLUSHED = new CacheState('FLUSHED', 1); |
| 3381 |
| 2924 /** | 3382 /** |
| 2925 * The data might or might not be in the cache but is in the process of being
recomputed. | 3383 * The data might or might not be in the cache but is in the process of being
recomputed. |
| 2926 * <p> | 3384 * <p> |
| 2927 * Valid Transitions: | 3385 * Valid Transitions: |
| 2928 * <ul> | 3386 * <ul> |
| 2929 * <li>{@link #ERROR} if an exception occurred while trying to compute the dat
a</li> | 3387 * <li>{@link #ERROR} if an exception occurred while trying to compute the dat
a</li> |
| 2930 * <li>{@link #VALID} if the data was successfully computed and stored in the
cache</li> | 3388 * <li>{@link #VALID} if the data was successfully computed and stored in the
cache</li> |
| 2931 * </ul> | 3389 * </ul> |
| 2932 */ | 3390 */ |
| 2933 static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2); | 3391 static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2); |
| 3392 |
| 2934 /** | 3393 /** |
| 2935 * The data is not in the cache and needs to be recomputed so that results can
be reported. | 3394 * The data is not in the cache and needs to be recomputed so that results can
be reported. |
| 2936 * <p> | 3395 * <p> |
| 2937 * Valid Transitions: | 3396 * Valid Transitions: |
| 2938 * <ul> | 3397 * <ul> |
| 2939 * <li>{@link #IN_PROCESS} if an attempt is being made to recompute the data</
li> | 3398 * <li>{@link #IN_PROCESS} if an attempt is being made to recompute the data</
li> |
| 2940 * </ul> | 3399 * </ul> |
| 2941 */ | 3400 */ |
| 2942 static final CacheState INVALID = new CacheState('INVALID', 3); | 3401 static final CacheState INVALID = new CacheState('INVALID', 3); |
| 3402 |
| 2943 /** | 3403 /** |
| 2944 * The data is in the cache and up-to-date. | 3404 * The data is in the cache and up-to-date. |
| 2945 * <p> | 3405 * <p> |
| 2946 * Valid Transitions: | 3406 * Valid Transitions: |
| 2947 * <ul> | 3407 * <ul> |
| 2948 * <li>{@link #FLUSHED} if the data is removed in order to manage memory usage
</li> | 3408 * <li>{@link #FLUSHED} if the data is removed in order to manage memory usage
</li> |
| 2949 * <li>{@link #INVALID} if a source was modified in such a way as to invalidat
e the previous data</li> | 3409 * <li>{@link #INVALID} if a source was modified in such a way as to invalidat
e the previous data</li> |
| 2950 * </ul> | 3410 * </ul> |
| 2951 */ | 3411 */ |
| 2952 static final CacheState VALID = new CacheState('VALID', 4); | 3412 static final CacheState VALID = new CacheState('VALID', 4); |
| 2953 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V
ALID]; | 3413 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V
ALID]; |
| 2954 final String __name; | 3414 |
| 2955 final int __ordinal; | 3415 /// The name of this enum constant, as declared in the enum declaration. |
| 2956 int get ordinal => __ordinal; | 3416 final String name; |
| 2957 CacheState(this.__name, this.__ordinal) { | 3417 |
| 3418 /// The position in the enum declaration. |
| 3419 final int ordinal; |
| 3420 CacheState(this.name, this.ordinal) { |
| 2958 } | 3421 } |
| 2959 int compareTo(CacheState other) => __ordinal - other.__ordinal; | 3422 int compareTo(CacheState other) => ordinal - other.ordinal; |
| 2960 String toString() => __name; | 3423 String toString() => name; |
| 2961 } | 3424 } |
| 3425 |
| 2962 /** | 3426 /** |
| 2963 * Instances of the class {@code ChangeNoticeImpl} represent a change to the ana
lysis results | 3427 * Instances of the class {@code ChangeNoticeImpl} represent a change to the ana
lysis results |
| 2964 * associated with a given source. | 3428 * associated with a given source. |
| 2965 * @coverage dart.engine | 3429 * @coverage dart.engine |
| 2966 */ | 3430 */ |
| 2967 class ChangeNoticeImpl implements ChangeNotice { | 3431 class ChangeNoticeImpl implements ChangeNotice { |
| 3432 |
| 2968 /** | 3433 /** |
| 2969 * The source for which the result is being reported. | 3434 * The source for which the result is being reported. |
| 2970 */ | 3435 */ |
| 2971 Source _source; | 3436 Source _source; |
| 3437 |
| 2972 /** | 3438 /** |
| 2973 * The fully resolved AST that changed as a result of the analysis, or {@code
null} if the AST was | 3439 * The fully resolved AST that changed as a result of the analysis, or {@code
null} if the AST was |
| 2974 * not changed. | 3440 * not changed. |
| 2975 */ | 3441 */ |
| 2976 CompilationUnit _compilationUnit; | 3442 CompilationUnit _compilationUnit; |
| 3443 |
| 2977 /** | 3444 /** |
| 2978 * The errors that changed as a result of the analysis, or {@code null} if err
ors were not | 3445 * The errors that changed as a result of the analysis, or {@code null} if err
ors were not |
| 2979 * changed. | 3446 * changed. |
| 2980 */ | 3447 */ |
| 2981 List<AnalysisError> _errors; | 3448 List<AnalysisError> _errors; |
| 3449 |
| 2982 /** | 3450 /** |
| 2983 * The line information associated with the source, or {@code null} if errors
were not changed. | 3451 * The line information associated with the source, or {@code null} if errors
were not changed. |
| 2984 */ | 3452 */ |
| 2985 LineInfo _lineInfo; | 3453 LineInfo _lineInfo; |
| 3454 |
| 2986 /** | 3455 /** |
| 2987 * An empty array of change notices. | 3456 * An empty array of change notices. |
| 2988 */ | 3457 */ |
| 2989 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); | 3458 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); |
| 3459 |
| 2990 /** | 3460 /** |
| 2991 * Initialize a newly created notice associated with the given source. | 3461 * Initialize a newly created notice associated with the given source. |
| 2992 * @param source the source for which the change is being reported | 3462 * @param source the source for which the change is being reported |
| 2993 */ | 3463 */ |
| 2994 ChangeNoticeImpl(Source source) { | 3464 ChangeNoticeImpl(Source source) { |
| 2995 this._source = source; | 3465 this._source = source; |
| 2996 } | 3466 } |
| 3467 |
| 2997 /** | 3468 /** |
| 2998 * Return the fully resolved AST that changed as a result of the analysis, or
{@code null} if the | 3469 * Return the fully resolved AST that changed as a result of the analysis, or
{@code null} if the |
| 2999 * AST was not changed. | 3470 * AST was not changed. |
| 3000 * @return the fully resolved AST that changed as a result of the analysis | 3471 * @return the fully resolved AST that changed as a result of the analysis |
| 3001 */ | 3472 */ |
| 3002 CompilationUnit get compilationUnit => _compilationUnit; | 3473 CompilationUnit get compilationUnit => _compilationUnit; |
| 3474 |
| 3003 /** | 3475 /** |
| 3004 * Return the errors that changed as a result of the analysis, or {@code null}
if errors were not | 3476 * Return the errors that changed as a result of the analysis, or {@code null}
if errors were not |
| 3005 * changed. | 3477 * changed. |
| 3006 * @return the errors that changed as a result of the analysis | 3478 * @return the errors that changed as a result of the analysis |
| 3007 */ | 3479 */ |
| 3008 List<AnalysisError> get errors => _errors; | 3480 List<AnalysisError> get errors => _errors; |
| 3481 |
| 3009 /** | 3482 /** |
| 3010 * Return the line information associated with the source, or {@code null} if
errors were not | 3483 * Return the line information associated with the source, or {@code null} if
errors were not |
| 3011 * changed. | 3484 * changed. |
| 3012 * @return the line information associated with the source | 3485 * @return the line information associated with the source |
| 3013 */ | 3486 */ |
| 3014 LineInfo get lineInfo => _lineInfo; | 3487 LineInfo get lineInfo => _lineInfo; |
| 3488 |
| 3015 /** | 3489 /** |
| 3016 * Return the source for which the result is being reported. | 3490 * Return the source for which the result is being reported. |
| 3017 * @return the source for which the result is being reported | 3491 * @return the source for which the result is being reported |
| 3018 */ | 3492 */ |
| 3019 Source get source => _source; | 3493 Source get source => _source; |
| 3494 |
| 3020 /** | 3495 /** |
| 3021 * Set the fully resolved AST that changed as a result of the analysis to the
given AST. | 3496 * Set the fully resolved AST that changed as a result of the analysis to the
given AST. |
| 3022 * @param compilationUnit the fully resolved AST that changed as a result of t
he analysis | 3497 * @param compilationUnit the fully resolved AST that changed as a result of t
he analysis |
| 3023 */ | 3498 */ |
| 3024 void set compilationUnit(CompilationUnit compilationUnit2) { | 3499 void set compilationUnit(CompilationUnit compilationUnit2) { |
| 3025 this._compilationUnit = compilationUnit2; | 3500 this._compilationUnit = compilationUnit2; |
| 3026 } | 3501 } |
| 3502 |
| 3027 /** | 3503 /** |
| 3028 * Set the errors that changed as a result of the analysis to the given errors
and set the line | 3504 * Set the errors that changed as a result of the analysis to the given errors
and set the line |
| 3029 * information to the given line information. | 3505 * information to the given line information. |
| 3030 * @param errors the errors that changed as a result of the analysis | 3506 * @param errors the errors that changed as a result of the analysis |
| 3031 * @param lineInfo the line information associated with the source | 3507 * @param lineInfo the line information associated with the source |
| 3032 */ | 3508 */ |
| 3033 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { | 3509 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { |
| 3034 this._errors = errors2; | 3510 this._errors = errors2; |
| 3035 this._lineInfo = lineInfo2; | 3511 this._lineInfo = lineInfo2; |
| 3036 } | 3512 } |
| 3037 } | 3513 } |
| 3514 |
| 3038 /** | 3515 /** |
| 3039 * Instances of the class {@code DelegatingAnalysisContextImpl} extend {@link An
alysisContextImplanalysis context} to delegate sources to the appropriate analys
is context. For instance, if the | 3516 * Instances of the class {@code DelegatingAnalysisContextImpl} extend {@link An
alysisContextImplanalysis context} to delegate sources to the appropriate analys
is context. For instance, if the |
| 3040 * source is in a system library then the analysis context from the {@link DartS
dk} is used. | 3517 * source is in a system library then the analysis context from the {@link DartS
dk} is used. |
| 3041 * @coverage dart.engine | 3518 * @coverage dart.engine |
| 3042 */ | 3519 */ |
| 3043 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { | 3520 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { |
| 3521 |
| 3044 /** | 3522 /** |
| 3045 * This references the {@link InternalAnalysisContext} held onto by the {@link
DartSdk} which is | 3523 * This references the {@link InternalAnalysisContext} held onto by the {@link
DartSdk} which is |
| 3046 * used (instead of this {@link AnalysisContext}) for SDK sources. This field
is set when | 3524 * used (instead of this {@link AnalysisContext}) for SDK sources. This field
is set when |
| 3047 * #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 | 3525 * #setSourceFactory(SourceFactory) is called, and references the analysis con
text in the{@link DartUriResolver} in the {@link SourceFactory}, this analysis c
ontext assumes that there |
| 3048 * will be such a resolver. | 3526 * will be such a resolver. |
| 3049 */ | 3527 */ |
| 3050 InternalAnalysisContext _sdkAnalysisContext; | 3528 InternalAnalysisContext _sdkAnalysisContext; |
| 3051 /** | |
| 3052 * Initialize a newly created delegating analysis context. | |
| 3053 */ | |
| 3054 DelegatingAnalysisContextImpl() : super() { | |
| 3055 } | |
| 3056 void addSourceInfo(Source source, SourceEntry info) { | 3529 void addSourceInfo(Source source, SourceEntry info) { |
| 3057 if (source.isInSystemLibrary()) { | 3530 if (source.isInSystemLibrary()) { |
| 3058 _sdkAnalysisContext.addSourceInfo(source, info); | 3531 _sdkAnalysisContext.addSourceInfo(source, info); |
| 3059 } else { | 3532 } else { |
| 3060 super.addSourceInfo(source, info); | 3533 super.addSourceInfo(source, info); |
| 3061 } | 3534 } |
| 3062 } | 3535 } |
| 3063 List<AnalysisError> computeErrors(Source source) { | 3536 List<AnalysisError> computeErrors(Source source) { |
| 3064 if (source.isInSystemLibrary()) { | 3537 if (source.isInSystemLibrary()) { |
| 3065 return _sdkAnalysisContext.computeErrors(source); | 3538 return _sdkAnalysisContext.computeErrors(source); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3130 return super.getKindOf(source); | 3603 return super.getKindOf(source); |
| 3131 } | 3604 } |
| 3132 } | 3605 } |
| 3133 List<Source> getLibrariesContaining(Source source) { | 3606 List<Source> getLibrariesContaining(Source source) { |
| 3134 if (source.isInSystemLibrary()) { | 3607 if (source.isInSystemLibrary()) { |
| 3135 return _sdkAnalysisContext.getLibrariesContaining(source); | 3608 return _sdkAnalysisContext.getLibrariesContaining(source); |
| 3136 } else { | 3609 } else { |
| 3137 return super.getLibrariesContaining(source); | 3610 return super.getLibrariesContaining(source); |
| 3138 } | 3611 } |
| 3139 } | 3612 } |
| 3613 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 3614 if (librarySource.isInSystemLibrary()) { |
| 3615 return _sdkAnalysisContext.getLibrariesDependingOn(librarySource); |
| 3616 } else { |
| 3617 return super.getLibrariesDependingOn(librarySource); |
| 3618 } |
| 3619 } |
| 3140 LibraryElement getLibraryElement(Source source) { | 3620 LibraryElement getLibraryElement(Source source) { |
| 3141 if (source.isInSystemLibrary()) { | 3621 if (source.isInSystemLibrary()) { |
| 3142 return _sdkAnalysisContext.getLibraryElement(source); | 3622 return _sdkAnalysisContext.getLibraryElement(source); |
| 3143 } else { | 3623 } else { |
| 3144 return super.getLibraryElement(source); | 3624 return super.getLibraryElement(source); |
| 3145 } | 3625 } |
| 3146 } | 3626 } |
| 3147 List<Source> get librarySources => ArrayUtils.addAll(super.librarySources, _sd
kAnalysisContext.librarySources); | 3627 List<Source> get librarySources => ArrayUtils.addAll(super.librarySources, _sd
kAnalysisContext.librarySources); |
| 3148 LineInfo getLineInfo(Source source) { | 3628 LineInfo getLineInfo(Source source) { |
| 3149 if (source.isInSystemLibrary()) { | 3629 if (source.isInSystemLibrary()) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3213 if (elementMap.isEmpty) { | 3693 if (elementMap.isEmpty) { |
| 3214 return; | 3694 return; |
| 3215 } | 3695 } |
| 3216 Source source = new JavaIterator(elementMap.keys.toSet()).next(); | 3696 Source source = new JavaIterator(elementMap.keys.toSet()).next(); |
| 3217 if (source.isInSystemLibrary()) { | 3697 if (source.isInSystemLibrary()) { |
| 3218 _sdkAnalysisContext.recordLibraryElements(elementMap); | 3698 _sdkAnalysisContext.recordLibraryElements(elementMap); |
| 3219 } else { | 3699 } else { |
| 3220 super.recordLibraryElements(elementMap); | 3700 super.recordLibraryElements(elementMap); |
| 3221 } | 3701 } |
| 3222 } | 3702 } |
| 3223 void recordResolutionErrors(Source source, Source librarySource, List<Analysis
Error> errors, LineInfo lineInfo) { | |
| 3224 if (source.isInSystemLibrary()) { | |
| 3225 _sdkAnalysisContext.recordResolutionErrors(source, librarySource, errors,
lineInfo); | |
| 3226 } else { | |
| 3227 super.recordResolutionErrors(source, librarySource, errors, lineInfo); | |
| 3228 } | |
| 3229 } | |
| 3230 void recordResolvedCompilationUnit(Source source, Source librarySource, Compil
ationUnit unit) { | |
| 3231 if (source.isInSystemLibrary()) { | |
| 3232 _sdkAnalysisContext.recordResolvedCompilationUnit(source, librarySource, u
nit); | |
| 3233 } else { | |
| 3234 super.recordResolvedCompilationUnit(source, librarySource, unit); | |
| 3235 } | |
| 3236 } | |
| 3237 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library)
{ | 3703 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library)
{ |
| 3238 if (source.isInSystemLibrary()) { | 3704 if (source.isInSystemLibrary()) { |
| 3239 return _sdkAnalysisContext.resolveCompilationUnit(source, library); | 3705 return _sdkAnalysisContext.resolveCompilationUnit(source, library); |
| 3240 } else { | 3706 } else { |
| 3241 return super.resolveCompilationUnit(source, library); | 3707 return super.resolveCompilationUnit(source, library); |
| 3242 } | 3708 } |
| 3243 } | 3709 } |
| 3244 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { | 3710 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { |
| 3245 if (unitSource.isInSystemLibrary()) { | 3711 if (unitSource.isInSystemLibrary()) { |
| 3246 return _sdkAnalysisContext.resolveCompilationUnit2(unitSource, librarySour
ce); | 3712 return _sdkAnalysisContext.resolveCompilationUnit2(unitSource, librarySour
ce); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3269 _sdkAnalysisContext = sdk.context as InternalAnalysisContext; | 3735 _sdkAnalysisContext = sdk.context as InternalAnalysisContext; |
| 3270 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { | 3736 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { |
| 3271 _sdkAnalysisContext = null; | 3737 _sdkAnalysisContext = null; |
| 3272 throw new IllegalStateException("The context provided by an SDK cannot i
tself be a delegating analysis context"); | 3738 throw new IllegalStateException("The context provided by an SDK cannot i
tself be a delegating analysis context"); |
| 3273 } | 3739 } |
| 3274 } else { | 3740 } else { |
| 3275 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal
ysisContextImpls must have a DartSdk associated with the provided SourceFactory.
"); | 3741 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal
ysisContextImpls must have a DartSdk associated with the provided SourceFactory.
"); |
| 3276 } | 3742 } |
| 3277 } | 3743 } |
| 3278 } | 3744 } |
| 3745 |
| 3279 /** | 3746 /** |
| 3280 * Instances of the class {@code InstrumentedAnalysisContextImpl} implement an{@
link AnalysisContext analysis context} by recording instrumentation data and del
egating to | 3747 * Instances of the class {@code InstrumentedAnalysisContextImpl} implement an{@
link AnalysisContext analysis context} by recording instrumentation data and del
egating to |
| 3281 * another analysis context to do the non-instrumentation work. | 3748 * another analysis context to do the non-instrumentation work. |
| 3282 * @coverage dart.engine | 3749 * @coverage dart.engine |
| 3283 */ | 3750 */ |
| 3284 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { | 3751 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { |
| 3752 |
| 3285 /** | 3753 /** |
| 3286 * Record an exception that was thrown during analysis. | 3754 * Record an exception that was thrown during analysis. |
| 3287 * @param instrumentation the instrumentation builder being used to record the
exception | 3755 * @param instrumentation the instrumentation builder being used to record the
exception |
| 3288 * @param exception the exception being reported | 3756 * @param exception the exception being reported |
| 3289 */ | 3757 */ |
| 3290 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { | 3758 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { |
| 3291 instrumentation.record(exception); | 3759 instrumentation.record(exception); |
| 3292 } | 3760 } |
| 3761 |
| 3293 /** | 3762 /** |
| 3294 * The unique identifier used to identify this analysis context in the instrum
entation data. | 3763 * The unique identifier used to identify this analysis context in the instrum
entation data. |
| 3295 */ | 3764 */ |
| 3296 String _contextId = UUID.randomUUID().toString(); | 3765 String _contextId = UUID.randomUUID().toString(); |
| 3766 |
| 3297 /** | 3767 /** |
| 3298 * The analysis context to which all of the non-instrumentation work is delega
ted. | 3768 * The analysis context to which all of the non-instrumentation work is delega
ted. |
| 3299 */ | 3769 */ |
| 3300 InternalAnalysisContext _basis; | 3770 InternalAnalysisContext _basis; |
| 3771 |
| 3301 /** | 3772 /** |
| 3302 * Create a new {@link InstrumentedAnalysisContextImpl} which wraps a new{@lin
k AnalysisContextImpl} as the basis context. | 3773 * Create a new {@link InstrumentedAnalysisContextImpl} which wraps a new{@lin
k AnalysisContextImpl} as the basis context. |
| 3303 */ | 3774 */ |
| 3304 InstrumentedAnalysisContextImpl() { | 3775 InstrumentedAnalysisContextImpl() { |
| 3305 _jtd_constructor_178_impl(); | 3776 _jtd_constructor_182_impl(); |
| 3306 } | 3777 } |
| 3307 _jtd_constructor_178_impl() { | 3778 _jtd_constructor_182_impl() { |
| 3308 _jtd_constructor_179_impl(new AnalysisContextImpl()); | 3779 _jtd_constructor_183_impl(new AnalysisContextImpl()); |
| 3309 } | 3780 } |
| 3781 |
| 3310 /** | 3782 /** |
| 3311 * Create a new {@link InstrumentedAnalysisContextImpl} with a specified basis
context, aka the | 3783 * Create a new {@link InstrumentedAnalysisContextImpl} with a specified basis
context, aka the |
| 3312 * context to wrap and instrument. | 3784 * context to wrap and instrument. |
| 3313 * @param context some {@link InstrumentedAnalysisContext} to wrap and instrum
ent | 3785 * @param context some {@link InstrumentedAnalysisContext} to wrap and instrum
ent |
| 3314 */ | 3786 */ |
| 3315 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { | 3787 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { |
| 3316 _jtd_constructor_179_impl(context); | 3788 _jtd_constructor_183_impl(context); |
| 3317 } | 3789 } |
| 3318 _jtd_constructor_179_impl(InternalAnalysisContext context) { | 3790 _jtd_constructor_183_impl(InternalAnalysisContext context) { |
| 3319 _basis = context; | 3791 _basis = context; |
| 3320 } | 3792 } |
| 3321 void addSourceInfo(Source source, SourceEntry info) { | 3793 void addSourceInfo(Source source, SourceEntry info) { |
| 3322 _basis.addSourceInfo(source, info); | 3794 _basis.addSourceInfo(source, info); |
| 3323 } | 3795 } |
| 3324 void applyChanges(ChangeSet changeSet) { | 3796 void applyChanges(ChangeSet changeSet) { |
| 3325 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
applyChanges"); | 3797 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
applyChanges"); |
| 3326 try { | 3798 try { |
| 3327 instrumentation.metric3("contextId", _contextId); | 3799 instrumentation.metric3("contextId", _contextId); |
| 3328 _basis.applyChanges(changeSet); | 3800 _basis.applyChanges(changeSet); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3401 try { | 3873 try { |
| 3402 instrumentation.metric3("contextId", _contextId); | 3874 instrumentation.metric3("contextId", _contextId); |
| 3403 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte
xtImpl(); | 3875 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte
xtImpl(); |
| 3404 _basis.extractContextInto(container, newContext._basis); | 3876 _basis.extractContextInto(container, newContext._basis); |
| 3405 return newContext; | 3877 return newContext; |
| 3406 } finally { | 3878 } finally { |
| 3407 instrumentation.log(); | 3879 instrumentation.log(); |
| 3408 } | 3880 } |
| 3409 } | 3881 } |
| 3410 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) => _basis.extractContextInto(container, newContext); | 3882 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) => _basis.extractContextInto(container, newContext); |
| 3883 AnalysisOptions get analysisOptions { |
| 3884 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getAnalysisOptions"); |
| 3885 try { |
| 3886 instrumentation.metric3("contextId", _contextId); |
| 3887 return _basis.analysisOptions; |
| 3888 } finally { |
| 3889 instrumentation.log(); |
| 3890 } |
| 3891 } |
| 3892 |
| 3411 /** | 3893 /** |
| 3412 * @return the underlying {@link AnalysisContext}. | 3894 * @return the underlying {@link AnalysisContext}. |
| 3413 */ | 3895 */ |
| 3414 AnalysisContext get basis => _basis; | 3896 AnalysisContext get basis => _basis; |
| 3415 Element getElement(ElementLocation location) { | 3897 Element getElement(ElementLocation location) { |
| 3416 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getElement"); | 3898 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getElement"); |
| 3417 try { | 3899 try { |
| 3418 instrumentation.metric3("contextId", _contextId); | 3900 instrumentation.metric3("contextId", _contextId); |
| 3419 return _basis.getElement(location); | 3901 return _basis.getElement(location); |
| 3420 } finally { | 3902 } finally { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3510 instrumentation.metric3("contextId", _contextId); | 3992 instrumentation.metric3("contextId", _contextId); |
| 3511 List<Source> ret = _basis.getLibrariesContaining(source); | 3993 List<Source> ret = _basis.getLibrariesContaining(source); |
| 3512 if (ret != null) { | 3994 if (ret != null) { |
| 3513 instrumentation.metric2("Source-count", ret.length); | 3995 instrumentation.metric2("Source-count", ret.length); |
| 3514 } | 3996 } |
| 3515 return ret; | 3997 return ret; |
| 3516 } finally { | 3998 } finally { |
| 3517 instrumentation.log(); | 3999 instrumentation.log(); |
| 3518 } | 4000 } |
| 3519 } | 4001 } |
| 4002 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 4003 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibrariesDependingOn"); |
| 4004 try { |
| 4005 instrumentation.metric3("contextId", _contextId); |
| 4006 List<Source> ret = _basis.getLibrariesDependingOn(librarySource); |
| 4007 if (ret != null) { |
| 4008 instrumentation.metric2("Source-count", ret.length); |
| 4009 } |
| 4010 return ret; |
| 4011 } finally { |
| 4012 instrumentation.log(); |
| 4013 } |
| 4014 } |
| 3520 LibraryElement getLibraryElement(Source source) { | 4015 LibraryElement getLibraryElement(Source source) { |
| 3521 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryElement"); | 4016 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryElement"); |
| 3522 try { | 4017 try { |
| 3523 instrumentation.metric3("contextId", _contextId); | 4018 instrumentation.metric3("contextId", _contextId); |
| 3524 return _basis.getLibraryElement(source); | 4019 return _basis.getLibraryElement(source); |
| 3525 } finally { | 4020 } finally { |
| 3526 instrumentation.log(); | 4021 instrumentation.log(); |
| 3527 } | 4022 } |
| 3528 } | 4023 } |
| 3529 List<Source> get librarySources { | 4024 List<Source> get librarySources { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3640 instrumentation.metric2("ChangeNotice-count", ret.length); | 4135 instrumentation.metric2("ChangeNotice-count", ret.length); |
| 3641 } | 4136 } |
| 3642 return ret; | 4137 return ret; |
| 3643 } finally { | 4138 } finally { |
| 3644 instrumentation.log(); | 4139 instrumentation.log(); |
| 3645 } | 4140 } |
| 3646 } | 4141 } |
| 3647 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 4142 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 3648 _basis.recordLibraryElements(elementMap); | 4143 _basis.recordLibraryElements(elementMap); |
| 3649 } | 4144 } |
| 3650 void recordResolutionErrors(Source source, Source librarySource, List<Analysis
Error> errors, LineInfo lineInfo) { | |
| 3651 _basis.recordResolutionErrors(source, librarySource, errors, lineInfo); | |
| 3652 } | |
| 3653 void recordResolvedCompilationUnit(Source source, Source librarySource, Compil
ationUnit unit) { | |
| 3654 _basis.recordResolvedCompilationUnit(source, librarySource, unit); | |
| 3655 } | |
| 3656 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { | 4145 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { |
| 3657 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); | 4146 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); |
| 3658 try { | 4147 try { |
| 3659 instrumentation.metric3("contextId", _contextId); | 4148 instrumentation.metric3("contextId", _contextId); |
| 3660 return _basis.resolveCompilationUnit(unitSource, library); | 4149 return _basis.resolveCompilationUnit(unitSource, library); |
| 3661 } on AnalysisException catch (e) { | 4150 } on AnalysisException catch (e) { |
| 3662 recordAnalysisException(instrumentation, e); | 4151 recordAnalysisException(instrumentation, e); |
| 3663 throw e; | 4152 throw e; |
| 3664 } finally { | 4153 } finally { |
| 3665 instrumentation.log(); | 4154 instrumentation.log(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3682 try { | 4171 try { |
| 3683 instrumentation.metric3("contextId", _contextId); | 4172 instrumentation.metric3("contextId", _contextId); |
| 3684 return _basis.resolveHtmlUnit(htmlSource); | 4173 return _basis.resolveHtmlUnit(htmlSource); |
| 3685 } on AnalysisException catch (e) { | 4174 } on AnalysisException catch (e) { |
| 3686 recordAnalysisException(instrumentation, e); | 4175 recordAnalysisException(instrumentation, e); |
| 3687 throw e; | 4176 throw e; |
| 3688 } finally { | 4177 } finally { |
| 3689 instrumentation.log(); | 4178 instrumentation.log(); |
| 3690 } | 4179 } |
| 3691 } | 4180 } |
| 4181 void set analysisOptions(AnalysisOptions options) { |
| 4182 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisOptions"); |
| 4183 try { |
| 4184 instrumentation.metric3("contextId", _contextId); |
| 4185 _basis.analysisOptions = options; |
| 4186 } finally { |
| 4187 instrumentation.log(); |
| 4188 } |
| 4189 } |
| 3692 void setContents(Source source, String contents) { | 4190 void setContents(Source source, String contents) { |
| 3693 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setContents"); | 4191 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setContents"); |
| 3694 try { | 4192 try { |
| 3695 instrumentation.metric3("contextId", _contextId); | 4193 instrumentation.metric3("contextId", _contextId); |
| 3696 _basis.setContents(source, contents); | 4194 _basis.setContents(source, contents); |
| 3697 } finally { | 4195 } finally { |
| 3698 instrumentation.log(); | 4196 instrumentation.log(); |
| 3699 } | 4197 } |
| 3700 } | 4198 } |
| 3701 void set sourceFactory(SourceFactory factory) { | 4199 void set sourceFactory(SourceFactory factory) { |
| 3702 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setSourceFactory"); | 4200 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setSourceFactory"); |
| 3703 try { | 4201 try { |
| 3704 instrumentation.metric3("contextId", _contextId); | 4202 instrumentation.metric3("contextId", _contextId); |
| 3705 _basis.sourceFactory = factory; | 4203 _basis.sourceFactory = factory; |
| 3706 } finally { | 4204 } finally { |
| 3707 instrumentation.log(); | 4205 instrumentation.log(); |
| 3708 } | 4206 } |
| 3709 } | 4207 } |
| 3710 Iterable<Source> sourcesToResolve(List<Source> changedSources) { | 4208 Iterable<Source> sourcesToResolve(List<Source> changedSources) { |
| 3711 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
sourcesToResolve"); | 4209 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
sourcesToResolve"); |
| 3712 try { | 4210 try { |
| 3713 instrumentation.metric3("contextId", _contextId); | 4211 instrumentation.metric3("contextId", _contextId); |
| 3714 return _basis.sourcesToResolve(changedSources); | 4212 return _basis.sourcesToResolve(changedSources); |
| 3715 } finally { | 4213 } finally { |
| 3716 instrumentation.log(); | 4214 instrumentation.log(); |
| 3717 } | 4215 } |
| 3718 } | 4216 } |
| 3719 } | 4217 } |
| 4218 |
| 3720 /** | 4219 /** |
| 3721 * The interface {@code InternalAnalysisContext} defines additional behavior for
an analysis context | 4220 * The interface {@code InternalAnalysisContext} defines additional behavior for
an analysis context |
| 3722 * that is required by internal users of the context. | 4221 * that is required by internal users of the context. |
| 3723 */ | 4222 */ |
| 3724 abstract class InternalAnalysisContext implements AnalysisContext { | 4223 abstract class InternalAnalysisContext implements AnalysisContext { |
| 4224 |
| 3725 /** | 4225 /** |
| 3726 * Add the given source with the given information to this context. | 4226 * Add the given source with the given information to this context. |
| 3727 * @param source the source to be added | 4227 * @param source the source to be added |
| 3728 * @param info the information about the source | 4228 * @param info the information about the source |
| 3729 */ | 4229 */ |
| 3730 void addSourceInfo(Source source, SourceEntry info); | 4230 void addSourceInfo(Source source, SourceEntry info); |
| 4231 |
| 3731 /** | 4232 /** |
| 3732 * Return an AST structure corresponding to the given source, but ensure that
the structure has | 4233 * Return an AST structure corresponding to the given source, but ensure that
the structure has |
| 3733 * not already been resolved and will not be resolved by any other threads or
in any other | 4234 * not already been resolved and will not be resolved by any other threads or
in any other |
| 3734 * library. | 4235 * library. |
| 3735 * @param source the compilation unit for which an AST structure should be ret
urned | 4236 * @param source the compilation unit for which an AST structure should be ret
urned |
| 3736 * @return the AST structure representing the content of the source | 4237 * @return the AST structure representing the content of the source |
| 3737 * @throws AnalysisException if the analysis could not be performed | 4238 * @throws AnalysisException if the analysis could not be performed |
| 3738 */ | 4239 */ |
| 3739 CompilationUnit computeResolvableCompilationUnit(Source source); | 4240 CompilationUnit computeResolvableCompilationUnit(Source source); |
| 4241 |
| 3740 /** | 4242 /** |
| 3741 * Initialize the specified context by removing the specified sources from the
receiver and adding | 4243 * Initialize the specified context by removing the specified sources from the
receiver and adding |
| 3742 * them to the specified context. | 4244 * them to the specified context. |
| 3743 * @param container the container containing sources that should be removed fr
om this context and | 4245 * @param container the container containing sources that should be removed fr
om this context and |
| 3744 * added to the returned context | 4246 * added to the returned context |
| 3745 * @param newContext the context to be initialized | 4247 * @param newContext the context to be initialized |
| 3746 * @return the analysis context that was initialized | 4248 * @return the analysis context that was initialized |
| 3747 */ | 4249 */ |
| 3748 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext); | 4250 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext); |
| 4251 |
| 3749 /** | 4252 /** |
| 3750 * Return a namespace containing mappings for all of the public names defined
by the given | 4253 * Return a namespace containing mappings for all of the public names defined
by the given |
| 3751 * library. | 4254 * library. |
| 3752 * @param library the library whose public namespace is to be returned | 4255 * @param library the library whose public namespace is to be returned |
| 3753 * @return the public namespace of the given library | 4256 * @return the public namespace of the given library |
| 3754 */ | 4257 */ |
| 3755 Namespace getPublicNamespace(LibraryElement library); | 4258 Namespace getPublicNamespace(LibraryElement library); |
| 4259 |
| 3756 /** | 4260 /** |
| 3757 * Return a namespace containing mappings for all of the public names defined
by the library | 4261 * Return a namespace containing mappings for all of the public names defined
by the library |
| 3758 * defined by the given source. | 4262 * defined by the given source. |
| 3759 * @param source the source defining the library whose public namespace is to
be returned | 4263 * @param source the source defining the library whose public namespace is to
be returned |
| 3760 * @return the public namespace corresponding to the library defined by the gi
ven source | 4264 * @return the public namespace corresponding to the library defined by the gi
ven source |
| 3761 * @throws AnalysisException if the public namespace could not be computed | 4265 * @throws AnalysisException if the public namespace could not be computed |
| 3762 */ | 4266 */ |
| 3763 Namespace getPublicNamespace2(Source source); | 4267 Namespace getPublicNamespace2(Source source); |
| 4268 |
| 3764 /** | 4269 /** |
| 3765 * Given a table mapping the source for the libraries represented by the corre
sponding elements to | 4270 * Given a table mapping the source for the libraries represented by the corre
sponding elements to |
| 3766 * the elements representing the libraries, record those mappings. | 4271 * the elements representing the libraries, record those mappings. |
| 3767 * @param elementMap a table mapping the source for the libraries represented
by the elements to | 4272 * @param elementMap a table mapping the source for the libraries represented
by the elements to |
| 3768 * the elements representing the libraries | 4273 * the elements representing the libraries |
| 3769 */ | 4274 */ |
| 3770 void recordLibraryElements(Map<Source, LibraryElement> elementMap); | 4275 void recordLibraryElements(Map<Source, LibraryElement> elementMap); |
| 3771 /** | |
| 3772 * Give the resolution errors and line info associated with the given source,
add the information | |
| 3773 * to the cache. | |
| 3774 * @param source the source with which the information is associated | |
| 3775 * @param librarySource the source of the defining compilation unit of the lib
rary in which the | |
| 3776 * source was resolved | |
| 3777 * @param errors the resolution errors associated with the source | |
| 3778 * @param lineInfo the line information associated with the source | |
| 3779 */ | |
| 3780 void recordResolutionErrors(Source source, Source librarySource, List<Analysis
Error> errors, LineInfo lineInfo); | |
| 3781 /** | |
| 3782 * Give the resolved compilation unit associated with the given source, add th
e unit to the cache. | |
| 3783 * @param source the source with which the unit is associated | |
| 3784 * @param librarySource the source of the defining compilation unit of the lib
rary in which the | |
| 3785 * source was resolved | |
| 3786 * @param unit the compilation unit associated with the source | |
| 3787 */ | |
| 3788 void recordResolvedCompilationUnit(Source source, Source librarySource, Compil
ationUnit unit); | |
| 3789 } | 4276 } |
| 4277 |
| 3790 /** | 4278 /** |
| 3791 * Instances of the class {@code RecordingErrorListener} implement an error list
ener that will | 4279 * Instances of the class {@code RecordingErrorListener} implement an error list
ener that will |
| 3792 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors | 4280 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors |
| 3793 * within an analysis context. | 4281 * within an analysis context. |
| 3794 * @coverage dart.engine | 4282 * @coverage dart.engine |
| 3795 */ | 4283 */ |
| 3796 class RecordingErrorListener implements AnalysisErrorListener { | 4284 class RecordingErrorListener implements AnalysisErrorListener { |
| 4285 |
| 3797 /** | 4286 /** |
| 3798 * A HashMap of lists containing the errors that were collected, keyed by each
{@link Source}. | 4287 * A HashMap of lists containing the errors that were collected, keyed by each
{@link Source}. |
| 3799 */ | 4288 */ |
| 3800 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError>
>(); | 4289 Map<Source, List<AnalysisError>> _errors = new Map<Source, List<AnalysisError>
>(); |
| 4290 |
| 4291 /** |
| 4292 * Add all of the errors recorded by the given listener to this listener. |
| 4293 * @param listener the listener that has recorded the errors to be added |
| 4294 */ |
| 4295 void addAll(RecordingErrorListener listener) { |
| 4296 for (AnalysisError error in listener.errors) { |
| 4297 onError(error); |
| 4298 } |
| 4299 } |
| 4300 |
| 3801 /** | 4301 /** |
| 3802 * Answer the errors collected by the listener. | 4302 * Answer the errors collected by the listener. |
| 3803 * @return an array of errors (not {@code null}, contains no {@code null}s) | 4303 * @return an array of errors (not {@code null}, contains no {@code null}s) |
| 3804 */ | 4304 */ |
| 3805 List<AnalysisError> get errors { | 4305 List<AnalysisError> get errors { |
| 3806 Set<MapEntry<Source, List<AnalysisError>>> entrySet2 = getMapEntrySet(_error
s); | 4306 Set<MapEntry<Source, List<AnalysisError>>> entrySet2 = getMapEntrySet(_error
s); |
| 3807 if (entrySet2.length == 0) { | 4307 if (entrySet2.length == 0) { |
| 3808 return AnalysisError.NO_ERRORS; | 4308 return AnalysisError.NO_ERRORS; |
| 3809 } | 4309 } |
| 3810 List<AnalysisError> resultList = new List<AnalysisError>(); | 4310 List<AnalysisError> resultList = new List<AnalysisError>(); |
| 3811 for (MapEntry<Source, List<AnalysisError>> entry in entrySet2) { | 4311 for (MapEntry<Source, List<AnalysisError>> entry in entrySet2) { |
| 3812 resultList.addAll(entry.getValue()); | 4312 resultList.addAll(entry.getValue()); |
| 3813 } | 4313 } |
| 3814 return new List.from(resultList); | 4314 return new List.from(resultList); |
| 3815 } | 4315 } |
| 4316 |
| 3816 /** | 4317 /** |
| 3817 * Answer the errors collected by the listener for some passed {@link Source}. | 4318 * Answer the errors collected by the listener for some passed {@link Source}. |
| 3818 * @param source some {@link Source} for which the caller wants the set of {@l
ink AnalysisError}s | 4319 * @param source some {@link Source} for which the caller wants the set of {@l
ink AnalysisError}s |
| 3819 * collected by this listener | 4320 * collected by this listener |
| 3820 * @return the errors collected by the listener for the passed {@link Source} | 4321 * @return the errors collected by the listener for the passed {@link Source} |
| 3821 */ | 4322 */ |
| 3822 List<AnalysisError> getErrors2(Source source) { | 4323 List<AnalysisError> getErrors2(Source source) { |
| 3823 List<AnalysisError> errorsForSource = _errors[source]; | 4324 List<AnalysisError> errorsForSource = _errors[source]; |
| 3824 if (errorsForSource == null) { | 4325 if (errorsForSource == null) { |
| 3825 return AnalysisError.NO_ERRORS; | 4326 return AnalysisError.NO_ERRORS; |
| 3826 } else { | 4327 } else { |
| 3827 return new List.from(errorsForSource); | 4328 return new List.from(errorsForSource); |
| 3828 } | 4329 } |
| 3829 } | 4330 } |
| 3830 void onError(AnalysisError event) { | 4331 void onError(AnalysisError event) { |
| 3831 Source source2 = event.source; | 4332 Source source2 = event.source; |
| 3832 List<AnalysisError> errorsForSource = _errors[source2]; | 4333 List<AnalysisError> errorsForSource = _errors[source2]; |
| 3833 if (_errors[source2] == null) { | 4334 if (_errors[source2] == null) { |
| 3834 errorsForSource = new List<AnalysisError>(); | 4335 errorsForSource = new List<AnalysisError>(); |
| 3835 _errors[source2] = errorsForSource; | 4336 _errors[source2] = errorsForSource; |
| 3836 } | 4337 } |
| 3837 errorsForSource.add(event); | 4338 errorsForSource.add(event); |
| 3838 } | 4339 } |
| 3839 } | 4340 } |
| 4341 |
| 3840 /** | 4342 /** |
| 3841 * Instances of the class {@code ResolutionEraser} remove any resolution informa
tion from an AST | 4343 * Instances of the class {@code ResolutionEraser} remove any resolution informa
tion from an AST |
| 3842 * structure when used to visit that structure. | 4344 * structure when used to visit that structure. |
| 3843 */ | 4345 */ |
| 3844 class ResolutionEraser extends GeneralizingASTVisitor<Object> { | 4346 class ResolutionEraser extends GeneralizingASTVisitor<Object> { |
| 3845 Object visitAssignmentExpression(AssignmentExpression node) { | 4347 Object visitAssignmentExpression(AssignmentExpression node) { |
| 3846 node.element = null; | 4348 node.element = null; |
| 3847 return super.visitAssignmentExpression(node); | 4349 return super.visitAssignmentExpression(node); |
| 3848 } | 4350 } |
| 3849 Object visitBinaryExpression(BinaryExpression node) { | 4351 Object visitBinaryExpression(BinaryExpression node) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3901 } | 4403 } |
| 3902 Object visitSimpleIdentifier(SimpleIdentifier node) { | 4404 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 3903 node.element = null; | 4405 node.element = null; |
| 3904 return super.visitSimpleIdentifier(node); | 4406 return super.visitSimpleIdentifier(node); |
| 3905 } | 4407 } |
| 3906 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 4408 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 3907 node.element = null; | 4409 node.element = null; |
| 3908 return super.visitSuperConstructorInvocation(node); | 4410 return super.visitSuperConstructorInvocation(node); |
| 3909 } | 4411 } |
| 3910 } | 4412 } |
| 4413 |
| 3911 /** | 4414 /** |
| 3912 * The interface {@code Logger} defines the behavior of objects that can be used
to receive | 4415 * The interface {@code Logger} defines the behavior of objects that can be used
to receive |
| 3913 * information about errors within the analysis engine. Implementations usually
write this | 4416 * information about errors within the analysis engine. Implementations usually
write this |
| 3914 * information to a file, but can also record the information for later use (suc
h as during testing) | 4417 * information to a file, but can also record the information for later use (suc
h as during testing) |
| 3915 * or even ignore the information. | 4418 * or even ignore the information. |
| 3916 * @coverage dart.engine.utilities | 4419 * @coverage dart.engine.utilities |
| 3917 */ | 4420 */ |
| 3918 abstract class Logger { | 4421 abstract class Logger { |
| 3919 static Logger NULL = new Logger_NullLogger(); | 4422 static Logger NULL = new Logger_NullLogger(); |
| 4423 |
| 3920 /** | 4424 /** |
| 3921 * Log the given message as an error. | 4425 * Log the given message as an error. |
| 3922 * @param message an explanation of why the error occurred or what it means | 4426 * @param message an explanation of why the error occurred or what it means |
| 3923 */ | 4427 */ |
| 3924 void logError(String message); | 4428 void logError(String message); |
| 4429 |
| 3925 /** | 4430 /** |
| 3926 * Log the given exception as one representing an error. | 4431 * Log the given exception as one representing an error. |
| 3927 * @param message an explanation of why the error occurred or what it means | 4432 * @param message an explanation of why the error occurred or what it means |
| 3928 * @param exception the exception being logged | 4433 * @param exception the exception being logged |
| 3929 */ | 4434 */ |
| 3930 void logError2(String message, Exception exception); | 4435 void logError2(String message, Exception exception); |
| 4436 |
| 3931 /** | 4437 /** |
| 3932 * Log the given exception as one representing an error. | 4438 * Log the given exception as one representing an error. |
| 3933 * @param exception the exception being logged | 4439 * @param exception the exception being logged |
| 3934 */ | 4440 */ |
| 3935 void logError3(Exception exception); | 4441 void logError3(Exception exception); |
| 4442 |
| 3936 /** | 4443 /** |
| 3937 * Log the given informational message. | 4444 * Log the given informational message. |
| 3938 * @param message an explanation of why the error occurred or what it means | 4445 * @param message an explanation of why the error occurred or what it means |
| 3939 * @param exception the exception being logged | 4446 * @param exception the exception being logged |
| 3940 */ | 4447 */ |
| 3941 void logInformation(String message); | 4448 void logInformation(String message); |
| 4449 |
| 3942 /** | 4450 /** |
| 3943 * Log the given exception as one representing an informational message. | 4451 * Log the given exception as one representing an informational message. |
| 3944 * @param message an explanation of why the error occurred or what it means | 4452 * @param message an explanation of why the error occurred or what it means |
| 3945 * @param exception the exception being logged | 4453 * @param exception the exception being logged |
| 3946 */ | 4454 */ |
| 3947 void logInformation2(String message, Exception exception); | 4455 void logInformation2(String message, Exception exception); |
| 3948 } | 4456 } |
| 4457 |
| 3949 /** | 4458 /** |
| 3950 * Implementation of {@link Logger} that does nothing. | 4459 * Implementation of {@link Logger} that does nothing. |
| 3951 */ | 4460 */ |
| 3952 class Logger_NullLogger implements Logger { | 4461 class Logger_NullLogger implements Logger { |
| 3953 void logError(String message) { | 4462 void logError(String message) { |
| 3954 } | 4463 } |
| 3955 void logError2(String message, Exception exception) { | 4464 void logError2(String message, Exception exception) { |
| 3956 } | 4465 } |
| 3957 void logError3(Exception exception) { | 4466 void logError3(Exception exception) { |
| 3958 } | 4467 } |
| 3959 void logInformation(String message) { | 4468 void logInformation(String message) { |
| 3960 } | 4469 } |
| 3961 void logInformation2(String message, Exception exception) { | 4470 void logInformation2(String message, Exception exception) { |
| 3962 } | 4471 } |
| 3963 } | 4472 } |
| OLD | NEW |