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

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

Issue 184893003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void set logger(Logger logger) { 120 void set logger(Logger logger) {
121 this._logger = logger == null ? Logger.NULL : logger; 121 this._logger = logger == null ? Logger.NULL : logger;
122 } 122 }
123 } 123 }
124 124
125 /** 125 /**
126 * Container with statistics about the [AnalysisContext]. 126 * Container with statistics about the [AnalysisContext].
127 */ 127 */
128 abstract class AnalysisContentStatistics { 128 abstract class AnalysisContentStatistics {
129 /** 129 /**
130 * Return the statistics for each kind of cached data.
131 *
132 * @return the statistics for each kind of cached data
133 */
134 List<AnalysisContentStatistics_CacheRow> get cacheRows;
135
136 /**
130 * Return the exceptions that caused some entries to have a state of [CacheSta te#ERROR]. 137 * Return the exceptions that caused some entries to have a state of [CacheSta te#ERROR].
131 * 138 *
132 * @return the exceptions that caused some entries to have a state of [CacheSt ate#ERROR] 139 * @return the exceptions that caused some entries to have a state of [CacheSt ate#ERROR]
133 */ 140 */
134 List<AnalysisException> get exceptions; 141 List<AnalysisException> get exceptions;
135 142
136 /** 143 /**
137 * Return the statistics for each kind of cached data. 144 * Return an array containing all of the sources in the cache.
138 * 145 *
139 * @return the statistics for each kind of cached data 146 * @return an array containing all of the sources in the cache
140 */ 147 */
141 List<AnalysisContentStatistics_CacheRow> get cacheRows; 148 List<Source> get sources;
142 } 149 }
143 150
144 /** 151 /**
145 * Information about single item in the cache. 152 * Information about single item in the cache.
146 */ 153 */
147 abstract class AnalysisContentStatistics_CacheRow { 154 abstract class AnalysisContentStatistics_CacheRow {
148 int get errorCount; 155 int get errorCount;
149 156
150 int get flushedCount; 157 int get flushedCount;
151 158
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 * 281 *
275 * @param source the source whose line information is to be returned 282 * @param source the source whose line information is to be returned
276 * @return the line information for the given source 283 * @return the line information for the given source
277 * @throws AnalysisException if the line information could not be determined b ecause the analysis 284 * @throws AnalysisException if the line information could not be determined b ecause the analysis
278 * could not be performed 285 * could not be performed
279 * @see #getLineInfo(Source) 286 * @see #getLineInfo(Source)
280 */ 287 */
281 LineInfo computeLineInfo(Source source); 288 LineInfo computeLineInfo(Source source);
282 289
283 /** 290 /**
291 * Return `true` if the given source exists.
292 *
293 * This method should be used rather than the method [Source#exists] because c ontexts can
294 * have local overrides of the content of a source that the source is not awar e of and a source
295 * with local content is considered to exist even if there is no file on disk.
296 *
297 * @param source the source whose modification stamp is to be returned
298 * @return `true` if the source exists
299 */
300 bool exists(Source source);
301
302 /**
284 * Create a new context in which analysis can be performed. Any sources in the specified container 303 * Create a new context in which analysis can be performed. Any sources in the specified container
285 * will be removed from this context and added to the newly created context. 304 * will be removed from this context and added to the newly created context.
286 * 305 *
287 * @param container the container containing sources that should be removed fr om this context and 306 * @param container the container containing sources that should be removed fr om this context and
288 * added to the returned context 307 * added to the returned context
289 * @return the analysis context that was created 308 * @return the analysis context that was created
290 */ 309 */
291 AnalysisContext extractContext(SourceContainer container); 310 AnalysisContext extractContext(SourceContainer container);
292 311
293 /** 312 /**
294 * Return the set of analysis options controlling the behavior of this context . Clients should not 313 * Return the set of analysis options controlling the behavior of this context . Clients should not
295 * modify the returned set of options. The options should only be set by invok ing the method 314 * modify the returned set of options. The options should only be set by invok ing the method
296 * [setAnalysisOptions]. 315 * [setAnalysisOptions].
297 * 316 *
298 * @return the set of analysis options controlling the behavior of this contex t 317 * @return the set of analysis options controlling the behavior of this contex t
299 */ 318 */
300 AnalysisOptions get analysisOptions; 319 AnalysisOptions get analysisOptions;
301 320
302 /** 321 /**
322 * Return the element model corresponding to the compilation unit defined by t he given source in
323 * the library defined by the given source, or `null` if the element model doe s not
324 * currently exist or if the library cannot be analyzed for some reason.
325 *
326 * @param unitSource the source of the compilation unit
327 * @param librarySource the source of the defining compilation unit of the lib rary containing the
328 * compilation unit
329 * @return the element model corresponding to the compilation unit defined by the given source
330 */
331 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib rarySource);
332
333 /**
334 * Get the contents and timestamp of the given source.
335 *
336 * This method should be used rather than the method [Source#getContents] beca use contexts
337 * can have local overrides of the content of a source that the source is not aware of.
338 *
339 * @param source the source whose content is to be returned
340 * @return the contents and timestamp of the source
341 * @throws Exception if the contents of the source could not be accessed
342 */
343 TimestampedData<String> getContents(Source source);
344
345 /**
346 * Get the contents of the given source and pass it to the given content recei ver.
347 *
348 * This method should be used rather than the method [Source#getContentsToRece iver]
349 * because contexts can have local overrides of the content of a source that t he source is not
350 * aware of.
351 *
352 * @param source the source whose content is to be returned
353 * @param receiver the content receiver to which the content of the source wil l be passed
354 * @throws Exception if the contents of the source could not be accessed
355 */
356 void getContents2(Source source, Source_ContentReceiver receiver);
357
358 /**
303 * Return the element referenced by the given location, or `null` if the eleme nt is not 359 * Return the element referenced by the given location, or `null` if the eleme nt is not
304 * immediately available or if there is no element with the given location. Th e latter condition 360 * immediately available or if there is no element with the given location. Th e latter condition
305 * can occur, for example, if the location describes an element from a differe nt context or if the 361 * can occur, for example, if the location describes an element from a differe nt context or if the
306 * element has been removed from this context as a result of some change since it was originally 362 * element has been removed from this context as a result of some change since it was originally
307 * obtained. 363 * obtained.
308 * 364 *
309 * @param location the reference describing the element to be returned 365 * @param location the reference describing the element to be returned
310 * @return the element referenced by the given location 366 * @return the element referenced by the given location
311 */ 367 */
312 Element getElement(ElementLocation location); 368 Element getElement(ElementLocation location);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 * not known. The line information is used to map offsets from the beginning o f the source to line 487 * not known. The line information is used to map offsets from the beginning o f the source to line
432 * and column pairs. 488 * and column pairs.
433 * 489 *
434 * @param source the source whose line information is to be returned 490 * @param source the source whose line information is to be returned
435 * @return the line information for the given source 491 * @return the line information for the given source
436 * @see #computeLineInfo(Source) 492 * @see #computeLineInfo(Source)
437 */ 493 */
438 LineInfo getLineInfo(Source source); 494 LineInfo getLineInfo(Source source);
439 495
440 /** 496 /**
497 * Return the modification stamp for the given source. A modification stamp is a non-negative
498 * integer with the property that if the contents of the source have not been modified since the
499 * last time the modification stamp was accessed then the same value will be r eturned, but if the
500 * contents of the source have been modified one or more times (even if the ne t change is zero)
501 * the stamps will be different.
502 *
503 * This method should be used rather than the method [Source#getModificationSt amp] because
504 * contexts can have local overrides of the content of a source that the sourc e is not aware of.
505 *
506 * @param source the source whose modification stamp is to be returned
507 * @return the modification stamp for the source
508 */
509 int getModificationStamp(Source source);
510
511 /**
441 * Return an array containing all of the sources known to this context and the ir resolution state 512 * Return an array containing all of the sources known to this context and the ir resolution state
442 * is not valid or flush. So, these sources are not safe to update during refa ctoring, because we 513 * is not valid or flush. So, these sources are not safe to update during refa ctoring, because we
443 * may be don't know all the references in them. 514 * may be don't know all the references in them.
444 * 515 *
445 * @return the sources known to this context and are not safe for refactoring 516 * @return the sources known to this context and are not safe for refactoring
446 */ 517 */
447 List<Source> get refactoringUnsafeSources; 518 List<Source> get refactoringUnsafeSources;
448 519
449 /** 520 /**
450 * Return a fully resolved AST for a single compilation unit within the given library, or 521 * Return a fully resolved AST for a single compilation unit within the given library, or
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 706
636 /** 707 /**
637 * Set the source factory used to create the sources that can be analyzed in t his context to the 708 * Set the source factory used to create the sources that can be analyzed in t his context to the
638 * given source factory. Clients can safely assume that all analysis results h ave been 709 * given source factory. Clients can safely assume that all analysis results h ave been
639 * invalidated. 710 * invalidated.
640 * 711 *
641 * @param factory the source factory used to create the sources that can be an alyzed in this 712 * @param factory the source factory used to create the sources that can be an alyzed in this
642 * context 713 * context
643 */ 714 */
644 void set sourceFactory(SourceFactory factory); 715 void set sourceFactory(SourceFactory factory);
645
646 /**
647 * Given a collection of sources with content that has changed, return an [Ite rable]
648 * identifying the sources that need to be resolved.
649 *
650 * @param changedSources an array of sources (not `null`, contains no `null`s)
651 * @return An iterable returning the sources to be resolved
652 */
653 Iterable<Source> sourcesToResolve(List<Source> changedSources);
654 } 716 }
655 717
656 /** 718 /**
657 * The interface `AnalysisErrorInfo` contains the analysis errors and line infor mation for the 719 * The interface `AnalysisErrorInfo` contains the analysis errors and line infor mation for the
658 * errors. 720 * errors.
659 */ 721 */
660 abstract class AnalysisErrorInfo { 722 abstract class AnalysisErrorInfo {
661 /** 723 /**
662 * Return the errors that as a result of the analysis, or `null` if there were no errors. 724 * Return the errors that as a result of the analysis, or `null` if there were no errors.
663 * 725 *
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 */ 770 */
709 AnalysisException.con3(Exception cause) : super.withCause(cause); 771 AnalysisException.con3(Exception cause) : super.withCause(cause);
710 } 772 }
711 773
712 /** 774 /**
713 * The interface `AnalysisOptions` defines the behavior of objects that provide access to a 775 * The interface `AnalysisOptions` defines the behavior of objects that provide access to a
714 * set of analysis options used to control the behavior of an analysis context. 776 * set of analysis options used to control the behavior of an analysis context.
715 */ 777 */
716 abstract class AnalysisOptions { 778 abstract class AnalysisOptions {
717 /** 779 /**
780 * Return `true` if analysis is to analyze Angular.
781 *
782 * @return `true` if analysis is to analyze Angular
783 */
784 bool get analyzeAngular;
785
786 /**
718 * Return `true` if analysis is to parse and analyze function bodies. 787 * Return `true` if analysis is to parse and analyze function bodies.
719 * 788 *
720 * @return `true` if analysis is to parse and analyzer function bodies 789 * @return `true` if analysis is to parse and analyzer function bodies
721 */ 790 */
722 bool get analyzeFunctionBodies; 791 bool get analyzeFunctionBodies;
723 792
724 /** 793 /**
725 * Return the maximum number of sources for which AST structures should be kep t in the cache. 794 * Return the maximum number of sources for which AST structures should be kep t in the cache.
726 * 795 *
727 * @return the maximum number of sources for which AST structures should be ke pt in the cache 796 * @return the maximum number of sources for which AST structures should be ke pt in the cache
728 */ 797 */
729 int get cacheSize; 798 int get cacheSize;
730 799
731 /** 800 /**
732 * Return `true` if analysis is to generate dart2js related hint results. 801 * Return `true` if analysis is to generate dart2js related hint results.
733 * 802 *
734 * @return `true` if analysis is to generate dart2js related hint results 803 * @return `true` if analysis is to generate dart2js related hint results
735 */ 804 */
736 bool get dart2jsHint; 805 bool get dart2jsHint;
737 806
738 /** 807 /**
808 * Return `true` if errors, warnings and hints should be generated for sources in the SDK.
809 * The default value is `false`.
810 *
811 * @return `true` if errors, warnings and hints should be generated for the SD K
812 */
813 bool get generateSdkErrors;
814
815 /**
739 * Return `true` if analysis is to generate hint results (e.g. type inference based 816 * Return `true` if analysis is to generate hint results (e.g. type inference based
740 * information and pub best practices). 817 * information and pub best practices).
741 * 818 *
742 * @return `true` if analysis is to generate hint results 819 * @return `true` if analysis is to generate hint results
743 */ 820 */
744 bool get hint; 821 bool get hint;
745 822
746 /** 823 /**
747 * Return `true` if incremental analysis should be used. 824 * Return `true` if incremental analysis should be used.
748 * 825 *
749 * @return `true` if incremental analysis should be used 826 * @return `true` if incremental analysis should be used
750 */ 827 */
751 bool get incremental; 828 bool get incremental;
752 829
753 /** 830 /**
754 * Return `true` if analysis is to parse comments. 831 * Return `true` if analysis is to parse comments.
755 * 832 *
756 * @return `true` if analysis is to parse comments 833 * @return `true` if analysis is to parse comments
757 */ 834 */
758 bool get preserveComments; 835 bool get preserveComments;
759
760 /**
761 * Return `true` if analysis is to analyze Angular.
762 *
763 * @return `true` if analysis is to analyze Angular
764 */
765 bool get analyzeAngular;
766 } 836 }
767 837
768 /** 838 /**
769 * Instances of the class `AnalysisResult` 839 * Instances of the class `AnalysisResult`
770 */ 840 */
771 class AnalysisResult { 841 class AnalysisResult {
772 /** 842 /**
773 * The change notices associated with this result, or `null` if there were no changes and 843 * The change notices associated with this result, or `null` if there were no changes and
774 * there is no more work to be done. 844 * there is no more work to be done.
775 */ 845 */
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 for (Source source in sources) { 1033 for (Source source in sources) {
964 builder.append(prefix); 1034 builder.append(prefix);
965 builder.append(source.fullName); 1035 builder.append(source.fullName);
966 prefix = ", "; 1036 prefix = ", ";
967 } 1037 }
968 return true; 1038 return true;
969 } 1039 }
970 } 1040 }
971 1041
972 /** 1042 /**
1043 * Instances of the class `ObsoleteSourceAnalysisException` represent an analysi s attempt that
1044 * failed because a source was deleted between the time the analysis started and the time the
1045 * results of the analysis were ready to be recorded.
1046 */
1047 class ObsoleteSourceAnalysisException extends AnalysisException {
1048 /**
1049 * The source that was removed while it was being analyzed.
1050 */
1051 Source _source;
1052
1053 /**
1054 * Initialize a newly created exception to represent the removal of the given source.
1055 *
1056 * @param source the source that was removed while it was being analyzed
1057 */
1058 ObsoleteSourceAnalysisException(Source source) : super.con1("The source '${sou rce.fullName}' was removed while it was being analyzed") {
1059 this._source = source;
1060 }
1061
1062 /**
1063 * Return the source that was removed while it was being analyzed.
1064 *
1065 * @return the source that was removed
1066 */
1067 Source get source => _source;
1068 }
1069
1070 /**
973 * Instances of the class `AnalysisCache` implement an LRU cache of information related to 1071 * Instances of the class `AnalysisCache` implement an LRU cache of information related to
974 * analysis. 1072 * analysis.
975 */ 1073 */
976 class AnalysisCache { 1074 class AnalysisCache {
977 /** 1075 /**
978 * A table mapping the sources known to the context to the information known a bout the source. 1076 * A table mapping the sources known to the context to the information known a bout the source.
979 */ 1077 */
980 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); 1078 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>();
981 1079
982 /** 1080 /**
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 } 1254 }
1157 if (sourceToRemove < 0) { 1255 if (sourceToRemove < 0) {
1158 AnalysisEngine.instance.logger.logError2("Internal error: Could not flush data from the cache", new JavaException()); 1256 AnalysisEngine.instance.logger.logError2("Internal error: Could not flush data from the cache", new JavaException());
1159 return null; 1257 return null;
1160 } 1258 }
1161 return _recentlyUsed.removeAt(sourceToRemove); 1259 return _recentlyUsed.removeAt(sourceToRemove);
1162 } 1260 }
1163 } 1261 }
1164 1262
1165 /** 1263 /**
1166 * Information about Angular application.
1167 */
1168 class AngularApplicationInfo {
1169 final Source entryPoint;
1170
1171 final List<AngularElement> elements;
1172
1173 AngularApplicationInfo(this.entryPoint, this.elements);
1174 }
1175
1176 /**
1177 * Instances of the class `CacheRetentionPolicy` define the behavior of objects that determine 1264 * Instances of the class `CacheRetentionPolicy` define the behavior of objects that determine
1178 * how important it is for data to be retained in the analysis cache. 1265 * how important it is for data to be retained in the analysis cache.
1179 */ 1266 */
1180 abstract class CacheRetentionPolicy { 1267 abstract class CacheRetentionPolicy {
1181 /** 1268 /**
1182 * Return the priority of retaining the AST structure for the given source. 1269 * Return the priority of retaining the AST structure for the given source.
1183 * 1270 *
1184 * @param source the source whose AST structure is being considered for remova l 1271 * @param source the source whose AST structure is being considered for remova l
1185 * @param sourceEntry the entry representing the source 1272 * @param sourceEntry the entry representing the source
1186 * @return the priority of retaining the AST structure for the given source 1273 * @return the priority of retaining the AST structure for the given source
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 * The data descriptor representing the resolved AST structure. 1417 * The data descriptor representing the resolved AST structure.
1331 */ 1418 */
1332 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescripto r<CompilationUnit>("DartEntry.RESOLVED_UNIT"); 1419 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescripto r<CompilationUnit>("DartEntry.RESOLVED_UNIT");
1333 1420
1334 /** 1421 /**
1335 * The data descriptor representing the source kind. 1422 * The data descriptor representing the source kind.
1336 */ 1423 */
1337 static final DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<Sourc eKind>("DartEntry.SOURCE_KIND"); 1424 static final DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<Sourc eKind>("DartEntry.SOURCE_KIND");
1338 1425
1339 /** 1426 /**
1427 * The data descriptor representing the token stream.
1428 */
1429 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS = new DataDescrip tor<List<AnalysisError>>("DartEntry.SCAN_ERRORS");
1430
1431 /**
1432 * The data descriptor representing the token stream.
1433 */
1434 static final DataDescriptor<Token> TOKEN_STREAM = new DataDescriptor<Token>("D artEntry.TOKEN_STREAM");
1435
1436 /**
1340 * The data descriptor representing the errors resulting from verifying the so urce. 1437 * The data descriptor representing the errors resulting from verifying the so urce.
1341 */ 1438 */
1342 static final DataDescriptor<List<AnalysisError>> VERIFICATION_ERRORS = new Dat aDescriptor<List<AnalysisError>>("DartEntry.VERIFICATION_ERRORS"); 1439 static final DataDescriptor<List<AnalysisError>> VERIFICATION_ERRORS = new Dat aDescriptor<List<AnalysisError>>("DartEntry.VERIFICATION_ERRORS");
1343 1440
1344 /** 1441 /**
1442 * The data descriptor representing the errors reported during Angular resolut ion.
1443 */
1444 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS");
1445
1446 /**
1345 * Return all of the errors associated with the compilation unit that are curr ently cached. 1447 * Return all of the errors associated with the compilation unit that are curr ently cached.
1346 * 1448 *
1347 * @return all of the errors associated with the compilation unit 1449 * @return all of the errors associated with the compilation unit
1348 */ 1450 */
1349 List<AnalysisError> get allErrors; 1451 List<AnalysisError> get allErrors;
1350 1452
1351 /** 1453 /**
1352 * Return a valid parsed compilation unit, either an unresolved AST structure or the result of 1454 * Return a valid parsed compilation unit, either an unresolved AST structure or the result of
1353 * resolving the AST structure in the context of some library, or `null` if th ere is no 1455 * resolving the AST structure in the context of some library, or `null` if th ere is no
1354 * parsed compilation unit available. 1456 * parsed compilation unit available.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 bool get isRefactoringSafe; 1507 bool get isRefactoringSafe;
1406 } 1508 }
1407 1509
1408 /** 1510 /**
1409 * Instances of the class `DartEntryImpl` implement a [DartEntry]. 1511 * Instances of the class `DartEntryImpl` implement a [DartEntry].
1410 * 1512 *
1411 * @coverage dart.engine 1513 * @coverage dart.engine
1412 */ 1514 */
1413 class DartEntryImpl extends SourceEntryImpl implements DartEntry { 1515 class DartEntryImpl extends SourceEntryImpl implements DartEntry {
1414 /** 1516 /**
1517 * The state of the cached token stream.
1518 */
1519 CacheState _tokenStreamState = CacheState.INVALID;
1520
1521 /**
1522 * The head of the token stream, or `null` if the token stream is not currentl y cached.
1523 */
1524 Token _tokenStream;
1525
1526 /**
1527 * The state of the cached scan errors.
1528 */
1529 CacheState _scanErrorsState = CacheState.INVALID;
1530
1531 /**
1532 * The errors produced while scanning the compilation unit, or `null` if the e rrors are not
1533 * currently cached.
1534 */
1535 List<AnalysisError> _scanErrors = AnalysisError.NO_ERRORS;
1536
1537 /**
1415 * The state of the cached source kind. 1538 * The state of the cached source kind.
1416 */ 1539 */
1417 CacheState _sourceKindState = CacheState.INVALID; 1540 CacheState _sourceKindState = CacheState.INVALID;
1418 1541
1419 /** 1542 /**
1420 * The kind of this source. 1543 * The kind of this source.
1421 */ 1544 */
1422 SourceKind _sourceKind = SourceKind.UNKNOWN; 1545 SourceKind _sourceKind = SourceKind.UNKNOWN;
1423 1546
1424 /** 1547 /**
(...skipping 12 matching lines...) Expand all
1437 * cached. 1560 * cached.
1438 */ 1561 */
1439 CompilationUnit _parsedUnit; 1562 CompilationUnit _parsedUnit;
1440 1563
1441 /** 1564 /**
1442 * The state of the cached parse errors. 1565 * The state of the cached parse errors.
1443 */ 1566 */
1444 CacheState _parseErrorsState = CacheState.INVALID; 1567 CacheState _parseErrorsState = CacheState.INVALID;
1445 1568
1446 /** 1569 /**
1447 * The errors produced while scanning and parsing the compilation unit, or `nu ll` if the 1570 * The errors produced while parsing the compilation unit, or `null` if the er rors are not
1448 * errors are not currently cached. 1571 * currently cached.
1449 */ 1572 */
1450 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; 1573 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS;
1451 1574
1452 /** 1575 /**
1453 * The state of the cached list of imported libraries. 1576 * The state of the cached list of imported libraries.
1454 */ 1577 */
1455 CacheState _importedLibrariesState = CacheState.INVALID; 1578 CacheState _importedLibrariesState = CacheState.INVALID;
1456 1579
1457 /** 1580 /**
1458 * The list of libraries imported by the library, or an empty array if the lis t is not currently 1581 * The list of libraries imported by the library, or an empty array if the lis t is not currently
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 * The state of the cached launchable flag. 1646 * The state of the cached launchable flag.
1524 */ 1647 */
1525 CacheState _launchableState = CacheState.INVALID; 1648 CacheState _launchableState = CacheState.INVALID;
1526 1649
1527 /** 1650 /**
1528 * An integer holding bit masks such as [LAUNCHABLE] and [CLIENT_CODE]. 1651 * An integer holding bit masks such as [LAUNCHABLE] and [CLIENT_CODE].
1529 */ 1652 */
1530 int _bitmask = 0; 1653 int _bitmask = 0;
1531 1654
1532 /** 1655 /**
1656 * The error produced while performing Angular resolution, or an empty array i f there are no
1657 * errors if the error are not currently cached.
1658 */
1659 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS;
1660
1661 /**
1533 * The index of the bit in the [bitmask] indicating that this library is launc hable: that 1662 * The index of the bit in the [bitmask] indicating that this library is launc hable: that
1534 * the file has a main method. 1663 * the file has a main method.
1535 */ 1664 */
1536 static int _LAUNCHABLE_INDEX = 1; 1665 static int _LAUNCHABLE_INDEX = 1;
1537 1666
1538 /** 1667 /**
1539 * The index of the bit in the [bitmask] indicating that the library is client code: that 1668 * The index of the bit in the [bitmask] indicating that the library is client code: that
1540 * the library depends on the html library. If the library is not "client code ", then it is 1669 * the library depends on the html library. If the library is not "client code ", then it is
1541 * referred to as "server code". 1670 * referred to as "server code".
1542 */ 1671 */
1543 static int _CLIENT_CODE_INDEX = 2; 1672 static int _CLIENT_CODE_INDEX = 2;
1544 1673
1545 /** 1674 /**
1546 * Add the given library to the list of libraries that contain this part. This method should only 1675 * Add the given library to the list of libraries that contain this part. This method should only
1547 * be invoked on entries that represent a part. 1676 * be invoked on entries that represent a part.
1548 * 1677 *
1549 * @param librarySource the source of the library to be added 1678 * @param librarySource the source of the library to be added
1550 */ 1679 */
1551 void addContainingLibrary(Source librarySource) { 1680 void addContainingLibrary(Source librarySource) {
1552 _containingLibraries.add(librarySource); 1681 _containingLibraries.add(librarySource);
1553 } 1682 }
1554 1683
1555 /** 1684 /**
1556 * Flush any AST structures being maintained by this entry. 1685 * Flush any AST structures being maintained by this entry.
1557 */ 1686 */
1558 void flushAstStructures() { 1687 void flushAstStructures() {
1688 if (identical(_tokenStreamState, CacheState.VALID)) {
1689 _tokenStreamState = CacheState.FLUSHED;
1690 _tokenStream = null;
1691 }
1559 if (identical(_parsedUnitState, CacheState.VALID)) { 1692 if (identical(_parsedUnitState, CacheState.VALID)) {
1560 _parsedUnitState = CacheState.FLUSHED; 1693 _parsedUnitState = CacheState.FLUSHED;
1561 _parsedUnitAccessed = false; 1694 _parsedUnitAccessed = false;
1562 _parsedUnit = null; 1695 _parsedUnit = null;
1563 } 1696 }
1564 _resolutionState.flushAstStructures(); 1697 _resolutionState.flushAstStructures();
1565 } 1698 }
1566 1699
1567 List<AnalysisError> get allErrors { 1700 List<AnalysisError> get allErrors {
1568 List<AnalysisError> errors = new List<AnalysisError>(); 1701 List<AnalysisError> errors = new List<AnalysisError>();
1569 for (AnalysisError error in _parseErrors) { 1702 ListUtilities.addAll(errors, _scanErrors);
1570 errors.add(error); 1703 ListUtilities.addAll(errors, _parseErrors);
1571 }
1572 DartEntryImpl_ResolutionState state = _resolutionState; 1704 DartEntryImpl_ResolutionState state = _resolutionState;
1573 while (state != null) { 1705 while (state != null) {
1574 for (AnalysisError error in state._resolutionErrors) { 1706 ListUtilities.addAll(errors, state._resolutionErrors);
1575 errors.add(error); 1707 ListUtilities.addAll(errors, state._verificationErrors);
1576 } 1708 ListUtilities.addAll(errors, state._hints);
1577 for (AnalysisError error in state._verificationErrors) {
1578 errors.add(error);
1579 }
1580 for (AnalysisError error in state._hints) {
1581 errors.add(error);
1582 }
1583 state = state._nextState; 1709 state = state._nextState;
1584 } 1710 }
1585 ; 1711 ListUtilities.addAll(errors, _angularErrors);
1586 if (errors.length == 0) { 1712 if (errors.length == 0) {
1587 return AnalysisError.NO_ERRORS; 1713 return AnalysisError.NO_ERRORS;
1588 } 1714 }
1589 return new List.from(errors); 1715 return new List.from(errors);
1590 } 1716 }
1591 1717
1592 CompilationUnit get anyParsedCompilationUnit { 1718 CompilationUnit get anyParsedCompilationUnit {
1593 if (identical(_parsedUnitState, CacheState.VALID)) { 1719 if (identical(_parsedUnitState, CacheState.VALID)) {
1594 _parsedUnitAccessed = true; 1720 _parsedUnitAccessed = true;
1595 return _parsedUnit; 1721 return _parsedUnit;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 1792 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
1667 return _clientServerState; 1793 return _clientServerState;
1668 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { 1794 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
1669 return _launchableState; 1795 return _launchableState;
1670 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { 1796 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
1671 return _parseErrorsState; 1797 return _parseErrorsState;
1672 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 1798 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
1673 return _parsedUnitState; 1799 return _parsedUnitState;
1674 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 1800 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
1675 return _publicNamespaceState; 1801 return _publicNamespaceState;
1802 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
1803 return _scanErrorsState;
1676 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 1804 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
1677 return _sourceKindState; 1805 return _sourceKindState;
1806 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
1807 return _tokenStreamState;
1678 } else { 1808 } else {
1679 return super.getState(descriptor); 1809 return super.getState(descriptor);
1680 } 1810 }
1681 } 1811 }
1682 1812
1683 CacheState getState2(DataDescriptor descriptor, Source librarySource) { 1813 CacheState getState2(DataDescriptor descriptor, Source librarySource) {
1684 DartEntryImpl_ResolutionState state = _resolutionState; 1814 DartEntryImpl_ResolutionState state = _resolutionState;
1685 while (state != null) { 1815 while (state != null) {
1686 if (librarySource == state._librarySource) { 1816 if (librarySource == state._librarySource) {
1687 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 1817 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
(...skipping 12 matching lines...) Expand all
1700 } 1830 }
1701 ; 1831 ;
1702 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR ORS) || identical(descriptor, DartEntry.HINTS)) { 1832 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR ORS) || identical(descriptor, DartEntry.HINTS)) {
1703 return CacheState.INVALID; 1833 return CacheState.INVALID;
1704 } else { 1834 } else {
1705 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1835 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1706 } 1836 }
1707 } 1837 }
1708 1838
1709 Object getValue(DataDescriptor descriptor) { 1839 Object getValue(DataDescriptor descriptor) {
1710 if (identical(descriptor, DartEntry.CONTAINING_LIBRARIES)) { 1840 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) {
1841 return _angularErrors;
1842 } else if (identical(descriptor, DartEntry.CONTAINING_LIBRARIES)) {
1711 return new List.from(_containingLibraries); 1843 return new List.from(_containingLibraries);
1712 } else if (identical(descriptor, DartEntry.ELEMENT)) { 1844 } else if (identical(descriptor, DartEntry.ELEMENT)) {
1713 return _element; 1845 return _element;
1714 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 1846 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
1715 return _exportedLibraries; 1847 return _exportedLibraries;
1716 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 1848 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
1717 return _importedLibraries; 1849 return _importedLibraries;
1718 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { 1850 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
1719 return _includedParts; 1851 return _includedParts;
1720 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 1852 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
1721 return BooleanArray.get2(_bitmask, _CLIENT_CODE_INDEX); 1853 return BooleanArray.get2(_bitmask, _CLIENT_CODE_INDEX);
1722 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { 1854 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
1723 return BooleanArray.get2(_bitmask, _LAUNCHABLE_INDEX); 1855 return BooleanArray.get2(_bitmask, _LAUNCHABLE_INDEX);
1724 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { 1856 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
1725 return _parseErrors; 1857 return _parseErrors;
1726 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 1858 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
1727 _parsedUnitAccessed = true; 1859 _parsedUnitAccessed = true;
1728 return _parsedUnit; 1860 return _parsedUnit;
1729 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 1861 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
1730 return _publicNamespace; 1862 return _publicNamespace;
1863 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
1864 return _scanErrors;
1731 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 1865 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
1732 return _sourceKind; 1866 return _sourceKind;
1867 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
1868 return _tokenStream;
1733 } 1869 }
1734 return super.getValue(descriptor); 1870 return super.getValue(descriptor);
1735 } 1871 }
1736 1872
1737 Object getValue2(DataDescriptor descriptor, Source librarySource) { 1873 Object getValue2(DataDescriptor descriptor, Source librarySource) {
1738 DartEntryImpl_ResolutionState state = _resolutionState; 1874 DartEntryImpl_ResolutionState state = _resolutionState;
1739 while (state != null) { 1875 while (state != null) {
1740 if (librarySource == state._librarySource) { 1876 if (librarySource == state._librarySource) {
1741 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 1877 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
1742 return state._resolutionErrors; 1878 return state._resolutionErrors;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 1916 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
1781 return identical(_clientServerState, CacheState.INVALID); 1917 return identical(_clientServerState, CacheState.INVALID);
1782 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { 1918 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
1783 return identical(_launchableState, CacheState.INVALID); 1919 return identical(_launchableState, CacheState.INVALID);
1784 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { 1920 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
1785 return identical(_parseErrorsState, CacheState.INVALID); 1921 return identical(_parseErrorsState, CacheState.INVALID);
1786 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 1922 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
1787 return identical(_parsedUnitState, CacheState.INVALID); 1923 return identical(_parsedUnitState, CacheState.INVALID);
1788 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 1924 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
1789 return identical(_publicNamespaceState, CacheState.INVALID); 1925 return identical(_publicNamespaceState, CacheState.INVALID);
1926 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
1927 return identical(_scanErrorsState, CacheState.INVALID);
1790 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 1928 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
1791 return identical(_sourceKindState, CacheState.INVALID); 1929 return identical(_sourceKindState, CacheState.INVALID);
1930 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
1931 return identical(_tokenStreamState, CacheState.INVALID);
1792 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(d escriptor, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICAT ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 1932 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(d escriptor, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICAT ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) {
1793 DartEntryImpl_ResolutionState state = _resolutionState; 1933 DartEntryImpl_ResolutionState state = _resolutionState;
1794 while (state != null) { 1934 while (state != null) {
1795 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 1935 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
1796 return identical(state._resolutionErrorsState, CacheState.INVALID); 1936 return identical(state._resolutionErrorsState, CacheState.INVALID);
1797 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 1937 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
1798 return identical(state._resolvedUnitState, CacheState.INVALID); 1938 return identical(state._resolvedUnitState, CacheState.INVALID);
1799 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 1939 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
1800 return identical(state._verificationErrorsState, CacheState.INVALID); 1940 return identical(state._verificationErrorsState, CacheState.INVALID);
1801 } else if (identical(descriptor, DartEntry.HINTS)) { 1941 } else if (identical(descriptor, DartEntry.HINTS)) {
1802 return identical(state._hintsState, CacheState.INVALID); 1942 return identical(state._hintsState, CacheState.INVALID);
1803 } 1943 }
1804 } 1944 }
1805 return false; 1945 return false;
1806 } else { 1946 } else {
1807 return identical(super.getState(descriptor), CacheState.INVALID); 1947 return identical(super.getState(descriptor), CacheState.INVALID);
1808 } 1948 }
1809 } 1949 }
1810 1950
1811 void invalidateAllInformation() { 1951 void invalidateAllInformation() {
1812 super.invalidateAllInformation(); 1952 super.invalidateAllInformation();
1953 _scanErrors = AnalysisError.NO_ERRORS;
1954 _scanErrorsState = CacheState.INVALID;
1955 _tokenStream = null;
1956 _tokenStreamState = CacheState.INVALID;
1813 _sourceKind = SourceKind.UNKNOWN; 1957 _sourceKind = SourceKind.UNKNOWN;
1814 _sourceKindState = CacheState.INVALID; 1958 _sourceKindState = CacheState.INVALID;
1815 _parseErrors = AnalysisError.NO_ERRORS; 1959 _parseErrors = AnalysisError.NO_ERRORS;
1816 _parseErrorsState = CacheState.INVALID; 1960 _parseErrorsState = CacheState.INVALID;
1817 _parsedUnit = null; 1961 _parsedUnit = null;
1818 _parsedUnitAccessed = false; 1962 _parsedUnitAccessed = false;
1819 _parsedUnitState = CacheState.INVALID; 1963 _parsedUnitState = CacheState.INVALID;
1820 discardCachedResolutionInformation(); 1964 discardCachedResolutionInformation();
1821 } 1965 }
1822 1966
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 _includedPartsState = CacheState.INVALID; 2039 _includedPartsState = CacheState.INVALID;
1896 } 2040 }
1897 } 2041 }
1898 2042
1899 /** 2043 /**
1900 * Record that an error occurred while attempting to scan or parse the entry r epresented by this 2044 * Record that an error occurred while attempting to scan or parse the entry r epresented by this
1901 * entry. This will set the state of all information, including any resolution -based information, 2045 * entry. This will set the state of all information, including any resolution -based information,
1902 * as being in error. 2046 * as being in error.
1903 */ 2047 */
1904 void recordParseError() { 2048 void recordParseError() {
1905 setState(SourceEntry.LINE_INFO, CacheState.ERROR);
1906 _sourceKind = SourceKind.UNKNOWN; 2049 _sourceKind = SourceKind.UNKNOWN;
1907 _sourceKindState = CacheState.ERROR; 2050 _sourceKindState = CacheState.ERROR;
1908 _parseErrors = AnalysisError.NO_ERRORS; 2051 _parseErrors = AnalysisError.NO_ERRORS;
1909 _parseErrorsState = CacheState.ERROR; 2052 _parseErrorsState = CacheState.ERROR;
1910 _parsedUnit = null; 2053 _parsedUnit = null;
1911 _parsedUnitAccessed = false; 2054 _parsedUnitAccessed = false;
1912 _parsedUnitState = CacheState.ERROR; 2055 _parsedUnitState = CacheState.ERROR;
1913 recordDependencyError(); 2056 recordDependencyError();
1914 recordResolutionError(); 2057 recordResolutionError();
1915 } 2058 }
1916 2059
1917 /** 2060 /**
1918 * Record that the parse-related information for the associated source is abou t to be computed by 2061 * Record that the parse-related information for the associated source is abou t to be computed by
1919 * the current thread. 2062 * the current thread.
1920 */ 2063 */
1921 void recordParseInProcess() { 2064 void recordParseInProcess() {
1922 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
1923 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS);
1924 }
1925 if (_sourceKindState != CacheState.VALID) { 2065 if (_sourceKindState != CacheState.VALID) {
1926 _sourceKindState = CacheState.IN_PROCESS; 2066 _sourceKindState = CacheState.IN_PROCESS;
1927 } 2067 }
1928 if (_parseErrorsState != CacheState.VALID) { 2068 if (_parseErrorsState != CacheState.VALID) {
1929 _parseErrorsState = CacheState.IN_PROCESS; 2069 _parseErrorsState = CacheState.IN_PROCESS;
1930 } 2070 }
1931 if (_parsedUnitState != CacheState.VALID) { 2071 if (_parsedUnitState != CacheState.VALID) {
1932 _parsedUnitState = CacheState.IN_PROCESS; 2072 _parsedUnitState = CacheState.IN_PROCESS;
1933 } 2073 }
1934 } 2074 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 if (identical(_launchableState, CacheState.IN_PROCESS)) { 2122 if (identical(_launchableState, CacheState.IN_PROCESS)) {
1983 _launchableState = CacheState.INVALID; 2123 _launchableState = CacheState.INVALID;
1984 } 2124 }
1985 if (identical(_publicNamespaceState, CacheState.IN_PROCESS)) { 2125 if (identical(_publicNamespaceState, CacheState.IN_PROCESS)) {
1986 _publicNamespaceState = CacheState.INVALID; 2126 _publicNamespaceState = CacheState.INVALID;
1987 } 2127 }
1988 _resolutionState.recordResolutionNotInProcess(); 2128 _resolutionState.recordResolutionNotInProcess();
1989 } 2129 }
1990 2130
1991 /** 2131 /**
2132 * Record that an error occurred while attempting to scan or parse the entry r epresented by this
2133 * entry. This will set the state of all information, including any resolution -based information,
2134 * as being in error.
2135 */
2136 void recordScanError() {
2137 setState(SourceEntry.LINE_INFO, CacheState.ERROR);
2138 _scanErrors = AnalysisError.NO_ERRORS;
2139 _scanErrorsState = CacheState.ERROR;
2140 _tokenStream = null;
2141 _tokenStreamState = CacheState.ERROR;
2142 recordParseError();
2143 }
2144
2145 /**
2146 * Record that the scan-related information for the associated source is about to be computed by
2147 * the current thread.
2148 */
2149 void recordScanInProcess() {
2150 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
2151 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS);
2152 }
2153 if (_scanErrorsState != CacheState.VALID) {
2154 _scanErrorsState = CacheState.IN_PROCESS;
2155 }
2156 if (_tokenStreamState != CacheState.VALID) {
2157 _tokenStreamState = CacheState.IN_PROCESS;
2158 }
2159 }
2160
2161 /**
2162 * Record that an in-process scan has stopped without recording results becaus e the results were
2163 * invalidated before they could be recorded.
2164 */
2165 void recordScanNotInProcess() {
2166 if (identical(getState(SourceEntry.LINE_INFO), CacheState.IN_PROCESS)) {
2167 setState(SourceEntry.LINE_INFO, CacheState.INVALID);
2168 }
2169 if (identical(_scanErrorsState, CacheState.IN_PROCESS)) {
2170 _scanErrorsState = CacheState.INVALID;
2171 }
2172 if (identical(_tokenStreamState, CacheState.IN_PROCESS)) {
2173 _tokenStreamState = CacheState.INVALID;
2174 }
2175 }
2176
2177 /**
1992 * Remove the given library from the list of libraries that contain this part. This method should 2178 * Remove the given library from the list of libraries that contain this part. This method should
1993 * only be invoked on entries that represent a part. 2179 * only be invoked on entries that represent a part.
1994 * 2180 *
1995 * @param librarySource the source of the library to be removed 2181 * @param librarySource the source of the library to be removed
1996 */ 2182 */
1997 void removeContainingLibrary(Source librarySource) { 2183 void removeContainingLibrary(Source librarySource) {
1998 _containingLibraries.remove(librarySource); 2184 _containingLibraries.remove(librarySource);
1999 } 2185 }
2000 2186
2001 /** 2187 /**
(...skipping 30 matching lines...) Expand all
2032 * Set the list of libraries that contain this compilation unit to contain onl y the given source. 2218 * Set the list of libraries that contain this compilation unit to contain onl y the given source.
2033 * This method should only be invoked on entries that represent a library. 2219 * This method should only be invoked on entries that represent a library.
2034 * 2220 *
2035 * @param librarySource the source of the single library that the list should contain 2221 * @param librarySource the source of the single library that the list should contain
2036 */ 2222 */
2037 void set containingLibrary(Source librarySource) { 2223 void set containingLibrary(Source librarySource) {
2038 _containingLibraries.clear(); 2224 _containingLibraries.clear();
2039 _containingLibraries.add(librarySource); 2225 _containingLibraries.add(librarySource);
2040 } 2226 }
2041 2227
2042 /**
2043 * Set the results of parsing the compilation unit at the given time to the gi ven values.
2044 *
2045 * @param modificationStamp the earliest time at which the source was last mod ified before the
2046 * parsing was started
2047 * @param lineInfo the line information resulting from parsing the compilation unit
2048 * @param unit the AST structure resulting from parsing the compilation unit
2049 * @param errors the parse errors resulting from parsing the compilation unit
2050 */
2051 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit unit, List<AnalysisError> errors) {
2052 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
2053 setValue(SourceEntry.LINE_INFO, lineInfo);
2054 }
2055 if (_parsedUnitState != CacheState.VALID) {
2056 _parsedUnit = unit;
2057 _parsedUnitAccessed = false;
2058 _parsedUnitState = CacheState.VALID;
2059 }
2060 if (_parseErrorsState != CacheState.VALID) {
2061 _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors;
2062 _parseErrorsState = CacheState.VALID;
2063 }
2064 }
2065
2066 void setState(DataDescriptor descriptor, CacheState state) { 2228 void setState(DataDescriptor descriptor, CacheState state) {
2067 if (identical(descriptor, DartEntry.ELEMENT)) { 2229 if (identical(descriptor, DartEntry.ELEMENT)) {
2068 _element = updatedValue(state, _element, null); 2230 _element = updatedValue(state, _element, null);
2069 _elementState = state; 2231 _elementState = state;
2070 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 2232 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
2071 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_ ARRAY); 2233 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_ ARRAY);
2072 _exportedLibrariesState = state; 2234 _exportedLibrariesState = state;
2073 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 2235 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
2074 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_ ARRAY); 2236 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_ ARRAY);
2075 _importedLibrariesState = state; 2237 _importedLibrariesState = state;
(...skipping 12 matching lines...) Expand all
2088 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 2250 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
2089 CompilationUnit newUnit = updatedValue(state, _parsedUnit, null); 2251 CompilationUnit newUnit = updatedValue(state, _parsedUnit, null);
2090 if (newUnit != _parsedUnit) { 2252 if (newUnit != _parsedUnit) {
2091 _parsedUnitAccessed = false; 2253 _parsedUnitAccessed = false;
2092 } 2254 }
2093 _parsedUnit = newUnit; 2255 _parsedUnit = newUnit;
2094 _parsedUnitState = state; 2256 _parsedUnitState = state;
2095 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 2257 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
2096 _publicNamespace = updatedValue(state, _publicNamespace, null); 2258 _publicNamespace = updatedValue(state, _publicNamespace, null);
2097 _publicNamespaceState = state; 2259 _publicNamespaceState = state;
2260 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
2261 _scanErrors = updatedValue(state, _scanErrors, AnalysisError.NO_ERRORS);
2262 _scanErrorsState = state;
2098 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 2263 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
2099 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN); 2264 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN);
2100 _sourceKindState = state; 2265 _sourceKindState = state;
2266 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
2267 _tokenStream = updatedValue(state, _tokenStream, null);
2268 _tokenStreamState = state;
2101 } else { 2269 } else {
2102 super.setState(descriptor, state); 2270 super.setState(descriptor, state);
2103 } 2271 }
2104 } 2272 }
2105 2273
2106 /** 2274 /**
2107 * Set the state of the data represented by the given descriptor in the contex t of the given 2275 * Set the state of the data represented by the given descriptor in the contex t of the given
2108 * library to the given state. 2276 * library to the given state.
2109 * 2277 *
2110 * @param descriptor the descriptor representing the data whose state is to be set 2278 * @param descriptor the descriptor representing the data whose state is to be set
(...skipping 14 matching lines...) Expand all
2125 state._verificationErrorsState = cacheState; 2293 state._verificationErrorsState = cacheState;
2126 } else if (identical(descriptor, DartEntry.HINTS)) { 2294 } else if (identical(descriptor, DartEntry.HINTS)) {
2127 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR ORS); 2295 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR ORS);
2128 state._hintsState = cacheState; 2296 state._hintsState = cacheState;
2129 } else { 2297 } else {
2130 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 2298 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
2131 } 2299 }
2132 } 2300 }
2133 2301
2134 void setValue(DataDescriptor descriptor, Object value) { 2302 void setValue(DataDescriptor descriptor, Object value) {
2135 if (identical(descriptor, DartEntry.ELEMENT)) { 2303 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) {
2304 _angularErrors = value == null ? AnalysisError.NO_ERRORS : (value as List< AnalysisError>);
2305 } else if (identical(descriptor, DartEntry.ELEMENT)) {
2136 _element = value as LibraryElement; 2306 _element = value as LibraryElement;
2137 _elementState = CacheState.VALID; 2307 _elementState = CacheState.VALID;
2138 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 2308 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
2139 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S ource>); 2309 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S ource>);
2140 _exportedLibrariesState = CacheState.VALID; 2310 _exportedLibrariesState = CacheState.VALID;
2141 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 2311 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
2142 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S ource>); 2312 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S ource>);
2143 _importedLibrariesState = CacheState.VALID; 2313 _importedLibrariesState = CacheState.VALID;
2144 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { 2314 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
2145 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc e>); 2315 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc e>);
2146 _includedPartsState = CacheState.VALID; 2316 _includedPartsState = CacheState.VALID;
2147 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 2317 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
2148 _bitmask = BooleanArray.set2(_bitmask, _CLIENT_CODE_INDEX, value as bool); 2318 _bitmask = BooleanArray.set2(_bitmask, _CLIENT_CODE_INDEX, value as bool);
2149 _clientServerState = CacheState.VALID; 2319 _clientServerState = CacheState.VALID;
2150 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { 2320 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
2151 _bitmask = BooleanArray.set2(_bitmask, _LAUNCHABLE_INDEX, value as bool); 2321 _bitmask = BooleanArray.set2(_bitmask, _LAUNCHABLE_INDEX, value as bool);
2152 _launchableState = CacheState.VALID; 2322 _launchableState = CacheState.VALID;
2153 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { 2323 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
2154 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>); 2324 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>);
2155 _parseErrorsState = CacheState.VALID; 2325 _parseErrorsState = CacheState.VALID;
2156 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 2326 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
2157 _parsedUnit = value as CompilationUnit; 2327 _parsedUnit = value as CompilationUnit;
2158 _parsedUnitAccessed = false; 2328 _parsedUnitAccessed = false;
2159 _parsedUnitState = CacheState.VALID; 2329 _parsedUnitState = CacheState.VALID;
2160 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 2330 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
2161 _publicNamespace = value as Namespace; 2331 _publicNamespace = value as Namespace;
2162 _publicNamespaceState = CacheState.VALID; 2332 _publicNamespaceState = CacheState.VALID;
2333 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
2334 _scanErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<Ana lysisError>);
2335 _scanErrorsState = CacheState.VALID;
2163 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 2336 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
2164 _sourceKind = value as SourceKind; 2337 _sourceKind = value as SourceKind;
2165 _sourceKindState = CacheState.VALID; 2338 _sourceKindState = CacheState.VALID;
2339 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
2340 _tokenStream = value as Token;
2341 _tokenStreamState = CacheState.VALID;
2166 } else { 2342 } else {
2167 super.setValue(descriptor, value); 2343 super.setValue(descriptor, value);
2168 } 2344 }
2169 } 2345 }
2170 2346
2171 /** 2347 /**
2172 * Set the value of the data represented by the given descriptor in the contex t of the given 2348 * Set the value of the data represented by the given descriptor in the contex t of the given
2173 * library to the given value, and set the state of that data to [CacheState#V ALID]. 2349 * library to the given value, and set the state of that data to [CacheState#V ALID].
2174 * 2350 *
2175 * @param descriptor the descriptor representing which data is to have its val ue set 2351 * @param descriptor the descriptor representing which data is to have its val ue set
(...skipping 14 matching lines...) Expand all
2190 state._verificationErrorsState = CacheState.VALID; 2366 state._verificationErrorsState = CacheState.VALID;
2191 } else if (identical(descriptor, DartEntry.HINTS)) { 2367 } else if (identical(descriptor, DartEntry.HINTS)) {
2192 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>); 2368 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>);
2193 state._hintsState = CacheState.VALID; 2369 state._hintsState = CacheState.VALID;
2194 } 2370 }
2195 } 2371 }
2196 2372
2197 void copyFrom(SourceEntryImpl entry) { 2373 void copyFrom(SourceEntryImpl entry) {
2198 super.copyFrom(entry); 2374 super.copyFrom(entry);
2199 DartEntryImpl other = entry as DartEntryImpl; 2375 DartEntryImpl other = entry as DartEntryImpl;
2376 _scanErrorsState = other._scanErrorsState;
2377 _scanErrors = other._scanErrors;
2378 _tokenStreamState = other._tokenStreamState;
2379 _tokenStream = other._tokenStream;
2200 _sourceKindState = other._sourceKindState; 2380 _sourceKindState = other._sourceKindState;
2201 _sourceKind = other._sourceKind; 2381 _sourceKind = other._sourceKind;
2202 _parsedUnitState = other._parsedUnitState; 2382 _parsedUnitState = other._parsedUnitState;
2203 _parsedUnit = other._parsedUnit; 2383 _parsedUnit = other._parsedUnit;
2204 _parsedUnitAccessed = other._parsedUnitAccessed; 2384 _parsedUnitAccessed = other._parsedUnitAccessed;
2205 _parseErrorsState = other._parseErrorsState; 2385 _parseErrorsState = other._parseErrorsState;
2206 _parseErrors = other._parseErrors; 2386 _parseErrors = other._parseErrors;
2207 _includedPartsState = other._includedPartsState; 2387 _includedPartsState = other._includedPartsState;
2208 _includedParts = other._includedParts; 2388 _includedParts = other._includedParts;
2209 _exportedLibrariesState = other._exportedLibrariesState; 2389 _exportedLibrariesState = other._exportedLibrariesState;
2210 _exportedLibraries = other._exportedLibraries; 2390 _exportedLibraries = other._exportedLibraries;
2211 _importedLibrariesState = other._importedLibrariesState; 2391 _importedLibrariesState = other._importedLibrariesState;
2212 _importedLibraries = other._importedLibraries; 2392 _importedLibraries = other._importedLibraries;
2213 _containingLibraries = new List<Source>.from(other._containingLibraries); 2393 _containingLibraries = new List<Source>.from(other._containingLibraries);
2214 _resolutionState.copyFrom(other._resolutionState); 2394 _resolutionState.copyFrom(other._resolutionState);
2215 _elementState = other._elementState; 2395 _elementState = other._elementState;
2216 _element = other._element; 2396 _element = other._element;
2217 _publicNamespaceState = other._publicNamespaceState; 2397 _publicNamespaceState = other._publicNamespaceState;
2218 _publicNamespace = other._publicNamespace; 2398 _publicNamespace = other._publicNamespace;
2219 _clientServerState = other._clientServerState; 2399 _clientServerState = other._clientServerState;
2220 _launchableState = other._launchableState; 2400 _launchableState = other._launchableState;
2221 _bitmask = other._bitmask; 2401 _bitmask = other._bitmask;
2402 _angularErrors = other._angularErrors;
2222 } 2403 }
2223 2404
2224 bool hasErrorState() => super.hasErrorState() || identical(_sourceKindState, C acheState.ERROR) || identical(_parsedUnitState, CacheState.ERROR) || identical(_ parseErrorsState, CacheState.ERROR) || identical(_importedLibrariesState, CacheS tate.ERROR) || identical(_exportedLibrariesState, CacheState.ERROR) || identical (_includedPartsState, CacheState.ERROR) || identical(_elementState, CacheState.E RROR) || identical(_publicNamespaceState, CacheState.ERROR) || identical(_client ServerState, CacheState.ERROR) || identical(_launchableState, CacheState.ERROR) || _resolutionState.hasErrorState(); 2405 bool hasErrorState() => super.hasErrorState() || identical(_scanErrorsState, C acheState.ERROR) || identical(_tokenStreamState, CacheState.ERROR) || identical( _sourceKindState, CacheState.ERROR) || identical(_parsedUnitState, CacheState.ER ROR) || identical(_parseErrorsState, CacheState.ERROR) || identical(_importedLib rariesState, CacheState.ERROR) || identical(_exportedLibrariesState, CacheState. ERROR) || identical(_includedPartsState, CacheState.ERROR) || identical(_element State, CacheState.ERROR) || identical(_publicNamespaceState, CacheState.ERROR) | | identical(_clientServerState, CacheState.ERROR) || identical(_launchableState, CacheState.ERROR) || _resolutionState.hasErrorState();
2225 2406
2226 void writeOn(JavaStringBuilder builder) { 2407 void writeOn(JavaStringBuilder builder) {
2227 builder.append("Dart: "); 2408 builder.append("Dart: ");
2228 super.writeOn(builder); 2409 super.writeOn(builder);
2410 builder.append("; tokenStream = ");
2411 builder.append(_tokenStreamState);
2412 builder.append("; scanErrors = ");
2413 builder.append(_scanErrorsState);
2229 builder.append("; sourceKind = "); 2414 builder.append("; sourceKind = ");
2230 builder.append(_sourceKindState); 2415 builder.append(_sourceKindState);
2231 builder.append("; parsedUnit = "); 2416 builder.append("; parsedUnit = ");
2232 builder.append(_parsedUnitState); 2417 builder.append(_parsedUnitState);
2233 builder.append(" ("); 2418 builder.append(" (");
2234 builder.append(_parsedUnitAccessed ? "T" : "F"); 2419 builder.append(_parsedUnitAccessed ? "T" : "F");
2235 builder.append("); parseErrors = "); 2420 builder.append("); parseErrors = ");
2236 builder.append(_parseErrorsState); 2421 builder.append(_parseErrorsState);
2237 builder.append("; exportedLibraries = "); 2422 builder.append("; exportedLibraries = ");
2238 builder.append(_exportedLibrariesState); 2423 builder.append(_exportedLibrariesState);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 * The interface `HtmlEntry` defines the behavior of objects that maintain the i nformation 2707 * The interface `HtmlEntry` defines the behavior of objects that maintain the i nformation
2523 * cached by an analysis context about an individual HTML file. 2708 * cached by an analysis context about an individual HTML file.
2524 * 2709 *
2525 * @coverage dart.engine 2710 * @coverage dart.engine
2526 */ 2711 */
2527 abstract class HtmlEntry implements SourceEntry { 2712 abstract class HtmlEntry implements SourceEntry {
2528 /** 2713 /**
2529 * The data descriptor representing the information about an Angular applicati on this source is 2714 * The data descriptor representing the information about an Angular applicati on this source is
2530 * used in. 2715 * used in.
2531 */ 2716 */
2532 static final DataDescriptor<AngularApplicationInfo> ANGULAR_APPLICATION = new DataDescriptor<AngularApplicationInfo>("HtmlEntry.ANGULAR_APPLICATION"); 2717 static final DataDescriptor<AngularApplication> ANGULAR_APPLICATION = new Data Descriptor<AngularApplication>("HtmlEntry.ANGULAR_APPLICATION");
2533 2718
2534 /** 2719 /**
2535 * The data descriptor representing the information about an Angular component this source is used 2720 * The data descriptor representing the information about an Angular component this source is used
2536 * as template for. 2721 * as template for.
2537 */ 2722 */
2538 static final DataDescriptor<AngularComponentElement> ANGULAR_COMPONENT = new D ataDescriptor<AngularComponentElement>("HtmlEntry.ANGULAR_COMPONENT"); 2723 static final DataDescriptor<AngularComponentElement> ANGULAR_COMPONENT = new D ataDescriptor<AngularComponentElement>("HtmlEntry.ANGULAR_COMPONENT");
2539 2724
2540 /** 2725 /**
2541 * The data descriptor representing the information about an Angular applicati on this source is 2726 * The data descriptor representing the information about an Angular applicati on this source is
2542 * entry point for. 2727 * entry point for.
2543 */ 2728 */
2544 static final DataDescriptor<AngularApplicationInfo> ANGULAR_ENTRY = new DataDe scriptor<AngularApplicationInfo>("HtmlEntry.ANGULAR_ENTRY"); 2729 static final DataDescriptor<AngularApplication> ANGULAR_ENTRY = new DataDescri ptor<AngularApplication>("HtmlEntry.ANGULAR_ENTRY");
2545 2730
2546 /** 2731 /**
2547 * The data descriptor representing the errors reported during Angular resolut ion. 2732 * The data descriptor representing the errors reported during Angular resolut ion.
2548 */ 2733 */
2549 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("HtmlEntry.ANGULAR_ERRORS"); 2734 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("HtmlEntry.ANGULAR_ERRORS");
2550 2735
2551 /** 2736 /**
2552 * The data descriptor representing the HTML element. 2737 * The data descriptor representing the HTML element.
2553 */ 2738 */
2554 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem ent>("HtmlEntry.ELEMENT"); 2739 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem ent>("HtmlEntry.ELEMENT");
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 HtmlElement _element; 2856 HtmlElement _element;
2672 2857
2673 /** 2858 /**
2674 * The state of the [angularApplication]. 2859 * The state of the [angularApplication].
2675 */ 2860 */
2676 CacheState _angularApplicationState = CacheState.VALID; 2861 CacheState _angularApplicationState = CacheState.VALID;
2677 2862
2678 /** 2863 /**
2679 * Information about the Angular Application this unit is used in. 2864 * Information about the Angular Application this unit is used in.
2680 */ 2865 */
2681 AngularApplicationInfo _angularApplication; 2866 AngularApplication _angularApplication;
2682 2867
2683 /** 2868 /**
2684 * The state of the [angularEntry]. 2869 * The state of the [angularEntry].
2685 */ 2870 */
2686 CacheState _angularEntryState = CacheState.VALID; 2871 CacheState _angularEntryState = CacheState.INVALID;
2687 2872
2688 /** 2873 /**
2689 * Information about the Angular Application this unit is entry point for. 2874 * Information about the Angular Application this unit is entry point for.
2690 */ 2875 */
2691 AngularApplicationInfo _angularEntry = null; 2876 AngularApplication _angularEntry = null;
2692 2877
2693 /** 2878 /**
2694 * The state of the [angularComponent]. 2879 * The state of the [angularComponent].
2695 */ 2880 */
2696 CacheState _angularComponentState = CacheState.VALID; 2881 CacheState _angularComponentState = CacheState.VALID;
2697 2882
2698 /** 2883 /**
2699 * Information about the [AngularComponentElement] this unit is used as templa te for. 2884 * Information about the [AngularComponentElement] this unit is used as templa te for.
2700 */ 2885 */
2701 AngularComponentElement _angularComponent = null; 2886 AngularComponentElement _angularComponent = null;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 _resolvedUnitState = CacheState.INVALID; 3033 _resolvedUnitState = CacheState.INVALID;
2849 _referencedLibraries = Source.EMPTY_ARRAY; 3034 _referencedLibraries = Source.EMPTY_ARRAY;
2850 _referencedLibrariesState = CacheState.INVALID; 3035 _referencedLibrariesState = CacheState.INVALID;
2851 invalidateAllResolutionInformation(); 3036 invalidateAllResolutionInformation();
2852 } 3037 }
2853 3038
2854 /** 3039 /**
2855 * Invalidate all of the resolution information associated with the HTML file. 3040 * Invalidate all of the resolution information associated with the HTML file.
2856 */ 3041 */
2857 void invalidateAllResolutionInformation() { 3042 void invalidateAllResolutionInformation() {
3043 _angularEntry = null;
3044 _angularEntryState = CacheState.INVALID;
2858 _angularErrors = AnalysisError.NO_ERRORS; 3045 _angularErrors = AnalysisError.NO_ERRORS;
2859 _angularErrorsState = CacheState.INVALID; 3046 _angularErrorsState = CacheState.INVALID;
2860 _element = null; 3047 _element = null;
2861 _elementState = CacheState.INVALID; 3048 _elementState = CacheState.INVALID;
2862 _resolutionErrors = AnalysisError.NO_ERRORS; 3049 _resolutionErrors = AnalysisError.NO_ERRORS;
2863 _resolutionErrorsState = CacheState.INVALID; 3050 _resolutionErrorsState = CacheState.INVALID;
2864 _hints = AnalysisError.NO_ERRORS; 3051 _hints = AnalysisError.NO_ERRORS;
2865 _hintsState = CacheState.INVALID; 3052 _hintsState = CacheState.INVALID;
2866 } 3053 }
2867 3054
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 } else if (identical(descriptor, HtmlEntry.HINTS)) { 3110 } else if (identical(descriptor, HtmlEntry.HINTS)) {
2924 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS); 3111 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS);
2925 _hintsState = state; 3112 _hintsState = state;
2926 } else { 3113 } else {
2927 super.setState(descriptor, state); 3114 super.setState(descriptor, state);
2928 } 3115 }
2929 } 3116 }
2930 3117
2931 void setValue(DataDescriptor descriptor, Object value) { 3118 void setValue(DataDescriptor descriptor, Object value) {
2932 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { 3119 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) {
2933 _angularApplication = value as AngularApplicationInfo; 3120 _angularApplication = value as AngularApplication;
2934 _angularApplicationState = CacheState.VALID; 3121 _angularApplicationState = CacheState.VALID;
2935 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { 3122 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) {
2936 _angularComponent = value as AngularComponentElement; 3123 _angularComponent = value as AngularComponentElement;
2937 _angularComponentState = CacheState.VALID; 3124 _angularComponentState = CacheState.VALID;
2938 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { 3125 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) {
2939 _angularEntry = value as AngularApplicationInfo; 3126 _angularEntry = value as AngularApplication;
2940 _angularEntryState = CacheState.VALID; 3127 _angularEntryState = CacheState.VALID;
2941 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { 3128 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) {
2942 _angularErrors = value as List<AnalysisError>; 3129 _angularErrors = value as List<AnalysisError>;
2943 _angularErrorsState = CacheState.VALID; 3130 _angularErrorsState = CacheState.VALID;
2944 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { 3131 } else if (identical(descriptor, HtmlEntry.ELEMENT)) {
2945 _element = value as HtmlElement; 3132 _element = value as HtmlElement;
2946 _elementState = CacheState.VALID; 3133 _elementState = CacheState.VALID;
2947 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { 3134 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) {
2948 _parseErrors = value as List<AnalysisError>; 3135 _parseErrors = value as List<AnalysisError>;
2949 _parseErrorsState = CacheState.VALID; 3136 _parseErrorsState = CacheState.VALID;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
3286 builder.append(_lineInfoState); 3473 builder.append(_lineInfoState);
3287 } 3474 }
3288 } 3475 }
3289 3476
3290 /** 3477 /**
3291 * Implementation of the [AnalysisContentStatistics]. 3478 * Implementation of the [AnalysisContentStatistics].
3292 */ 3479 */
3293 class AnalysisContentStatisticsImpl implements AnalysisContentStatistics { 3480 class AnalysisContentStatisticsImpl implements AnalysisContentStatistics {
3294 Map<String, AnalysisContentStatistics_CacheRow> _dataMap = new Map<String, Ana lysisContentStatistics_CacheRow>(); 3481 Map<String, AnalysisContentStatistics_CacheRow> _dataMap = new Map<String, Ana lysisContentStatistics_CacheRow>();
3295 3482
3483 List<Source> _sources = new List<Source>();
3484
3296 Set<AnalysisException> _exceptions = new Set<AnalysisException>(); 3485 Set<AnalysisException> _exceptions = new Set<AnalysisException>();
3297 3486
3487 void addSource(Source source) {
3488 _sources.add(source);
3489 }
3490
3298 List<AnalysisContentStatistics_CacheRow> get cacheRows { 3491 List<AnalysisContentStatistics_CacheRow> get cacheRows {
3299 Iterable<AnalysisContentStatistics_CacheRow> items = _dataMap.values; 3492 Iterable<AnalysisContentStatistics_CacheRow> items = _dataMap.values;
3300 return new List.from(items); 3493 return new List.from(items);
3301 } 3494 }
3302 3495
3303 List<AnalysisException> get exceptions => new List.from(_exceptions); 3496 List<AnalysisException> get exceptions => new List.from(_exceptions);
3304 3497
3305 void putCacheItem(DartEntry dartEntry, DataDescriptor descriptor) { 3498 List<Source> get sources => new List.from(_sources);
3306 putCacheItem3(dartEntry, descriptor, dartEntry.getState(descriptor)); 3499
3500 void putCacheItem(DartEntry dartEntry, Source librarySource, DataDescriptor de scriptor) {
3501 putCacheItem3(dartEntry, descriptor, dartEntry.getState2(descriptor, library Source));
3307 } 3502 }
3308 3503
3309 void putCacheItem2(DartEntry dartEntry, Source librarySource, DataDescriptor d escriptor) { 3504 void putCacheItem2(SourceEntry dartEntry, DataDescriptor descriptor) {
3310 putCacheItem3(dartEntry, descriptor, dartEntry.getState2(descriptor, library Source)); 3505 putCacheItem3(dartEntry, descriptor, dartEntry.getState(descriptor));
3311 } 3506 }
3312 3507
3313 void putCacheItem3(SourceEntry dartEntry, DataDescriptor rowDesc, CacheState s tate) { 3508 void putCacheItem3(SourceEntry dartEntry, DataDescriptor rowDesc, CacheState s tate) {
3314 String rowName = rowDesc.toString(); 3509 String rowName = rowDesc.toString();
3315 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys isContentStatisticsImpl_CacheRowImpl; 3510 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys isContentStatisticsImpl_CacheRowImpl;
3316 if (row == null) { 3511 if (row == null) {
3317 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName); 3512 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName);
3318 _dataMap[rowName] = row; 3513 _dataMap[rowName] = row;
3319 } 3514 }
3320 row.incState(state); 3515 row.incState(state);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3388 * priority source's AST structure to be flushed. 3583 * priority source's AST structure to be flushed.
3389 */ 3584 */
3390 static int _PRIORITY_ORDER_SIZE_DELTA = 4; 3585 static int _PRIORITY_ORDER_SIZE_DELTA = 4;
3391 3586
3392 /** 3587 /**
3393 * The set of analysis options controlling the behavior of this context. 3588 * The set of analysis options controlling the behavior of this context.
3394 */ 3589 */
3395 AnalysisOptionsImpl _options = new AnalysisOptionsImpl(); 3590 AnalysisOptionsImpl _options = new AnalysisOptionsImpl();
3396 3591
3397 /** 3592 /**
3593 * A cache of content used to override the default content of a source.
3594 */
3595 ContentCache _contentCache = new ContentCache();
3596
3597 /**
3398 * The source factory used to create the sources that can be analyzed in this context. 3598 * The source factory used to create the sources that can be analyzed in this context.
3399 */ 3599 */
3400 SourceFactory _sourceFactory; 3600 SourceFactory _sourceFactory;
3401 3601
3402 /** 3602 /**
3403 * A table mapping the sources known to the context to the information known a bout the source. 3603 * A table mapping the sources known to the context to the information known a bout the source.
3404 */ 3604 */
3405 AnalysisCache _cache; 3605 AnalysisCache _cache;
3406 3606
3407 /** 3607 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 * [cacheLock] before accessing this field. 3643 * [cacheLock] before accessing this field.
3444 */ 3644 */
3445 IncrementalAnalysisCache _incrementalAnalysisCache; 3645 IncrementalAnalysisCache _incrementalAnalysisCache;
3446 3646
3447 /** 3647 /**
3448 * The object used to manage the list of sources that need to be analyzed. 3648 * The object used to manage the list of sources that need to be analyzed.
3449 */ 3649 */
3450 WorkManager _workManager = new WorkManager(); 3650 WorkManager _workManager = new WorkManager();
3451 3651
3452 /** 3652 /**
3653 * The set of [AngularApplication] in this context.
3654 */
3655 Set<AngularApplication> _angularApplications = new Set();
3656
3657 /**
3453 * Initialize a newly created analysis context. 3658 * Initialize a newly created analysis context.
3454 */ 3659 */
3455 AnalysisContextImpl() : super() { 3660 AnalysisContextImpl() : super() {
3456 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); 3661 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this);
3457 _cache = new AnalysisCache(AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, new Analy sisContextImpl_ContextRetentionPolicy(this)); 3662 _cache = new AnalysisCache(AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, new Analy sisContextImpl_ContextRetentionPolicy(this));
3458 } 3663 }
3459 3664
3460 void addSourceInfo(Source source, SourceEntry info) { 3665 void addSourceInfo(Source source, SourceEntry info) {
3461 // This implementation assumes that the access to the cache does not need to be synchronized 3666 // This implementation assumes that the access to the cache does not need to be synchronized
3462 // because no other object can have access to this context while this method is being invoked. 3667 // because no other object can have access to this context while this method is being invoked.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3553 nameNode = nameNode.parent; 3758 nameNode = nameNode.parent;
3554 } 3759 }
3555 return null; 3760 return null;
3556 } 3761 }
3557 3762
3558 List<AnalysisError> computeErrors(Source source) { 3763 List<AnalysisError> computeErrors(Source source) {
3559 bool enableHints = _options.hint; 3764 bool enableHints = _options.hint;
3560 SourceEntry sourceEntry = getReadableSourceEntry(source); 3765 SourceEntry sourceEntry = getReadableSourceEntry(source);
3561 if (sourceEntry is DartEntry) { 3766 if (sourceEntry is DartEntry) {
3562 List<AnalysisError> errors = new List<AnalysisError>(); 3767 List<AnalysisError> errors = new List<AnalysisError>();
3563 DartEntry dartEntry = sourceEntry; 3768 try {
3564 ListUtilities.addAll(errors, getDartParseData(source, dartEntry, DartEntry .PARSE_ERRORS)); 3769 DartEntry dartEntry = sourceEntry;
3565 dartEntry = getReadableDartEntry(source); 3770 ListUtilities.addAll(errors, getDartScanData(source, dartEntry, DartEntr y.SCAN_ERRORS));
3566 if (identical(dartEntry.getValue(DartEntry.SOURCE_KIND), SourceKind.LIBRAR Y)) { 3771 dartEntry = getReadableDartEntry(source);
3567 ListUtilities.addAll(errors, getDartResolutionData(source, source, dartE ntry, DartEntry.RESOLUTION_ERRORS)); 3772 ListUtilities.addAll(errors, getDartParseData(source, dartEntry, DartEnt ry.PARSE_ERRORS));
3568 ListUtilities.addAll(errors, getDartVerificationData(source, source, dar tEntry, DartEntry.VERIFICATION_ERRORS)); 3773 dartEntry = getReadableDartEntry(source);
3569 if (enableHints) { 3774 if (identical(dartEntry.getValue(DartEntry.SOURCE_KIND), SourceKind.LIBR ARY)) {
3570 ListUtilities.addAll(errors, getDartHintData(source, source, dartEntry , DartEntry.HINTS)); 3775 ListUtilities.addAll(errors, getDartResolutionData(source, source, dar tEntry, DartEntry.RESOLUTION_ERRORS));
3571 } 3776 dartEntry = getReadableDartEntry(source);
3572 } else { 3777 ListUtilities.addAll(errors, getDartVerificationData(source, source, d artEntry, DartEntry.VERIFICATION_ERRORS));
3573 List<Source> libraries = getLibrariesContaining(source);
3574 for (Source librarySource in libraries) {
3575 ListUtilities.addAll(errors, getDartResolutionData(source, librarySour ce, dartEntry, DartEntry.RESOLUTION_ERRORS));
3576 ListUtilities.addAll(errors, getDartVerificationData(source, librarySo urce, dartEntry, DartEntry.VERIFICATION_ERRORS));
3577 if (enableHints) { 3778 if (enableHints) {
3578 ListUtilities.addAll(errors, getDartHintData(source, librarySource, dartEntry, DartEntry.HINTS)); 3779 dartEntry = getReadableDartEntry(source);
3780 ListUtilities.addAll(errors, getDartHintData(source, source, dartEnt ry, DartEntry.HINTS));
3781 }
3782 } else {
3783 List<Source> libraries = getLibrariesContaining(source);
3784 for (Source librarySource in libraries) {
3785 ListUtilities.addAll(errors, getDartResolutionData(source, librarySo urce, dartEntry, DartEntry.RESOLUTION_ERRORS));
3786 dartEntry = getReadableDartEntry(source);
3787 ListUtilities.addAll(errors, getDartVerificationData(source, library Source, dartEntry, DartEntry.VERIFICATION_ERRORS));
3788 if (enableHints) {
3789 dartEntry = getReadableDartEntry(source);
3790 ListUtilities.addAll(errors, getDartHintData(source, librarySource , dartEntry, DartEntry.HINTS));
3791 }
3579 } 3792 }
3580 } 3793 }
3794 } on ObsoleteSourceAnalysisException catch (exception) {
3795 AnalysisEngine.instance.logger.logInformation3("Could not compute errors ", exception);
3581 } 3796 }
3582 if (errors.isEmpty) { 3797 if (errors.isEmpty) {
3583 return AnalysisError.NO_ERRORS; 3798 return AnalysisError.NO_ERRORS;
3584 } 3799 }
3585 return new List.from(errors); 3800 return new List.from(errors);
3586 } else if (sourceEntry is HtmlEntry) { 3801 } else if (sourceEntry is HtmlEntry) {
3587 HtmlEntry htmlEntry = sourceEntry; 3802 HtmlEntry htmlEntry = sourceEntry;
3588 return getHtmlResolutionData2(source, htmlEntry, HtmlEntry.RESOLUTION_ERRO RS); 3803 try {
3804 return getHtmlResolutionData2(source, htmlEntry, HtmlEntry.RESOLUTION_ER RORS);
3805 } on ObsoleteSourceAnalysisException catch (exception) {
3806 AnalysisEngine.instance.logger.logInformation3("Could not compute errors ", exception);
3807 }
3589 } 3808 }
3590 return AnalysisError.NO_ERRORS; 3809 return AnalysisError.NO_ERRORS;
3591 } 3810 }
3592 3811
3593 List<Source> computeExportedLibraries(Source source) => getDartDependencyData2 (source, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); 3812 List<Source> computeExportedLibraries(Source source) => getDartDependencyData2 (source, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY);
3594 3813
3595 HtmlElement computeHtmlElement(Source source) => getHtmlResolutionData(source, HtmlEntry.ELEMENT, null); 3814 HtmlElement computeHtmlElement(Source source) => getHtmlResolutionData(source, HtmlEntry.ELEMENT, null);
3596 3815
3597 List<Source> computeImportedLibraries(Source source) => getDartDependencyData2 (source, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); 3816 List<Source> computeImportedLibraries(Source source) => getDartDependencyData2 (source, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY);
3598 3817
3599 SourceKind computeKindOf(Source source) { 3818 SourceKind computeKindOf(Source source) {
3600 SourceEntry sourceEntry = getReadableSourceEntry(source); 3819 SourceEntry sourceEntry = getReadableSourceEntry(source);
3601 if (sourceEntry == null) { 3820 if (sourceEntry == null) {
3602 return SourceKind.UNKNOWN; 3821 return SourceKind.UNKNOWN;
3603 } else if (sourceEntry is DartEntry) { 3822 } else if (sourceEntry is DartEntry) {
3604 try { 3823 try {
3605 return getDartParseData(source, sourceEntry, DartEntry.SOURCE_KIND); 3824 return getDartParseData(source, sourceEntry, DartEntry.SOURCE_KIND);
3606 } on AnalysisException catch (exception) { 3825 } on AnalysisException catch (exception) {
3607 return SourceKind.UNKNOWN; 3826 return SourceKind.UNKNOWN;
3608 } 3827 }
3609 } 3828 }
3610 return sourceEntry.kind; 3829 return sourceEntry.kind;
3611 } 3830 }
3612 3831
3613 LibraryElement computeLibraryElement(Source source) => getDartResolutionData2( source, source, DartEntry.ELEMENT, null); 3832 LibraryElement computeLibraryElement(Source source) => getDartResolutionData2( source, source, DartEntry.ELEMENT, null);
3614 3833
3615 LineInfo computeLineInfo(Source source) { 3834 LineInfo computeLineInfo(Source source) {
3616 SourceEntry sourceEntry = getReadableSourceEntry(source); 3835 SourceEntry sourceEntry = getReadableSourceEntry(source);
3617 if (sourceEntry is HtmlEntry) { 3836 try {
3618 return getHtmlParseData(source, SourceEntry.LINE_INFO, null); 3837 if (sourceEntry is HtmlEntry) {
3619 } else if (sourceEntry is DartEntry) { 3838 return getHtmlParseData(source, SourceEntry.LINE_INFO, null);
3620 return getDartParseData2(source, SourceEntry.LINE_INFO, null); 3839 } else if (sourceEntry is DartEntry) {
3840 return getDartScanData2(source, SourceEntry.LINE_INFO, null);
3841 }
3842 } on ObsoleteSourceAnalysisException catch (exception) {
3843 AnalysisEngine.instance.logger.logInformation3("Could not compute ${Source Entry.LINE_INFO.toString()}", exception);
3621 } 3844 }
3622 return null; 3845 return null;
3623 } 3846 }
3624 3847
3625 ResolvableHtmlUnit computeResolvableAngularComponentHtmlUnit(Source source) { 3848 ResolvableHtmlUnit computeResolvableAngularComponentHtmlUnit(Source source) {
3626 HtmlEntry htmlEntry = getReadableHtmlEntry(source); 3849 HtmlEntry htmlEntry = getReadableHtmlEntry(source);
3627 if (htmlEntry == null) { 3850 if (htmlEntry == null) {
3628 throw new AnalysisException.con1("computeResolvableAngularComponentHtmlUni t invoked for non-HTML file: ${source.fullName}"); 3851 throw new AnalysisException.con1("computeResolvableAngularComponentHtmlUni t invoked for non-HTML file: ${source.fullName}");
3629 } 3852 }
3630 htmlEntry = cacheHtmlResolutionData(source, htmlEntry, HtmlEntry.RESOLVED_UN IT); 3853 htmlEntry = cacheHtmlResolutionData(source, htmlEntry, HtmlEntry.RESOLVED_UN IT);
(...skipping 30 matching lines...) Expand all
3661 } 3884 }
3662 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); 3885 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT);
3663 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); 3886 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT);
3664 if (unit == null) { 3887 if (unit == null) {
3665 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t could not parse ${source.fullName}"); 3888 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t could not parse ${source.fullName}");
3666 } 3889 }
3667 // If the unit is ever modified by resolution then we will need to create a copy of it. 3890 // If the unit is ever modified by resolution then we will need to create a copy of it.
3668 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit); 3891 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit);
3669 } 3892 }
3670 3893
3894 bool exists(Source source) {
3895 if (source == null) {
3896 return false;
3897 }
3898 if (_contentCache.getContents(source) != null) {
3899 return true;
3900 }
3901 return source.exists();
3902 }
3903
3671 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis Context); 3904 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis Context);
3672 3905
3673 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) { 3906 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) {
3674 List<Source> sourcesToRemove = new List<Source>(); 3907 List<Source> sourcesToRemove = new List<Source>();
3675 { 3908 {
3676 // Move sources in the specified directory to the new context 3909 // Move sources in the specified directory to the new context
3677 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3910 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3678 Source source = entry.getKey(); 3911 Source source = entry.getKey();
3679 if (container.contains(source)) { 3912 if (container.contains(source)) {
3680 sourcesToRemove.add(source); 3913 sourcesToRemove.add(source);
3681 newContext.addSourceInfo(source, entry.getValue().writableCopy); 3914 newContext.addSourceInfo(source, entry.getValue().writableCopy);
3682 } 3915 }
3683 } 3916 }
3684 } 3917 }
3685 return newContext; 3918 return newContext;
3686 } 3919 }
3687 3920
3688 AnalysisOptions get analysisOptions => _options; 3921 AnalysisOptions get analysisOptions => _options;
3689 3922
3923 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib rarySource) {
3924 LibraryElement libraryElement = getLibraryElement(librarySource);
3925 if (libraryElement != null) {
3926 // try defining unit
3927 CompilationUnitElement definingUnit = libraryElement.definingCompilationUn it;
3928 if (definingUnit.source == unitSource) {
3929 return definingUnit;
3930 }
3931 // try parts
3932 for (CompilationUnitElement partUnit in libraryElement.parts) {
3933 if (partUnit.source == unitSource) {
3934 return partUnit;
3935 }
3936 }
3937 }
3938 return null;
3939 }
3940
3941 TimestampedData<String> getContents(Source source) {
3942 String contents = _contentCache.getContents(source);
3943 if (contents != null) {
3944 return new TimestampedData<String>(_contentCache.getModificationStamp(sour ce), contents);
3945 }
3946 return source.contents;
3947 }
3948
3949 void getContents2(Source source, Source_ContentReceiver receiver) {
3950 String contents = _contentCache.getContents(source);
3951 if (contents != null) {
3952 receiver.accept(contents, _contentCache.getModificationStamp(source));
3953 return;
3954 }
3955 source.getContentsToReceiver(receiver);
3956 }
3957
3690 Element getElement(ElementLocation location) { 3958 Element getElement(ElementLocation location) {
3691 // TODO(brianwilkerson) This should not be a "get" method. 3959 // TODO(brianwilkerson) This should not be a "get" method.
3692 try { 3960 try {
3693 List<String> components = (location as ElementLocationImpl).components; 3961 List<String> components = (location as ElementLocationImpl).components;
3694 Source librarySource = computeSourceFromEncoding(components[0]); 3962 Source librarySource = computeSourceFromEncoding(components[0]);
3695 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; 3963 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl;
3696 for (int i = 1; i < components.length; i++) { 3964 for (int i = 1; i < components.length; i++) {
3697 if (element == null) { 3965 if (element == null) {
3698 return null; 3966 return null;
3699 } 3967 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3841 List<Source> get librarySources => getSources(SourceKind.LIBRARY); 4109 List<Source> get librarySources => getSources(SourceKind.LIBRARY);
3842 4110
3843 LineInfo getLineInfo(Source source) { 4111 LineInfo getLineInfo(Source source) {
3844 SourceEntry sourceEntry = getReadableSourceEntry(source); 4112 SourceEntry sourceEntry = getReadableSourceEntry(source);
3845 if (sourceEntry != null) { 4113 if (sourceEntry != null) {
3846 return sourceEntry.getValue(SourceEntry.LINE_INFO); 4114 return sourceEntry.getValue(SourceEntry.LINE_INFO);
3847 } 4115 }
3848 return null; 4116 return null;
3849 } 4117 }
3850 4118
4119 int getModificationStamp(Source source) {
4120 int stamp = _contentCache.getModificationStamp(source);
4121 if (stamp != null) {
4122 return stamp;
4123 }
4124 return source.modificationStamp;
4125 }
4126
3851 Namespace getPublicNamespace(LibraryElement library) { 4127 Namespace getPublicNamespace(LibraryElement library) {
3852 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this is not part of the 4128 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this is not part of the
3853 // API of the interface. 4129 // API of the interface.
3854 Source source = library.definingCompilationUnit.source; 4130 Source source = library.definingCompilationUnit.source;
3855 DartEntry dartEntry = getReadableDartEntry(source); 4131 DartEntry dartEntry = getReadableDartEntry(source);
3856 if (dartEntry == null) { 4132 if (dartEntry == null) {
3857 return null; 4133 return null;
3858 } 4134 }
3859 Namespace namespace = null; 4135 Namespace namespace = null;
3860 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { 4136 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3974 getSourcesNeedingProcessing2(entry.getKey(), entry.getValue(), false, hi ntsEnabled, sources); 4250 getSourcesNeedingProcessing2(entry.getKey(), entry.getValue(), false, hi ntsEnabled, sources);
3975 } 4251 }
3976 } 4252 }
3977 return new List<Source>.from(sources); 4253 return new List<Source>.from(sources);
3978 } 4254 }
3979 4255
3980 AnalysisContentStatistics get statistics { 4256 AnalysisContentStatistics get statistics {
3981 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl (); 4257 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl ();
3982 { 4258 {
3983 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { 4259 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) {
4260 statistics.addSource(mapEntry.getKey());
3984 SourceEntry entry = mapEntry.getValue(); 4261 SourceEntry entry = mapEntry.getValue();
3985 if (entry is DartEntry) { 4262 if (entry is DartEntry) {
3986 Source source = mapEntry.getKey(); 4263 Source source = mapEntry.getKey();
3987 DartEntry dartEntry = entry; 4264 DartEntry dartEntry = entry;
3988 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); 4265 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
3989 // get library independent values 4266 // get library independent values
3990 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS); 4267 statistics.putCacheItem2(dartEntry, SourceEntry.LINE_INFO);
3991 statistics.putCacheItem(dartEntry, DartEntry.PARSED_UNIT); 4268 statistics.putCacheItem2(dartEntry, DartEntry.PARSE_ERRORS);
3992 statistics.putCacheItem(dartEntry, DartEntry.SOURCE_KIND); 4269 statistics.putCacheItem2(dartEntry, DartEntry.PARSED_UNIT);
3993 statistics.putCacheItem(dartEntry, SourceEntry.LINE_INFO); 4270 statistics.putCacheItem2(dartEntry, DartEntry.SOURCE_KIND);
3994 if (identical(kind, SourceKind.LIBRARY)) { 4271 if (identical(kind, SourceKind.LIBRARY)) {
3995 statistics.putCacheItem(dartEntry, DartEntry.ELEMENT); 4272 statistics.putCacheItem2(dartEntry, DartEntry.ELEMENT);
3996 statistics.putCacheItem(dartEntry, DartEntry.EXPORTED_LIBRARIES); 4273 statistics.putCacheItem2(dartEntry, DartEntry.EXPORTED_LIBRARIES);
3997 statistics.putCacheItem(dartEntry, DartEntry.IMPORTED_LIBRARIES); 4274 statistics.putCacheItem2(dartEntry, DartEntry.IMPORTED_LIBRARIES);
3998 statistics.putCacheItem(dartEntry, DartEntry.INCLUDED_PARTS); 4275 statistics.putCacheItem2(dartEntry, DartEntry.INCLUDED_PARTS);
3999 statistics.putCacheItem(dartEntry, DartEntry.IS_CLIENT); 4276 statistics.putCacheItem2(dartEntry, DartEntry.IS_CLIENT);
4000 statistics.putCacheItem(dartEntry, DartEntry.IS_LAUNCHABLE); 4277 statistics.putCacheItem2(dartEntry, DartEntry.IS_LAUNCHABLE);
4001 } 4278 }
4002 // get library-specific values 4279 // get library-specific values
4003 List<Source> librarySources = getLibrariesContaining(source); 4280 List<Source> librarySources = getLibrariesContaining(source);
4004 for (Source librarySource in librarySources) { 4281 for (Source librarySource in librarySources) {
4005 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.HINTS); 4282 statistics.putCacheItem(dartEntry, librarySource, DartEntry.HINTS);
4006 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLUT ION_ERRORS); 4283 statistics.putCacheItem(dartEntry, librarySource, DartEntry.RESOLUTI ON_ERRORS);
4007 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLVE D_UNIT); 4284 statistics.putCacheItem(dartEntry, librarySource, DartEntry.RESOLVED _UNIT);
4008 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.VERIFIC ATION_ERRORS); 4285 statistics.putCacheItem(dartEntry, librarySource, DartEntry.VERIFICA TION_ERRORS);
4009 } 4286 }
4287 } else if (entry is HtmlEntry) {
4288 HtmlEntry htmlEntry = entry;
4289 statistics.putCacheItem2(htmlEntry, SourceEntry.LINE_INFO);
4290 statistics.putCacheItem2(htmlEntry, HtmlEntry.PARSE_ERRORS);
4291 statistics.putCacheItem2(htmlEntry, HtmlEntry.PARSED_UNIT);
4292 statistics.putCacheItem2(htmlEntry, HtmlEntry.RESOLUTION_ERRORS);
4293 statistics.putCacheItem2(htmlEntry, HtmlEntry.RESOLVED_UNIT);
4294 statistics.putCacheItem2(htmlEntry, HtmlEntry.HINTS);
4010 } 4295 }
4011 } 4296 }
4012 } 4297 }
4013 return statistics; 4298 return statistics;
4014 } 4299 }
4015 4300
4016 TypeProvider get typeProvider { 4301 TypeProvider get typeProvider {
4017 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 4302 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
4018 return new TypeProviderImpl(computeLibraryElement(coreSource)); 4303 return new TypeProviderImpl(computeLibraryElement(coreSource));
4019 } 4304 }
4020 4305
4306 TimestampedData<CompilationUnit> internalParseCompilationUnit(Source source) {
4307 DartEntry dartEntry = getReadableDartEntry(source);
4308 if (dartEntry == null) {
4309 throw new AnalysisException.con1("internalParseCompilationUnit invoked for non-Dart file: ${source.fullName}");
4310 }
4311 dartEntry = cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT);
4312 CompilationUnit unit = dartEntry.anyParsedCompilationUnit;
4313 if (unit == null) {
4314 throw new AnalysisException.con2("internalParseCompilationUnit could not c ache a parsed unit: ${source.fullName}", dartEntry.exception);
4315 }
4316 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, unit );
4317 }
4318
4021 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement) { 4319 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement) {
4022 DartEntry dartEntry = getReadableDartEntry(unitSource); 4320 DartEntry dartEntry = getReadableDartEntry(unitSource);
4023 if (dartEntry == null) { 4321 if (dartEntry == null) {
4024 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f or non-Dart file: ${unitSource.fullName}"); 4322 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f or non-Dart file: ${unitSource.fullName}");
4025 } 4323 }
4026 Source librarySource = libraryElement.source; 4324 Source librarySource = libraryElement.source;
4027 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, Da rtEntry.RESOLVED_UNIT); 4325 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, Da rtEntry.RESOLVED_UNIT);
4028 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart Entry.getValue2(DartEntry.RESOLVED_UNIT, librarySource)); 4326 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart Entry.getValue2(DartEntry.RESOLVED_UNIT, librarySource));
4029 } 4327 }
4030 4328
4329 TimestampedData<Token> internalScanTokenStream(Source source) {
4330 DartEntry dartEntry = getReadableDartEntry(source);
4331 if (dartEntry == null) {
4332 throw new AnalysisException.con1("internalScanTokenStream invoked for non- Dart file: ${source.fullName}");
4333 }
4334 dartEntry = cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM);
4335 return new TimestampedData<Token>(dartEntry.modificationTime, dartEntry.getV alue(DartEntry.TOKEN_STREAM));
4336 }
4337
4031 bool isClientLibrary(Source librarySource) { 4338 bool isClientLibrary(Source librarySource) {
4032 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); 4339 SourceEntry sourceEntry = getReadableSourceEntry(librarySource);
4033 if (sourceEntry is DartEntry) { 4340 if (sourceEntry is DartEntry) {
4034 DartEntry dartEntry = sourceEntry; 4341 DartEntry dartEntry = sourceEntry;
4035 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE ntry.IS_LAUNCHABLE); 4342 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE ntry.IS_LAUNCHABLE);
4036 } 4343 }
4037 return false; 4344 return false;
4038 } 4345 }
4039 4346
4040 bool isServerLibrary(Source librarySource) { 4347 bool isServerLibrary(Source librarySource) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4083 } 4390 }
4084 String taskDescriptor = task.toString(); 4391 String taskDescriptor = task.toString();
4085 if (_recentTasks.add(taskDescriptor)) { 4392 if (_recentTasks.add(taskDescriptor)) {
4086 logInformation("Performing task: ${taskDescriptor}"); 4393 logInformation("Performing task: ${taskDescriptor}");
4087 } else { 4394 } else {
4088 logInformation("*** Performing repeated task: ${taskDescriptor}"); 4395 logInformation("*** Performing repeated task: ${taskDescriptor}");
4089 } 4396 }
4090 int performStart = JavaSystem.currentTimeMillis(); 4397 int performStart = JavaSystem.currentTimeMillis();
4091 try { 4398 try {
4092 task.perform(_resultRecorder); 4399 task.perform(_resultRecorder);
4400 } on ObsoleteSourceAnalysisException catch (exception) {
4401 AnalysisEngine.instance.logger.logInformation3("Could not perform analysis task: ${taskDescriptor}", exception);
4093 } on AnalysisException catch (exception) { 4402 } on AnalysisException catch (exception) {
4094 if (exception.cause is! JavaIOException) { 4403 if (exception.cause is! JavaIOException) {
4095 AnalysisEngine.instance.logger.logError2("Internal error while performin g the task: ${task}", exception); 4404 AnalysisEngine.instance.logger.logError2("Internal error while performin g the task: ${task}", exception);
4096 } 4405 }
4097 } 4406 }
4098 int performEnd = JavaSystem.currentTimeMillis(); 4407 int performEnd = JavaSystem.currentTimeMillis();
4099 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r untimeType.toString(), performEnd - performStart); 4408 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r untimeType.toString(), performEnd - performStart);
4100 } 4409 }
4101 4410
4102 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 4411 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
4182 for (int i = 0; i < count; i++) { 4491 for (int i = 0; i < count; i++) {
4183 _priorityOrder[i] = sources[i]; 4492 _priorityOrder[i] = sources[i];
4184 } 4493 }
4185 } 4494 }
4186 } 4495 }
4187 } 4496 }
4188 4497
4189 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) { 4498 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) {
4190 { 4499 {
4191 _recentTasks.clear(); 4500 _recentTasks.clear();
4192 String originalContents = _sourceFactory.setContents(source, contents); 4501 String originalContents = _contentCache.setContents(source, contents);
4193 if (contents != null) { 4502 if (contents != null) {
4194 if (contents != originalContents) { 4503 if (contents != originalContents) {
4195 if (_options.incremental) { 4504 if (_options.incremental) {
4196 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increme ntalAnalysisCache, source, originalContents, contents, offset, oldLength, newLen gth, getReadableSourceEntry(source)); 4505 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increme ntalAnalysisCache, source, originalContents, contents, offset, oldLength, newLen gth, getReadableSourceEntry(source));
4197 } 4506 }
4198 sourceChanged(source); 4507 sourceChanged(source);
4199 } 4508 }
4200 } else if (originalContents != null) { 4509 } else if (originalContents != null) {
4201 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source); 4510 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source);
4202 sourceChanged(source); 4511 sourceChanged(source);
4203 } 4512 }
4204 } 4513 }
4205 } 4514 }
4206 4515
4207 void setContents(Source source, String contents) { 4516 void setContents(Source source, String contents) {
4208 { 4517 {
4209 _recentTasks.clear(); 4518 _recentTasks.clear();
4210 String originalContents = _sourceFactory.setContents(source, contents); 4519 String originalContents = _contentCache.setContents(source, contents);
4211 if (contents != null) { 4520 if (contents != null) {
4212 if (contents != originalContents) { 4521 if (contents != originalContents) {
4213 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementa lAnalysisCache, source); 4522 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementa lAnalysisCache, source);
4214 sourceChanged(source); 4523 sourceChanged(source);
4215 } 4524 }
4216 } else if (originalContents != null) { 4525 } else if (originalContents != null) {
4217 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source); 4526 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source);
4218 sourceChanged(source); 4527 sourceChanged(source);
4219 } 4528 }
4220 } 4529 }
4221 } 4530 }
4222 4531
4223 void set sourceFactory(SourceFactory factory) { 4532 void set sourceFactory(SourceFactory factory) {
4224 { 4533 {
4225 if (identical(_sourceFactory, factory)) { 4534 if (identical(_sourceFactory, factory)) {
4226 return; 4535 return;
4227 } else if (factory.context != null) { 4536 } else if (factory.context != null) {
4228 throw new IllegalStateException("Source factories cannot be shared betwe en contexts"); 4537 throw new IllegalStateException("Source factories cannot be shared betwe en contexts");
4229 } 4538 }
4230 if (_sourceFactory != null) { 4539 if (_sourceFactory != null) {
4231 _sourceFactory.context = null; 4540 _sourceFactory.context = null;
4232 } 4541 }
4233 factory.context = this; 4542 factory.context = this;
4234 _sourceFactory = factory; 4543 _sourceFactory = factory;
4235 invalidateAllResolutionInformation(); 4544 invalidateAllResolutionInformation();
4236 } 4545 }
4237 } 4546 }
4238 4547
4239 Iterable<Source> sourcesToResolve(List<Source> changedSources) {
4240 List<Source> librarySources = new List<Source>();
4241 for (Source source in changedSources) {
4242 if (identical(computeKindOf(source), SourceKind.LIBRARY)) {
4243 librarySources.add(source);
4244 }
4245 }
4246 return librarySources;
4247 }
4248
4249 /** 4548 /**
4250 * Record the results produced by performing a [ResolveDartLibraryTask]. If th e results were 4549 * Record the results produced by performing a [ResolveDartLibraryTask]. If th e results were
4251 * computed from data that is now out-of-date, then the results will not be re corded. 4550 * computed from data that is now out-of-date, then the results will not be re corded.
4252 * 4551 *
4253 * @param task the task that was performed 4552 * @param task the task that was performed
4254 * @return an entry containing the computed results 4553 * @return an entry containing the computed results
4255 * @throws AnalysisException if the results could not be recorded 4554 * @throws AnalysisException if the results could not be recorded
4256 */ 4555 */
4257 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { 4556 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) {
4258 LibraryResolver resolver = task.libraryResolver; 4557 LibraryResolver resolver = task.libraryResolver;
(...skipping 28 matching lines...) Expand all
4287 if (allModificationTimesMatch(resolvedLibraries)) { 4586 if (allModificationTimesMatch(resolvedLibraries)) {
4288 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 4587 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
4289 RecordingErrorListener errorListener = resolver.errorListener; 4588 RecordingErrorListener errorListener = resolver.errorListener;
4290 for (Library library in resolvedLibraries) { 4589 for (Library library in resolvedLibraries) {
4291 Source librarySource = library.librarySource; 4590 Source librarySource = library.librarySource;
4292 for (Source source in library.compilationUnitSources) { 4591 for (Source source in library.compilationUnitSources) {
4293 CompilationUnit unit = library.getAST(source); 4592 CompilationUnit unit = library.getAST(source);
4294 List<AnalysisError> errors = errorListener.getErrors2(source); 4593 List<AnalysisError> errors = errorListener.getErrors2(source);
4295 LineInfo lineInfo = getLineInfo(source); 4594 LineInfo lineInfo = getLineInfo(source);
4296 DartEntry dartEntry = _cache.get(source) as DartEntry; 4595 DartEntry dartEntry = _cache.get(source) as DartEntry;
4297 int sourceTime = source.modificationStamp; 4596 int sourceTime = getModificationStamp(source);
4298 if (dartEntry.modificationTime != sourceTime) { 4597 if (dartEntry.modificationTime != sourceTime) {
4299 // The source has changed without the context being notified. Si mulate notification. 4598 // The source has changed without the context being notified. Si mulate notification.
4300 sourceChanged(source); 4599 sourceChanged(source);
4301 dartEntry = getReadableDartEntry(source); 4600 dartEntry = getReadableDartEntry(source);
4302 if (dartEntry == null) { 4601 if (dartEntry == null) {
4303 throw new AnalysisException.con1("A Dart file became a non-Dar t file: ${source.fullName}"); 4602 throw new AnalysisException.con1("A Dart file became a non-Dar t file: ${source.fullName}");
4304 } 4603 }
4305 } 4604 }
4306 DartEntryImpl dartCopy = dartEntry.writableCopy; 4605 DartEntryImpl dartCopy = dartEntry.writableCopy;
4307 if (thrownException == null) { 4606 if (thrownException == null) {
(...skipping 23 matching lines...) Expand all
4331 } 4630 }
4332 } 4631 }
4333 } else { 4632 } else {
4334 PrintStringWriter writer = new PrintStringWriter(); 4633 PrintStringWriter writer = new PrintStringWriter();
4335 writer.println("Library resolution results discarded for"); 4634 writer.println("Library resolution results discarded for");
4336 for (Library library in resolvedLibraries) { 4635 for (Library library in resolvedLibraries) {
4337 for (Source source in library.compilationUnitSources) { 4636 for (Source source in library.compilationUnitSources) {
4338 DartEntry dartEntry = getReadableDartEntry(source); 4637 DartEntry dartEntry = getReadableDartEntry(source);
4339 if (dartEntry != null) { 4638 if (dartEntry != null) {
4340 int resultTime = library.getModificationTime(source); 4639 int resultTime = library.getModificationTime(source);
4341 writer.println(" ${debuggingString(source)}; sourceTime = ${sou rce.modificationStamp}, resultTime = ${resultTime}, cacheTime = ${dartEntry.modi ficationTime}"); 4640 writer.println(" ${debuggingString(source)}; sourceTime = ${get ModificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry. modificationTime}");
4342 DartEntryImpl dartCopy = dartEntry.writableCopy; 4641 DartEntryImpl dartCopy = dartEntry.writableCopy;
4343 if (thrownException == null || resultTime >= 0) { 4642 if (thrownException == null || resultTime >= 0) {
4344 // 4643 //
4345 // The analysis was performed on out-of-date sources. Mark the cache so that the 4644 // The analysis was performed on out-of-date sources. Mark the cache so that the
4346 // sources will be re-analyzed using the up-to-date sources. 4645 // sources will be re-analyzed using the up-to-date sources.
4347 // 4646 //
4348 dartCopy.recordResolutionNotInProcess(); 4647 dartCopy.recordResolutionNotInProcess();
4349 } else { 4648 } else {
4350 // 4649 //
4351 // We could not determine whether the sources were up-to-date or out-of-date. Mark 4650 // We could not determine whether the sources were up-to-date or out-of-date. Mark
4352 // the cache so that we won't attempt to re-analyze the source s until there's a 4651 // the cache so that we won't attempt to re-analyze the source s until there's a
4353 // good chance that we'll be able to do so without error. 4652 // good chance that we'll be able to do so without error.
4354 // 4653 //
4355 dartCopy.recordResolutionError(); 4654 dartCopy.recordResolutionError();
4356 _cache.remove(source); 4655 _cache.remove(source);
4357 } 4656 }
4358 dartCopy.exception = thrownException; 4657 dartCopy.exception = thrownException;
4359 _cache.put(source, dartCopy); 4658 _cache.put(source, dartCopy);
4360 if (source == unitSource) { 4659 if (source == unitSource) {
4361 unitEntry = dartCopy; 4660 unitEntry = dartCopy;
4362 } 4661 }
4363 } else { 4662 } else {
4364 writer.println(" ${debuggingString(source)}; sourceTime = ${sou rce.modificationStamp}, no entry"); 4663 writer.println(" ${debuggingString(source)}; sourceTime = ${get ModificationStamp(source)}, no entry");
4365 } 4664 }
4366 } 4665 }
4367 } 4666 }
4368 logInformation(writer.toString()); 4667 logInformation(writer.toString());
4369 } 4668 }
4370 } 4669 }
4371 } 4670 }
4372 if (thrownException != null) { 4671 if (thrownException != null) {
4373 throw thrownException; 4672 throw thrownException;
4374 } 4673 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4422 bool allModificationTimesMatch(Set<Library> resolvedLibraries) { 4721 bool allModificationTimesMatch(Set<Library> resolvedLibraries) {
4423 bool allTimesMatch = true; 4722 bool allTimesMatch = true;
4424 for (Library library in resolvedLibraries) { 4723 for (Library library in resolvedLibraries) {
4425 for (Source source in library.compilationUnitSources) { 4724 for (Source source in library.compilationUnitSources) {
4426 DartEntry dartEntry = getReadableDartEntry(source); 4725 DartEntry dartEntry = getReadableDartEntry(source);
4427 if (dartEntry == null) { 4726 if (dartEntry == null) {
4428 // This shouldn't be possible because we should never have performed t he task if the 4727 // This shouldn't be possible because we should never have performed t he task if the
4429 // source didn't represent a Dart file, but check to be safe. 4728 // source didn't represent a Dart file, but check to be safe.
4430 throw new AnalysisException.con1("Internal error: attempting to resolv e non-Dart file as a Dart file: ${source.fullName}"); 4729 throw new AnalysisException.con1("Internal error: attempting to resolv e non-Dart file as a Dart file: ${source.fullName}");
4431 } 4730 }
4432 int sourceTime = source.modificationStamp; 4731 int sourceTime = getModificationStamp(source);
4433 int resultTime = library.getModificationTime(source); 4732 int resultTime = library.getModificationTime(source);
4434 if (sourceTime != resultTime) { 4733 if (sourceTime != resultTime) {
4435 // The source has changed without the context being notified. Simulate notification. 4734 // The source has changed without the context being notified. Simulate notification.
4436 sourceChanged(source); 4735 sourceChanged(source);
4437 allTimesMatch = false; 4736 allTimesMatch = false;
4438 } 4737 }
4439 } 4738 }
4440 } 4739 }
4441 return allTimesMatch; 4740 return allTimesMatch;
4442 } 4741 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4501 4800
4502 /** 4801 /**
4503 * Given a source for a Dart file, return a cache entry in which the state of the data represented 4802 * Given a source for a Dart file, return a cache entry in which the state of the data represented
4504 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR]. This 4803 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR]. This
4505 * method assumes that the data can be produced by parsing the source if it is not already cached. 4804 * method assumes that the data can be produced by parsing the source if it is not already cached.
4506 * 4805 *
4507 * @param source the source representing the Dart file 4806 * @param source the source representing the Dart file
4508 * @param dartEntry the cache entry associated with the Dart file 4807 * @param dartEntry the cache entry associated with the Dart file
4509 * @param descriptor the descriptor representing the data to be returned 4808 * @param descriptor the descriptor representing the data to be returned
4510 * @return a cache entry containing the required data 4809 * @return a cache entry containing the required data
4511 * @throws AnalysisException if data could not be returned because the source could not be 4810 * @throws AnalysisException if data could not be returned because the source could not be parsed
4512 * resolved
4513 */ 4811 */
4514 DartEntry cacheDartParseData(Source source, DartEntry dartEntry, DataDescripto r descriptor) { 4812 DartEntry cacheDartParseData(Source source, DartEntry dartEntry, DataDescripto r descriptor) {
4515 if (identical(descriptor, DartEntry.PARSED_UNIT)) { 4813 if (identical(descriptor, DartEntry.PARSED_UNIT)) {
4516 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; 4814 CompilationUnit unit = dartEntry.anyParsedCompilationUnit;
4517 if (unit != null) { 4815 if (unit != null) {
4518 return dartEntry; 4816 return dartEntry;
4519 } 4817 }
4520 } 4818 }
4521 // 4819 //
4522 // Check to see whether we already have the information being requested. 4820 // Check to see whether we already have the information being requested.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4558 // 4856 //
4559 // TODO(brianwilkerson) As an optimization, if we already have the element model for the 4857 // TODO(brianwilkerson) As an optimization, if we already have the element model for the
4560 // library we can use ResolveDartUnitTask to produce the resolved AST stru cture much faster. 4858 // library we can use ResolveDartUnitTask to produce the resolved AST stru cture much faster.
4561 dartEntry = new ResolveDartLibraryTask(this, unitSource, librarySource).pe rform(_resultRecorder) as DartEntry; 4859 dartEntry = new ResolveDartLibraryTask(this, unitSource, librarySource).pe rform(_resultRecorder) as DartEntry;
4562 state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.getState(de scriptor) : dartEntry.getState2(descriptor, librarySource); 4860 state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.getState(de scriptor) : dartEntry.getState2(descriptor, librarySource);
4563 } 4861 }
4564 return dartEntry; 4862 return dartEntry;
4565 } 4863 }
4566 4864
4567 /** 4865 /**
4866 * Given a source for a Dart file, return a cache entry in which the state of the data represented
4867 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR]. This
4868 * method assumes that the data can be produced by scanning the source if it i s not already
4869 * cached.
4870 *
4871 * @param source the source representing the Dart file
4872 * @param dartEntry the cache entry associated with the Dart file
4873 * @param descriptor the descriptor representing the data to be returned
4874 * @return a cache entry containing the required data
4875 * @throws AnalysisException if data could not be returned because the source could not be scanned
4876 */
4877 DartEntry cacheDartScanData(Source source, DartEntry dartEntry, DataDescriptor descriptor) {
4878 //
4879 // Check to see whether we already have the information being requested.
4880 //
4881 CacheState state = dartEntry.getState(descriptor);
4882 while (state != CacheState.ERROR && state != CacheState.VALID) {
4883 //
4884 // If not, compute the information. Unless the modification date of the so urce continues to
4885 // change, this loop will eventually terminate.
4886 //
4887 // TODO(brianwilkerson) Convert this to get the contents from the cache. ( I'm not sure how
4888 // that would work in an asynchronous environment.)
4889 try {
4890 dartEntry = new ScanDartTask(this, source, getContents(source)).perform( _resultRecorder) as DartEntry;
4891 } on AnalysisException catch (exception) {
4892 throw exception;
4893 } on JavaException catch (exception) {
4894 throw new AnalysisException.con3(exception);
4895 }
4896 state = dartEntry.getState(descriptor);
4897 }
4898 return dartEntry;
4899 }
4900
4901 /**
4568 * Given a source for a Dart file and the library that contains it, return a c ache entry in which 4902 * Given a source for a Dart file and the library that contains it, return a c ache entry in which
4569 * the state of the data represented by the given descriptor is either [CacheS tate#VALID] or 4903 * the state of the data represented by the given descriptor is either [CacheS tate#VALID] or
4570 * [CacheState#ERROR]. This method assumes that the data can be produced by ve rifying the 4904 * [CacheState#ERROR]. This method assumes that the data can be produced by ve rifying the
4571 * source in the given library if the data is not already cached. 4905 * source in the given library if the data is not already cached.
4572 * 4906 *
4573 * @param unitSource the source representing the Dart file 4907 * @param unitSource the source representing the Dart file
4574 * @param librarySource the source representing the library containing the Dar t file 4908 * @param librarySource the source representing the library containing the Dar t file
4575 * @param dartEntry the cache entry associated with the Dart file 4909 * @param dartEntry the cache entry associated with the Dart file
4576 * @param descriptor the descriptor representing the data to be returned 4910 * @param descriptor the descriptor representing the data to be returned
4577 * @return a cache entry containing the required data 4911 * @return a cache entry containing the required data
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
4705 * Create a source information object suitable for the given source. Return th e source information 5039 * Create a source information object suitable for the given source. Return th e source information
4706 * object that was created, or `null` if the source should not be tracked by t his context. 5040 * object that was created, or `null` if the source should not be tracked by t his context.
4707 * 5041 *
4708 * @param source the source for which an information object is being created 5042 * @param source the source for which an information object is being created
4709 * @return the source information object that was created 5043 * @return the source information object that was created
4710 */ 5044 */
4711 SourceEntry createSourceEntry(Source source) { 5045 SourceEntry createSourceEntry(Source source) {
4712 String name = source.shortName; 5046 String name = source.shortName;
4713 if (AnalysisEngine.isHtmlFileName(name)) { 5047 if (AnalysisEngine.isHtmlFileName(name)) {
4714 HtmlEntryImpl htmlEntry = new HtmlEntryImpl(); 5048 HtmlEntryImpl htmlEntry = new HtmlEntryImpl();
4715 htmlEntry.modificationTime = source.modificationStamp; 5049 htmlEntry.modificationTime = getModificationStamp(source);
4716 _cache.put(source, htmlEntry); 5050 _cache.put(source, htmlEntry);
4717 return htmlEntry; 5051 return htmlEntry;
4718 } else { 5052 } else {
4719 DartEntryImpl dartEntry = new DartEntryImpl(); 5053 DartEntryImpl dartEntry = new DartEntryImpl();
4720 dartEntry.modificationTime = source.modificationStamp; 5054 dartEntry.modificationTime = getModificationStamp(source);
4721 _cache.put(source, dartEntry); 5055 _cache.put(source, dartEntry);
4722 return dartEntry; 5056 return dartEntry;
4723 } 5057 }
4724 } 5058 }
4725 5059
4726 /** 5060 /**
4727 * Return a string with debugging information about the given source (the full name and 5061 * Return a string with debugging information about the given source (the full name and
4728 * modification stamp of the source). 5062 * modification stamp of the source).
4729 * 5063 *
4730 * @param source the source for which a debugging string is to be produced 5064 * @param source the source for which a debugging string is to be produced
4731 * @return debugging information about the given source 5065 * @return debugging information about the given source
4732 */ 5066 */
4733 String debuggingString(Source source) => "'${source.fullName}' [${source.modif icationStamp}]"; 5067 String debuggingString(Source source) => "'${source.fullName}' [${getModificat ionStamp(source)}]";
4734 5068
4735 /** 5069 /**
4736 * Return an array containing all of the change notices that are waiting to be returned. If there 5070 * Return an array containing all of the change notices that are waiting to be returned. If there
4737 * are no notices, then return either `null` or an empty array, depending on t he value of 5071 * are no notices, then return either `null` or an empty array, depending on t he value of
4738 * the argument. 5072 * the argument.
4739 * 5073 *
4740 * @param nullIfEmpty `true` if `null` should be returned when there are no no tices 5074 * @param nullIfEmpty `true` if `null` should be returned when there are no no tices
4741 * @return the change notices that are waiting to be returned 5075 * @return the change notices that are waiting to be returned
4742 */ 5076 */
4743 List<ChangeNotice> getChangeNotices(bool nullIfEmpty) { 5077 List<ChangeNotice> getChangeNotices(bool nullIfEmpty) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4780 * @param descriptor the descriptor representing the data to be returned 5114 * @param descriptor the descriptor representing the data to be returned
4781 * @param defaultValue the value to be returned if the source is not a Dart fi le 5115 * @param defaultValue the value to be returned if the source is not a Dart fi le
4782 * @return the requested data about the given source 5116 * @return the requested data about the given source
4783 * @throws AnalysisException if data could not be returned because the source could not be parsed 5117 * @throws AnalysisException if data could not be returned because the source could not be parsed
4784 */ 5118 */
4785 Object getDartDependencyData2(Source source, DataDescriptor descriptor, Object defaultValue) { 5119 Object getDartDependencyData2(Source source, DataDescriptor descriptor, Object defaultValue) {
4786 DartEntry dartEntry = getReadableDartEntry(source); 5120 DartEntry dartEntry = getReadableDartEntry(source);
4787 if (dartEntry == null) { 5121 if (dartEntry == null) {
4788 return defaultValue; 5122 return defaultValue;
4789 } 5123 }
4790 return getDartDependencyData(source, dartEntry, descriptor); 5124 try {
5125 return getDartDependencyData(source, dartEntry, descriptor);
5126 } on ObsoleteSourceAnalysisException catch (exception) {
5127 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri ptor.toString()}", exception);
5128 return defaultValue;
5129 }
4791 } 5130 }
4792 5131
4793 /** 5132 /**
4794 * Given a source for a Dart file and the library that contains it, return the data represented by 5133 * Given a source for a Dart file and the library that contains it, return the data represented by
4795 * the given descriptor that is associated with that source. This method assum es that the data can 5134 * the given descriptor that is associated with that source. This method assum es that the data can
4796 * be produced by generating hints for the library if it is not already cached . 5135 * be produced by generating hints for the library if it is not already cached .
4797 * 5136 *
4798 * @param unitSource the source representing the Dart file 5137 * @param unitSource the source representing the Dart file
4799 * @param librarySource the source representing the library containing the Dar t file 5138 * @param librarySource the source representing the library containing the Dar t file
4800 * @param dartEntry the entry representing the Dart file 5139 * @param dartEntry the entry representing the Dart file
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4840 * @param descriptor the descriptor representing the data to be returned 5179 * @param descriptor the descriptor representing the data to be returned
4841 * @param defaultValue the value to be returned if the source is not a Dart fi le 5180 * @param defaultValue the value to be returned if the source is not a Dart fi le
4842 * @return the requested data about the given source 5181 * @return the requested data about the given source
4843 * @throws AnalysisException if data could not be returned because the source could not be parsed 5182 * @throws AnalysisException if data could not be returned because the source could not be parsed
4844 */ 5183 */
4845 Object getDartParseData2(Source source, DataDescriptor descriptor, Object defa ultValue) { 5184 Object getDartParseData2(Source source, DataDescriptor descriptor, Object defa ultValue) {
4846 DartEntry dartEntry = getReadableDartEntry(source); 5185 DartEntry dartEntry = getReadableDartEntry(source);
4847 if (dartEntry == null) { 5186 if (dartEntry == null) {
4848 return defaultValue; 5187 return defaultValue;
4849 } 5188 }
4850 return getDartParseData(source, dartEntry, descriptor); 5189 try {
5190 return getDartParseData(source, dartEntry, descriptor);
5191 } on ObsoleteSourceAnalysisException catch (exception) {
5192 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri ptor.toString()}", exception);
5193 return defaultValue;
5194 }
4851 } 5195 }
4852 5196
4853 /** 5197 /**
4854 * Given a source for a Dart file and the library that contains it, return the data represented by 5198 * Given a source for a Dart file and the library that contains it, return the data represented by
4855 * the given descriptor that is associated with that source. This method assum es that the data can 5199 * the given descriptor that is associated with that source. This method assum es that the data can
4856 * be produced by resolving the source in the context of the library if it is not already cached. 5200 * be produced by resolving the source in the context of the library if it is not already cached.
4857 * 5201 *
4858 * @param unitSource the source representing the Dart file 5202 * @param unitSource the source representing the Dart file
4859 * @param librarySource the source representing the library containing the Dar t file 5203 * @param librarySource the source representing the library containing the Dar t file
4860 * @param dartEntry the entry representing the Dart file 5204 * @param dartEntry the entry representing the Dart file
(...skipping 24 matching lines...) Expand all
4885 * @param defaultValue the value to be returned if the source is not a Dart fi le 5229 * @param defaultValue the value to be returned if the source is not a Dart fi le
4886 * @return the requested data about the given source 5230 * @return the requested data about the given source
4887 * @throws AnalysisException if data could not be returned because the source could not be 5231 * @throws AnalysisException if data could not be returned because the source could not be
4888 * resolved 5232 * resolved
4889 */ 5233 */
4890 Object getDartResolutionData2(Source unitSource, Source librarySource, DataDes criptor descriptor, Object defaultValue) { 5234 Object getDartResolutionData2(Source unitSource, Source librarySource, DataDes criptor descriptor, Object defaultValue) {
4891 DartEntry dartEntry = getReadableDartEntry(unitSource); 5235 DartEntry dartEntry = getReadableDartEntry(unitSource);
4892 if (dartEntry == null) { 5236 if (dartEntry == null) {
4893 return defaultValue; 5237 return defaultValue;
4894 } 5238 }
4895 return getDartResolutionData(unitSource, librarySource, dartEntry, descripto r); 5239 try {
5240 return getDartResolutionData(unitSource, librarySource, dartEntry, descrip tor);
5241 } on ObsoleteSourceAnalysisException catch (exception) {
5242 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri ptor.toString()}", exception);
5243 return defaultValue;
5244 }
4896 } 5245 }
4897 5246
4898 /** 5247 /**
5248 * Given a source for a Dart file, return the data represented by the given de scriptor that is
5249 * associated with that source. This method assumes that the data can be produ ced by scanning the
5250 * source if it is not already cached.
5251 *
5252 * @param source the source representing the Dart file
5253 * @param dartEntry the cache entry associated with the Dart file
5254 * @param descriptor the descriptor representing the data to be returned
5255 * @return the requested data about the given source
5256 * @throws AnalysisException if data could not be returned because the source could not be scanned
5257 */
5258 Object getDartScanData(Source source, DartEntry dartEntry, DataDescriptor desc riptor) {
5259 dartEntry = cacheDartScanData(source, dartEntry, descriptor);
5260 return dartEntry.getValue(descriptor);
5261 }
5262
5263 /**
5264 * Given a source for a Dart file, return the data represented by the given de scriptor that is
5265 * associated with that source, or the given default value if the source is no t a Dart file. This
5266 * method assumes that the data can be produced by scanning the source if it i s not already
5267 * cached.
5268 *
5269 * @param source the source representing the Dart file
5270 * @param descriptor the descriptor representing the data to be returned
5271 * @param defaultValue the value to be returned if the source is not a Dart fi le
5272 * @return the requested data about the given source
5273 * @throws AnalysisException if data could not be returned because the source could not be scanned
5274 */
5275 Object getDartScanData2(Source source, DataDescriptor descriptor, Object defau ltValue) {
5276 DartEntry dartEntry = getReadableDartEntry(source);
5277 if (dartEntry == null) {
5278 return defaultValue;
5279 }
5280 try {
5281 return getDartScanData(source, dartEntry, descriptor);
5282 } on ObsoleteSourceAnalysisException catch (exception) {
5283 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri ptor.toString()}", exception);
5284 return defaultValue;
5285 }
5286 }
5287
5288 /**
4899 * Given a source for a Dart file and the library that contains it, return the data represented by 5289 * Given a source for a Dart file and the library that contains it, return the data represented by
4900 * the given descriptor that is associated with that source. This method assum es that the data can 5290 * the given descriptor that is associated with that source. This method assum es that the data can
4901 * be produced by verifying the source within the given library if it is not a lready cached. 5291 * be produced by verifying the source within the given library if it is not a lready cached.
4902 * 5292 *
4903 * @param unitSource the source representing the Dart file 5293 * @param unitSource the source representing the Dart file
4904 * @param librarySource the source representing the library containing the Dar t file 5294 * @param librarySource the source representing the library containing the Dar t file
4905 * @param dartEntry the entry representing the Dart file 5295 * @param dartEntry the entry representing the Dart file
4906 * @param descriptor the descriptor representing the data to be returned 5296 * @param descriptor the descriptor representing the data to be returned
4907 * @return the requested data about the given source 5297 * @return the requested data about the given source
4908 * @throws AnalysisException if data could not be returned because the source could not be 5298 * @throws AnalysisException if data could not be returned because the source could not be
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4948 * @param defaultValue the value to be returned if the source is not an HTML f ile 5338 * @param defaultValue the value to be returned if the source is not an HTML f ile
4949 * @return the requested data about the given source 5339 * @return the requested data about the given source
4950 * @throws AnalysisException if data could not be returned because the source could not be 5340 * @throws AnalysisException if data could not be returned because the source could not be
4951 * resolved 5341 * resolved
4952 */ 5342 */
4953 Object getHtmlResolutionData(Source source, DataDescriptor descriptor, Object defaultValue) { 5343 Object getHtmlResolutionData(Source source, DataDescriptor descriptor, Object defaultValue) {
4954 HtmlEntry htmlEntry = getReadableHtmlEntry(source); 5344 HtmlEntry htmlEntry = getReadableHtmlEntry(source);
4955 if (htmlEntry == null) { 5345 if (htmlEntry == null) {
4956 return defaultValue; 5346 return defaultValue;
4957 } 5347 }
4958 return getHtmlResolutionData2(source, htmlEntry, descriptor); 5348 try {
5349 return getHtmlResolutionData2(source, htmlEntry, descriptor);
5350 } on ObsoleteSourceAnalysisException catch (exception) {
5351 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri ptor.toString()}", exception);
5352 return defaultValue;
5353 }
4959 } 5354 }
4960 5355
4961 /** 5356 /**
4962 * Given a source for an HTML file, return the data represented by the given d escriptor that is 5357 * Given a source for an HTML file, return the data represented by the given d escriptor that is
4963 * associated with that source. This method assumes that the data can be produ ced by resolving the 5358 * associated with that source. This method assumes that the data can be produ ced by resolving the
4964 * source if it is not already cached. 5359 * source if it is not already cached.
4965 * 5360 *
4966 * @param source the source representing the HTML file 5361 * @param source the source representing the HTML file
4967 * @param htmlEntry the entry representing the HTML file 5362 * @param htmlEntry the entry representing the HTML file
4968 * @param descriptor the descriptor representing the data to be returned 5363 * @param descriptor the descriptor representing the data to be returned
(...skipping 11 matching lines...) Expand all
4980 5375
4981 /** 5376 /**
4982 * Look through the cache for a task that needs to be performed. Return the ta sk that was found, 5377 * Look through the cache for a task that needs to be performed. Return the ta sk that was found,
4983 * or `null` if there is no more work to be done. 5378 * or `null` if there is no more work to be done.
4984 * 5379 *
4985 * @return the next task that needs to be performed 5380 * @return the next task that needs to be performed
4986 */ 5381 */
4987 AnalysisTask get nextAnalysisTask { 5382 AnalysisTask get nextAnalysisTask {
4988 { 5383 {
4989 bool hintsEnabled = _options.hint; 5384 bool hintsEnabled = _options.hint;
5385 bool sdkErrorsEnabled = _options.generateSdkErrors;
4990 // 5386 //
4991 // Look for incremental analysis 5387 // Look for incremental analysis
4992 // 5388 //
4993 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork ()) { 5389 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork ()) {
4994 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalys isCache); 5390 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalys isCache);
4995 _incrementalAnalysisCache = null; 5391 _incrementalAnalysisCache = null;
4996 return task; 5392 return task;
4997 } 5393 }
4998 // 5394 //
4999 // Look for a priority source that needs to be analyzed. 5395 // Look for a priority source that needs to be analyzed.
5000 // 5396 //
5001 for (Source source in _priorityOrder) { 5397 for (Source source in _priorityOrder) {
5002 AnalysisTask task = getNextAnalysisTask2(source, _cache.get(source), tru e, hintsEnabled); 5398 AnalysisTask task = getNextAnalysisTask2(source, _cache.get(source), tru e, hintsEnabled, sdkErrorsEnabled);
5003 if (task != null) { 5399 if (task != null) {
5004 return task; 5400 return task;
5005 } 5401 }
5006 } 5402 }
5007 // 5403 //
5008 // Look for a non-priority source that needs to be analyzed. 5404 // Look for a non-priority source that needs to be analyzed.
5009 // 5405 //
5010 Source source = _workManager.nextSource; 5406 Source source = _workManager.nextSource;
5011 while (source != null) { 5407 while (source != null) {
5012 AnalysisTask task = getNextAnalysisTask2(source, _cache.get(source), fal se, hintsEnabled); 5408 AnalysisTask task = getNextAnalysisTask2(source, _cache.get(source), fal se, hintsEnabled, sdkErrorsEnabled);
5013 if (task != null) { 5409 if (task != null) {
5014 return task; 5410 return task;
5015 } 5411 }
5016 _workManager.remove(source); 5412 _workManager.remove(source);
5017 source = _workManager.nextSource; 5413 source = _workManager.nextSource;
5018 } 5414 }
5019 // // 5415 // //
5020 // // Look for a non-priority source that needs to be analyzed and wa s missed by the loop above. 5416 // // Look for a non-priority source that needs to be analyzed and wa s missed by the loop above.
5021 // // 5417 // //
5022 // for (Map.Entry<Source, SourceEntry> entry : cache.entrySet()) { 5418 // for (Map.Entry<Source, SourceEntry> entry : cache.entrySet()) {
(...skipping 12 matching lines...) Expand all
5035 * Look at the given source to see whether a task needs to be performed relate d to it. Return the 5431 * Look at the given source to see whether a task needs to be performed relate d to it. Return the
5036 * task that should be performed, or `null` if there is no more work to be don e for the 5432 * task that should be performed, or `null` if there is no more work to be don e for the
5037 * source. 5433 * source.
5038 * 5434 *
5039 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5435 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5040 * 5436 *
5041 * @param source the source to be checked 5437 * @param source the source to be checked
5042 * @param sourceEntry the cache entry associated with the source 5438 * @param sourceEntry the cache entry associated with the source
5043 * @param isPriority `true` if the source is a priority source 5439 * @param isPriority `true` if the source is a priority source
5044 * @param hintsEnabled `true` if hints are currently enabled 5440 * @param hintsEnabled `true` if hints are currently enabled
5441 * @param sdkErrorsEnabled `true` if errors, warnings and hints should be gene rated for
5442 * sources in the SDK
5045 * @return the next task that needs to be performed for the given source 5443 * @return the next task that needs to be performed for the given source
5046 */ 5444 */
5047 AnalysisTask getNextAnalysisTask2(Source source, SourceEntry sourceEntry, bool isPriority, bool hintsEnabled) { 5445 AnalysisTask getNextAnalysisTask2(Source source, SourceEntry sourceEntry, bool isPriority, bool hintsEnabled, bool sdkErrorsEnabled) {
5048 if (sourceEntry is DartEntry) { 5446 if (sourceEntry is DartEntry) {
5049 DartEntry dartEntry = sourceEntry; 5447 DartEntry dartEntry = sourceEntry;
5448 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS);
5449 if (identical(scanErrorsState, CacheState.INVALID) || (isPriority && ident ical(scanErrorsState, CacheState.FLUSHED))) {
5450 // TODO(brianwilkerson) Convert this to get the contents from the cache or to asynchronously
5451 // request the contents if they are not in the cache.
5452 try {
5453 DartEntryImpl dartCopy = dartEntry.writableCopy;
5454 dartCopy.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS);
5455 _cache.put(source, dartCopy);
5456 return new ScanDartTask(this, source, getContents(source));
5457 } on JavaException catch (exception) {
5458 DartEntryImpl dartCopy = dartEntry.writableCopy;
5459 dartCopy.recordScanError();
5460 dartCopy.exception = new AnalysisException.con3(exception);
5461 _cache.put(source, dartCopy);
5462 }
5463 }
5050 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); 5464 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
5051 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden tical(parseErrorsState, CacheState.FLUSHED))) { 5465 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden tical(parseErrorsState, CacheState.FLUSHED))) {
5052 DartEntryImpl dartCopy = dartEntry.writableCopy; 5466 DartEntryImpl dartCopy = dartEntry.writableCopy;
5053 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS); 5467 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
5054 _cache.put(source, dartCopy); 5468 _cache.put(source, dartCopy);
5055 return new ParseDartTask(this, source); 5469 return new ParseDartTask(this, source);
5056 } 5470 }
5057 if (isPriority && parseErrorsState != CacheState.ERROR) { 5471 if (isPriority && parseErrorsState != CacheState.ERROR) {
5058 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; 5472 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit;
5059 if (parseUnit == null) { 5473 if (parseUnit == null) {
(...skipping 29 matching lines...) Expand all
5089 // then there won't be any elements in the element model that we can use to resolve it. 5503 // then there won't be any elements in the element model that we can use to resolve it.
5090 // 5504 //
5091 //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL EMENT); 5505 //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL EMENT);
5092 //if (libraryElement != null) { 5506 //if (libraryElement != null) {
5093 DartEntryImpl dartCopy = dartEntry.writableCopy; 5507 DartEntryImpl dartCopy = dartEntry.writableCopy;
5094 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat e.IN_PROCESS); 5508 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat e.IN_PROCESS);
5095 _cache.put(source, dartCopy); 5509 _cache.put(source, dartCopy);
5096 //return new ResolveDartUnitTask(this, source, libraryElement); 5510 //return new ResolveDartUnitTask(this, source, libraryElement);
5097 return new ResolveDartLibraryTask(this, source, librarySource); 5511 return new ResolveDartLibraryTask(this, source, librarySource);
5098 } 5512 }
5099 CacheState verificationErrorsState = dartEntry.getState2(DartEntry.VER IFICATION_ERRORS, librarySource); 5513 if (sdkErrorsEnabled || !source.isInSystemLibrary) {
5100 if (identical(verificationErrorsState, CacheState.INVALID) || (isPrior ity && identical(verificationErrorsState, CacheState.FLUSHED))) { 5514 CacheState verificationErrorsState = dartEntry.getState2(DartEntry.V ERIFICATION_ERRORS, librarySource);
5101 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEM ENT); 5515 if (identical(verificationErrorsState, CacheState.INVALID) || (isPri ority && identical(verificationErrorsState, CacheState.FLUSHED))) {
5102 if (libraryElement != null) {
5103 DartEntryImpl dartCopy = dartEntry.writableCopy;
5104 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, C acheState.IN_PROCESS);
5105 _cache.put(source, dartCopy);
5106 return new GenerateDartErrorsTask(this, source, libraryElement);
5107 }
5108 }
5109 if (hintsEnabled) {
5110 CacheState hintsState = dartEntry.getState2(DartEntry.HINTS, library Source);
5111 if (identical(hintsState, CacheState.INVALID) || (isPriority && iden tical(hintsState, CacheState.FLUSHED))) {
5112 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL EMENT); 5516 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL EMENT);
5113 if (libraryElement != null) { 5517 if (libraryElement != null) {
5114 DartEntryImpl dartCopy = dartEntry.writableCopy; 5518 DartEntryImpl dartCopy = dartEntry.writableCopy;
5115 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.IN _PROCESS); 5519 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, CacheState.IN_PROCESS);
5116 _cache.put(source, dartCopy); 5520 _cache.put(source, dartCopy);
5117 return new GenerateDartHintsTask(this, libraryElement); 5521 return new GenerateDartErrorsTask(this, source, libraryElement);
5522 }
5523 }
5524 if (hintsEnabled) {
5525 CacheState hintsState = dartEntry.getState2(DartEntry.HINTS, libra rySource);
5526 if (identical(hintsState, CacheState.INVALID) || (isPriority && id entical(hintsState, CacheState.FLUSHED))) {
5527 LibraryElement libraryElement = libraryEntry.getValue(DartEntry. ELEMENT);
5528 if (libraryElement != null) {
5529 DartEntryImpl dartCopy = dartEntry.writableCopy;
5530 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState. IN_PROCESS);
5531 _cache.put(source, dartCopy);
5532 return new GenerateDartHintsTask(this, libraryElement);
5533 }
5118 } 5534 }
5119 } 5535 }
5120 } 5536 }
5121 } 5537 }
5122 } 5538 }
5123 } else if (sourceEntry is HtmlEntry) { 5539 } else if (sourceEntry is HtmlEntry) {
5124 HtmlEntry htmlEntry = sourceEntry; 5540 HtmlEntry htmlEntry = sourceEntry;
5125 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); 5541 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS);
5126 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden tical(parseErrorsState, CacheState.FLUSHED))) { 5542 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden tical(parseErrorsState, CacheState.FLUSHED))) {
5127 HtmlEntryImpl dartCopy = htmlEntry.writableCopy; 5543 HtmlEntryImpl dartCopy = htmlEntry.writableCopy;
(...skipping 10 matching lines...) Expand all
5138 return new ParseHtmlTask(this, source); 5554 return new ParseHtmlTask(this, source);
5139 } 5555 }
5140 } 5556 }
5141 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) ; 5557 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) ;
5142 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide ntical(resolvedUnitState, CacheState.FLUSHED))) { 5558 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide ntical(resolvedUnitState, CacheState.FLUSHED))) {
5143 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 5559 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5144 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS); 5560 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS);
5145 _cache.put(source, htmlCopy); 5561 _cache.put(source, htmlCopy);
5146 return new ResolveHtmlTask(this, source); 5562 return new ResolveHtmlTask(this, source);
5147 } 5563 }
5564 // Angular support
5148 if (_options.analyzeAngular) { 5565 if (_options.analyzeAngular) {
5566 // try to resolve as an Angular entry point
5567 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR Y);
5568 if (identical(angularEntryState, CacheState.INVALID)) {
5569 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5570 htmlCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS);
5571 _cache.put(source, htmlCopy);
5572 return new ResolveAngularEntryHtmlTask(this, source);
5573 }
5574 // try to resolve as an Angular application part
5149 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR ORS); 5575 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR ORS);
5150 if (identical(angularErrorsState, CacheState.INVALID)) { 5576 if (identical(angularErrorsState, CacheState.INVALID)) {
5151 AngularApplicationInfo entryInfo = htmlEntry.getValue(HtmlEntry.ANGULA R_ENTRY); 5577 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_ APPLICATION);
5152 if (entryInfo != null) { 5578 // try to resolve as an Angular template
5153 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 5579 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGUL AR_COMPONENT);
5154 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS);
5155 _cache.put(source, htmlCopy);
5156 return new ResolveAngularEntryHtmlTask(this, source, entryInfo);
5157 }
5158 AngularApplicationInfo applicationInfo = htmlEntry.getValue(HtmlEntry. ANGULAR_APPLICATION);
5159 if (applicationInfo != null) {
5160 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG ULAR_COMPONENT);
5161 if (component != null) {
5162 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5163 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS) ;
5164 _cache.put(source, htmlCopy);
5165 return new ResolveAngularComponentTemplateTask(this, source, compo nent, applicationInfo);
5166 }
5167 }
5168 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 5580 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5169 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); 5581 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS);
5170 _cache.put(source, htmlCopy); 5582 _cache.put(source, htmlCopy);
5583 return new ResolveAngularComponentTemplateTask(this, source, component , application);
5171 } 5584 }
5172 } 5585 }
5173 } 5586 }
5174 return null; 5587 return null;
5175 } 5588 }
5176 5589
5177 /** 5590 /**
5178 * Return a change notice for the given source, creating one if one does not a lready exist. 5591 * Return a change notice for the given source, creating one if one does not a lready exist.
5179 * 5592 *
5180 * @param source the source for which changes are being reported 5593 * @param source the source for which changes are being reported
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
5275 * 5688 *
5276 * @param source the source to be checked 5689 * @param source the source to be checked
5277 * @param sourceEntry the cache entry associated with the source 5690 * @param sourceEntry the cache entry associated with the source
5278 * @param isPriority `true` if the source is a priority source 5691 * @param isPriority `true` if the source is a priority source
5279 * @param hintsEnabled `true` if hints are currently enabled 5692 * @param hintsEnabled `true` if hints are currently enabled
5280 * @param sources the set to which sources should be added 5693 * @param sources the set to which sources should be added
5281 */ 5694 */
5282 void getSourcesNeedingProcessing2(Source source, SourceEntry sourceEntry, bool isPriority, bool hintsEnabled, Set<Source> sources) { 5695 void getSourcesNeedingProcessing2(Source source, SourceEntry sourceEntry, bool isPriority, bool hintsEnabled, Set<Source> sources) {
5283 if (sourceEntry is DartEntry) { 5696 if (sourceEntry is DartEntry) {
5284 DartEntry dartEntry = sourceEntry; 5697 DartEntry dartEntry = sourceEntry;
5698 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS);
5699 if (identical(scanErrorsState, CacheState.INVALID) || (isPriority && ident ical(scanErrorsState, CacheState.FLUSHED))) {
5700 sources.add(source);
5701 return;
5702 }
5285 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); 5703 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
5286 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden tical(parseErrorsState, CacheState.FLUSHED))) { 5704 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden tical(parseErrorsState, CacheState.FLUSHED))) {
5287 sources.add(source); 5705 sources.add(source);
5288 return; 5706 return;
5289 } 5707 }
5290 if (isPriority) { 5708 if (isPriority) {
5291 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; 5709 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit;
5292 if (parseUnit == null) { 5710 if (parseUnit == null) {
5293 sources.add(source); 5711 sources.add(source);
5294 return; 5712 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5335 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); 5753 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT);
5336 if (identical(parsedUnitState, CacheState.INVALID) || (isPriority && ident ical(parsedUnitState, CacheState.FLUSHED))) { 5754 if (identical(parsedUnitState, CacheState.INVALID) || (isPriority && ident ical(parsedUnitState, CacheState.FLUSHED))) {
5337 sources.add(source); 5755 sources.add(source);
5338 return; 5756 return;
5339 } 5757 }
5340 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) ; 5758 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) ;
5341 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide ntical(resolvedUnitState, CacheState.FLUSHED))) { 5759 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide ntical(resolvedUnitState, CacheState.FLUSHED))) {
5342 sources.add(source); 5760 sources.add(source);
5343 return; 5761 return;
5344 } 5762 }
5763 // Angular
5345 if (_options.analyzeAngular) { 5764 if (_options.analyzeAngular) {
5346 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR ORS); 5765 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR ORS);
5347 if (identical(angularErrorsState, CacheState.INVALID)) { 5766 if (identical(angularErrorsState, CacheState.INVALID)) {
5348 AngularApplicationInfo entryInfo = htmlEntry.getValue(HtmlEntry.ANGULA R_ENTRY); 5767 AngularApplication entryInfo = htmlEntry.getValue(HtmlEntry.ANGULAR_EN TRY);
5349 if (entryInfo != null) { 5768 if (entryInfo != null) {
5350 sources.add(source); 5769 sources.add(source);
5351 return; 5770 return;
5352 } 5771 }
5353 AngularApplicationInfo applicationInfo = htmlEntry.getValue(HtmlEntry. ANGULAR_APPLICATION); 5772 AngularApplication applicationInfo = htmlEntry.getValue(HtmlEntry.ANGU LAR_APPLICATION);
5354 if (applicationInfo != null) { 5773 if (applicationInfo != null) {
5355 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG ULAR_COMPONENT); 5774 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG ULAR_COMPONENT);
5356 if (component != null) { 5775 if (component != null) {
5357 sources.add(source); 5776 sources.add(source);
5358 return; 5777 return;
5359 } 5778 }
5360 } 5779 }
5361 } 5780 }
5362 } 5781 }
5363 } 5782 }
(...skipping 17 matching lines...) Expand all
5381 removeFromParts(source, dartEntry); 5800 removeFromParts(source, dartEntry);
5382 DartEntryImpl dartCopy = dartEntry.writableCopy; 5801 DartEntryImpl dartCopy = dartEntry.writableCopy;
5383 dartCopy.invalidateAllResolutionInformation(); 5802 dartCopy.invalidateAllResolutionInformation();
5384 mapEntry.setValue(dartCopy); 5803 mapEntry.setValue(dartCopy);
5385 _workManager.add(source, SourcePriority.UNKNOWN); 5804 _workManager.add(source, SourcePriority.UNKNOWN);
5386 } 5805 }
5387 } 5806 }
5388 } 5807 }
5389 5808
5390 /** 5809 /**
5810 * In response to a change to Angular entry point [HtmlElement], invalidate an y results that
5811 * depend on it.
5812 *
5813 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5814 *
5815 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be
5816 * re-accessed after this method returns.
5817 *
5818 * @param entryCopy the [HtmlEntryImpl] of the (maybe) Angular entry point bei ng invalidated
5819 */
5820 void invalidateAngularResolution(HtmlEntryImpl entryCopy) {
5821 AngularApplication application = entryCopy.getValue(HtmlEntry.ANGULAR_ENTRY) ;
5822 if (application == null) {
5823 return;
5824 }
5825 _angularApplications.remove(application);
5826 // invalidate Entry
5827 entryCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.INVALID);
5828 // reset HTML sources
5829 List<AngularElement> oldAngularElements = application.elements;
5830 for (AngularElement angularElement in oldAngularElements) {
5831 if (angularElement is AngularHasTemplateElement) {
5832 AngularHasTemplateElement hasTemplate = angularElement;
5833 Source templateSource = hasTemplate.templateSource;
5834 if (templateSource != null) {
5835 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource);
5836 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5837 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, null);
5838 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, null);
5839 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID);
5840 _cache.put(templateSource, htmlCopy);
5841 _workManager.add(templateSource, SourcePriority.HTML);
5842 }
5843 }
5844 }
5845 // reset Dart sources
5846 List<Source> oldElementSources = application.elementSources;
5847 for (Source elementSource in oldElementSources) {
5848 DartEntry dartEntry = getReadableDartEntry(elementSource);
5849 DartEntryImpl dartCopy = dartEntry.writableCopy;
5850 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
5851 _cache.put(elementSource, dartCopy);
5852 // notify about (disappeared) Angular errors
5853 ChangeNoticeImpl notice = getNotice(elementSource);
5854 notice.setErrors(dartCopy.allErrors, dartEntry.getValue(SourceEntry.LINE_I NFO));
5855 }
5856 }
5857
5858 /**
5391 * In response to a change to at least one of the compilation units in the giv en library, 5859 * In response to a change to at least one of the compilation units in the giv en library,
5392 * invalidate any results that are dependent on the result of resolving that l ibrary. 5860 * invalidate any results that are dependent on the result of resolving that l ibrary.
5393 * 5861 *
5394 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5862 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5395 * 5863 *
5396 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be 5864 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be
5397 * re-accessed after this method returns. 5865 * re-accessed after this method returns.
5398 * 5866 *
5399 * @param librarySource the source of the library being invalidated 5867 * @param librarySource the source of the library being invalidated
5400 * @param writer the writer to which debugging information should be written 5868 * @param writer the writer to which debugging information should be written
(...skipping 23 matching lines...) Expand all
5424 _workManager.add(librarySource, SourcePriority.NORMAL_PART); 5892 _workManager.add(librarySource, SourcePriority.NORMAL_PART);
5425 } 5893 }
5426 partCopy.invalidateAllResolutionInformation(); 5894 partCopy.invalidateAllResolutionInformation();
5427 _cache.put(partSource, partCopy); 5895 _cache.put(partSource, partCopy);
5428 if (writer != null) { 5896 if (writer != null) {
5429 writer.println(" Invalidated part source: ${debuggingString(partSou rce)} (previously modified at ${oldTime})"); 5897 writer.println(" Invalidated part source: ${debuggingString(partSou rce)} (previously modified at ${oldTime})");
5430 } 5898 }
5431 } 5899 }
5432 } 5900 }
5433 } 5901 }
5902 // invalidate Angular applications
5903 List<AngularApplication> angularApplicationsCopy = [];
5904 for (AngularApplication application in angularApplicationsCopy) {
5905 if (application.dependsOn(librarySource)) {
5906 Source entryPointSource = application.entryPoint;
5907 HtmlEntry entry = getReadableHtmlEntry(entryPointSource);
5908 HtmlEntryImpl entryCopy = entry.writableCopy;
5909 invalidateAngularResolution(entryCopy);
5910 _cache.put(entryPointSource, entryCopy);
5911 _workManager.add(entryPointSource, SourcePriority.HTML);
5912 }
5913 }
5434 } 5914 }
5435 5915
5436 /** 5916 /**
5437 * Return `true` if this library is, or depends on, dart:html. 5917 * Return `true` if this library is, or depends on, dart:html.
5438 * 5918 *
5439 * @param library the library being tested 5919 * @param library the library being tested
5440 * @param visitedLibraries a collection of the libraries that have been visite d, used to prevent 5920 * @param visitedLibraries a collection of the libraries that have been visite d, used to prevent
5441 * infinite recursion 5921 * infinite recursion
5442 * @return `true` if this library is, or depends on, dart:html 5922 * @return `true` if this library is, or depends on, dart:html
5443 */ 5923 */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5479 */ 5959 */
5480 void logInformation2(String message, Exception exception) { 5960 void logInformation2(String message, Exception exception) {
5481 if (exception == null) { 5961 if (exception == null) {
5482 AnalysisEngine.instance.logger.logInformation(message); 5962 AnalysisEngine.instance.logger.logInformation(message);
5483 } else { 5963 } else {
5484 AnalysisEngine.instance.logger.logInformation3(message, exception); 5964 AnalysisEngine.instance.logger.logInformation3(message, exception);
5485 } 5965 }
5486 } 5966 }
5487 5967
5488 /** 5968 /**
5489 * Updates [HtmlEntry]s that correspond to the previously known and new Angula r components. 5969 * Updates [HtmlEntry]s that correspond to the previously known and new Angula r application
5490 * 5970 * information.
5491 * @param library the [Library] that was resolved
5492 * @param dartCopy the [DartEntryImpl] to record new Angular components
5493 */ 5971 */
5494 void recordAngularComponents(HtmlEntryImpl entry, AngularApplicationInfo app) { 5972 void recordAngularEntryPoint(HtmlEntryImpl entry, ResolveAngularEntryHtmlTask task) {
5495 if (!_options.analyzeAngular) { 5973 AngularApplication application = task.application;
5496 return; 5974 if (application != null) {
5497 } 5975 _angularApplications.add(application);
5498 // reset old Angular errors 5976 // if this is an entry point, then we already resolved it
5499 AngularApplicationInfo oldApp = entry.getValue(HtmlEntry.ANGULAR_ENTRY); 5977 entry.setValue(HtmlEntry.ANGULAR_ERRORS, task.entryErrors);
5500 if (oldApp != null) { 5978 // schedule HTML templates analysis
5501 List<AngularElement> oldAngularElements = oldApp.elements; 5979 List<AngularElement> newAngularElements = application.elements;
5502 for (AngularElement angularElement in oldAngularElements) { 5980 for (AngularElement angularElement in newAngularElements) {
5503 if (angularElement is AngularComponentElement) { 5981 if (angularElement is AngularHasTemplateElement) {
5504 AngularComponentElement component = angularElement; 5982 AngularHasTemplateElement hasTemplate = angularElement;
5505 Source templateSource = component.templateSource; 5983 Source templateSource = hasTemplate.templateSource;
5506 if (templateSource != null) { 5984 if (templateSource != null) {
5507 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource); 5985 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource);
5508 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 5986 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5509 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, null); 5987 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, application);
5510 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, null); 5988 if (hasTemplate is AngularComponentElement) {
5511 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS) ; 5989 AngularComponentElement component = hasTemplate;
5512 _cache.put(templateSource, htmlCopy); 5990 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, component);
5513 // notify about (disappeared) HTML errors 5991 }
5514 ChangeNoticeImpl notice = getNotice(templateSource);
5515 notice.setErrors(htmlCopy.allErrors, computeLineInfo(templateSource) );
5516 }
5517 }
5518 }
5519 }
5520 // prepare for new Angular analysis
5521 if (app != null) {
5522 List<AngularElement> newAngularElements = app.elements;
5523 for (AngularElement angularElement in newAngularElements) {
5524 if (angularElement is AngularComponentElement) {
5525 AngularComponentElement component = angularElement;
5526 Source templateSource = component.templateSource;
5527 if (templateSource != null) {
5528 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource);
5529 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5530 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, app);
5531 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, component);
5532 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); 5992 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID);
5533 _cache.put(templateSource, htmlCopy); 5993 _cache.put(templateSource, htmlCopy);
5534 _workManager.add(templateSource, SourcePriority.HTML); 5994 _workManager.add(templateSource, SourcePriority.HTML);
5535 } 5995 }
5536 } 5996 }
5537 } 5997 }
5998 // update Dart sources errors
5999 List<Source> newElementSources = application.elementSources;
6000 for (Source elementSource in newElementSources) {
6001 DartEntry dartEntry = getReadableDartEntry(elementSource);
6002 DartEntryImpl dartCopy = dartEntry.writableCopy;
6003 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource ));
6004 _cache.put(elementSource, dartCopy);
6005 // notify about Dart errors
6006 ChangeNoticeImpl notice = getNotice(elementSource);
6007 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource));
6008 }
5538 } 6009 }
5539 // remember Angular application 6010 // remember Angular entry point
5540 entry.setValue(HtmlEntry.ANGULAR_ENTRY, app); 6011 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application);
5541 entry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID);
5542 } 6012 }
5543 6013
5544 /** 6014 /**
5545 * Given a cache entry and a library element, record the library element and o ther information 6015 * Given a cache entry and a library element, record the library element and o ther information
5546 * gleaned from the element in the cache entry. 6016 * gleaned from the element in the cache entry.
5547 * 6017 *
5548 * @param dartEntry the original cache entry from which the copy was made 6018 * @param dartEntry the original cache entry from which the copy was made
5549 * @param dartCopy the cache entry in which data is to be recorded 6019 * @param dartCopy the cache entry in which data is to be recorded
5550 * @param library the library element used to record information 6020 * @param library the library element used to record information
5551 * @param librarySource the source for the library used to record information 6021 * @param librarySource the source for the library used to record information
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5584 * @return an entry containing the computed results 6054 * @return an entry containing the computed results
5585 * @throws AnalysisException if the results could not be recorded 6055 * @throws AnalysisException if the results could not be recorded
5586 */ 6056 */
5587 DartEntry recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { 6057 DartEntry recordGenerateDartErrorsTask(GenerateDartErrorsTask task) {
5588 Source source = task.source; 6058 Source source = task.source;
5589 Source librarySource = task.libraryElement.source; 6059 Source librarySource = task.libraryElement.source;
5590 AnalysisException thrownException = task.exception; 6060 AnalysisException thrownException = task.exception;
5591 DartEntry dartEntry = null; 6061 DartEntry dartEntry = null;
5592 { 6062 {
5593 SourceEntry sourceEntry = _cache.get(source); 6063 SourceEntry sourceEntry = _cache.get(source);
5594 if (sourceEntry is! DartEntry) { 6064 if (sourceEntry == null) {
6065 throw new ObsoleteSourceAnalysisException(source);
6066 } else if (sourceEntry is! DartEntry) {
5595 // This shouldn't be possible because we should never have performed the task if the source 6067 // This shouldn't be possible because we should never have performed the task if the source
5596 // didn't represent a Dart file, but check to be safe. 6068 // didn't represent a Dart file, but check to be safe.
5597 throw new AnalysisException.con1("Internal error: attempting to verify n on-Dart file as a Dart file: ${source.fullName}"); 6069 throw new AnalysisException.con1("Internal error: attempting to verify n on-Dart file as a Dart file: ${source.fullName}");
5598 } 6070 }
5599 dartEntry = sourceEntry as DartEntry; 6071 dartEntry = sourceEntry as DartEntry;
5600 int sourceTime = source.modificationStamp; 6072 int sourceTime = getModificationStamp(source);
5601 int resultTime = task.modificationTime; 6073 int resultTime = task.modificationTime;
5602 if (sourceTime == resultTime) { 6074 if (sourceTime == resultTime) {
5603 if (dartEntry.modificationTime != sourceTime) { 6075 if (dartEntry.modificationTime != sourceTime) {
5604 // The source has changed without the context being notified. Simulate notification. 6076 // The source has changed without the context being notified. Simulate notification.
5605 sourceChanged(source); 6077 sourceChanged(source);
5606 dartEntry = getReadableDartEntry(source); 6078 dartEntry = getReadableDartEntry(source);
5607 if (dartEntry == null) { 6079 if (dartEntry == null) {
5608 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${source.fullName}"); 6080 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${source.fullName}");
5609 } 6081 }
5610 } 6082 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5663 DartEntry recordGenerateDartHintsTask(GenerateDartHintsTask task) { 6135 DartEntry recordGenerateDartHintsTask(GenerateDartHintsTask task) {
5664 Source librarySource = task.libraryElement.source; 6136 Source librarySource = task.libraryElement.source;
5665 AnalysisException thrownException = task.exception; 6137 AnalysisException thrownException = task.exception;
5666 DartEntry libraryEntry = null; 6138 DartEntry libraryEntry = null;
5667 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap; 6139 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap;
5668 if (hintMap == null) { 6140 if (hintMap == null) {
5669 { 6141 {
5670 // We don't have any information about which sources to mark as invalid other than the library 6142 // We don't have any information about which sources to mark as invalid other than the library
5671 // source. 6143 // source.
5672 SourceEntry sourceEntry = _cache.get(librarySource); 6144 SourceEntry sourceEntry = _cache.get(librarySource);
5673 if (sourceEntry is! DartEntry) { 6145 if (sourceEntry == null) {
6146 throw new ObsoleteSourceAnalysisException(librarySource);
6147 } else if (sourceEntry is! DartEntry) {
5674 // This shouldn't be possible because we should never have performed t he task if the source 6148 // This shouldn't be possible because we should never have performed t he task if the source
5675 // didn't represent a Dart file, but check to be safe. 6149 // didn't represent a Dart file, but check to be safe.
5676 throw new AnalysisException.con1("Internal error: attempting to genera te hints for non-Dart file as a Dart file: ${librarySource.fullName}"); 6150 throw new AnalysisException.con1("Internal error: attempting to genera te hints for non-Dart file as a Dart file: ${librarySource.fullName}");
5677 } 6151 }
5678 if (thrownException == null) { 6152 if (thrownException == null) {
5679 thrownException = new AnalysisException.con1("GenerateDartHintsTask re turned a null hint map without throwing an exception: ${librarySource.fullName}" ); 6153 thrownException = new AnalysisException.con1("GenerateDartHintsTask re turned a null hint map without throwing an exception: ${librarySource.fullName}" );
5680 } 6154 }
5681 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy; 6155 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy;
5682 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR); 6156 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR);
5683 dartCopy.exception = thrownException; 6157 dartCopy.exception = thrownException;
5684 _cache.put(librarySource, dartCopy); 6158 _cache.put(librarySource, dartCopy);
5685 } 6159 }
5686 throw thrownException; 6160 throw thrownException;
5687 } 6161 }
5688 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) { 6162 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) {
5689 Source unitSource = entry.getKey(); 6163 Source unitSource = entry.getKey();
5690 TimestampedData<List<AnalysisError>> results = entry.getValue(); 6164 TimestampedData<List<AnalysisError>> results = entry.getValue();
5691 { 6165 {
5692 SourceEntry sourceEntry = _cache.get(unitSource); 6166 SourceEntry sourceEntry = _cache.get(unitSource);
5693 if (sourceEntry is! DartEntry) { 6167 if (sourceEntry is! DartEntry) {
5694 // This shouldn't be possible because we should never have performed t he task if the source 6168 // This shouldn't be possible because we should never have performed t he task if the source
5695 // didn't represent a Dart file, but check to be safe. 6169 // didn't represent a Dart file, but check to be safe.
5696 throw new AnalysisException.con1("Internal error: attempting to parse non-Dart file as a Dart file: ${unitSource.fullName}"); 6170 throw new AnalysisException.con1("Internal error: attempting to parse non-Dart file as a Dart file: ${unitSource.fullName}");
5697 } 6171 }
5698 DartEntry dartEntry = sourceEntry as DartEntry; 6172 DartEntry dartEntry = sourceEntry as DartEntry;
5699 if (unitSource == librarySource) { 6173 if (unitSource == librarySource) {
5700 libraryEntry = dartEntry; 6174 libraryEntry = dartEntry;
5701 } 6175 }
5702 int sourceTime = unitSource.modificationStamp; 6176 int sourceTime = getModificationStamp(unitSource);
5703 int resultTime = results.modificationTime; 6177 int resultTime = results.modificationTime;
5704 if (sourceTime == resultTime) { 6178 if (sourceTime == resultTime) {
5705 if (dartEntry.modificationTime != sourceTime) { 6179 if (dartEntry.modificationTime != sourceTime) {
5706 // The source has changed without the context being notified. Simula te notification. 6180 // The source has changed without the context being notified. Simula te notification.
5707 sourceChanged(unitSource); 6181 sourceChanged(unitSource);
5708 dartEntry = getReadableDartEntry(unitSource); 6182 dartEntry = getReadableDartEntry(unitSource);
5709 if (dartEntry == null) { 6183 if (dartEntry == null) {
5710 throw new AnalysisException.con1("A Dart file became a non-Dart fi le: ${unitSource.fullName}"); 6184 throw new AnalysisException.con1("A Dart file became a non-Dart fi le: ${unitSource.fullName}");
5711 } 6185 }
5712 } 6186 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5783 * @param task the task that was performed 6257 * @param task the task that was performed
5784 * @return an entry containing the computed results 6258 * @return an entry containing the computed results
5785 * @throws AnalysisException if the results could not be recorded 6259 * @throws AnalysisException if the results could not be recorded
5786 */ 6260 */
5787 DartEntry recordParseDartTaskResults(ParseDartTask task) { 6261 DartEntry recordParseDartTaskResults(ParseDartTask task) {
5788 Source source = task.source; 6262 Source source = task.source;
5789 AnalysisException thrownException = task.exception; 6263 AnalysisException thrownException = task.exception;
5790 DartEntry dartEntry = null; 6264 DartEntry dartEntry = null;
5791 { 6265 {
5792 SourceEntry sourceEntry = _cache.get(source); 6266 SourceEntry sourceEntry = _cache.get(source);
5793 if (sourceEntry is! DartEntry) { 6267 if (sourceEntry == null) {
6268 throw new ObsoleteSourceAnalysisException(source);
6269 } else if (sourceEntry is! DartEntry) {
5794 // This shouldn't be possible because we should never have performed the task if the source 6270 // This shouldn't be possible because we should never have performed the task if the source
5795 // didn't represent a Dart file, but check to be safe. 6271 // didn't represent a Dart file, but check to be safe.
5796 throw new AnalysisException.con1("Internal error: attempting to parse no n-Dart file as a Dart file: ${source.fullName}"); 6272 throw new AnalysisException.con1("Internal error: attempting to parse no n-Dart file as a Dart file: ${source.fullName}");
5797 } 6273 }
5798 dartEntry = sourceEntry as DartEntry; 6274 dartEntry = sourceEntry as DartEntry;
5799 int sourceTime = source.modificationStamp; 6275 int sourceTime = getModificationStamp(source);
5800 int resultTime = task.modificationTime; 6276 int resultTime = task.modificationTime;
5801 if (sourceTime == resultTime) { 6277 if (sourceTime == resultTime) {
5802 if (dartEntry.modificationTime != sourceTime) { 6278 if (dartEntry.modificationTime != sourceTime) {
5803 // The source has changed without the context being notified. Simulate notification. 6279 // The source has changed without the context being notified. Simulate notification.
5804 sourceChanged(source); 6280 sourceChanged(source);
5805 dartEntry = getReadableDartEntry(source); 6281 dartEntry = getReadableDartEntry(source);
5806 if (dartEntry == null) { 6282 if (dartEntry == null) {
5807 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${source.fullName}"); 6283 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${source.fullName}");
5808 } 6284 }
5809 } 6285 }
5810 DartEntryImpl dartCopy = dartEntry.writableCopy; 6286 DartEntryImpl dartCopy = dartEntry.writableCopy;
5811 if (thrownException == null) { 6287 if (thrownException == null) {
5812 LineInfo lineInfo = task.lineInfo;
5813 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
5814 if (task.hasPartOfDirective() && !task.hasLibraryDirective()) { 6288 if (task.hasPartOfDirective() && !task.hasLibraryDirective()) {
5815 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); 6289 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
6290 dartCopy.removeContainingLibrary(source);
5816 _workManager.add(source, SourcePriority.NORMAL_PART); 6291 _workManager.add(source, SourcePriority.NORMAL_PART);
5817 } else { 6292 } else {
5818 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 6293 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
5819 dartCopy.containingLibrary = source; 6294 dartCopy.containingLibrary = source;
5820 _workManager.add(source, SourcePriority.LIBRARY); 6295 _workManager.add(source, SourcePriority.LIBRARY);
5821 } 6296 }
5822 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); 6297 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit);
5823 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); 6298 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors);
5824 _cache.storedAst(source); 6299 _cache.storedAst(source);
5825 ChangeNoticeImpl notice = getNotice(source); 6300 ChangeNoticeImpl notice = getNotice(source);
5826 notice.setErrors(dartEntry.allErrors, lineInfo); 6301 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN E_INFO));
5827 // Verify that the incrementally parsed and resolved unit in the incre mental cache 6302 // Verify that the incrementally parsed and resolved unit in the incre mental cache
5828 // is structurally equivalent to the fully parsed unit 6303 // is structurally equivalent to the fully parsed unit
5829 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_ incrementalAnalysisCache, source, task.compilationUnit); 6304 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_ incrementalAnalysisCache, source, task.compilationUnit);
5830 } else { 6305 } else {
5831 removeFromParts(source, dartEntry); 6306 removeFromParts(source, dartEntry);
5832 dartCopy.recordParseError(); 6307 dartCopy.recordParseError();
5833 _cache.removedAst(source); 6308 _cache.removedAst(source);
5834 } 6309 }
5835 dartCopy.exception = thrownException; 6310 dartCopy.exception = thrownException;
5836 _cache.put(source, dartCopy); 6311 _cache.put(source, dartCopy);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5875 * @param task the task that was performed 6350 * @param task the task that was performed
5876 * @return an entry containing the computed results 6351 * @return an entry containing the computed results
5877 * @throws AnalysisException if the results could not be recorded 6352 * @throws AnalysisException if the results could not be recorded
5878 */ 6353 */
5879 HtmlEntry recordParseHtmlTaskResults(ParseHtmlTask task) { 6354 HtmlEntry recordParseHtmlTaskResults(ParseHtmlTask task) {
5880 Source source = task.source; 6355 Source source = task.source;
5881 AnalysisException thrownException = task.exception; 6356 AnalysisException thrownException = task.exception;
5882 HtmlEntry htmlEntry = null; 6357 HtmlEntry htmlEntry = null;
5883 { 6358 {
5884 SourceEntry sourceEntry = _cache.get(source); 6359 SourceEntry sourceEntry = _cache.get(source);
5885 if (sourceEntry is! HtmlEntry) { 6360 if (sourceEntry == null) {
6361 throw new ObsoleteSourceAnalysisException(source);
6362 } else if (sourceEntry is! HtmlEntry) {
5886 // This shouldn't be possible because we should never have performed the task if the source 6363 // This shouldn't be possible because we should never have performed the task if the source
5887 // didn't represent an HTML file, but check to be safe. 6364 // didn't represent an HTML file, but check to be safe.
5888 throw new AnalysisException.con1("Internal error: attempting to parse no n-HTML file as a HTML file: ${source.fullName}"); 6365 throw new AnalysisException.con1("Internal error: attempting to parse no n-HTML file as a HTML file: ${source.fullName}");
5889 } 6366 }
5890 htmlEntry = sourceEntry as HtmlEntry; 6367 htmlEntry = sourceEntry as HtmlEntry;
5891 int sourceTime = source.modificationStamp; 6368 int sourceTime = getModificationStamp(source);
5892 int resultTime = task.modificationTime; 6369 int resultTime = task.modificationTime;
5893 if (sourceTime == resultTime) { 6370 if (sourceTime == resultTime) {
5894 if (htmlEntry.modificationTime != sourceTime) { 6371 if (htmlEntry.modificationTime != sourceTime) {
5895 // The source has changed without the context being notified. Simulate notification. 6372 // The source has changed without the context being notified. Simulate notification.
5896 sourceChanged(source); 6373 sourceChanged(source);
5897 htmlEntry = getReadableHtmlEntry(source); 6374 htmlEntry = getReadableHtmlEntry(source);
5898 if (htmlEntry == null) { 6375 if (htmlEntry == null) {
5899 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}"); 6376 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}");
5900 } 6377 }
5901 } 6378 }
5902 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; 6379 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
5903 if (thrownException == null) { 6380 if (thrownException == null) {
5904 LineInfo lineInfo = task.lineInfo; 6381 LineInfo lineInfo = task.lineInfo;
5905 ht.HtmlUnit unit = task.htmlUnit; 6382 ht.HtmlUnit unit = task.htmlUnit;
5906 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 6383 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
5907 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); 6384 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit);
5908 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); 6385 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors);
5909 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra ries); 6386 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra ries);
5910 _cache.storedAst(source); 6387 _cache.storedAst(source);
5911 ChangeNoticeImpl notice = getNotice(source); 6388 ChangeNoticeImpl notice = getNotice(source);
5912 notice.setErrors(htmlEntry.allErrors, lineInfo); 6389 notice.setErrors(htmlCopy.allErrors, lineInfo);
5913 } else { 6390 } else {
5914 htmlCopy.recordParseError(); 6391 htmlCopy.recordParseError();
5915 _cache.removedAst(source); 6392 _cache.removedAst(source);
5916 } 6393 }
5917 htmlCopy.exception = thrownException; 6394 htmlCopy.exception = thrownException;
5918 _cache.put(source, htmlCopy); 6395 _cache.put(source, htmlCopy);
5919 htmlEntry = htmlCopy; 6396 htmlEntry = htmlCopy;
5920 } else { 6397 } else {
5921 logInformation2("Parse results discarded for ${debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry .modificationTime}", thrownException); 6398 logInformation2("Parse results discarded for ${debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry .modificationTime}", thrownException);
5922 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; 6399 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5965 * 6442 *
5966 * @param task the task that was performed 6443 * @param task the task that was performed
5967 * @throws AnalysisException if the results could not be recorded 6444 * @throws AnalysisException if the results could not be recorded
5968 */ 6445 */
5969 HtmlEntry recordResolveAngularComponentTemplateTaskResults(ResolveAngularCompo nentTemplateTask task) { 6446 HtmlEntry recordResolveAngularComponentTemplateTaskResults(ResolveAngularCompo nentTemplateTask task) {
5970 Source source = task.source; 6447 Source source = task.source;
5971 AnalysisException thrownException = task.exception; 6448 AnalysisException thrownException = task.exception;
5972 HtmlEntry htmlEntry = null; 6449 HtmlEntry htmlEntry = null;
5973 { 6450 {
5974 SourceEntry sourceEntry = _cache.get(source); 6451 SourceEntry sourceEntry = _cache.get(source);
5975 if (sourceEntry is! HtmlEntry) { 6452 if (sourceEntry == null) {
6453 throw new ObsoleteSourceAnalysisException(source);
6454 } else if (sourceEntry is! HtmlEntry) {
5976 // This shouldn't be possible because we should never have performed the task if the source 6455 // This shouldn't be possible because we should never have performed the task if the source
5977 // didn't represent an HTML file, but check to be safe. 6456 // didn't represent an HTML file, but check to be safe.
5978 throw new AnalysisException.con1("Internal error: attempting to resolve non-HTML file as an HTML file: ${source.fullName}"); 6457 throw new AnalysisException.con1("Internal error: attempting to resolve non-HTML file as an HTML file: ${source.fullName}");
5979 } 6458 }
5980 htmlEntry = sourceEntry as HtmlEntry; 6459 htmlEntry = sourceEntry as HtmlEntry;
5981 int sourceTime = source.modificationStamp; 6460 int sourceTime = getModificationStamp(source);
5982 int resultTime = task.modificationTime; 6461 int resultTime = task.modificationTime;
5983 if (sourceTime == resultTime) { 6462 if (sourceTime == resultTime) {
5984 if (htmlEntry.modificationTime != sourceTime) { 6463 if (htmlEntry.modificationTime != sourceTime) {
5985 // The source has changed without the context being notified. Simulate notification. 6464 // The source has changed without the context being notified. Simulate notification.
5986 sourceChanged(source); 6465 sourceChanged(source);
5987 htmlEntry = getReadableHtmlEntry(source); 6466 htmlEntry = getReadableHtmlEntry(source);
5988 if (htmlEntry == null) { 6467 if (htmlEntry == null) {
5989 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}"); 6468 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}");
5990 } 6469 }
5991 } 6470 }
5992 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 6471 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5993 if (thrownException == null) { 6472 if (thrownException == null) {
5994 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); 6473 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors);
6474 // notify about errors
5995 ChangeNoticeImpl notice = getNotice(source); 6475 ChangeNoticeImpl notice = getNotice(source);
5996 notice.htmlUnit = task.resolvedUnit; 6476 notice.htmlUnit = task.resolvedUnit;
5997 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN E_INFO)); 6477 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN E_INFO));
5998 } else { 6478 } else {
5999 htmlCopy.recordResolutionError(); 6479 htmlCopy.recordResolutionError();
6000 } 6480 }
6001 htmlCopy.exception = thrownException; 6481 htmlCopy.exception = thrownException;
6002 _cache.put(source, htmlCopy); 6482 _cache.put(source, htmlCopy);
6003 htmlEntry = htmlCopy; 6483 htmlEntry = htmlCopy;
6004 } else { 6484 } else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6045 * 6525 *
6046 * @param task the task that was performed 6526 * @param task the task that was performed
6047 * @throws AnalysisException if the results could not be recorded 6527 * @throws AnalysisException if the results could not be recorded
6048 */ 6528 */
6049 HtmlEntry recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTask task) { 6529 HtmlEntry recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTask task) {
6050 Source source = task.source; 6530 Source source = task.source;
6051 AnalysisException thrownException = task.exception; 6531 AnalysisException thrownException = task.exception;
6052 HtmlEntry htmlEntry = null; 6532 HtmlEntry htmlEntry = null;
6053 { 6533 {
6054 SourceEntry sourceEntry = _cache.get(source); 6534 SourceEntry sourceEntry = _cache.get(source);
6055 if (sourceEntry is! HtmlEntry) { 6535 if (sourceEntry == null) {
6536 throw new ObsoleteSourceAnalysisException(source);
6537 } else if (sourceEntry is! HtmlEntry) {
6056 // This shouldn't be possible because we should never have performed the task if the source 6538 // This shouldn't be possible because we should never have performed the task if the source
6057 // didn't represent an HTML file, but check to be safe. 6539 // didn't represent an HTML file, but check to be safe.
6058 throw new AnalysisException.con1("Internal error: attempting to resolve non-HTML file as an HTML file: ${source.fullName}"); 6540 throw new AnalysisException.con1("Internal error: attempting to resolve non-HTML file as an HTML file: ${source.fullName}");
6059 } 6541 }
6060 htmlEntry = sourceEntry as HtmlEntry; 6542 htmlEntry = sourceEntry as HtmlEntry;
6061 int sourceTime = source.modificationStamp; 6543 int sourceTime = getModificationStamp(source);
6062 int resultTime = task.modificationTime; 6544 int resultTime = task.modificationTime;
6063 if (sourceTime == resultTime) { 6545 if (sourceTime == resultTime) {
6064 if (htmlEntry.modificationTime != sourceTime) { 6546 if (htmlEntry.modificationTime != sourceTime) {
6065 // The source has changed without the context being notified. Simulate notification. 6547 // The source has changed without the context being notified. Simulate notification.
6066 sourceChanged(source); 6548 sourceChanged(source);
6067 htmlEntry = getReadableHtmlEntry(source); 6549 htmlEntry = getReadableHtmlEntry(source);
6068 if (htmlEntry == null) { 6550 if (htmlEntry == null) {
6069 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}"); 6551 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}");
6070 } 6552 }
6071 } 6553 }
6072 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 6554 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
6073 if (thrownException == null) { 6555 if (thrownException == null) {
6074 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); 6556 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
6557 recordAngularEntryPoint(htmlCopy, task);
6558 _cache.storedAst(source);
6075 ChangeNoticeImpl notice = getNotice(source); 6559 ChangeNoticeImpl notice = getNotice(source);
6076 notice.htmlUnit = task.resolvedUnit; 6560 notice.htmlUnit = task.resolvedUnit;
6077 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN E_INFO)); 6561 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN E_INFO));
6078 } else { 6562 } else {
6079 htmlCopy.recordResolutionError(); 6563 htmlCopy.recordResolutionError();
6080 } 6564 }
6081 htmlCopy.exception = thrownException; 6565 htmlCopy.exception = thrownException;
6082 _cache.put(source, htmlCopy); 6566 _cache.put(source, htmlCopy);
6083 htmlEntry = htmlCopy; 6567 htmlEntry = htmlCopy;
6084 } else { 6568 } else {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6126 * @param task the task that was performed 6610 * @param task the task that was performed
6127 * @return an entry containing the computed results 6611 * @return an entry containing the computed results
6128 * @throws AnalysisException if the results could not be recorded 6612 * @throws AnalysisException if the results could not be recorded
6129 */ 6613 */
6130 DartEntry recordResolveDartDependenciesTaskResults(ResolveDartDependenciesTask task) { 6614 DartEntry recordResolveDartDependenciesTaskResults(ResolveDartDependenciesTask task) {
6131 Source source = task.source; 6615 Source source = task.source;
6132 AnalysisException thrownException = task.exception; 6616 AnalysisException thrownException = task.exception;
6133 DartEntry dartEntry = null; 6617 DartEntry dartEntry = null;
6134 { 6618 {
6135 SourceEntry sourceEntry = _cache.get(source); 6619 SourceEntry sourceEntry = _cache.get(source);
6136 if (sourceEntry is! DartEntry) { 6620 if (sourceEntry == null) {
6621 throw new ObsoleteSourceAnalysisException(source);
6622 } else if (sourceEntry is! DartEntry) {
6137 // This shouldn't be possible because we should never have performed the task if the source 6623 // This shouldn't be possible because we should never have performed the task if the source
6138 // didn't represent a Dart file, but check to be safe. 6624 // didn't represent a Dart file, but check to be safe.
6139 throw new AnalysisException.con1("Internal error: attempting to resolve Dart dependencies in a non-Dart file: ${source.fullName}"); 6625 throw new AnalysisException.con1("Internal error: attempting to resolve Dart dependencies in a non-Dart file: ${source.fullName}");
6140 } 6626 }
6141 dartEntry = sourceEntry as DartEntry; 6627 dartEntry = sourceEntry as DartEntry;
6142 int sourceTime = source.modificationStamp; 6628 int sourceTime = getModificationStamp(source);
6143 int resultTime = task.modificationTime; 6629 int resultTime = task.modificationTime;
6144 if (sourceTime == resultTime) { 6630 if (sourceTime == resultTime) {
6145 if (dartEntry.modificationTime != sourceTime) { 6631 if (dartEntry.modificationTime != sourceTime) {
6146 // The source has changed without the context being notified. Simulate notification. 6632 // The source has changed without the context being notified. Simulate notification.
6147 sourceChanged(source); 6633 sourceChanged(source);
6148 dartEntry = getReadableDartEntry(source); 6634 dartEntry = getReadableDartEntry(source);
6149 if (dartEntry == null) { 6635 if (dartEntry == null) {
6150 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${source.fullName}"); 6636 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${source.fullName}");
6151 } 6637 }
6152 } 6638 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
6215 * @return an entry containing the computed results 6701 * @return an entry containing the computed results
6216 * @throws AnalysisException if the results could not be recorded 6702 * @throws AnalysisException if the results could not be recorded
6217 */ 6703 */
6218 SourceEntry recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { 6704 SourceEntry recordResolveDartUnitTaskResults(ResolveDartUnitTask task) {
6219 Source unitSource = task.source; 6705 Source unitSource = task.source;
6220 Source librarySource = task.librarySource; 6706 Source librarySource = task.librarySource;
6221 AnalysisException thrownException = task.exception; 6707 AnalysisException thrownException = task.exception;
6222 DartEntry dartEntry = null; 6708 DartEntry dartEntry = null;
6223 { 6709 {
6224 SourceEntry sourceEntry = _cache.get(unitSource); 6710 SourceEntry sourceEntry = _cache.get(unitSource);
6225 if (sourceEntry is! DartEntry) { 6711 if (sourceEntry == null) {
6712 throw new ObsoleteSourceAnalysisException(unitSource);
6713 } else if (sourceEntry is! DartEntry) {
6226 // This shouldn't be possible because we should never have performed the task if the source 6714 // This shouldn't be possible because we should never have performed the task if the source
6227 // didn't represent a Dart file, but check to be safe. 6715 // didn't represent a Dart file, but check to be safe.
6228 throw new AnalysisException.con1("Internal error: attempting to resolve non-Dart file as a Dart file: ${unitSource.fullName}"); 6716 throw new AnalysisException.con1("Internal error: attempting to resolve non-Dart file as a Dart file: ${unitSource.fullName}");
6229 } 6717 }
6230 dartEntry = sourceEntry as DartEntry; 6718 dartEntry = sourceEntry as DartEntry;
6231 int sourceTime = unitSource.modificationStamp; 6719 int sourceTime = getModificationStamp(unitSource);
6232 int resultTime = task.modificationTime; 6720 int resultTime = task.modificationTime;
6233 if (sourceTime == resultTime) { 6721 if (sourceTime == resultTime) {
6234 if (dartEntry.modificationTime != sourceTime) { 6722 if (dartEntry.modificationTime != sourceTime) {
6235 // The source has changed without the context being notified. Simulate notification. 6723 // The source has changed without the context being notified. Simulate notification.
6236 sourceChanged(unitSource); 6724 sourceChanged(unitSource);
6237 dartEntry = getReadableDartEntry(unitSource); 6725 dartEntry = getReadableDartEntry(unitSource);
6238 if (dartEntry == null) { 6726 if (dartEntry == null) {
6239 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${unitSource.fullName}"); 6727 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${unitSource.fullName}");
6240 } 6728 }
6241 } 6729 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
6292 * @param task the task that was performed 6780 * @param task the task that was performed
6293 * @return an entry containing the computed results 6781 * @return an entry containing the computed results
6294 * @throws AnalysisException if the results could not be recorded 6782 * @throws AnalysisException if the results could not be recorded
6295 */ 6783 */
6296 SourceEntry recordResolveHtmlTaskResults(ResolveHtmlTask task) { 6784 SourceEntry recordResolveHtmlTaskResults(ResolveHtmlTask task) {
6297 Source source = task.source; 6785 Source source = task.source;
6298 AnalysisException thrownException = task.exception; 6786 AnalysisException thrownException = task.exception;
6299 HtmlEntry htmlEntry = null; 6787 HtmlEntry htmlEntry = null;
6300 { 6788 {
6301 SourceEntry sourceEntry = _cache.get(source); 6789 SourceEntry sourceEntry = _cache.get(source);
6302 if (sourceEntry is! HtmlEntry) { 6790 if (sourceEntry == null) {
6791 throw new ObsoleteSourceAnalysisException(source);
6792 } else if (sourceEntry is! HtmlEntry) {
6303 // This shouldn't be possible because we should never have performed the task if the source 6793 // This shouldn't be possible because we should never have performed the task if the source
6304 // didn't represent an HTML file, but check to be safe. 6794 // didn't represent an HTML file, but check to be safe.
6305 throw new AnalysisException.con1("Internal error: attempting to resolve non-HTML file as an HTML file: ${source.fullName}"); 6795 throw new AnalysisException.con1("Internal error: attempting to resolve non-HTML file as an HTML file: ${source.fullName}");
6306 } 6796 }
6307 htmlEntry = sourceEntry as HtmlEntry; 6797 htmlEntry = sourceEntry as HtmlEntry;
6308 int sourceTime = source.modificationStamp; 6798 int sourceTime = getModificationStamp(source);
6309 int resultTime = task.modificationTime; 6799 int resultTime = task.modificationTime;
6310 if (sourceTime == resultTime) { 6800 if (sourceTime == resultTime) {
6311 if (htmlEntry.modificationTime != sourceTime) { 6801 if (htmlEntry.modificationTime != sourceTime) {
6312 // The source has changed without the context being notified. Simulate notification. 6802 // The source has changed without the context being notified. Simulate notification.
6313 sourceChanged(source); 6803 sourceChanged(source);
6314 htmlEntry = getReadableHtmlEntry(source); 6804 htmlEntry = getReadableHtmlEntry(source);
6315 if (htmlEntry == null) { 6805 if (htmlEntry == null) {
6316 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}"); 6806 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}");
6317 } 6807 }
6318 } 6808 }
6319 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 6809 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
6320 if (thrownException == null) { 6810 if (thrownException == null) {
6321 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); 6811 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
6322 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); 6812 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
6323 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); 6813 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element);
6324 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); 6814 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors);
6325 _cache.storedAst(source); 6815 _cache.storedAst(source);
6326 ChangeNoticeImpl notice = getNotice(source); 6816 ChangeNoticeImpl notice = getNotice(source);
6327 notice.htmlUnit = task.resolvedUnit; 6817 notice.htmlUnit = task.resolvedUnit;
6328 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN E_INFO)); 6818 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN E_INFO));
6329 } else { 6819 } else {
6330 htmlCopy.recordResolutionError(); 6820 htmlCopy.recordResolutionError();
6331 _cache.removedAst(source); 6821 _cache.removedAst(source);
6332 } 6822 }
6333 htmlCopy.exception = thrownException; 6823 htmlCopy.exception = thrownException;
6334 recordAngularComponents(htmlCopy, task.angularApplication);
6335 _cache.put(source, htmlCopy); 6824 _cache.put(source, htmlCopy);
6336 htmlEntry = htmlCopy; 6825 htmlEntry = htmlCopy;
6337 } else { 6826 } else {
6338 logInformation2("Resolution results discarded for ${debuggingString(sour ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html Entry.modificationTime}", thrownException); 6827 logInformation2("Resolution results discarded for ${debuggingString(sour ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html Entry.modificationTime}", thrownException);
6339 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 6828 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
6340 if (thrownException == null || resultTime >= 0) { 6829 if (thrownException == null || resultTime >= 0) {
6341 // 6830 //
6342 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources 6831 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources
6343 // will be re-analyzed using the up-to-date sources. 6832 // will be re-analyzed using the up-to-date sources.
6344 // 6833 //
(...skipping 19 matching lines...) Expand all
6364 htmlEntry = htmlCopy; 6853 htmlEntry = htmlCopy;
6365 } 6854 }
6366 } 6855 }
6367 if (thrownException != null) { 6856 if (thrownException != null) {
6368 throw thrownException; 6857 throw thrownException;
6369 } 6858 }
6370 return htmlEntry; 6859 return htmlEntry;
6371 } 6860 }
6372 6861
6373 /** 6862 /**
6863 * Record the results produced by performing a [ScanDartTask]. If the results were computed
6864 * from data that is now out-of-date, then the results will not be recorded.
6865 *
6866 * @param task the task that was performed
6867 * @return an entry containing the computed results
6868 * @throws AnalysisException if the results could not be recorded
6869 */
6870 DartEntry recordScanDartTaskResults(ScanDartTask task) {
6871 Source source = task.source;
6872 AnalysisException thrownException = task.exception;
6873 DartEntry dartEntry = null;
6874 {
6875 SourceEntry sourceEntry = _cache.get(source);
6876 if (sourceEntry == null) {
6877 throw new ObsoleteSourceAnalysisException(source);
6878 } else if (sourceEntry is! DartEntry) {
6879 // This shouldn't be possible because we should never have performed the task if the source
6880 // didn't represent a Dart file, but check to be safe.
6881 throw new AnalysisException.con1("Internal error: attempting to parse no n-Dart file as a Dart file: ${source.fullName}");
6882 }
6883 dartEntry = sourceEntry as DartEntry;
6884 int sourceTime = getModificationStamp(source);
6885 int resultTime = task.modificationTime;
6886 if (sourceTime == resultTime) {
6887 if (dartEntry.modificationTime != sourceTime) {
6888 // The source has changed without the context being notified. Simulate notification.
6889 sourceChanged(source);
6890 dartEntry = getReadableDartEntry(source);
6891 if (dartEntry == null) {
6892 throw new AnalysisException.con1("A Dart file became a non-Dart file : ${source.fullName}");
6893 }
6894 }
6895 DartEntryImpl dartCopy = dartEntry.writableCopy;
6896 if (thrownException == null) {
6897 LineInfo lineInfo = task.lineInfo;
6898 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
6899 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream);
6900 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors);
6901 _cache.storedAst(source);
6902 _workManager.add(source, SourcePriority.NORMAL_PART);
6903 ChangeNoticeImpl notice = getNotice(source);
6904 notice.setErrors(dartEntry.allErrors, lineInfo);
6905 } else {
6906 removeFromParts(source, dartEntry);
6907 dartCopy.recordScanError();
6908 _cache.removedAst(source);
6909 }
6910 dartCopy.exception = thrownException;
6911 _cache.put(source, dartCopy);
6912 dartEntry = dartCopy;
6913 } else {
6914 logInformation2("Scan results discarded for ${debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry. modificationTime}", thrownException);
6915 DartEntryImpl dartCopy = dartEntry.writableCopy;
6916 if (thrownException == null || resultTime >= 0) {
6917 //
6918 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources
6919 // will be re-analyzed using the up-to-date sources.
6920 //
6921 // dartCopy.recordScanNotInProcess();
6922 removeFromParts(source, dartEntry);
6923 dartCopy.invalidateAllInformation();
6924 dartCopy.modificationTime = sourceTime;
6925 _cache.removedAst(source);
6926 _workManager.add(source, SourcePriority.UNKNOWN);
6927 } else {
6928 //
6929 // We could not determine whether the sources were up-to-date or out-o f-date. Mark the
6930 // cache so that we won't attempt to re-analyze the sources until ther e's a good chance
6931 // that we'll be able to do so without error.
6932 //
6933 dartCopy.recordScanError();
6934 }
6935 dartCopy.exception = thrownException;
6936 _cache.put(source, dartCopy);
6937 dartEntry = dartCopy;
6938 }
6939 }
6940 if (thrownException != null) {
6941 throw thrownException;
6942 }
6943 return dartEntry;
6944 }
6945
6946 /**
6374 * Remove the given library from the list of containing libraries for all of t he parts referenced 6947 * Remove the given library from the list of containing libraries for all of t he parts referenced
6375 * by the given entry. 6948 * by the given entry.
6376 * 6949 *
6377 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 6950 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
6378 * 6951 *
6379 * @param librarySource the library to be removed 6952 * @param librarySource the library to be removed
6380 * @param dartEntry the entry containing the list of included parts 6953 * @param dartEntry the entry containing the list of included parts
6381 */ 6954 */
6382 void removeFromParts(Source librarySource, DartEntry dartEntry) { 6955 void removeFromParts(Source librarySource, DartEntry dartEntry) {
6383 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); 6956 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6420 * @return `true` if the new source is a Dart file 6993 * @return `true` if the new source is a Dart file
6421 */ 6994 */
6422 bool sourceAvailable(Source source) { 6995 bool sourceAvailable(Source source) {
6423 SourceEntry sourceEntry = _cache.get(source); 6996 SourceEntry sourceEntry = _cache.get(source);
6424 if (sourceEntry == null) { 6997 if (sourceEntry == null) {
6425 sourceEntry = createSourceEntry(source); 6998 sourceEntry = createSourceEntry(source);
6426 logInformation("Added new source: ${debuggingString(source)}"); 6999 logInformation("Added new source: ${debuggingString(source)}");
6427 } else { 7000 } else {
6428 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; 7001 SourceEntryImpl sourceCopy = sourceEntry.writableCopy;
6429 int oldTime = sourceCopy.modificationTime; 7002 int oldTime = sourceCopy.modificationTime;
6430 sourceCopy.modificationTime = source.modificationStamp; 7003 sourceCopy.modificationTime = getModificationStamp(source);
6431 // TODO(brianwilkerson) Understand why we're not invalidating the cache. 7004 // TODO(brianwilkerson) Understand why we're not invalidating the cache.
6432 _cache.put(source, sourceCopy); 7005 _cache.put(source, sourceCopy);
6433 logInformation("Added new source: ${debuggingString(source)} (previously m odified at ${oldTime})"); 7006 logInformation("Added new source: ${debuggingString(source)} (previously m odified at ${oldTime})");
6434 } 7007 }
6435 if (sourceEntry is HtmlEntry) { 7008 if (sourceEntry is HtmlEntry) {
6436 _workManager.add(source, SourcePriority.HTML); 7009 _workManager.add(source, SourcePriority.HTML);
6437 } else { 7010 } else {
6438 _workManager.add(source, SourcePriority.UNKNOWN); 7011 _workManager.add(source, SourcePriority.UNKNOWN);
6439 } 7012 }
6440 return sourceEntry is DartEntry; 7013 return sourceEntry is DartEntry;
6441 } 7014 }
6442 7015
6443 /** 7016 /**
6444 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 7017 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
6445 * 7018 *
6446 * @param source the source that has been changed 7019 * @param source the source that has been changed
6447 */ 7020 */
6448 void sourceChanged(Source source) { 7021 void sourceChanged(Source source) {
6449 SourceEntry sourceEntry = _cache.get(source); 7022 SourceEntry sourceEntry = _cache.get(source);
6450 if (sourceEntry == null || sourceEntry.modificationTime == source.modificati onStamp) { 7023 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt amp(source)) {
6451 // Either we have removed this source, in which case we don't care that it is changed, or we 7024 // Either we have removed this source, in which case we don't care that it is changed, or we
6452 // have already invalidated the cache and don't need to invalidate it agai n. 7025 // have already invalidated the cache and don't need to invalidate it agai n.
6453 if (sourceEntry == null) { 7026 if (sourceEntry == null) {
6454 logInformation("Modified source, but there is no entry: ${debuggingStrin g(source)}"); 7027 logInformation("Modified source, but there is no entry: ${debuggingStrin g(source)}");
6455 } else { 7028 } else {
6456 logInformation("Modified source, but modification time matches: ${debugg ingString(source)}"); 7029 logInformation("Modified source, but modification time matches: ${debugg ingString(source)}");
6457 } 7030 }
6458 return; 7031 return;
6459 } 7032 }
6460 if (sourceEntry is HtmlEntry) { 7033 if (sourceEntry is HtmlEntry) {
6461 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; 7034 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy;
6462 int oldTime = htmlCopy.modificationTime; 7035 int oldTime = htmlCopy.modificationTime;
6463 htmlCopy.modificationTime = source.modificationStamp; 7036 htmlCopy.modificationTime = getModificationStamp(source);
7037 invalidateAngularResolution(htmlCopy);
6464 htmlCopy.invalidateAllInformation(); 7038 htmlCopy.invalidateAllInformation();
6465 _cache.put(source, htmlCopy); 7039 _cache.put(source, htmlCopy);
6466 _cache.removedAst(source); 7040 _cache.removedAst(source);
6467 _workManager.add(source, SourcePriority.HTML); 7041 _workManager.add(source, SourcePriority.HTML);
6468 logInformation("Modified HTML source: ${debuggingString(source)} (previous ly modified at ${oldTime})"); 7042 logInformation("Modified HTML source: ${debuggingString(source)} (previous ly modified at ${oldTime})");
6469 } else if (sourceEntry is DartEntry) { 7043 } else if (sourceEntry is DartEntry) {
6470 List<Source> containingLibraries = getLibrariesContaining(source); 7044 List<Source> containingLibraries = getLibrariesContaining(source);
6471 Set<Source> librariesToInvalidate = new Set<Source>(); 7045 Set<Source> librariesToInvalidate = new Set<Source>();
6472 for (Source containingLibrary in containingLibraries) { 7046 for (Source containingLibrary in containingLibraries) {
6473 librariesToInvalidate.add(containingLibrary); 7047 librariesToInvalidate.add(containingLibrary);
6474 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar y)) { 7048 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar y)) {
6475 librariesToInvalidate.add(dependentLibrary); 7049 librariesToInvalidate.add(dependentLibrary);
6476 } 7050 }
6477 } 7051 }
6478 PrintStringWriter writer = new PrintStringWriter(); 7052 PrintStringWriter writer = new PrintStringWriter();
6479 int oldTime = sourceEntry.modificationTime; 7053 int oldTime = sourceEntry.modificationTime;
6480 writer.println("Modified Dart source: ${debuggingString(source)} (previous ly modified at ${oldTime})"); 7054 writer.println("Modified Dart source: ${debuggingString(source)} (previous ly modified at ${oldTime})");
6481 for (Source library in librariesToInvalidate) { 7055 for (Source library in librariesToInvalidate) {
6482 // for (Source library : containingLibraries) { 7056 // for (Source library : containingLibraries) {
6483 invalidateLibraryResolution(library, writer); 7057 invalidateLibraryResolution(library, writer);
6484 } 7058 }
6485 removeFromParts(source, sourceEntry); 7059 removeFromParts(source, _cache.get(source) as DartEntry);
6486 DartEntryImpl dartCopy = sourceEntry.writableCopy; 7060 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy;
6487 dartCopy.modificationTime = source.modificationStamp; 7061 dartCopy.modificationTime = getModificationStamp(source);
6488 dartCopy.invalidateAllInformation(); 7062 dartCopy.invalidateAllInformation();
6489 _cache.put(source, dartCopy); 7063 _cache.put(source, dartCopy);
6490 _cache.removedAst(source); 7064 _cache.removedAst(source);
6491 _workManager.add(source, SourcePriority.UNKNOWN); 7065 _workManager.add(source, SourcePriority.UNKNOWN);
6492 logInformation(writer.toString()); 7066 logInformation(writer.toString());
6493 } 7067 }
6494 } 7068 }
6495 7069
6496 /** 7070 /**
6497 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 7071 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
6498 * 7072 *
6499 * @param source the source that has been deleted 7073 * @param source the source that has been deleted
6500 */ 7074 */
6501 void sourceRemoved(Source source) { 7075 void sourceRemoved(Source source) {
6502 PrintStringWriter writer = new PrintStringWriter(); 7076 PrintStringWriter writer = new PrintStringWriter();
6503 writer.println("Removed source: ${debuggingString(source)}"); 7077 writer.println("Removed source: ${debuggingString(source)}");
6504 SourceEntry sourceEntry = _cache.get(source); 7078 SourceEntry sourceEntry = _cache.get(source);
6505 if (sourceEntry is DartEntry) { 7079 if (sourceEntry is HtmlEntry) {
7080 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy;
7081 invalidateAngularResolution(htmlCopy);
7082 } else if (sourceEntry is DartEntry) {
6506 Set<Source> libraries = new Set<Source>(); 7083 Set<Source> libraries = new Set<Source>();
6507 for (Source librarySource in getLibrariesContaining(source)) { 7084 for (Source librarySource in getLibrariesContaining(source)) {
6508 libraries.add(librarySource); 7085 libraries.add(librarySource);
6509 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) { 7086 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) {
6510 libraries.add(dependentLibrary); 7087 libraries.add(dependentLibrary);
6511 } 7088 }
6512 } 7089 }
6513 for (Source librarySource in libraries) { 7090 for (Source librarySource in libraries) {
6514 invalidateLibraryResolution(librarySource, writer); 7091 invalidateLibraryResolution(librarySource, writer);
6515 } 7092 }
(...skipping 14 matching lines...) Expand all
6530 * @return `true` if at least one entry was invalid 7107 * @return `true` if at least one entry was invalid
6531 */ 7108 */
6532 bool validateCacheConsistency() { 7109 bool validateCacheConsistency() {
6533 int consistencyCheckStart = JavaSystem.nanoTime(); 7110 int consistencyCheckStart = JavaSystem.nanoTime();
6534 List<Source> missingSources = new List<Source>(); 7111 List<Source> missingSources = new List<Source>();
6535 int inconsistentCount = 0; 7112 int inconsistentCount = 0;
6536 { 7113 {
6537 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 7114 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
6538 Source source = entry.getKey(); 7115 Source source = entry.getKey();
6539 SourceEntry sourceEntry = entry.getValue(); 7116 SourceEntry sourceEntry = entry.getValue();
6540 int sourceTime = source.modificationStamp; 7117 int sourceTime = getModificationStamp(source);
6541 if (sourceTime != sourceEntry.modificationTime) { 7118 if (sourceTime != sourceEntry.modificationTime) {
6542 sourceChanged(source); 7119 sourceChanged(source);
6543 inconsistentCount++; 7120 inconsistentCount++;
6544 } 7121 }
6545 if (sourceEntry.exception != null) { 7122 if (sourceEntry.exception != null) {
6546 if (!source.exists()) { 7123 if (!exists(source)) {
6547 missingSources.add(source); 7124 missingSources.add(source);
6548 } 7125 }
6549 } 7126 }
6550 } 7127 }
6551 } 7128 }
6552 int consistencyCheckEnd = JavaSystem.nanoTime(); 7129 int consistencyCheckEnd = JavaSystem.nanoTime();
6553 PrintStringWriter writer = new PrintStringWriter(); 7130 PrintStringWriter writer = new PrintStringWriter();
6554 writer.print("Consistency check took "); 7131 writer.print("Consistency check took ");
6555 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); 7132 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0);
6556 writer.println(" ms and found"); 7133 writer.println(" ms and found");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6592 7169
6593 SourceEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) => AnalysisContextImpl_this.recordResolveAngularEntryHtmlTaskResults(task); 7170 SourceEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) => AnalysisContextImpl_this.recordResolveAngularEntryHtmlTaskResults(task);
6594 7171
6595 DartEntry visitResolveDartDependenciesTask(ResolveDartDependenciesTask task) = > AnalysisContextImpl_this.recordResolveDartDependenciesTaskResults(task); 7172 DartEntry visitResolveDartDependenciesTask(ResolveDartDependenciesTask task) = > AnalysisContextImpl_this.recordResolveDartDependenciesTaskResults(task);
6596 7173
6597 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis ContextImpl_this.recordResolveDartLibraryTaskResults(task); 7174 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis ContextImpl_this.recordResolveDartLibraryTaskResults(task);
6598 7175
6599 SourceEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisCont extImpl_this.recordResolveDartUnitTaskResults(task); 7176 SourceEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisCont extImpl_this.recordResolveDartUnitTaskResults(task);
6600 7177
6601 SourceEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_ this.recordResolveHtmlTaskResults(task); 7178 SourceEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_ this.recordResolveHtmlTaskResults(task);
7179
7180 SourceEntry visitScanDartTask(ScanDartTask task) => AnalysisContextImpl_this.r ecordScanDartTaskResults(task);
6602 } 7181 }
6603 7182
6604 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy { 7183 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy {
6605 final AnalysisContextImpl AnalysisContextImpl_this; 7184 final AnalysisContextImpl AnalysisContextImpl_this;
6606 7185
6607 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this); 7186 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this);
6608 7187
6609 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { 7188 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) {
6610 for (Source prioritySource in AnalysisContextImpl_this._priorityOrder) { 7189 for (Source prioritySource in AnalysisContextImpl_this._priorityOrder) {
6611 if (source == prioritySource) { 7190 if (source == prioritySource) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
6667 * A flag indicating whether analysis is to parse and analyze function bodies. 7246 * A flag indicating whether analysis is to parse and analyze function bodies.
6668 */ 7247 */
6669 bool analyzeFunctionBodies = true; 7248 bool analyzeFunctionBodies = true;
6670 7249
6671 /** 7250 /**
6672 * A flag indicating whether analysis is to generate dart2js related hint resu lts. 7251 * A flag indicating whether analysis is to generate dart2js related hint resu lts.
6673 */ 7252 */
6674 bool dart2jsHint = true; 7253 bool dart2jsHint = true;
6675 7254
6676 /** 7255 /**
7256 * A flag indicating whether errors, warnings and hints should be generated fo r sources in the
7257 * SDK.
7258 */
7259 bool _generateSdkErrors = false;
7260
7261 /**
6677 * A flag indicating whether analysis is to generate hint results (e.g. type i nference based 7262 * A flag indicating whether analysis is to generate hint results (e.g. type i nference based
6678 * information and pub best practices). 7263 * information and pub best practices).
6679 */ 7264 */
6680 bool hint = true; 7265 bool hint = true;
6681 7266
6682 /** 7267 /**
6683 * A flag indicating whether incremental analysis should be used. 7268 * A flag indicating whether incremental analysis should be used.
6684 */ 7269 */
6685 bool incremental = false; 7270 bool incremental = false;
6686 7271
6687 /** 7272 /**
6688 * A flag indicating whether analysis is to parse comments. 7273 * A flag indicating whether analysis is to parse comments.
6689 */ 7274 */
6690 bool preserveComments = true; 7275 bool preserveComments = true;
6691 7276
6692 /** 7277 /**
6693 * A flag indicating whether analysis is to parse comments. 7278 * A flag indicating whether analysis is to analyze Angular.
6694 */ 7279 */
6695 bool analyzeAngular = true; 7280 bool analyzeAngular = true;
6696 7281
6697 /** 7282 /**
6698 * Initialize a newly created set of analysis options to have their default va lues. 7283 * Initialize a newly created set of analysis options to have their default va lues.
6699 */ 7284 */
6700 AnalysisOptionsImpl(); 7285 AnalysisOptionsImpl();
6701 7286
6702 /** 7287 /**
6703 * Initialize a newly created set of analysis options to have the same values as those in the 7288 * Initialize a newly created set of analysis options to have the same values as those in the
6704 * given set of analysis options. 7289 * given set of analysis options.
6705 * 7290 *
6706 * @param options the analysis options whose values are being copied 7291 * @param options the analysis options whose values are being copied
6707 */ 7292 */
6708 AnalysisOptionsImpl.con1(AnalysisOptions options) { 7293 AnalysisOptionsImpl.con1(AnalysisOptions options) {
6709 cacheSize = options.cacheSize; 7294 cacheSize = options.cacheSize;
6710 dart2jsHint = options.dart2jsHint; 7295 dart2jsHint = options.dart2jsHint;
6711 hint = options.hint; 7296 hint = options.hint;
6712 incremental = options.incremental; 7297 incremental = options.incremental;
6713 analyzeAngular = options.analyzeAngular; 7298 }
7299
7300 bool get generateSdkErrors => _generateSdkErrors;
7301
7302 /**
7303 * Set whether errors, warnings and hints should be generated for sources in t he SDK to match the
7304 * given value.
7305 *
7306 * @param generate `true` if errors, warnings and hints should be generated fo r sources in
7307 * the SDK
7308 */
7309 void set generateSdkErrors(bool generate) {
7310 _generateSdkErrors = generate;
6714 } 7311 }
6715 } 7312 }
6716 7313
6717 /** 7314 /**
6718 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis results 7315 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis results
6719 * associated with a given source. 7316 * associated with a given source.
6720 * 7317 *
6721 * @coverage dart.engine 7318 * @coverage dart.engine
6722 */ 7319 */
6723 class ChangeNoticeImpl implements ChangeNotice { 7320 class ChangeNoticeImpl implements ChangeNotice {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6769 * Set the errors that changed as a result of the analysis to the given errors and set the line 7366 * Set the errors that changed as a result of the analysis to the given errors and set the line
6770 * information to the given line information. 7367 * information to the given line information.
6771 * 7368 *
6772 * @param errors the errors that changed as a result of the analysis 7369 * @param errors the errors that changed as a result of the analysis
6773 * @param lineInfo the line information associated with the source 7370 * @param lineInfo the line information associated with the source
6774 */ 7371 */
6775 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) { 7372 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) {
6776 this._errors = errors; 7373 this._errors = errors;
6777 this._lineInfo = lineInfo; 7374 this._lineInfo = lineInfo;
6778 if (lineInfo == null) { 7375 if (lineInfo == null) {
6779 AnalysisEngine.instance.logger.logError2("No line info: ${source}", new Ja vaException()); 7376 AnalysisEngine.instance.logger.logInformation3("No line info: ${source}", new JavaException());
6780 } 7377 }
6781 } 7378 }
6782 7379
6783 String toString() => "Changes for ${source.fullName}"; 7380 String toString() => "Changes for ${source.fullName}";
6784 } 7381 }
6785 7382
6786 /** 7383 /**
6787 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex tImpl 7384 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex tImpl
6788 ] to delegate sources to the appropriate analysis context. For instance, if the 7385 ] to delegate sources to the appropriate analysis context. For instance, if the
6789 * source is in a system library then the analysis context from the [DartSdk] is used. 7386 * source is in a system library then the analysis context from the [DartSdk] is used.
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
7319 try { 7916 try {
7320 instrumentation.metric3("contextId", _contextId); 7917 instrumentation.metric3("contextId", _contextId);
7321 List<AnalysisError> errors = _basis.computeErrors(source); 7918 List<AnalysisError> errors = _basis.computeErrors(source);
7322 instrumentation.metric2("Errors-count", errors.length); 7919 instrumentation.metric2("Errors-count", errors.length);
7323 return errors; 7920 return errors;
7324 } finally { 7921 } finally {
7325 instrumentation.log(); 7922 instrumentation.log();
7326 } 7923 }
7327 } 7924 }
7328 7925
7329 List<Source> computeExportedLibraries(Source source) { 7926 List<Source> computeExportedLibraries(Source source) => _basis.computeExported Libraries(source);
7330 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeExportedLibraries");
7331 try {
7332 instrumentation.metric3("contextId", _contextId);
7333 return _basis.computeExportedLibraries(source);
7334 } finally {
7335 instrumentation.log();
7336 }
7337 }
7338 7927
7339 HtmlElement computeHtmlElement(Source source) { 7928 HtmlElement computeHtmlElement(Source source) {
7340 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeHtmlElement"); 7929 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeHtmlElement");
7341 try { 7930 try {
7342 instrumentation.metric3("contextId", _contextId); 7931 instrumentation.metric3("contextId", _contextId);
7343 return _basis.computeHtmlElement(source); 7932 return _basis.computeHtmlElement(source);
7344 } on AnalysisException catch (e) { 7933 } on AnalysisException catch (e) {
7345 recordAnalysisException(instrumentation, e); 7934 recordAnalysisException(instrumentation, e);
7346 throw e; 7935 throw e;
7347 } finally { 7936 } finally {
7348 instrumentation.log(); 7937 instrumentation.log();
7349 } 7938 }
7350 } 7939 }
7351 7940
7352 List<Source> computeImportedLibraries(Source source) { 7941 List<Source> computeImportedLibraries(Source source) => _basis.computeImported Libraries(source);
7353 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeImportedLibraries");
7354 try {
7355 instrumentation.metric3("contextId", _contextId);
7356 return _basis.computeImportedLibraries(source);
7357 } finally {
7358 instrumentation.log();
7359 }
7360 }
7361 7942
7362 SourceKind computeKindOf(Source source) { 7943 SourceKind computeKindOf(Source source) {
7363 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeKindOf"); 7944 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeKindOf");
7364 try { 7945 try {
7365 instrumentation.metric3("contextId", _contextId); 7946 instrumentation.metric3("contextId", _contextId);
7366 return _basis.computeKindOf(source); 7947 return _basis.computeKindOf(source);
7367 } finally { 7948 } finally {
7368 instrumentation.log(); 7949 instrumentation.log();
7369 } 7950 }
7370 } 7951 }
(...skipping 23 matching lines...) Expand all
7394 instrumentation.log(); 7975 instrumentation.log();
7395 } 7976 }
7396 } 7977 }
7397 7978
7398 ResolvableHtmlUnit computeResolvableAngularComponentHtmlUnit(Source source) => _basis.computeResolvableAngularComponentHtmlUnit(source); 7979 ResolvableHtmlUnit computeResolvableAngularComponentHtmlUnit(Source source) => _basis.computeResolvableAngularComponentHtmlUnit(source);
7399 7980
7400 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => _ basis.computeResolvableCompilationUnit(source); 7981 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => _ basis.computeResolvableCompilationUnit(source);
7401 7982
7402 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) => _basis.computeR esolvableHtmlUnit(source); 7983 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) => _basis.computeR esolvableHtmlUnit(source);
7403 7984
7985 bool exists(Source source) {
7986 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- exists");
7987 try {
7988 instrumentation.metric3("contextId", _contextId);
7989 return _basis.exists(source);
7990 } finally {
7991 instrumentation.log();
7992 }
7993 }
7994
7404 AnalysisContext extractContext(SourceContainer container) { 7995 AnalysisContext extractContext(SourceContainer container) {
7405 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- extractContext"); 7996 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- extractContext");
7406 try { 7997 try {
7407 instrumentation.metric3("contextId", _contextId); 7998 instrumentation.metric3("contextId", _contextId);
7408 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte xtImpl(); 7999 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte xtImpl();
7409 _basis.extractContextInto(container, newContext._basis); 8000 _basis.extractContextInto(container, newContext._basis);
7410 return newContext; 8001 return newContext;
7411 } finally { 8002 } finally {
7412 instrumentation.log(); 8003 instrumentation.log();
7413 } 8004 }
7414 } 8005 }
7415 8006
7416 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) => _basis.extractContextInto(container, newContext); 8007 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) => _basis.extractContextInto(container, newContext);
7417 8008
7418 AnalysisOptions get analysisOptions { 8009 AnalysisOptions get analysisOptions {
7419 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getAnalysisOptions"); 8010 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getAnalysisOptions");
7420 try { 8011 try {
7421 instrumentation.metric3("contextId", _contextId); 8012 instrumentation.metric3("contextId", _contextId);
7422 return _basis.analysisOptions; 8013 return _basis.analysisOptions;
7423 } finally { 8014 } finally {
7424 instrumentation.log(); 8015 instrumentation.log();
7425 } 8016 }
7426 } 8017 }
7427 8018
7428 /** 8019 /**
7429 * @return the underlying [AnalysisContext]. 8020 * @return the underlying [AnalysisContext].
7430 */ 8021 */
7431 AnalysisContext get basis => _basis; 8022 AnalysisContext get basis => _basis;
7432 8023
8024 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib rarySource) {
8025 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getCompilationUnitElement");
8026 try {
8027 instrumentation.metric3("contextId", _contextId);
8028 return _basis.getCompilationUnitElement(unitSource, librarySource);
8029 } finally {
8030 instrumentation.log();
8031 }
8032 }
8033
8034 TimestampedData<String> getContents(Source source) => _basis.getContents(sourc e);
8035
8036 void getContents2(Source source, Source_ContentReceiver receiver) {
8037 _basis.getContents2(source, receiver);
8038 }
8039
7433 Element getElement(ElementLocation location) { 8040 Element getElement(ElementLocation location) {
7434 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getElement"); 8041 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getElement");
7435 try { 8042 try {
7436 instrumentation.metric3("contextId", _contextId); 8043 instrumentation.metric3("contextId", _contextId);
7437 return _basis.getElement(location); 8044 return _basis.getElement(location);
7438 } finally { 8045 } finally {
7439 instrumentation.log(); 8046 instrumentation.log();
7440 } 8047 }
7441 } 8048 }
7442 8049
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
7583 } 8190 }
7584 8191
7585 LineInfo getLineInfo(Source source) { 8192 LineInfo getLineInfo(Source source) {
7586 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLineInfo"); 8193 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLineInfo");
7587 try { 8194 try {
7588 instrumentation.metric3("contextId", _contextId); 8195 instrumentation.metric3("contextId", _contextId);
7589 return _basis.getLineInfo(source); 8196 return _basis.getLineInfo(source);
7590 } finally { 8197 } finally {
7591 instrumentation.log(); 8198 instrumentation.log();
7592 } 8199 }
8200 }
8201
8202 int getModificationStamp(Source source) {
8203 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getModificationStamp");
8204 try {
8205 instrumentation.metric3("contextId", _contextId);
8206 return _basis.getModificationStamp(source);
8207 } finally {
8208 instrumentation.log();
8209 }
7593 } 8210 }
7594 8211
7595 Namespace getPublicNamespace(LibraryElement library) => _basis.getPublicNamesp ace(library); 8212 Namespace getPublicNamespace(LibraryElement library) => _basis.getPublicNamesp ace(library);
7596 8213
7597 Namespace getPublicNamespace2(Source source) => _basis.getPublicNamespace2(sou rce); 8214 Namespace getPublicNamespace2(Source source) => _basis.getPublicNamespace2(sou rce);
7598 8215
7599 List<Source> get refactoringUnsafeSources => _basis.refactoringUnsafeSources; 8216 List<Source> get refactoringUnsafeSources {
8217 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getRefactoringUnsafeSources");
8218 try {
8219 instrumentation.metric3("contextId", _contextId);
8220 return _basis.refactoringUnsafeSources;
8221 } finally {
8222 instrumentation.log();
8223 }
8224 }
7600 8225
7601 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) { 8226 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) {
7602 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getResolvedCompilationUnit"); 8227 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getResolvedCompilationUnit");
7603 try { 8228 try {
7604 instrumentation.metric3("contextId", _contextId); 8229 instrumentation.metric3("contextId", _contextId);
7605 return _basis.getResolvedCompilationUnit(unitSource, library); 8230 return _basis.getResolvedCompilationUnit(unitSource, library);
7606 } finally { 8231 } finally {
7607 instrumentation.log(); 8232 instrumentation.log();
7608 } 8233 }
7609 } 8234 }
(...skipping 25 matching lines...) Expand all
7635 return _basis.sourceFactory; 8260 return _basis.sourceFactory;
7636 } finally { 8261 } finally {
7637 instrumentation.log2(2); 8262 instrumentation.log2(2);
7638 } 8263 }
7639 } 8264 }
7640 8265
7641 AnalysisContentStatistics get statistics => _basis.statistics; 8266 AnalysisContentStatistics get statistics => _basis.statistics;
7642 8267
7643 TypeProvider get typeProvider => _basis.typeProvider; 8268 TypeProvider get typeProvider => _basis.typeProvider;
7644 8269
8270 TimestampedData<CompilationUnit> internalParseCompilationUnit(Source source) = > _basis.internalParseCompilationUnit(source);
8271
7645 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement) => _basis.internalResolveCompilationUnit(uni tSource, libraryElement); 8272 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement) => _basis.internalResolveCompilationUnit(uni tSource, libraryElement);
7646 8273
8274 TimestampedData<Token> internalScanTokenStream(Source source) => _basis.intern alScanTokenStream(source);
8275
7647 bool isClientLibrary(Source librarySource) { 8276 bool isClientLibrary(Source librarySource) {
7648 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- isClientLibrary"); 8277 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- isClientLibrary");
7649 try { 8278 try {
7650 instrumentation.metric3("contextId", _contextId); 8279 instrumentation.metric3("contextId", _contextId);
7651 return _basis.isClientLibrary(librarySource); 8280 return _basis.isClientLibrary(librarySource);
7652 } finally { 8281 } finally {
7653 instrumentation.log(); 8282 instrumentation.log();
7654 } 8283 }
7655 } 8284 }
7656 8285
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
7802 8431
7803 void set sourceFactory(SourceFactory factory) { 8432 void set sourceFactory(SourceFactory factory) {
7804 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setSourceFactory"); 8433 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setSourceFactory");
7805 try { 8434 try {
7806 instrumentation.metric3("contextId", _contextId); 8435 instrumentation.metric3("contextId", _contextId);
7807 _basis.sourceFactory = factory; 8436 _basis.sourceFactory = factory;
7808 } finally { 8437 } finally {
7809 instrumentation.log(); 8438 instrumentation.log();
7810 } 8439 }
7811 } 8440 }
7812
7813 Iterable<Source> sourcesToResolve(List<Source> changedSources) {
7814 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- sourcesToResolve");
7815 try {
7816 instrumentation.metric3("contextId", _contextId);
7817 return _basis.sourcesToResolve(changedSources);
7818 } finally {
7819 instrumentation.log();
7820 }
7821 }
7822 } 8441 }
7823 8442
7824 /** 8443 /**
7825 * The interface `InternalAnalysisContext` defines additional behavior for an an alysis context 8444 * The interface `InternalAnalysisContext` defines additional behavior for an an alysis context
7826 * that is required by internal users of the context. 8445 * that is required by internal users of the context.
7827 */ 8446 */
7828 abstract class InternalAnalysisContext implements AnalysisContext { 8447 abstract class InternalAnalysisContext implements AnalysisContext {
7829 /** 8448 /**
7830 * Add the given source with the given information to this context. 8449 * Add the given source with the given information to this context.
7831 * 8450 *
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
7925 /** 8544 /**
7926 * Returns a type provider for this context or throws an exception if dart:cor e cannot be 8545 * Returns a type provider for this context or throws an exception if dart:cor e cannot be
7927 * resolved. 8546 * resolved.
7928 * 8547 *
7929 * @return the type provider (not `null`) 8548 * @return the type provider (not `null`)
7930 * @throws AnalysisException if dart:core cannot be resolved 8549 * @throws AnalysisException if dart:core cannot be resolved
7931 */ 8550 */
7932 TypeProvider get typeProvider; 8551 TypeProvider get typeProvider;
7933 8552
7934 /** 8553 /**
8554 * Return a time-stamped parsed AST for the given source.
8555 *
8556 * @param source the source of the compilation unit for which an AST is to be returned
8557 * @return a time-stamped AST for the source
8558 * @throws AnalysisException if the source could not be parsed
8559 */
8560 TimestampedData<CompilationUnit> internalParseCompilationUnit(Source source);
8561
8562 /**
7935 * Return a time-stamped fully-resolved compilation unit for the given source in the given 8563 * Return a time-stamped fully-resolved compilation unit for the given source in the given
7936 * library. 8564 * library.
7937 * 8565 *
7938 * @param unitSource the source of the compilation unit for which a resolved A ST structure is to 8566 * @param unitSource the source of the compilation unit for which a resolved A ST structure is to
7939 * be returned 8567 * be returned
7940 * @param libraryElement the element representing the library in which the com pilation unit is to 8568 * @param libraryElement the element representing the library in which the com pilation unit is to
7941 * be resolved 8569 * be resolved
7942 * @return a time-stamped fully-resolved compilation unit for the source 8570 * @return a time-stamped fully-resolved compilation unit for the source
7943 * @throws AnalysisException if the resolved compilation unit could not be com puted 8571 * @throws AnalysisException if the resolved compilation unit could not be com puted
7944 */ 8572 */
7945 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement); 8573 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement);
7946 8574
7947 /** 8575 /**
8576 * Return a time-stamped token stream for the given source.
8577 *
8578 * @param source the source of the compilation unit for which a token stream i s to be returned
8579 * @return a time-stamped token stream for the source
8580 * @throws AnalysisException if the token stream could not be computed
8581 */
8582 TimestampedData<Token> internalScanTokenStream(Source source);
8583
8584 /**
7948 * Given a table mapping the source for the libraries represented by the corre sponding elements to 8585 * Given a table mapping the source for the libraries represented by the corre sponding elements to
7949 * the elements representing the libraries, record those mappings. 8586 * the elements representing the libraries, record those mappings.
7950 * 8587 *
7951 * @param elementMap a table mapping the source for the libraries represented by the elements to 8588 * @param elementMap a table mapping the source for the libraries represented by the elements to
7952 * the elements representing the libraries 8589 * the elements representing the libraries
7953 */ 8590 */
7954 void recordLibraryElements(Map<Source, LibraryElement> elementMap); 8591 void recordLibraryElements(Map<Source, LibraryElement> elementMap);
7955 } 8592 }
7956 8593
7957 /** 8594 /**
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
8460 List<ToolkitObjectElement> toolkitObjects = local.toolkitObjects; 9097 List<ToolkitObjectElement> toolkitObjects = local.toolkitObjects;
8461 if (toolkitObjects.length == 1 && toolkitObjects[0] is AngularElement) { 9098 if (toolkitObjects.length == 1 && toolkitObjects[0] is AngularElement) {
8462 return toolkitObjects[0] as AngularElement; 9099 return toolkitObjects[0] as AngularElement;
8463 } 9100 }
8464 } 9101 }
8465 // not a special Element 9102 // not a special Element
8466 return null; 9103 return null;
8467 } 9104 }
8468 9105
8469 /** 9106 /**
8470 * Returns the array of all top-level Angular elements that could be used in t he application with
8471 * this entry point. Maybe `null` of not an Angular entry point.
8472 */
8473 static List<AngularElement> getAngularElements(AnalysisContext context, ht.Htm lUnit unit) {
8474 if (hasAngularAnnotation(unit)) {
8475 CompilationUnit dartUnit = getDartUnit(context, unit);
8476 if (dartUnit != null) {
8477 LibraryElement libraryElement = dartUnit.element.library;
8478 return getAngularElements2(libraryElement);
8479 }
8480 }
8481 return null;
8482 }
8483
8484 /**
8485 * @return `true` if the given [HtmlUnit] has <code>ng-app</code> annotation. 9107 * @return `true` if the given [HtmlUnit] has <code>ng-app</code> annotation.
8486 */ 9108 */
8487 static bool hasAngularAnnotation(ht.HtmlUnit htmlUnit) { 9109 static bool hasAngularAnnotation(ht.HtmlUnit htmlUnit) {
8488 try { 9110 try {
8489 htmlUnit.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_hasAngular Annotation()); 9111 htmlUnit.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_hasAngular Annotation());
8490 } on AngularHtmlUnitResolver_FoundAppError catch (e) { 9112 } on AngularHtmlUnitResolver_FoundAppError catch (e) {
8491 return true; 9113 return true;
8492 } 9114 }
8493 return false; 9115 return false;
8494 } 9116 }
(...skipping 17 matching lines...) Expand all
8512 } 9134 }
8513 } 9135 }
8514 9136
8515 /** 9137 /**
8516 * Returns the array of all top-level Angular elements that could be used in t his library. 9138 * Returns the array of all top-level Angular elements that could be used in t his library.
8517 * 9139 *
8518 * @param libraryElement the [LibraryElement] to analyze 9140 * @param libraryElement the [LibraryElement] to analyze
8519 * @return the array of all top-level Angular elements that could be used in t his library 9141 * @return the array of all top-level Angular elements that could be used in t his library
8520 */ 9142 */
8521 static void addAngularElements2(Set<AngularElement> angularElements, LibraryEl ement library, Set<LibraryElement> visited) { 9143 static void addAngularElements2(Set<AngularElement> angularElements, LibraryEl ement library, Set<LibraryElement> visited) {
9144 if (library == null) {
9145 return;
9146 }
8522 if (!visited.add(library)) { 9147 if (!visited.add(library)) {
8523 return; 9148 return;
8524 } 9149 }
8525 // add Angular elements from current library 9150 // add Angular elements from current library
8526 for (CompilationUnitElement unit in library.units) { 9151 for (CompilationUnitElement unit in library.units) {
9152 angularElements.addAll(unit.angularViews);
8527 for (ClassElement type in unit.types) { 9153 for (ClassElement type in unit.types) {
8528 addAngularElements(angularElements, type); 9154 addAngularElements(angularElements, type);
8529 } 9155 }
8530 } 9156 }
8531 // handle imports 9157 // handle imports
8532 for (ImportElement importElement in library.imports) { 9158 for (ImportElement importElement in library.imports) {
8533 LibraryElement importedLibrary = importElement.importedLibrary; 9159 LibraryElement importedLibrary = importElement.importedLibrary;
8534 addAngularElements2(angularElements, importedLibrary, visited); 9160 addAngularElements2(angularElements, importedLibrary, visited);
8535 } 9161 }
8536 } 9162 }
8537 9163
8538 static StringToken createStringToken(String name, int offset) => new StringTok en(TokenType.IDENTIFIER, name, offset); 9164 static StringToken createStringToken(String name, int offset) => new StringTok en(TokenType.IDENTIFIER, name, offset);
8539 9165
8540 /** 9166 /**
8541 * Returns the array of all top-level Angular elements that could be used in t his library. 9167 * Returns the array of all top-level Angular elements that could be used in t his library.
8542 * 9168 *
8543 * @param libraryElement the [LibraryElement] to analyze 9169 * @param libraryElement the [LibraryElement] to analyze
8544 * @return the array of all top-level Angular elements that could be used in t his library 9170 * @return the array of all top-level Angular elements that could be used in t his library
8545 */ 9171 */
8546 static List<AngularElement> getAngularElements2(LibraryElement libraryElement) { 9172 static List<AngularElement> getAngularElements(Set<LibraryElement> libraries, LibraryElement libraryElement) {
8547 Set<AngularElement> angularElements = new Set(); 9173 Set<AngularElement> angularElements = new Set();
8548 addAngularElements2(angularElements, libraryElement, new Set()); 9174 addAngularElements2(angularElements, libraryElement, libraries);
8549 return new List.from(angularElements); 9175 return new List.from(angularElements);
8550 } 9176 }
8551 9177
8552 /** 9178 /**
8553 * Returns the external Dart [CompilationUnit] referenced by the given [HtmlUn it]. 9179 * Returns the external Dart [CompilationUnit] referenced by the given [HtmlUn it].
8554 */ 9180 */
8555 static CompilationUnit getDartUnit(AnalysisContext context, ht.HtmlUnit unit) { 9181 static CompilationUnit getDartUnit(AnalysisContext context, ht.HtmlUnit unit) {
8556 for (HtmlScriptElement script in unit.element.scripts) { 9182 for (HtmlScriptElement script in unit.element.scripts) {
8557 if (script is ExternalHtmlScriptElement) { 9183 if (script is ExternalHtmlScriptElement) {
8558 Source scriptSource = script.scriptSource; 9184 Source scriptSource = script.scriptSource;
8559 if (scriptSource != null) { 9185 if (scriptSource != null) {
8560 return context.resolveCompilationUnit2(scriptSource, scriptSource); 9186 return context.resolveCompilationUnit2(scriptSource, scriptSource);
8561 } 9187 }
8562 } 9188 }
8563 } 9189 }
8564 return null; 9190 return null;
8565 } 9191 }
8566 9192
9193 static Set<Source> getLibrarySources(Set<LibraryElement> libraries) {
9194 Set<Source> sources = new Set();
9195 for (LibraryElement library in libraries) {
9196 sources.add(library.source);
9197 }
9198 return sources;
9199 }
9200
8567 InternalAnalysisContext _context; 9201 InternalAnalysisContext _context;
8568 9202
8569 TypeProvider _typeProvider; 9203 TypeProvider _typeProvider;
8570 9204
8571 AnalysisErrorListener _errorListener; 9205 AngularHtmlUnitResolver_FilteringAnalysisErrorListener _errorListener;
8572 9206
8573 Source _source; 9207 Source _source;
8574 9208
8575 LineInfo _lineInfo; 9209 LineInfo _lineInfo;
8576 9210
8577 ht.HtmlUnit _unit; 9211 ht.HtmlUnit _unit;
8578 9212
8579 List<AngularElement> _angularElements; 9213 List<AngularElement> _angularElements;
8580 9214
8581 List<NgProcessor> _processors = []; 9215 List<NgProcessor> _processors = [];
(...skipping 12 matching lines...) Expand all
8594 9228
8595 Set<LibraryElement> _injectedLibraries = new Set(); 9229 Set<LibraryElement> _injectedLibraries = new Set();
8596 9230
8597 Scope _topNameScope; 9231 Scope _topNameScope;
8598 9232
8599 Scope _nameScope; 9233 Scope _nameScope;
8600 9234
8601 AngularHtmlUnitResolver(InternalAnalysisContext context, AnalysisErrorListener errorListener, Source source, LineInfo lineInfo, ht.HtmlUnit unit) { 9235 AngularHtmlUnitResolver(InternalAnalysisContext context, AnalysisErrorListener errorListener, Source source, LineInfo lineInfo, ht.HtmlUnit unit) {
8602 this._context = context; 9236 this._context = context;
8603 this._typeProvider = context.typeProvider; 9237 this._typeProvider = context.typeProvider;
8604 this._errorListener = errorListener; 9238 this._errorListener = new AngularHtmlUnitResolver_FilteringAnalysisErrorList ener(errorListener);
8605 this._source = source; 9239 this._source = source;
8606 this._lineInfo = lineInfo; 9240 this._lineInfo = lineInfo;
8607 this._unit = unit; 9241 this._unit = unit;
8608 } 9242 }
8609 9243
8610 /** 9244 /**
8611 * The [AngularApplicationInfo] for the Web application with this entry point, may be 9245 * The [AngularApplication] for the Web application with this entry point, may be
8612 * `null` if not an entry point. 9246 * `null` if not an entry point.
8613 */ 9247 */
8614 AngularApplicationInfo calculateAngularApplication() { 9248 AngularApplication calculateAngularApplication() {
8615 // check if Angular at all 9249 // check if Angular at all
8616 if (!hasAngularAnnotation(_unit)) { 9250 if (!hasAngularAnnotation(_unit)) {
8617 return null; 9251 return null;
8618 } 9252 }
8619 // prepare resolved Dart unit 9253 // prepare resolved Dart unit
8620 CompilationUnit dartUnit = getDartUnit(_context, _unit); 9254 CompilationUnit dartUnit = getDartUnit(_context, _unit);
8621 if (dartUnit == null) { 9255 if (dartUnit == null) {
8622 return null; 9256 return null;
8623 } 9257 }
8624 // prepare accessible Angular elements 9258 // prepare accessible Angular elements
8625 LibraryElement libraryElement = dartUnit.element.library; 9259 LibraryElement libraryElement = dartUnit.element.library;
8626 List<AngularElement> angularElements = getAngularElements2(libraryElement); 9260 Set<LibraryElement> libraries = new Set();
8627 // resolve template URIs 9261 List<AngularElement> angularElements = getAngularElements(libraries, library Element);
9262 // resolve AngularComponentElement template URIs
8628 // TODO(scheglov) resolve to HtmlElement to allow F3 ? 9263 // TODO(scheglov) resolve to HtmlElement to allow F3 ?
9264 Set<Source> angularElementsSources = new Set();
8629 for (AngularElement angularElement in angularElements) { 9265 for (AngularElement angularElement in angularElements) {
8630 if (angularElement is AngularComponentElement) { 9266 if (angularElement is AngularHasTemplateElement) {
8631 AngularComponentElement component = angularElement; 9267 AngularHasTemplateElement hasTemplate = angularElement;
8632 String templateUri = component.templateUri; 9268 angularElementsSources.add(angularElement.source);
9269 String templateUri = hasTemplate.templateUri;
8633 if (templateUri == null) { 9270 if (templateUri == null) {
8634 continue; 9271 continue;
8635 } 9272 }
8636 try { 9273 try {
8637 Source templateSource = _source.resolveRelative(parseUriWithException( templateUri)); 9274 Source templateSource = _source.resolveRelative(parseUriWithException( templateUri));
8638 if (templateSource == null || !templateSource.exists()) { 9275 if (!_context.exists(templateSource)) {
8639 templateSource = _context.sourceFactory.resolveUri(_source, "package :${templateUri}"); 9276 templateSource = _context.sourceFactory.resolveUri(_source, "package :${templateUri}");
8640 if (templateSource == null || !templateSource.exists()) { 9277 if (!_context.exists(templateSource)) {
8641 reportError7(component.templateUriOffset, templateUri.length, Angu larCode.URI_DOES_NOT_EXIST, [templateUri]); 9278 _errorListener.onError(new AnalysisError.con2(angularElement.sourc e, hasTemplate.templateUriOffset, templateUri.length, AngularCode.URI_DOES_NOT_E XIST, [templateUri]));
8642 continue; 9279 continue;
8643 } 9280 }
8644 } 9281 }
8645 if (!AnalysisEngine.isHtmlFileName(templateUri)) { 9282 if (!AnalysisEngine.isHtmlFileName(templateUri)) {
8646 continue; 9283 continue;
8647 } 9284 }
8648 (component as AngularComponentElementImpl).templateSource = templateSo urce; 9285 if (hasTemplate is AngularComponentElementImpl) {
9286 hasTemplate.templateSource = templateSource;
9287 }
9288 if (hasTemplate is AngularViewElementImpl) {
9289 hasTemplate.templateSource = templateSource;
9290 }
8649 } on URISyntaxException catch (exception) { 9291 } on URISyntaxException catch (exception) {
8650 reportError7(component.templateUriOffset, templateUri.length, AngularC ode.INVALID_URI, [templateUri]); 9292 _errorListener.onError(new AnalysisError.con2(angularElement.source, h asTemplate.templateUriOffset, templateUri.length, AngularCode.INVALID_URI, [temp lateUri]));
8651 } 9293 }
8652 } 9294 }
8653 } 9295 }
9296 // create AngularApplication
9297 AngularApplication application = new AngularApplication(_source, getLibraryS ources(libraries), angularElements, new List.from(angularElementsSources));
9298 // set AngularApplication for each AngularElement
9299 for (AngularElement angularElement in angularElements) {
9300 (angularElement as AngularElementImpl).application = application;
9301 }
8654 // done 9302 // done
8655 return new AngularApplicationInfo(_source, angularElements); 9303 return application;
8656 } 9304 }
8657 9305
8658 /** 9306 /**
8659 * Resolves [source] as an [AngularComponentElement] template file. 9307 * Resolves [source] as an [AngularComponentElement] template file.
8660 * 9308 *
8661 * @param application the Angular application we are resolving for 9309 * @param application the Angular application we are resolving for
8662 * @param component the [AngularComponentElement] to resolve template for, not `null` 9310 * @param component the [AngularComponentElement] to resolve template for, not `null`
8663 */ 9311 */
8664 void resolveComponentTemplate(AngularApplicationInfo application, AngularCompo nentElement component) { 9312 void resolveComponentTemplate(AngularApplication application, AngularComponent Element component) {
8665 _isAngular = true; 9313 _isAngular = true;
8666 resolveInternal(application.elements, component); 9314 resolveInternal(application.elements, component);
8667 } 9315 }
8668 9316
8669 /** 9317 /**
8670 * Resolves [source] as an Angular application entry point. 9318 * Resolves [source] as an Angular application entry point.
8671 */ 9319 */
8672 void resolveEntryPoint(AngularApplicationInfo application) { 9320 void resolveEntryPoint(AngularApplication application) {
8673 resolveInternal(application.elements, null); 9321 resolveInternal(application.elements, null);
8674 } 9322 }
8675 9323
8676 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { 9324 Object visitXmlAttributeNode(ht.XmlAttributeNode node) {
8677 parseEmbeddedExpressions2(node); 9325 parseEmbeddedExpressions2(node);
8678 resolveExpressions(node.expressions); 9326 resolveExpressions(node.expressions);
8679 return super.visitXmlAttributeNode(node); 9327 return super.visitXmlAttributeNode(node);
8680 } 9328 }
8681 9329
8682 Object visitXmlTagNode(ht.XmlTagNode node) { 9330 Object visitXmlTagNode(ht.XmlTagNode node) {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
8928 // add Scope variables - no type, no location, just to avoid warnings 9576 // add Scope variables - no type, no location, just to avoid warnings
8929 { 9577 {
8930 Type2 type = _typeProvider.dynamicType; 9578 Type2 type = _typeProvider.dynamicType;
8931 _topNameScope.define(createLocalVariable2(type, "\$id")); 9579 _topNameScope.define(createLocalVariable2(type, "\$id"));
8932 _topNameScope.define(createLocalVariable2(type, "\$parent")); 9580 _topNameScope.define(createLocalVariable2(type, "\$parent"));
8933 _topNameScope.define(createLocalVariable2(type, "\$root")); 9581 _topNameScope.define(createLocalVariable2(type, "\$root"));
8934 } 9582 }
8935 } 9583 }
8936 9584
8937 /** 9585 /**
8938 * Defines variable for the given [AngularElement]. 9586 * Defines variable for the given [AngularElement] with type of the enclosing
9587 * [ClassElement].
8939 */ 9588 */
8940 void defineTopElementVariable(AngularElement element) { 9589 void defineTopVariable_forClassElement(AngularElement element) {
8941 ClassElement classElement = element.enclosingElement as ClassElement; 9590 ClassElement classElement = element.enclosingElement as ClassElement;
8942 InterfaceType type = classElement.type; 9591 InterfaceType type = classElement.type;
8943 LocalVariableElementImpl variable = createLocalVariable2(type, element.name) ; 9592 LocalVariableElementImpl variable = createLocalVariable2(type, element.name) ;
8944 defineTopVariable(variable); 9593 defineTopVariable(variable);
8945 variable.toolkitObjects = <AngularElement> [element]; 9594 variable.toolkitObjects = <AngularElement> [element];
8946 } 9595 }
8947 9596
8948 /** 9597 /**
9598 * Defines variable for the given [AngularScopePropertyElement].
9599 */
9600 void defineTopVariable_forScopeProperty(AngularScopePropertyElement element) {
9601 Type2 type = element.type;
9602 LocalVariableElementImpl variable = createLocalVariable2(type, element.name) ;
9603 defineTopVariable(variable);
9604 variable.toolkitObjects = <AngularElement> [element];
9605 }
9606
9607 /**
8949 * Parse the value of the given token for embedded expressions, and add any em bedded expressions 9608 * Parse the value of the given token for embedded expressions, and add any em bedded expressions
8950 * that are found to the given list of expressions. 9609 * that are found to the given list of expressions.
8951 * 9610 *
8952 * @param expressions the list to which embedded expressions are to be added 9611 * @param expressions the list to which embedded expressions are to be added
8953 * @param token the token whose value is to be parsed 9612 * @param token the token whose value is to be parsed
8954 */ 9613 */
8955 void parseEmbeddedExpressions(List<AngularMoustacheXmlExpression> expressions, ht.Token token) { 9614 void parseEmbeddedExpressions(List<AngularMoustacheXmlExpression> expressions, ht.Token token) {
8956 // prepare Token information 9615 // prepare Token information
8957 String lexeme = token.lexeme; 9616 String lexeme = token.lexeme;
8958 int offset = token.offset; 9617 int offset = token.offset;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
9041 */ 9700 */
9042 void resolveInternal(List<AngularElement> angularElements, AngularComponentEle ment component) { 9701 void resolveInternal(List<AngularElement> angularElements, AngularComponentEle ment component) {
9043 this._angularElements = angularElements; 9702 this._angularElements = angularElements;
9044 // add built-in processors 9703 // add built-in processors
9045 _processors.add(NgModelProcessor.INSTANCE); 9704 _processors.add(NgModelProcessor.INSTANCE);
9046 // _processors.add(NgRepeatProcessor.INSTANCE); 9705 // _processors.add(NgRepeatProcessor.INSTANCE);
9047 // add element's libraries 9706 // add element's libraries
9048 for (AngularElement angularElement in angularElements) { 9707 for (AngularElement angularElement in angularElements) {
9049 _injectedLibraries.add(angularElement.library); 9708 _injectedLibraries.add(angularElement.library);
9050 } 9709 }
9051 // add accessible processors
9052 for (AngularElement angularElement in angularElements) {
9053 NgProcessor processor = createProcessor(angularElement);
9054 if (processor != null) {
9055 _processors.add(processor);
9056 }
9057 }
9058 // prepare Dart library 9710 // prepare Dart library
9059 createLibraryElement(); 9711 createLibraryElement();
9060 (_unit.element as HtmlElementImpl).angularCompilationUnit = _unitElement; 9712 (_unit.element as HtmlElementImpl).angularCompilationUnit = _unitElement;
9061 // prepare Dart resolver 9713 // prepare Dart resolver
9062 createResolver(); 9714 createResolver();
9063 // maybe resolving component template 9715 // maybe resolving component template
9064 if (component != null) { 9716 if (component != null) {
9065 defineTopElementVariable(component); 9717 defineTopVariable_forClassElement(component);
9718 for (AngularScopePropertyElement scopeProperty in component.scopePropertie s) {
9719 defineTopVariable_forScopeProperty(scopeProperty);
9720 }
9721 }
9722 // add processors
9723 for (AngularElement angularElement in angularElements) {
9724 NgProcessor processor = createProcessor(angularElement);
9725 if (processor != null) {
9726 _processors.add(processor);
9727 }
9066 } 9728 }
9067 // define filters 9729 // define filters
9068 for (AngularElement angularElement in angularElements) { 9730 for (AngularElement angularElement in angularElements) {
9069 if (angularElement is AngularFilterElement) { 9731 if (angularElement is AngularFilterElement) {
9070 defineTopElementVariable(angularElement); 9732 defineTopVariable_forClassElement(angularElement);
9071 } 9733 }
9072 } 9734 }
9073 // run this HTML visitor 9735 // run this HTML visitor
9074 _unit.accept(this); 9736 _unit.accept(this);
9075 // simulate imports for injects 9737 // simulate imports for injects
9076 { 9738 {
9077 List<ImportElement> imports = []; 9739 List<ImportElement> imports = [];
9078 for (LibraryElement injectedLibrary in _injectedLibraries) { 9740 for (LibraryElement injectedLibrary in _injectedLibraries) {
9079 ImportElementImpl importElement = new ImportElementImpl(-1); 9741 ImportElementImpl importElement = new ImportElementImpl(-1);
9080 importElement.importedLibrary = injectedLibrary; 9742 importElement.importedLibrary = injectedLibrary;
(...skipping 24 matching lines...) Expand all
9105 /** 9767 /**
9106 * The "ng-model" directive is special, it contributes to the top-level name s cope. These models 9768 * The "ng-model" directive is special, it contributes to the top-level name s cope. These models
9107 * can be used before actual "ng-model" attribute in HTML. So, we need to defi ne them once we 9769 * can be used before actual "ng-model" attribute in HTML. So, we need to defi ne them once we
9108 * found [NG_APP] context. 9770 * found [NG_APP] context.
9109 */ 9771 */
9110 void visitModelDirectives(ht.XmlTagNode appNode) { 9772 void visitModelDirectives(ht.XmlTagNode appNode) {
9111 appNode.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDir ectives(this)); 9773 appNode.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDir ectives(this));
9112 } 9774 }
9113 } 9775 }
9114 9776
9777 class AngularHtmlUnitResolver_FilteringAnalysisErrorListener implements Analysis ErrorListener {
9778 AnalysisErrorListener _listener;
9779
9780 AngularHtmlUnitResolver_FilteringAnalysisErrorListener(AnalysisErrorListener l istener) {
9781 this._listener = listener;
9782 }
9783
9784 void onError(AnalysisError error) {
9785 ErrorCode errorCode = error.errorCode;
9786 if (identical(errorCode, StaticWarningCode.UNDEFINED_GETTER) || identical(er rorCode, StaticWarningCode.UNDEFINED_IDENTIFIER) || identical(errorCode, StaticT ypeWarningCode.UNDEFINED_GETTER)) {
9787 return;
9788 }
9789 _listener.onError(error);
9790 }
9791 }
9792
9115 class AngularHtmlUnitResolver_FoundAppError extends Error { 9793 class AngularHtmlUnitResolver_FoundAppError extends Error {
9116 } 9794 }
9117 9795
9118 class RecursiveXmlVisitor_AngularHtmlUnitResolver_hasAngularAnnotation extends h t.RecursiveXmlVisitor<Object> { 9796 class RecursiveXmlVisitor_AngularHtmlUnitResolver_hasAngularAnnotation extends h t.RecursiveXmlVisitor<Object> {
9119 Object visitXmlTagNode(ht.XmlTagNode node) { 9797 Object visitXmlTagNode(ht.XmlTagNode node) {
9120 if (node.getAttribute(AngularHtmlUnitResolver._NG_APP) != null) { 9798 if (node.getAttribute(AngularHtmlUnitResolver._NG_APP) != null) {
9121 throw new AngularHtmlUnitResolver_FoundAppError(); 9799 throw new AngularHtmlUnitResolver_FoundAppError();
9122 } 9800 }
9123 return super.visitXmlTagNode(node); 9801 return super.visitXmlTagNode(node);
9124 } 9802 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
9338 * attributes as expressions. 10016 * attributes as expressions.
9339 */ 10017 */
9340 class NgDirectiveElementProcessor extends NgDirectiveProcessor { 10018 class NgDirectiveElementProcessor extends NgDirectiveProcessor {
9341 AngularDirectiveElement _element; 10019 AngularDirectiveElement _element;
9342 10020
9343 NgDirectiveElementProcessor(AngularDirectiveElement element) { 10021 NgDirectiveElementProcessor(AngularDirectiveElement element) {
9344 this._element = element; 10022 this._element = element;
9345 } 10023 }
9346 10024
9347 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { 10025 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) {
10026 String selectorAttributeName = null;
10027 {
10028 AngularSelectorElement selector = _element.selector;
10029 if (selector is HasAttributeSelectorElementImpl) {
10030 selectorAttributeName = selector.name;
10031 // resolve attribute expression
10032 ht.XmlAttributeNode attribute = node.getAttribute(selectorAttributeName) ;
10033 if (attribute != null) {
10034 attribute.element = selector;
10035 }
10036 }
10037 }
10038 //
9348 for (AngularPropertyElement property in _element.properties) { 10039 for (AngularPropertyElement property in _element.properties) {
9349 // prepare attribute name 10040 // prepare attribute name
9350 String name = property.name; 10041 String name = property.name;
9351 if (name == ".") { 10042 if (name == ".") {
9352 AngularSelectorElement selector = _element.selector; 10043 name = selectorAttributeName;
9353 if (selector is HasAttributeSelectorElementImpl) {
9354 name = selector.name;
9355 }
9356 } 10044 }
9357 // resolve attribute expression 10045 // resolve attribute expression
9358 ht.XmlAttributeNode attribute = node.getAttribute(name); 10046 ht.XmlAttributeNode attribute = node.getAttribute(name);
9359 if (attribute != null) { 10047 if (attribute != null) {
9360 attribute.element = property; 10048 // if not resolved as the selector, resolve as a property
10049 if (name != selectorAttributeName) {
10050 attribute.element = property;
10051 }
9361 // resolve if binding 10052 // resolve if binding
9362 if (property.propertyKind != AngularPropertyKind.ATTR) { 10053 if (property.propertyKind != AngularPropertyKind.ATTR) {
9363 resolver.pushNameScope(); 10054 resolver.pushNameScope();
9364 try { 10055 try {
9365 onNgEventDirective(resolver); 10056 onNgEventDirective(resolver);
9366 AngularExpression expression = parseAngularExpression(resolver, attr ibute); 10057 AngularExpression expression = parseAngularExpression(resolver, attr ibute);
9367 resolver.resolveExpression(expression); 10058 resolver.resolveExpression(expression);
9368 setExpression(attribute, expression); 10059 setExpression(attribute, expression);
9369 } finally { 10060 } finally {
9370 resolver.popNameScope(); 10061 resolver.popNameScope();
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
9688 E visitResolveDartUnitTask(ResolveDartUnitTask task); 10379 E visitResolveDartUnitTask(ResolveDartUnitTask task);
9689 10380
9690 /** 10381 /**
9691 * Visit a [ResolveHtmlTask]. 10382 * Visit a [ResolveHtmlTask].
9692 * 10383 *
9693 * @param task the task to be visited 10384 * @param task the task to be visited
9694 * @return the result of visiting the task 10385 * @return the result of visiting the task
9695 * @throws AnalysisException if the visitor throws an exception for some reaso n 10386 * @throws AnalysisException if the visitor throws an exception for some reaso n
9696 */ 10387 */
9697 E visitResolveHtmlTask(ResolveHtmlTask task); 10388 E visitResolveHtmlTask(ResolveHtmlTask task);
10389
10390 /**
10391 * Visit a [ScanDartTask].
10392 *
10393 * @param task the task to be visited
10394 * @return the result of visiting the task
10395 * @throws AnalysisException if the visitor throws an exception for some reaso n
10396 */
10397 E visitScanDartTask(ScanDartTask task);
9698 } 10398 }
9699 10399
9700 /** 10400 /**
9701 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings for a single 10401 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings for a single
9702 * Dart source. 10402 * Dart source.
9703 */ 10403 */
9704 class GenerateDartErrorsTask extends AnalysisTask { 10404 class GenerateDartErrorsTask extends AnalysisTask {
9705 /** 10405 /**
9706 * The source for which errors and warnings are to be produced. 10406 * The source for which errors and warnings are to be produced.
9707 */ 10407 */
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
9972 * The source to be parsed. 10672 * The source to be parsed.
9973 */ 10673 */
9974 final Source source; 10674 final Source source;
9975 10675
9976 /** 10676 /**
9977 * The time at which the contents of the source were last modified. 10677 * The time at which the contents of the source were last modified.
9978 */ 10678 */
9979 int _modificationTime = -1; 10679 int _modificationTime = -1;
9980 10680
9981 /** 10681 /**
9982 * The line information that was produced.
9983 */
9984 LineInfo _lineInfo;
9985
9986 /**
9987 * The compilation unit that was produced by parsing the source. 10682 * The compilation unit that was produced by parsing the source.
9988 */ 10683 */
9989 CompilationUnit _unit; 10684 CompilationUnit _unit;
9990 10685
9991 /** 10686 /**
9992 * The errors that were produced by scanning and parsing the source. 10687 * The errors that were produced by scanning and parsing the source.
9993 */ 10688 */
9994 List<AnalysisError> _errors = AnalysisError.NO_ERRORS; 10689 List<AnalysisError> _errors = AnalysisError.NO_ERRORS;
9995 10690
9996 /** 10691 /**
(...skipping 26 matching lines...) Expand all
10023 10718
10024 /** 10719 /**
10025 * Return the errors that were produced by scanning and parsing the source, or `null` if the 10720 * Return the errors that were produced by scanning and parsing the source, or `null` if the
10026 * task has not yet been performed or if an exception occurred. 10721 * task has not yet been performed or if an exception occurred.
10027 * 10722 *
10028 * @return the errors that were produced by scanning and parsing the source 10723 * @return the errors that were produced by scanning and parsing the source
10029 */ 10724 */
10030 List<AnalysisError> get errors => _errors; 10725 List<AnalysisError> get errors => _errors;
10031 10726
10032 /** 10727 /**
10033 * Return the line information that was produced, or `null` if the task has no t yet been
10034 * performed or if an exception occurred.
10035 *
10036 * @return the line information that was produced
10037 */
10038 LineInfo get lineInfo => _lineInfo;
10039
10040 /**
10041 * Return the time at which the contents of the source that was parsed were la st modified, or a 10728 * Return the time at which the contents of the source that was parsed were la st modified, or a
10042 * negative value if the task has not yet been performed or if an exception oc curred. 10729 * negative value if the task has not yet been performed or if an exception oc curred.
10043 * 10730 *
10044 * @return the time at which the contents of the source that was parsed were l ast modified 10731 * @return the time at which the contents of the source that was parsed were l ast modified
10045 */ 10732 */
10046 int get modificationTime => _modificationTime; 10733 int get modificationTime => _modificationTime;
10047 10734
10048 /** 10735 /**
10049 * Return `true` if the source contains a 'library' directive, or `false` if t he task 10736 * Return `true` if the source contains a 'library' directive, or `false` if t he task
10050 * has not yet been performed or if an exception occurred. 10737 * has not yet been performed or if an exception occurred.
(...skipping 12 matching lines...) Expand all
10063 10750
10064 String get taskDescription { 10751 String get taskDescription {
10065 if (source == null) { 10752 if (source == null) {
10066 return "parse as dart null source"; 10753 return "parse as dart null source";
10067 } 10754 }
10068 return "parse as dart ${source.fullName}"; 10755 return "parse as dart ${source.fullName}";
10069 } 10756 }
10070 10757
10071 void internalPerform() { 10758 void internalPerform() {
10072 RecordingErrorListener errorListener = new RecordingErrorListener(); 10759 RecordingErrorListener errorListener = new RecordingErrorListener();
10073 List<Token> token = [null]; 10760 InternalAnalysisContext context = this.context;
10074 // 10761 TimestampedData<Token> data = context.internalScanTokenStream(source);
10075 // Scan the contents of the file. 10762 _modificationTime = data.modificationTime;
10076 // 10763 Token token = data.data;
10077 Source_ContentReceiver receiver = new Source_ContentReceiver_ParseDartTask_i nternalPerform(this, errorListener, token); 10764 if (token == null) {
10078 try { 10765 throw new AnalysisException.con1("Could not get token stream for ${source. fullName}");
10079 source.getContents(receiver);
10080 } on JavaException catch (exception) {
10081 _modificationTime = source.modificationStamp;
10082 throw new AnalysisException.con3(exception);
10083 }
10084 if (token[0] == null) {
10085 throw new AnalysisException.con1("Could not get contents for '${source.ful lName}'");
10086 } 10766 }
10087 // 10767 //
10088 // Then parse the token stream. 10768 // Then parse the token stream.
10089 // 10769 //
10090 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse .start(); 10770 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse .start();
10091 try { 10771 try {
10092 Parser parser = new Parser(source, errorListener); 10772 Parser parser = new Parser(source, errorListener);
10093 parser.parseFunctionBodies = context.analysisOptions.analyzeFunctionBodies ; 10773 parser.parseFunctionBodies = context.analysisOptions.analyzeFunctionBodies ;
10094 _unit = parser.parseCompilationUnit(token[0]); 10774 _unit = parser.parseCompilationUnit(token);
10095 _errors = errorListener.getErrors2(source); 10775 _errors = errorListener.getErrors2(source);
10096 for (Directive directive in _unit.directives) { 10776 for (Directive directive in _unit.directives) {
10097 if (directive is LibraryDirective) { 10777 if (directive is LibraryDirective) {
10098 _hasLibraryDirective2 = true; 10778 _hasLibraryDirective2 = true;
10099 } else if (directive is PartOfDirective) { 10779 } else if (directive is PartOfDirective) {
10100 _hasPartOfDirective2 = true; 10780 _hasPartOfDirective2 = true;
10101 } 10781 }
10102 } 10782 }
10103 _unit.lineInfo = _lineInfo; 10783 _unit.lineInfo = context.getLineInfo(source);
10104 } finally { 10784 } finally {
10105 timeCounterParse.stop(); 10785 timeCounterParse.stop();
10106 } 10786 }
10107 } 10787 }
10108 } 10788 }
10109 10789
10110 class Source_ContentReceiver_ParseDartTask_internalPerform implements Source_Con tentReceiver {
10111 final ParseDartTask ParseDartTask_this;
10112
10113 RecordingErrorListener errorListener;
10114
10115 List<Token> token;
10116
10117 Source_ContentReceiver_ParseDartTask_internalPerform(this.ParseDartTask_this, this.errorListener, this.token);
10118
10119 void accept(String contents, int modificationTime) {
10120 ParseDartTask_this._modificationTime = modificationTime;
10121 TimeCounter_TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.s tart();
10122 try {
10123 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceR eader(contents), errorListener);
10124 scanner.preserveComments = ParseDartTask_this.context.analysisOptions.pres erveComments;
10125 token[0] = scanner.tokenize();
10126 ParseDartTask_this._lineInfo = new LineInfo(scanner.lineStarts);
10127 } finally {
10128 timeCounterScan.stop();
10129 }
10130 }
10131 }
10132
10133 /** 10790 /**
10134 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil e. 10791 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil e.
10135 */ 10792 */
10136 class ParseHtmlTask extends AnalysisTask { 10793 class ParseHtmlTask extends AnalysisTask {
10137 /** 10794 /**
10138 * The source to be parsed. 10795 * The source to be parsed.
10139 */ 10796 */
10140 final Source source; 10797 final Source source;
10141 10798
10142 /** 10799 /**
(...skipping 20 matching lines...) Expand all
10163 * An array containing the sources of the libraries that are referenced within the HTML. 10820 * An array containing the sources of the libraries that are referenced within the HTML.
10164 */ 10821 */
10165 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; 10822 List<Source> _referencedLibraries = Source.EMPTY_ARRAY;
10166 10823
10167 /** 10824 /**
10168 * The name of the 'src' attribute in a HTML tag. 10825 * The name of the 'src' attribute in a HTML tag.
10169 */ 10826 */
10170 static String _ATTRIBUTE_SRC = "src"; 10827 static String _ATTRIBUTE_SRC = "src";
10171 10828
10172 /** 10829 /**
10173 * The name of the 'type' attribute in a HTML tag.
10174 */
10175 static String _ATTRIBUTE_TYPE = "type";
10176
10177 /**
10178 * The name of the 'script' tag in an HTML file. 10830 * The name of the 'script' tag in an HTML file.
10179 */ 10831 */
10180 static String _TAG_SCRIPT = "script"; 10832 static String _TAG_SCRIPT = "script";
10181 10833
10182 /** 10834 /**
10183 * The value of the 'type' attribute of a 'script' tag that indicates that the script is written
10184 * in Dart.
10185 */
10186 static String _TYPE_DART = "application/dart";
10187
10188 /**
10189 * Initialize a newly created task to perform analysis within the given contex t. 10835 * Initialize a newly created task to perform analysis within the given contex t.
10190 * 10836 *
10191 * @param context the context in which the task is to be performed 10837 * @param context the context in which the task is to be performed
10192 * @param source the source to be parsed 10838 * @param source the source to be parsed
10193 */ 10839 */
10194 ParseHtmlTask(InternalAnalysisContext context, this.source) : super(context); 10840 ParseHtmlTask(InternalAnalysisContext context, this.source) : super(context);
10195 10841
10196 accept(AnalysisTaskVisitor visitor) => visitor.visitParseHtmlTask(this); 10842 accept(AnalysisTaskVisitor visitor) => visitor.visitParseHtmlTask(this);
10197 10843
10198 /** 10844 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
10234 List<Source> get referencedLibraries => _referencedLibraries; 10880 List<Source> get referencedLibraries => _referencedLibraries;
10235 10881
10236 String get taskDescription { 10882 String get taskDescription {
10237 if (source == null) { 10883 if (source == null) {
10238 return "parse as html null source"; 10884 return "parse as html null source";
10239 } 10885 }
10240 return "parse as html ${source.fullName}"; 10886 return "parse as html ${source.fullName}";
10241 } 10887 }
10242 10888
10243 void internalPerform() { 10889 void internalPerform() {
10244 ht.HtmlScanner scanner = new ht.HtmlScanner(source);
10245 try { 10890 try {
10246 source.getContents(scanner); 10891 TimestampedData<String> contents = context.getContents(source);
10892 _modificationTime = contents.modificationTime;
10893 ht.AbstractScanner scanner = new ht.StringScanner(source, contents.data);
10894 scanner.passThroughElements = <String> [_TAG_SCRIPT];
10895 ht.Token token = scanner.tokenize();
10896 _lineInfo = new LineInfo(scanner.lineStarts);
10897 RecordingErrorListener errorListener = new RecordingErrorListener();
10898 _unit = new ht.HtmlParser(source, errorListener).parse(token, _lineInfo);
10899 _errors = errorListener.getErrors2(source);
10900 _referencedLibraries = librarySources;
10247 } on JavaException catch (exception) { 10901 } on JavaException catch (exception) {
10248 throw new AnalysisException.con3(exception); 10902 throw new AnalysisException.con3(exception);
10249 } 10903 }
10250 ht.HtmlScanResult scannerResult = scanner.result;
10251 _modificationTime = scannerResult.modificationTime;
10252 _lineInfo = new LineInfo(scannerResult.lineStarts);
10253 RecordingErrorListener errorListener = new RecordingErrorListener();
10254 ht.HtmlParseResult result = new ht.HtmlParser(source, errorListener).parse(s cannerResult);
10255 _unit = result.htmlUnit;
10256 _errors = errorListener.getErrors2(source);
10257 _referencedLibraries = librarySources;
10258 } 10904 }
10259 10905
10260 /** 10906 /**
10261 * Return the sources of libraries that are referenced in the specified HTML f ile. 10907 * Return the sources of libraries that are referenced in the specified HTML f ile.
10262 * 10908 *
10263 * @return the sources of libraries that are referenced in the HTML file 10909 * @return the sources of libraries that are referenced in the HTML file
10264 */ 10910 */
10265 List<Source> get librarySources { 10911 List<Source> get librarySources {
10266 List<Source> libraries = new List<Source>(); 10912 List<Source> libraries = new List<Source>();
10267 _unit.accept(new RecursiveXmlVisitor_ParseHtmlTask_getLibrarySources(this, l ibraries)); 10913 _unit.accept(new RecursiveXmlVisitor_ParseHtmlTask_getLibrarySources(this, l ibraries));
(...skipping 16 matching lines...) Expand all
10284 for (ht.XmlAttributeNode attribute in node.attributes) { 10930 for (ht.XmlAttributeNode attribute in node.attributes) {
10285 if (javaStringEqualsIgnoreCase(attribute.name, ParseHtmlTask._ATTRIBUTE_SR C)) { 10931 if (javaStringEqualsIgnoreCase(attribute.name, ParseHtmlTask._ATTRIBUTE_SR C)) {
10286 scriptAttribute = attribute; 10932 scriptAttribute = attribute;
10287 } 10933 }
10288 } 10934 }
10289 if (scriptAttribute != null) { 10935 if (scriptAttribute != null) {
10290 try { 10936 try {
10291 Uri uri = new Uri(path: scriptAttribute.text); 10937 Uri uri = new Uri(path: scriptAttribute.text);
10292 String fileName = uri.path; 10938 String fileName = uri.path;
10293 Source librarySource = ParseHtmlTask_this.context.sourceFactory.resolveU ri(ParseHtmlTask_this.source, fileName); 10939 Source librarySource = ParseHtmlTask_this.context.sourceFactory.resolveU ri(ParseHtmlTask_this.source, fileName);
10294 if (librarySource != null && librarySource.exists()) { 10940 if (ParseHtmlTask_this.context.exists(librarySource)) {
10295 libraries.add(librarySource); 10941 libraries.add(librarySource);
10296 } 10942 }
10297 } on URISyntaxException catch (e) { 10943 } on URISyntaxException catch (e) {
10298 } 10944 }
10299 } 10945 }
10300 return super.visitHtmlScriptTagNode(node); 10946 return super.visitHtmlScriptTagNode(node);
10301 } 10947 }
10302 } 10948 }
10303 10949
10304 /** 10950 /**
10305 * Instances of the class `ResolveAngularComponentTemplateTask` resolve HTML tem plate 10951 * Instances of the class `ResolveAngularComponentTemplateTask` resolve HTML tem plate
10306 * referenced by [AngularComponentElement]. 10952 * referenced by [AngularComponentElement].
10307 */ 10953 */
10308 class ResolveAngularComponentTemplateTask extends AnalysisTask { 10954 class ResolveAngularComponentTemplateTask extends AnalysisTask {
10309 /** 10955 /**
10310 * The [AngularComponentElement] to resolve template for. 10956 * The [AngularComponentElement] to resolve template for.
10311 */ 10957 */
10312 AngularComponentElement _component; 10958 AngularComponentElement _component;
10313 10959
10314 /** 10960 /**
10315 * The Angular application to resolve in context of. 10961 * The Angular application to resolve in context of.
10316 */ 10962 */
10317 AngularApplicationInfo _application; 10963 AngularApplication _application;
10318 10964
10319 /** 10965 /**
10320 * The source to be resolved. 10966 * The source to be resolved.
10321 */ 10967 */
10322 final Source source; 10968 final Source source;
10323 10969
10324 /** 10970 /**
10325 * The time at which the contents of the source were last modified. 10971 * The time at which the contents of the source were last modified.
10326 */ 10972 */
10327 int _modificationTime = -1; 10973 int _modificationTime = -1;
10328 10974
10329 /** 10975 /**
10330 * The [HtmlUnit] that was resolved by this task. 10976 * The [HtmlUnit] that was resolved by this task.
10331 */ 10977 */
10332 ht.HtmlUnit _resolvedUnit; 10978 ht.HtmlUnit _resolvedUnit;
10333 10979
10334 /** 10980 /**
10335 * The resolution errors that were discovered while resolving the source. 10981 * The resolution errors that were discovered while resolving the source.
10336 */ 10982 */
10337 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; 10983 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS;
10338 10984
10339 /** 10985 /**
10340 * Initialize a newly created task to perform analysis within the given contex t. 10986 * Initialize a newly created task to perform analysis within the given contex t.
10341 * 10987 *
10342 * @param context the context in which the task is to be performed 10988 * @param context the context in which the task is to be performed
10343 * @param source the source to be resolved 10989 * @param source the source to be resolved
10344 * @param component the component that uses this HTML template, not `null` 10990 * @param component the component that uses this HTML template, not `null`
10345 * @param application the Angular application to resolve in context of 10991 * @param application the Angular application to resolve in context of
10346 */ 10992 */
10347 ResolveAngularComponentTemplateTask(InternalAnalysisContext context, this.sour ce, AngularComponentElement component, AngularApplicationInfo application) : sup er(context) { 10993 ResolveAngularComponentTemplateTask(InternalAnalysisContext context, this.sour ce, AngularComponentElement component, AngularApplication application) : super(c ontext) {
10348 this._component = component; 10994 this._component = component;
10349 this._application = application; 10995 this._application = application;
10350 } 10996 }
10351 10997
10352 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularComponentTem plateTask(this); 10998 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularComponentTem plateTask(this);
10353 10999
10354 /** 11000 /**
10355 * Return the time at which the contents of the source that was parsed were la st modified, or a 11001 * Return the time at which the contents of the source that was parsed were la st modified, or a
10356 * negative value if the task has not yet been performed or if an exception oc curred. 11002 * negative value if the task has not yet been performed or if an exception oc curred.
10357 * 11003 *
(...skipping 16 matching lines...) Expand all
10374 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableAngularComp onentHtmlUnit(source); 11020 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableAngularComp onentHtmlUnit(source);
10375 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit; 11021 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit;
10376 if (unit == null) { 11022 if (unit == null) {
10377 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t returned a value without a parsed HTML unit"); 11023 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t returned a value without a parsed HTML unit");
10378 } 11024 }
10379 _modificationTime = resolvableHtmlUnit.modificationTime; 11025 _modificationTime = resolvableHtmlUnit.modificationTime;
10380 // prepare for resolution 11026 // prepare for resolution
10381 RecordingErrorListener errorListener = new RecordingErrorListener(); 11027 RecordingErrorListener errorListener = new RecordingErrorListener();
10382 LineInfo lineInfo = context.getLineInfo(source); 11028 LineInfo lineInfo = context.getLineInfo(source);
10383 // do resolve 11029 // do resolve
10384 AngularHtmlUnitResolver resolver = new AngularHtmlUnitResolver(context, erro rListener, source, lineInfo, unit); 11030 if (_application != null) {
10385 resolver.resolveComponentTemplate(_application, _component); 11031 AngularHtmlUnitResolver resolver = new AngularHtmlUnitResolver(context, er rorListener, source, lineInfo, unit);
11032 resolver.resolveComponentTemplate(_application, _component);
11033 _resolvedUnit = unit;
11034 }
10386 // remember errors 11035 // remember errors
10387 _resolutionErrors = errorListener.getErrors2(source); 11036 _resolutionErrors = errorListener.getErrors2(source);
10388 // remember resolved unit
10389 _resolvedUnit = unit;
10390 } 11037 }
10391 } 11038 }
10392 11039
10393 /** 11040 /**
10394 * Instances of the class `ResolveAngularEntryHtmlTask` resolve a specific HTML file as an 11041 * Instances of the class `ResolveAngularEntryHtmlTask` resolve a specific HTML file as an
10395 * Angular entry point. 11042 * Angular entry point.
10396 */ 11043 */
10397 class ResolveAngularEntryHtmlTask extends AnalysisTask { 11044 class ResolveAngularEntryHtmlTask extends AnalysisTask {
10398 /** 11045 /**
10399 * The source to be resolved. 11046 * The source to be resolved.
10400 */ 11047 */
10401 final Source source; 11048 final Source source;
10402 11049
10403 /** 11050 /**
10404 * The Angular application to resolve in context of. 11051 * The listener to record errors.
10405 */ 11052 */
10406 AngularApplicationInfo _application; 11053 RecordingErrorListener _errorListener = new RecordingErrorListener();
10407 11054
10408 /** 11055 /**
10409 * The time at which the contents of the source were last modified. 11056 * The time at which the contents of the source were last modified.
10410 */ 11057 */
10411 int _modificationTime = -1; 11058 int _modificationTime = -1;
10412 11059
10413 /** 11060 /**
10414 * The [HtmlUnit] that was resolved by this task. 11061 * The [HtmlUnit] that was resolved by this task.
10415 */ 11062 */
10416 ht.HtmlUnit _resolvedUnit; 11063 ht.HtmlUnit _resolvedUnit;
10417 11064
10418 /** 11065 /**
10419 * The element produced by resolving the source. 11066 * The element produced by resolving the source.
10420 */ 11067 */
10421 HtmlElement _element = null; 11068 HtmlElement _element = null;
10422 11069
10423 /** 11070 /**
10424 * The resolution errors that were discovered while resolving the source. 11071 * The Angular application to resolve in context of.
10425 */ 11072 */
10426 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; 11073 AngularApplication _application;
10427 11074
10428 /** 11075 /**
10429 * Initialize a newly created task to perform analysis within the given contex t. 11076 * Initialize a newly created task to perform analysis within the given contex t.
10430 * 11077 *
10431 * @param context the context in which the task is to be performed 11078 * @param context the context in which the task is to be performed
10432 * @param source the source to be resolved 11079 * @param source the source to be resolved
10433 * @param application the Angular application to resolve in context of
10434 */ 11080 */
10435 ResolveAngularEntryHtmlTask(InternalAnalysisContext context, this.source, Angu larApplicationInfo application) : super(context) { 11081 ResolveAngularEntryHtmlTask(InternalAnalysisContext context, this.source) : su per(context);
10436 this._application = application;
10437 }
10438 11082
10439 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularEntryHtmlTas k(this); 11083 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularEntryHtmlTas k(this);
10440 11084
11085 /**
11086 * Returns the [AngularApplication] for the Web application with this Angular entry point,
11087 * maybe `null` if not an Angular entry point.
11088 */
11089 AngularApplication get application => _application;
11090
10441 HtmlElement get element => _element; 11091 HtmlElement get element => _element;
10442 11092
10443 /** 11093 /**
11094 * The resolution errors that were discovered while resolving the source.
11095 */
11096 List<AnalysisError> get entryErrors => _errorListener.getErrors2(source);
11097
11098 /**
11099 * Returns [AnalysisError]s recorded for the given [Source].
11100 */
11101 List<AnalysisError> getErrors(Source source) => _errorListener.getErrors2(sour ce);
11102
11103 /**
10444 * Return the time at which the contents of the source that was parsed were la st modified, or a 11104 * Return the time at which the contents of the source that was parsed were la st modified, or a
10445 * negative value if the task has not yet been performed or if an exception oc curred. 11105 * negative value if the task has not yet been performed or if an exception oc curred.
10446 * 11106 *
10447 * @return the time at which the contents of the source that was parsed were l ast modified 11107 * @return the time at which the contents of the source that was parsed were l ast modified
10448 */ 11108 */
10449 int get modificationTime => _modificationTime; 11109 int get modificationTime => _modificationTime;
10450 11110
10451 List<AnalysisError> get resolutionErrors => _resolutionErrors;
10452
10453 /** 11111 /**
10454 * Return the [HtmlUnit] that was resolved by this task. 11112 * Return the [HtmlUnit] that was resolved by this task.
10455 * 11113 *
10456 * @return the [HtmlUnit] that was resolved by this task 11114 * @return the [HtmlUnit] that was resolved by this task
10457 */ 11115 */
10458 ht.HtmlUnit get resolvedUnit => _resolvedUnit; 11116 ht.HtmlUnit get resolvedUnit => _resolvedUnit;
10459 11117
10460 String get taskDescription { 11118 String get taskDescription {
10461 if (source == null) { 11119 if (source == null) {
10462 return "resolve as Angular entry point null source"; 11120 return "resolve as Angular entry point null source";
10463 } 11121 }
10464 return "resolve as Angular entry point ${source.fullName}"; 11122 return "resolve as Angular entry point ${source.fullName}";
10465 } 11123 }
10466 11124
10467 void internalPerform() { 11125 void internalPerform() {
10468 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableAngularComp onentHtmlUnit(source); 11126 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableAngularComp onentHtmlUnit(source);
10469 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit; 11127 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit;
10470 if (unit == null) { 11128 if (unit == null) {
10471 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t returned a value without a parsed HTML unit"); 11129 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t returned a value without a parsed HTML unit");
10472 } 11130 }
10473 _modificationTime = resolvableHtmlUnit.modificationTime; 11131 _modificationTime = resolvableHtmlUnit.modificationTime;
10474 // prepare for resolution 11132 // prepare for resolution
10475 RecordingErrorListener errorListener = new RecordingErrorListener();
10476 LineInfo lineInfo = context.getLineInfo(source); 11133 LineInfo lineInfo = context.getLineInfo(source);
11134 // try to resolve as an Angular entry point
11135 _application = new AngularHtmlUnitResolver(context, _errorListener, source, lineInfo, unit).calculateAngularApplication();
10477 // do resolve 11136 // do resolve
10478 new AngularHtmlUnitResolver(context, errorListener, source, lineInfo, unit). resolveEntryPoint(_application); 11137 if (_application != null) {
10479 // remember errors 11138 new AngularHtmlUnitResolver(context, _errorListener, source, lineInfo, uni t).resolveEntryPoint(_application);
10480 _resolutionErrors = errorListener.getErrors2(source); 11139 }
10481 // remember resolved unit 11140 // remember resolved unit
10482 _resolvedUnit = unit; 11141 _resolvedUnit = unit;
10483 } 11142 }
10484 } 11143 }
10485 11144
10486 /** 11145 /**
10487 * Instances of the class `ResolveDartDependenciesTask` resolve the import, expo rt, and part 11146 * Instances of the class `ResolveDartDependenciesTask` resolve the import, expo rt, and part
10488 * directives in a single source. 11147 * directives in a single source.
10489 */ 11148 */
10490 class ResolveDartDependenciesTask extends AnalysisTask { 11149 class ResolveDartDependenciesTask extends AnalysisTask {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
10556 int get modificationTime => _modificationTime; 11215 int get modificationTime => _modificationTime;
10557 11216
10558 String get taskDescription { 11217 String get taskDescription {
10559 if (source == null) { 11218 if (source == null) {
10560 return "resolve dart dependencies null source"; 11219 return "resolve dart dependencies null source";
10561 } 11220 }
10562 return "resolve dart dependencies ${source.fullName}"; 11221 return "resolve dart dependencies ${source.fullName}";
10563 } 11222 }
10564 11223
10565 void internalPerform() { 11224 void internalPerform() {
10566 ResolvableCompilationUnit unit = context.computeResolvableCompilationUnit(so urce); 11225 TimestampedData<CompilationUnit> unit = context.internalParseCompilationUnit (source);
10567 _modificationTime = unit.modificationTime; 11226 _modificationTime = unit.modificationTime;
10568 //
10569 // Then parse the token stream.
10570 //
10571 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse .start(); 11227 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse .start();
10572 try { 11228 try {
10573 for (Directive directive in unit.compilationUnit.directives) { 11229 for (Directive directive in unit.data.directives) {
10574 if (directive is ExportDirective) { 11230 if (directive is ExportDirective) {
10575 Source exportSource = resolveSource(source, directive); 11231 Source exportSource = resolveSource(source, directive);
10576 if (exportSource != null) { 11232 if (exportSource != null) {
10577 _exportedSources.add(exportSource); 11233 _exportedSources.add(exportSource);
10578 } 11234 }
10579 } else if (directive is ImportDirective) { 11235 } else if (directive is ImportDirective) {
10580 Source importSource = resolveSource(source, directive); 11236 Source importSource = resolveSource(source, directive);
10581 if (importSource != null) { 11237 if (importSource != null) {
10582 _importedSources.add(importSource); 11238 _importedSources.add(importSource);
10583 } 11239 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
10847 * The element produced by resolving the source. 11503 * The element produced by resolving the source.
10848 */ 11504 */
10849 HtmlElement _element = null; 11505 HtmlElement _element = null;
10850 11506
10851 /** 11507 /**
10852 * The resolution errors that were discovered while resolving the source. 11508 * The resolution errors that were discovered while resolving the source.
10853 */ 11509 */
10854 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; 11510 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS;
10855 11511
10856 /** 11512 /**
10857 * The flag that says is this unit is an Angular application.
10858 */
10859 bool _isAngularApplication2 = false;
10860
10861 /**
10862 * The Angular application information, maybe `null`
10863 */
10864 AngularApplicationInfo _angularApplication;
10865
10866 /**
10867 * Initialize a newly created task to perform analysis within the given contex t. 11513 * Initialize a newly created task to perform analysis within the given contex t.
10868 * 11514 *
10869 * @param context the context in which the task is to be performed 11515 * @param context the context in which the task is to be performed
10870 * @param source the source to be resolved 11516 * @param source the source to be resolved
10871 */ 11517 */
10872 ResolveHtmlTask(InternalAnalysisContext context, this.source) : super(context) ; 11518 ResolveHtmlTask(InternalAnalysisContext context, this.source) : super(context) ;
10873 11519
10874 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this); 11520 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this);
10875 11521
10876 /**
10877 * Returns the [AngularApplicationInfo] for the Web application with this Angu lar entry
10878 * point, maybe `null` if not an Angular entry point.
10879 */
10880 AngularApplicationInfo get angularApplication => _angularApplication;
10881
10882 HtmlElement get element => _element; 11522 HtmlElement get element => _element;
10883 11523
10884 /** 11524 /**
10885 * Return the time at which the contents of the source that was parsed were la st modified, or a 11525 * Return the time at which the contents of the source that was parsed were la st modified, or a
10886 * negative value if the task has not yet been performed or if an exception oc curred. 11526 * negative value if the task has not yet been performed or if an exception oc curred.
10887 * 11527 *
10888 * @return the time at which the contents of the source that was parsed were l ast modified 11528 * @return the time at which the contents of the source that was parsed were l ast modified
10889 */ 11529 */
10890 int get modificationTime => _modificationTime; 11530 int get modificationTime => _modificationTime;
10891 11531
10892 List<AnalysisError> get resolutionErrors => _resolutionErrors; 11532 List<AnalysisError> get resolutionErrors => _resolutionErrors;
10893 11533
10894 /** 11534 /**
10895 * Return the [HtmlUnit] that was resolved by this task. 11535 * Return the [HtmlUnit] that was resolved by this task.
10896 * 11536 *
10897 * @return the [HtmlUnit] that was resolved by this task 11537 * @return the [HtmlUnit] that was resolved by this task
10898 */ 11538 */
10899 ht.HtmlUnit get resolvedUnit => _resolvedUnit; 11539 ht.HtmlUnit get resolvedUnit => _resolvedUnit;
10900 11540
10901 /**
10902 * Returns `true` if analyzed unit is an Angular application.
10903 */
10904 bool get isAngularApplication => _isAngularApplication2;
10905
10906 String get taskDescription { 11541 String get taskDescription {
10907 if (source == null) { 11542 if (source == null) {
10908 return "resolve as html null source"; 11543 return "resolve as html null source";
10909 } 11544 }
10910 return "resolve as html ${source.fullName}"; 11545 return "resolve as html ${source.fullName}";
10911 } 11546 }
10912 11547
10913 void internalPerform() { 11548 void internalPerform() {
10914 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so urce); 11549 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so urce);
10915 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit; 11550 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit;
10916 if (unit == null) { 11551 if (unit == null) {
10917 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t returned a value without a parsed HTML unit"); 11552 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t returned a value without a parsed HTML unit");
10918 } 11553 }
10919 _modificationTime = resolvableHtmlUnit.modificationTime; 11554 _modificationTime = resolvableHtmlUnit.modificationTime;
10920 // build standard HTML element 11555 // build standard HTML element
10921 HtmlUnitBuilder builder = new HtmlUnitBuilder(context); 11556 HtmlUnitBuilder builder = new HtmlUnitBuilder(context);
10922 _element = builder.buildHtmlElement2(source, _modificationTime, unit); 11557 _element = builder.buildHtmlElement2(source, _modificationTime, unit);
10923 RecordingErrorListener errorListener = builder.errorListener; 11558 RecordingErrorListener errorListener = builder.errorListener;
10924 LineInfo lineInfo = context.getLineInfo(source);
10925 // try to resolve as an Angular entry point
10926 if (context.analysisOptions.analyzeAngular) {
10927 _isAngularApplication2 = AngularHtmlUnitResolver.hasAngularAnnotation(unit );
10928 _angularApplication = new AngularHtmlUnitResolver(context, errorListener, source, lineInfo, unit).calculateAngularApplication();
10929 }
10930 // record all resolution errors 11559 // record all resolution errors
10931 _resolutionErrors = errorListener.getErrors2(source); 11560 _resolutionErrors = errorListener.getErrors2(source);
10932 // remember resolved unit 11561 // remember resolved unit
10933 _resolvedUnit = unit; 11562 _resolvedUnit = unit;
10934 } 11563 }
10935 } 11564 }
10936 11565
10937 /** 11566 /**
11567 * Instances of the class `ScanDartTask` scan a specific source as a Dart file.
11568 */
11569 class ScanDartTask extends AnalysisTask {
11570 /**
11571 * The source to be scanned.
11572 */
11573 final Source source;
11574
11575 /**
11576 * The contents of the source.
11577 */
11578 String _content;
11579
11580 /**
11581 * The time at which the contents of the source were last modified.
11582 */
11583 int _modificationTime = 0;
11584
11585 /**
11586 * The token stream that was produced by scanning the source.
11587 */
11588 Token _tokenStream;
11589
11590 /**
11591 * The line information that was produced.
11592 */
11593 LineInfo _lineInfo;
11594
11595 /**
11596 * The errors that were produced by scanning the source.
11597 */
11598 List<AnalysisError> _errors = AnalysisError.NO_ERRORS;
11599
11600 /**
11601 * Initialize a newly created task to perform analysis within the given contex t.
11602 *
11603 * @param context the context in which the task is to be performed
11604 * @param source the source to be parsed
11605 * @param contentData the time-stamped contents of the source
11606 */
11607 ScanDartTask(InternalAnalysisContext context, this.source, TimestampedData<Str ing> contentData) : super(context) {
11608 this._content = contentData.data;
11609 this._modificationTime = contentData.modificationTime;
11610 }
11611
11612 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this);
11613
11614 /**
11615 * Return the errors that were produced by scanning the source, or `null` if t he task has
11616 * not yet been performed or if an exception occurred.
11617 *
11618 * @return the errors that were produced by scanning the source
11619 */
11620 List<AnalysisError> get errors => _errors;
11621
11622 /**
11623 * Return the line information that was produced, or `null` if the task has no t yet been
11624 * performed or if an exception occurred.
11625 *
11626 * @return the line information that was produced
11627 */
11628 LineInfo get lineInfo => _lineInfo;
11629
11630 /**
11631 * Return the time at which the contents of the source that was parsed were la st modified, or a
11632 * negative value if the task has not yet been performed or if an exception oc curred.
11633 *
11634 * @return the time at which the contents of the source that was parsed were l ast modified
11635 */
11636 int get modificationTime => _modificationTime;
11637
11638 /**
11639 * Return the token stream that was produced by scanning the source, or `null` if the task
11640 * has not yet been performed or if an exception occurred.
11641 *
11642 * @return the token stream that was produced by scanning the source
11643 */
11644 Token get tokenStream => _tokenStream;
11645
11646 String get taskDescription {
11647 if (source == null) {
11648 return "scan as dart null source";
11649 }
11650 return "scan as dart ${source.fullName}";
11651 }
11652
11653 void internalPerform() {
11654 RecordingErrorListener errorListener = new RecordingErrorListener();
11655 TimeCounter_TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.s tart();
11656 try {
11657 Scanner scanner = new Scanner(source, new CharSequenceReader(_content), er rorListener);
11658 scanner.preserveComments = context.analysisOptions.preserveComments;
11659 _tokenStream = scanner.tokenize();
11660 _lineInfo = new LineInfo(scanner.lineStarts);
11661 _errors = errorListener.getErrors2(source);
11662 } on JavaException catch (exception) {
11663 throw new AnalysisException.con3(exception);
11664 } finally {
11665 timeCounterScan.stop();
11666 }
11667 }
11668 }
11669
11670 /**
10938 * The interface `Logger` defines the behavior of objects that can be used to re ceive 11671 * The interface `Logger` defines the behavior of objects that can be used to re ceive
10939 * information about errors within the analysis engine. Implementations usually write this 11672 * information about errors within the analysis engine. Implementations usually write this
10940 * information to a file, but can also record the information for later use (suc h as during testing) 11673 * information to a file, but can also record the information for later use (suc h as during testing)
10941 * or even ignore the information. 11674 * or even ignore the information.
10942 * 11675 *
10943 * @coverage dart.engine.utilities 11676 * @coverage dart.engine.utilities
10944 */ 11677 */
10945 abstract class Logger { 11678 abstract class Logger {
10946 static final Logger NULL = new Logger_NullLogger(); 11679 static final Logger NULL = new Logger_NullLogger();
10947 11680
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
10986 11719
10987 void logError2(String message, Exception exception) { 11720 void logError2(String message, Exception exception) {
10988 } 11721 }
10989 11722
10990 void logInformation(String message) { 11723 void logInformation(String message) {
10991 } 11724 }
10992 11725
10993 void logInformation3(String message, Exception exception) { 11726 void logInformation3(String message, Exception exception) {
10994 } 11727 }
10995 } 11728 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698