| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 library engine; | 3 library engine; |
| 4 import 'dart:collection' show HasNextIterator; | 4 import 'dart:collection' show HasNextIterator; |
| 5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
| 6 import 'java_engine.dart'; | 6 import 'java_engine.dart'; |
| 7 import 'instrumentation.dart'; | 7 import 'instrumentation.dart'; |
| 8 import 'error.dart'; | 8 import 'error.dart'; |
| 9 import 'source.dart'; | 9 import 'source.dart'; |
| 10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; | 10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 * Instances of the class `AnalysisException` represent an exception that occurr
ed during the | 597 * Instances of the class `AnalysisException` represent an exception that occurr
ed during the |
| 598 * analysis of one or more sources. | 598 * analysis of one or more sources. |
| 599 * | 599 * |
| 600 * @coverage dart.engine | 600 * @coverage dart.engine |
| 601 */ | 601 */ |
| 602 class AnalysisException extends JavaException { | 602 class AnalysisException extends JavaException { |
| 603 | 603 |
| 604 /** | 604 /** |
| 605 * Initialize a newly created exception. | 605 * Initialize a newly created exception. |
| 606 */ | 606 */ |
| 607 AnalysisException() : super() { | 607 AnalysisException() : super(); |
| 608 _jtd_constructor_126_impl(); | |
| 609 } | |
| 610 _jtd_constructor_126_impl() { | |
| 611 } | |
| 612 | 608 |
| 613 /** | 609 /** |
| 614 * Initialize a newly created exception to have the given message. | 610 * Initialize a newly created exception to have the given message. |
| 615 * | 611 * |
| 616 * @param message the message associated with the exception | 612 * @param message the message associated with the exception |
| 617 */ | 613 */ |
| 618 AnalysisException.con1(String message) : super(message) { | 614 AnalysisException.con1(String message) : super(message); |
| 619 _jtd_constructor_127_impl(message); | |
| 620 } | |
| 621 _jtd_constructor_127_impl(String message) { | |
| 622 } | |
| 623 | 615 |
| 624 /** | 616 /** |
| 625 * Initialize a newly created exception to have the given message and cause. | 617 * Initialize a newly created exception to have the given message and cause. |
| 626 * | 618 * |
| 627 * @param message the message associated with the exception | 619 * @param message the message associated with the exception |
| 628 * @param cause the underlying exception that caused this exception | 620 * @param cause the underlying exception that caused this exception |
| 629 */ | 621 */ |
| 630 AnalysisException.con2(String message, Exception cause) : super(message, cause
) { | 622 AnalysisException.con2(String message, Exception cause) : super(message, cause
); |
| 631 _jtd_constructor_128_impl(message, cause); | |
| 632 } | |
| 633 _jtd_constructor_128_impl(String message, Exception cause) { | |
| 634 } | |
| 635 | 623 |
| 636 /** | 624 /** |
| 637 * Initialize a newly created exception to have the given cause. | 625 * Initialize a newly created exception to have the given cause. |
| 638 * | 626 * |
| 639 * @param cause the underlying exception that caused this exception | 627 * @param cause the underlying exception that caused this exception |
| 640 */ | 628 */ |
| 641 AnalysisException.con3(Exception cause) : super.withCause(cause) { | 629 AnalysisException.con3(Exception cause) : super.withCause(cause); |
| 642 _jtd_constructor_129_impl(cause); | |
| 643 } | |
| 644 _jtd_constructor_129_impl(Exception cause) { | |
| 645 } | |
| 646 } | 630 } |
| 647 /** | 631 /** |
| 648 * The interface `AnalysisOptions` defines the behavior of objects that provide
access to a | 632 * The interface `AnalysisOptions` defines the behavior of objects that provide
access to a |
| 649 * set of analysis options used to control the behavior of an analysis context. | 633 * set of analysis options used to control the behavior of an analysis context. |
| 650 */ | 634 */ |
| 651 abstract class AnalysisOptions { | 635 abstract class AnalysisOptions { |
| 652 | 636 |
| 653 /** | 637 /** |
| 654 * Return `true` if analysis is to generate audit results (e.g. type inference
based | 638 * Return `true` if analysis is to generate hint results (e.g. type inference
based |
| 655 * information and pub best practices). | 639 * information and pub best practices). |
| 656 * | 640 * |
| 657 * @return `true` if analysis is to generate audit results | 641 * @return `true` if analysis is to generate hint results |
| 658 */ | 642 */ |
| 659 bool get audit; | 643 bool get hint; |
| 660 | 644 |
| 661 /** | 645 /** |
| 662 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based | 646 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based |
| 663 * exclusively on the static type information. | 647 * exclusively on the static type information. |
| 664 * | 648 * |
| 665 * @return `true` if analysis is to use strict mode | 649 * @return `true` if analysis is to use strict mode |
| 666 */ | 650 */ |
| 667 bool get strictMode; | 651 bool get strictMode; |
| 668 } | 652 } |
| 669 /** | 653 /** |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 */ | 792 */ |
| 809 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra
ryElement>("DartEntry.ELEMENT"); | 793 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra
ryElement>("DartEntry.ELEMENT"); |
| 810 | 794 |
| 811 /** | 795 /** |
| 812 * The data descriptor representing the list of exported libraries. This data
is only available | 796 * The data descriptor representing the list of exported libraries. This data
is only available |
| 813 * for Dart files that are the defining compilation unit of a library. | 797 * for Dart files that are the defining compilation unit of a library. |
| 814 */ | 798 */ |
| 815 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES = new DataDescrip
tor<List<Source>>("DartEntry.EXPORTED_LIBRARIES"); | 799 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES = new DataDescrip
tor<List<Source>>("DartEntry.EXPORTED_LIBRARIES"); |
| 816 | 800 |
| 817 /** | 801 /** |
| 802 * The data descriptor representing the hints resulting from auditing the sour
ce. |
| 803 */ |
| 804 static final DataDescriptor<List<AnalysisError>> HINTS = new DataDescriptor<Li
st<AnalysisError>>("DartEntry.HINTS"); |
| 805 |
| 806 /** |
| 818 * The data descriptor representing the list of imported libraries. This data
is only available | 807 * The data descriptor representing the list of imported libraries. This data
is only available |
| 819 * for Dart files that are the defining compilation unit of a library. | 808 * for Dart files that are the defining compilation unit of a library. |
| 820 */ | 809 */ |
| 821 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES = new DataDescrip
tor<List<Source>>("DartEntry.IMPORTED_LIBRARIES"); | 810 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES = new DataDescrip
tor<List<Source>>("DartEntry.IMPORTED_LIBRARIES"); |
| 822 | 811 |
| 823 /** | 812 /** |
| 824 * The data descriptor representing the list of included parts. This data is o
nly available for | 813 * The data descriptor representing the list of included parts. This data is o
nly available for |
| 825 * Dart files that are the defining compilation unit of a library. | 814 * Dart files that are the defining compilation unit of a library. |
| 826 */ | 815 */ |
| 827 static final DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<
List<Source>>("DartEntry.INCLUDED_PARTS"); | 816 static final DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<
List<Source>>("DartEntry.INCLUDED_PARTS"); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 List<AnalysisError> get allErrors { | 1031 List<AnalysisError> get allErrors { |
| 1043 List<AnalysisError> errors = new List<AnalysisError>(); | 1032 List<AnalysisError> errors = new List<AnalysisError>(); |
| 1044 for (AnalysisError error in _parseErrors) { | 1033 for (AnalysisError error in _parseErrors) { |
| 1045 errors.add(error); | 1034 errors.add(error); |
| 1046 } | 1035 } |
| 1047 DartEntryImpl_ResolutionState state = _resolutionState; | 1036 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1048 while (state != null) { | 1037 while (state != null) { |
| 1049 for (AnalysisError error in state._resolutionErrors) { | 1038 for (AnalysisError error in state._resolutionErrors) { |
| 1050 errors.add(error); | 1039 errors.add(error); |
| 1051 } | 1040 } |
| 1041 for (AnalysisError error in state._hints) { |
| 1042 errors.add(error); |
| 1043 } |
| 1052 state = state._nextState; | 1044 state = state._nextState; |
| 1053 } | 1045 } |
| 1054 ; | 1046 ; |
| 1055 if (errors.length == 0) { | 1047 if (errors.length == 0) { |
| 1056 return AnalysisError.NO_ERRORS; | 1048 return AnalysisError.NO_ERRORS; |
| 1057 } | 1049 } |
| 1058 return new List.from(errors); | 1050 return new List.from(errors); |
| 1059 } | 1051 } |
| 1060 CompilationUnit get anyParsedCompilationUnit { | 1052 CompilationUnit get anyParsedCompilationUnit { |
| 1061 if (identical(_parsedUnitState, CacheState.VALID)) { | 1053 if (identical(_parsedUnitState, CacheState.VALID)) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 } | 1093 } |
| 1102 } | 1094 } |
| 1103 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource2)
{ | 1095 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource2)
{ |
| 1104 DartEntryImpl_ResolutionState state = _resolutionState; | 1096 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1105 while (state != null) { | 1097 while (state != null) { |
| 1106 if (librarySource2 == state._librarySource) { | 1098 if (librarySource2 == state._librarySource) { |
| 1107 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1099 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1108 return _resolutionState._resolutionErrorsState; | 1100 return _resolutionState._resolutionErrorsState; |
| 1109 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1101 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1110 return _resolutionState._resolvedUnitState; | 1102 return _resolutionState._resolvedUnitState; |
| 1103 } else if (identical(descriptor, DartEntry.HINTS)) { |
| 1104 return _resolutionState._hintsState; |
| 1111 } else { | 1105 } else { |
| 1112 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); | 1106 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); |
| 1113 } | 1107 } |
| 1114 } | 1108 } |
| 1115 state = state._nextState; | 1109 state = state._nextState; |
| 1116 } | 1110 } |
| 1117 ; | 1111 ; |
| 1118 return CacheState.INVALID; | 1112 return CacheState.INVALID; |
| 1119 } | 1113 } |
| 1120 Object getValue(DataDescriptor descriptor) { | 1114 Object getValue(DataDescriptor descriptor) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1142 return super.getValue(descriptor); | 1136 return super.getValue(descriptor); |
| 1143 } | 1137 } |
| 1144 Object getValue2(DataDescriptor descriptor, Source librarySource2) { | 1138 Object getValue2(DataDescriptor descriptor, Source librarySource2) { |
| 1145 DartEntryImpl_ResolutionState state = _resolutionState; | 1139 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1146 while (state != null) { | 1140 while (state != null) { |
| 1147 if (librarySource2 == state._librarySource) { | 1141 if (librarySource2 == state._librarySource) { |
| 1148 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1142 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1149 return state._resolutionErrors as Object; | 1143 return state._resolutionErrors as Object; |
| 1150 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1144 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1151 return state._resolvedUnit as Object; | 1145 return state._resolvedUnit as Object; |
| 1146 } else if (identical(descriptor, DartEntry.HINTS)) { |
| 1147 return state._hints as Object; |
| 1152 } else { | 1148 } else { |
| 1153 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); | 1149 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); |
| 1154 } | 1150 } |
| 1155 } | 1151 } |
| 1156 state = state._nextState; | 1152 state = state._nextState; |
| 1157 } | 1153 } |
| 1158 ; | 1154 ; |
| 1159 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1155 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript
or, DartEntry.HINTS)) { |
| 1160 return AnalysisError.NO_ERRORS as Object; | 1156 return AnalysisError.NO_ERRORS as Object; |
| 1161 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1157 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1162 return null; | 1158 return null; |
| 1163 } else { | 1159 } else { |
| 1164 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1160 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1165 } | 1161 } |
| 1166 } | 1162 } |
| 1167 DartEntryImpl get writableCopy { | 1163 DartEntryImpl get writableCopy { |
| 1168 DartEntryImpl copy = new DartEntryImpl(); | 1164 DartEntryImpl copy = new DartEntryImpl(); |
| 1169 copy.copyFrom(this); | 1165 copy.copyFrom(this); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 * as being in error. | 1206 * as being in error. |
| 1211 */ | 1207 */ |
| 1212 void recordParseError() { | 1208 void recordParseError() { |
| 1213 setState(SourceEntry.LINE_INFO, CacheState.ERROR); | 1209 setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 1214 _sourceKind = SourceKind.UNKNOWN; | 1210 _sourceKind = SourceKind.UNKNOWN; |
| 1215 _sourceKindState = CacheState.ERROR; | 1211 _sourceKindState = CacheState.ERROR; |
| 1216 _parseErrors = AnalysisError.NO_ERRORS; | 1212 _parseErrors = AnalysisError.NO_ERRORS; |
| 1217 _parseErrorsState = CacheState.ERROR; | 1213 _parseErrorsState = CacheState.ERROR; |
| 1218 _parsedUnit = null; | 1214 _parsedUnit = null; |
| 1219 _parsedUnitState = CacheState.ERROR; | 1215 _parsedUnitState = CacheState.ERROR; |
| 1216 _exportedLibraries = Source.EMPTY_ARRAY; |
| 1217 _exportedLibrariesState = CacheState.ERROR; |
| 1218 _importedLibraries = Source.EMPTY_ARRAY; |
| 1219 _importedLibrariesState = CacheState.ERROR; |
| 1220 _includedParts = Source.EMPTY_ARRAY; |
| 1221 _includedPartsState = CacheState.ERROR; |
| 1220 recordResolutionError(); | 1222 recordResolutionError(); |
| 1221 } | 1223 } |
| 1222 | 1224 |
| 1223 /** | 1225 /** |
| 1224 * Record that the parse-related information for the associated source is abou
t to be computed by | 1226 * Record that the parse-related information for the associated source is abou
t to be computed by |
| 1225 * the current thread. | 1227 * the current thread. |
| 1226 */ | 1228 */ |
| 1227 void recordParseInProcess() { | 1229 void recordParseInProcess() { |
| 1228 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { | 1230 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { |
| 1229 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS); | 1231 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS); |
| 1230 } | 1232 } |
| 1231 if (_sourceKindState != CacheState.VALID) { | 1233 if (_sourceKindState != CacheState.VALID) { |
| 1232 _sourceKindState = CacheState.IN_PROCESS; | 1234 _sourceKindState = CacheState.IN_PROCESS; |
| 1233 } | 1235 } |
| 1234 if (_parseErrorsState != CacheState.VALID) { | 1236 if (_parseErrorsState != CacheState.VALID) { |
| 1235 _parseErrorsState = CacheState.IN_PROCESS; | 1237 _parseErrorsState = CacheState.IN_PROCESS; |
| 1236 } | 1238 } |
| 1237 if (_parsedUnitState != CacheState.VALID) { | 1239 if (_parsedUnitState != CacheState.VALID) { |
| 1238 _parsedUnitState = CacheState.IN_PROCESS; | 1240 _parsedUnitState = CacheState.IN_PROCESS; |
| 1239 } | 1241 } |
| 1242 if (_exportedLibrariesState != CacheState.VALID) { |
| 1243 _exportedLibrariesState = CacheState.IN_PROCESS; |
| 1244 } |
| 1245 if (_importedLibrariesState != CacheState.VALID) { |
| 1246 _importedLibrariesState = CacheState.IN_PROCESS; |
| 1247 } |
| 1248 if (_includedPartsState != CacheState.VALID) { |
| 1249 _includedPartsState = CacheState.IN_PROCESS; |
| 1250 } |
| 1240 } | 1251 } |
| 1241 | 1252 |
| 1242 /** | 1253 /** |
| 1243 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 1254 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 1244 * entry. This will set the state of all resolution-based information as being
in error, but will | 1255 * entry. This will set the state of all resolution-based information as being
in error, but will |
| 1245 * not change the state of any parse results. | 1256 * not change the state of any parse results. |
| 1246 */ | 1257 */ |
| 1247 void recordResolutionError() { | 1258 void recordResolutionError() { |
| 1248 _element = null; | 1259 _element = null; |
| 1249 _elementState = CacheState.ERROR; | 1260 _elementState = CacheState.ERROR; |
| 1250 _includedParts = Source.EMPTY_ARRAY; | |
| 1251 _includedPartsState = CacheState.ERROR; | |
| 1252 _exportedLibraries = Source.EMPTY_ARRAY; | |
| 1253 _exportedLibrariesState = CacheState.ERROR; | |
| 1254 _importedLibraries = Source.EMPTY_ARRAY; | |
| 1255 _importedLibrariesState = CacheState.ERROR; | |
| 1256 _bitmask = 0; | 1261 _bitmask = 0; |
| 1257 _clientServerState = CacheState.ERROR; | 1262 _clientServerState = CacheState.ERROR; |
| 1258 _launchableState = CacheState.ERROR; | 1263 _launchableState = CacheState.ERROR; |
| 1259 _publicNamespace = null; | 1264 _publicNamespace = null; |
| 1260 _publicNamespaceState = CacheState.ERROR; | 1265 _publicNamespaceState = CacheState.ERROR; |
| 1261 _resolutionState.recordResolutionError(); | 1266 _resolutionState.recordResolutionError(); |
| 1262 } | 1267 } |
| 1263 | 1268 |
| 1264 /** | 1269 /** |
| 1265 * Remove any resolution information associated with this compilation unit bei
ng part of the given | 1270 * Remove any resolution information associated with this compilation unit bei
ng part of the given |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 * @param cacheState the new state of the data represented by the given descri
ptor | 1362 * @param cacheState the new state of the data represented by the given descri
ptor |
| 1358 */ | 1363 */ |
| 1359 void setState2(DataDescriptor<Object> descriptor, Source librarySource, CacheS
tate cacheState) { | 1364 void setState2(DataDescriptor<Object> descriptor, Source librarySource, CacheS
tate cacheState) { |
| 1360 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); | 1365 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); |
| 1361 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1366 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1362 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors
, AnalysisError.NO_ERRORS); | 1367 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors
, AnalysisError.NO_ERRORS); |
| 1363 state._resolutionErrorsState = cacheState; | 1368 state._resolutionErrorsState = cacheState; |
| 1364 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1369 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1365 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); | 1370 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); |
| 1366 state._resolvedUnitState = cacheState; | 1371 state._resolvedUnitState = cacheState; |
| 1372 } else if (identical(descriptor, DartEntry.HINTS)) { |
| 1373 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR
ORS); |
| 1374 state._hintsState = cacheState; |
| 1367 } else { | 1375 } else { |
| 1368 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1376 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1369 } | 1377 } |
| 1370 } | 1378 } |
| 1371 void setValue(DataDescriptor descriptor, Object value) { | 1379 void setValue(DataDescriptor descriptor, Object value) { |
| 1372 if (identical(descriptor, DartEntry.ELEMENT)) { | 1380 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 1373 _element = value as LibraryElement; | 1381 _element = value as LibraryElement; |
| 1374 _elementState = CacheState.VALID; | 1382 _elementState = CacheState.VALID; |
| 1375 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 1383 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1376 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); | 1384 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 * @param value the new value of the data represented by the given descriptor
and library | 1430 * @param value the new value of the data represented by the given descriptor
and library |
| 1423 */ | 1431 */ |
| 1424 void setValue2(DataDescriptor descriptor, Source librarySource, Object value)
{ | 1432 void setValue2(DataDescriptor descriptor, Source librarySource, Object value)
{ |
| 1425 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); | 1433 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); |
| 1426 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 1434 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1427 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); | 1435 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); |
| 1428 state._resolutionErrorsState = CacheState.VALID; | 1436 state._resolutionErrorsState = CacheState.VALID; |
| 1429 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 1437 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1430 state._resolvedUnit = value as CompilationUnit; | 1438 state._resolvedUnit = value as CompilationUnit; |
| 1431 state._resolvedUnitState = CacheState.VALID; | 1439 state._resolvedUnitState = CacheState.VALID; |
| 1440 } else if (identical(descriptor, DartEntry.HINTS)) { |
| 1441 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); |
| 1442 state._hintsState = CacheState.VALID; |
| 1432 } | 1443 } |
| 1433 } | 1444 } |
| 1434 void copyFrom(SourceEntryImpl entry) { | 1445 void copyFrom(SourceEntryImpl entry) { |
| 1435 super.copyFrom(entry); | 1446 super.copyFrom(entry); |
| 1436 DartEntryImpl other = entry as DartEntryImpl; | 1447 DartEntryImpl other = entry as DartEntryImpl; |
| 1437 _sourceKindState = other._sourceKindState; | 1448 _sourceKindState = other._sourceKindState; |
| 1438 _sourceKind = other._sourceKind; | 1449 _sourceKind = other._sourceKind; |
| 1439 _parsedUnitState = other._parsedUnitState; | 1450 _parsedUnitState = other._parsedUnitState; |
| 1440 _parsedUnit = other._parsedUnit; | 1451 _parsedUnit = other._parsedUnit; |
| 1441 _parseErrorsState = other._parseErrorsState; | 1452 _parseErrorsState = other._parseErrorsState; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 * currently cached. | 1537 * currently cached. |
| 1527 */ | 1538 */ |
| 1528 CompilationUnit _resolvedUnit; | 1539 CompilationUnit _resolvedUnit; |
| 1529 | 1540 |
| 1530 /** | 1541 /** |
| 1531 * The state of the cached resolution errors. | 1542 * The state of the cached resolution errors. |
| 1532 */ | 1543 */ |
| 1533 CacheState _resolutionErrorsState = CacheState.INVALID; | 1544 CacheState _resolutionErrorsState = CacheState.INVALID; |
| 1534 | 1545 |
| 1535 /** | 1546 /** |
| 1536 * The errors produced while resolving the compilation unit, or `null` if the
errors are | 1547 * The errors produced while resolving the compilation unit, or an empty array
if the errors are |
| 1537 * not currently cached. | 1548 * not currently cached. |
| 1538 */ | 1549 */ |
| 1539 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 1550 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1540 | 1551 |
| 1541 /** | 1552 /** |
| 1553 * The state of the cached hints. |
| 1554 */ |
| 1555 CacheState _hintsState = CacheState.INVALID; |
| 1556 |
| 1557 /** |
| 1558 * The hints produced while auditing the compilation unit, or an empty array i
f the hints are |
| 1559 * not currently cached. |
| 1560 */ |
| 1561 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; |
| 1562 |
| 1563 /** |
| 1542 * Set this state to be exactly like the given state, recursively copying the
next state as | 1564 * Set this state to be exactly like the given state, recursively copying the
next state as |
| 1543 * necessary. | 1565 * necessary. |
| 1544 * | 1566 * |
| 1545 * @param other the state to be copied | 1567 * @param other the state to be copied |
| 1546 */ | 1568 */ |
| 1547 void copyFrom(DartEntryImpl_ResolutionState other) { | 1569 void copyFrom(DartEntryImpl_ResolutionState other) { |
| 1548 _librarySource = other._librarySource; | 1570 _librarySource = other._librarySource; |
| 1549 _resolvedUnitState = other._resolvedUnitState; | 1571 _resolvedUnitState = other._resolvedUnitState; |
| 1550 _resolvedUnit = other._resolvedUnit; | 1572 _resolvedUnit = other._resolvedUnit; |
| 1551 _resolutionErrorsState = other._resolutionErrorsState; | 1573 _resolutionErrorsState = other._resolutionErrorsState; |
| 1552 _resolutionErrors = other._resolutionErrors; | 1574 _resolutionErrors = other._resolutionErrors; |
| 1575 _hintsState = other._hintsState; |
| 1576 _hints = other._hints; |
| 1553 if (other._nextState != null) { | 1577 if (other._nextState != null) { |
| 1554 _nextState = new DartEntryImpl_ResolutionState(); | 1578 _nextState = new DartEntryImpl_ResolutionState(); |
| 1555 _nextState.copyFrom(other._nextState); | 1579 _nextState.copyFrom(other._nextState); |
| 1556 } | 1580 } |
| 1557 } | 1581 } |
| 1558 | 1582 |
| 1559 /** | 1583 /** |
| 1560 * Invalidate all of the resolution information associated with the compilatio
n unit. | 1584 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 1561 */ | 1585 */ |
| 1562 void invalidateAllResolutionInformation() { | 1586 void invalidateAllResolutionInformation() { |
| 1563 _nextState = null; | 1587 _nextState = null; |
| 1564 _librarySource = null; | 1588 _librarySource = null; |
| 1565 _resolvedUnitState = CacheState.INVALID; | 1589 _resolvedUnitState = CacheState.INVALID; |
| 1566 _resolvedUnit = null; | 1590 _resolvedUnit = null; |
| 1567 _resolutionErrorsState = CacheState.INVALID; | 1591 _resolutionErrorsState = CacheState.INVALID; |
| 1568 _resolutionErrors = AnalysisError.NO_ERRORS; | 1592 _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1593 _hintsState = CacheState.INVALID; |
| 1594 _hints = AnalysisError.NO_ERRORS; |
| 1569 } | 1595 } |
| 1570 | 1596 |
| 1571 /** | 1597 /** |
| 1572 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 1598 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 1573 * entry. This will set the state of all resolution-based information as being
in error, but | 1599 * entry. This will set the state of all resolution-based information as being
in error, but |
| 1574 * will not change the state of any parse results. | 1600 * will not change the state of any parse results. |
| 1575 */ | 1601 */ |
| 1576 void recordResolutionError() { | 1602 void recordResolutionError() { |
| 1577 _nextState = null; | 1603 _nextState = null; |
| 1578 _librarySource = null; | 1604 _librarySource = null; |
| 1579 _resolvedUnitState = CacheState.ERROR; | 1605 _resolvedUnitState = CacheState.ERROR; |
| 1580 _resolvedUnit = null; | 1606 _resolvedUnit = null; |
| 1581 _resolutionErrorsState = CacheState.ERROR; | 1607 _resolutionErrorsState = CacheState.ERROR; |
| 1582 _resolutionErrors = AnalysisError.NO_ERRORS; | 1608 _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1609 _hintsState = CacheState.ERROR; |
| 1610 _hints = AnalysisError.NO_ERRORS; |
| 1583 } | 1611 } |
| 1584 } | 1612 } |
| 1585 /** | 1613 /** |
| 1586 * Instances of the class `DataDescriptor` are immutable constants representing
data that can | 1614 * Instances of the class `DataDescriptor` are immutable constants representing
data that can |
| 1587 * be stored in the cache. | 1615 * be stored in the cache. |
| 1588 */ | 1616 */ |
| 1589 class DataDescriptor<E> { | 1617 class DataDescriptor<E> { |
| 1590 | 1618 |
| 1591 /** | 1619 /** |
| 1592 * The name of the descriptor, used for debugging purposes. | 1620 * The name of the descriptor, used for debugging purposes. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 * The data descriptor representing the list of referenced libraries. | 1653 * The data descriptor representing the list of referenced libraries. |
| 1626 */ | 1654 */ |
| 1627 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescr
iptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); | 1655 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescr
iptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); |
| 1628 | 1656 |
| 1629 /** | 1657 /** |
| 1630 * The data descriptor representing the errors resulting from resolving the so
urce. | 1658 * The data descriptor representing the errors resulting from resolving the so
urce. |
| 1631 */ | 1659 */ |
| 1632 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD
escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); | 1660 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD
escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); |
| 1633 | 1661 |
| 1634 /** | 1662 /** |
| 1635 * The data descriptor representing the resolved AST structure. | |
| 1636 */ | |
| 1637 static final DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlU
nit>("HtmlEntry.RESOLVED_UNIT"); | |
| 1638 | |
| 1639 /** | |
| 1640 * Return all of the errors associated with the compilation unit that are curr
ently cached. | 1663 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 1641 * | 1664 * |
| 1642 * @return all of the errors associated with the compilation unit | 1665 * @return all of the errors associated with the compilation unit |
| 1643 */ | 1666 */ |
| 1644 List<AnalysisError> get allErrors; | 1667 List<AnalysisError> get allErrors; |
| 1645 HtmlEntryImpl get writableCopy; | 1668 HtmlEntryImpl get writableCopy; |
| 1646 } | 1669 } |
| 1647 /** | 1670 /** |
| 1648 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. | 1671 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. |
| 1649 * | 1672 * |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1666 */ | 1689 */ |
| 1667 CacheState _resolutionErrorsState = CacheState.INVALID; | 1690 CacheState _resolutionErrorsState = CacheState.INVALID; |
| 1668 | 1691 |
| 1669 /** | 1692 /** |
| 1670 * The errors produced while resolving the compilation unit, or `null` if the
errors are not | 1693 * The errors produced while resolving the compilation unit, or `null` if the
errors are not |
| 1671 * currently cached. | 1694 * currently cached. |
| 1672 */ | 1695 */ |
| 1673 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 1696 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1674 | 1697 |
| 1675 /** | 1698 /** |
| 1676 * The state of the cached parsed and resolved HTML unit. | |
| 1677 */ | |
| 1678 CacheState _resolvedUnitState = CacheState.INVALID; | |
| 1679 | |
| 1680 /** | |
| 1681 * The resolved HTML unit, or `null` if the resolved HTML unit is not currentl
y cached. | |
| 1682 */ | |
| 1683 HtmlUnit _resolvedUnit; | |
| 1684 | |
| 1685 /** | |
| 1686 * The state of the cached list of referenced libraries. | 1699 * The state of the cached list of referenced libraries. |
| 1687 */ | 1700 */ |
| 1688 CacheState _referencedLibrariesState = CacheState.INVALID; | 1701 CacheState _referencedLibrariesState = CacheState.INVALID; |
| 1689 | 1702 |
| 1690 /** | 1703 /** |
| 1691 * The list of libraries referenced in the HTML, or `null` if the list is not
currently | 1704 * The list of libraries referenced in the HTML, or `null` if the list is not
currently |
| 1692 * cached. Note that this list does not include libraries defined directly wit
hin the HTML file. | 1705 * cached. Note that this list does not include libraries defined directly wit
hin the HTML file. |
| 1693 */ | 1706 */ |
| 1694 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; | 1707 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; |
| 1695 | 1708 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1715 SourceKind get kind => SourceKind.HTML; | 1728 SourceKind get kind => SourceKind.HTML; |
| 1716 CacheState getState(DataDescriptor<Object> descriptor) { | 1729 CacheState getState(DataDescriptor<Object> descriptor) { |
| 1717 if (identical(descriptor, HtmlEntry.ELEMENT)) { | 1730 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1718 return _elementState; | 1731 return _elementState; |
| 1719 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 1732 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1720 return _parsedUnitState; | 1733 return _parsedUnitState; |
| 1721 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 1734 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1722 return _referencedLibrariesState; | 1735 return _referencedLibrariesState; |
| 1723 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 1736 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 1724 return _resolutionErrorsState; | 1737 return _resolutionErrorsState; |
| 1725 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | |
| 1726 return _resolvedUnitState; | |
| 1727 } | 1738 } |
| 1728 return super.getState(descriptor); | 1739 return super.getState(descriptor); |
| 1729 } | 1740 } |
| 1730 Object getValue(DataDescriptor descriptor) { | 1741 Object getValue(DataDescriptor descriptor) { |
| 1731 if (identical(descriptor, HtmlEntry.ELEMENT)) { | 1742 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1732 return _element as Object; | 1743 return _element as Object; |
| 1733 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 1744 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1734 return _parsedUnit as Object; | 1745 return _parsedUnit as Object; |
| 1735 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 1746 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1736 return _referencedLibraries as Object; | 1747 return _referencedLibraries as Object; |
| 1737 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 1748 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 1738 return _resolutionErrors as Object; | 1749 return _resolutionErrors as Object; |
| 1739 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | |
| 1740 return _resolvedUnit as Object; | |
| 1741 } | 1750 } |
| 1742 return super.getValue(descriptor); | 1751 return super.getValue(descriptor); |
| 1743 } | 1752 } |
| 1744 HtmlEntryImpl get writableCopy { | 1753 HtmlEntryImpl get writableCopy { |
| 1745 HtmlEntryImpl copy = new HtmlEntryImpl(); | 1754 HtmlEntryImpl copy = new HtmlEntryImpl(); |
| 1746 copy.copyFrom(this); | 1755 copy.copyFrom(this); |
| 1747 return copy; | 1756 return copy; |
| 1748 } | 1757 } |
| 1758 |
| 1759 /** |
| 1760 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 1761 */ |
| 1762 void invalidateAllResolutionInformation() { |
| 1763 _element = null; |
| 1764 _elementState = CacheState.INVALID; |
| 1765 _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1766 _resolutionErrorsState = CacheState.INVALID; |
| 1767 } |
| 1749 void setState(DataDescriptor<Object> descriptor, CacheState state) { | 1768 void setState(DataDescriptor<Object> descriptor, CacheState state) { |
| 1750 if (identical(descriptor, HtmlEntry.ELEMENT)) { | 1769 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1751 _element = updatedValue(state, _element, null); | 1770 _element = updatedValue(state, _element, null); |
| 1752 _elementState = state; | 1771 _elementState = state; |
| 1753 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 1772 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1754 _parsedUnit = updatedValue(state, _parsedUnit, null); | 1773 _parsedUnit = updatedValue(state, _parsedUnit, null); |
| 1755 _parsedUnitState = state; | 1774 _parsedUnitState = state; |
| 1756 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 1775 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1757 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM
PTY_ARRAY); | 1776 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM
PTY_ARRAY); |
| 1758 _referencedLibrariesState = state; | 1777 _referencedLibrariesState = state; |
| 1759 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 1778 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 1760 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N
O_ERRORS); | 1779 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N
O_ERRORS); |
| 1761 _resolutionErrorsState = state; | 1780 _resolutionErrorsState = state; |
| 1762 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | |
| 1763 _resolvedUnit = updatedValue(state, _resolvedUnit, null); | |
| 1764 _resolvedUnitState = state; | |
| 1765 } else { | 1781 } else { |
| 1766 super.setState(descriptor, state); | 1782 super.setState(descriptor, state); |
| 1767 } | 1783 } |
| 1768 } | 1784 } |
| 1769 void setValue(DataDescriptor descriptor, Object value) { | 1785 void setValue(DataDescriptor descriptor, Object value) { |
| 1770 if (identical(descriptor, HtmlEntry.ELEMENT)) { | 1786 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1771 _element = value as HtmlElement; | 1787 _element = value as HtmlElement; |
| 1772 _elementState = CacheState.VALID; | 1788 _elementState = CacheState.VALID; |
| 1773 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 1789 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1774 _parsedUnit = value as HtmlUnit; | 1790 _parsedUnit = value as HtmlUnit; |
| 1775 _parsedUnitState = CacheState.VALID; | 1791 _parsedUnitState = CacheState.VALID; |
| 1776 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 1792 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1777 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List
<Source>); | 1793 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List
<Source>); |
| 1778 _referencedLibrariesState = CacheState.VALID; | 1794 _referencedLibrariesState = CacheState.VALID; |
| 1779 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 1795 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 1780 _resolutionErrors = value as List<AnalysisError>; | 1796 _resolutionErrors = value as List<AnalysisError>; |
| 1781 _resolutionErrorsState = CacheState.VALID; | 1797 _resolutionErrorsState = CacheState.VALID; |
| 1782 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | |
| 1783 _resolvedUnit = value as HtmlUnit; | |
| 1784 _resolvedUnitState = CacheState.VALID; | |
| 1785 } else { | 1798 } else { |
| 1786 super.setValue(descriptor, value); | 1799 super.setValue(descriptor, value); |
| 1787 } | 1800 } |
| 1788 } | 1801 } |
| 1789 void copyFrom(SourceEntryImpl entry) { | 1802 void copyFrom(SourceEntryImpl entry) { |
| 1790 super.copyFrom(entry); | 1803 super.copyFrom(entry); |
| 1791 HtmlEntryImpl other = entry as HtmlEntryImpl; | 1804 HtmlEntryImpl other = entry as HtmlEntryImpl; |
| 1792 _parsedUnitState = other._parsedUnitState; | 1805 _parsedUnitState = other._parsedUnitState; |
| 1793 _parsedUnit = other._parsedUnit; | 1806 _parsedUnit = other._parsedUnit; |
| 1794 _referencedLibrariesState = other._referencedLibrariesState; | 1807 _referencedLibrariesState = other._referencedLibrariesState; |
| 1795 _referencedLibraries = other._referencedLibraries; | 1808 _referencedLibraries = other._referencedLibraries; |
| 1796 _resolutionErrors = other._resolutionErrors; | 1809 _resolutionErrors = other._resolutionErrors; |
| 1797 _resolutionErrorsState = other._resolutionErrorsState; | 1810 _resolutionErrorsState = other._resolutionErrorsState; |
| 1798 _resolvedUnitState = other._resolvedUnitState; | |
| 1799 _resolvedUnit = other._resolvedUnit; | |
| 1800 _elementState = other._elementState; | 1811 _elementState = other._elementState; |
| 1801 _element = other._element; | 1812 _element = other._element; |
| 1802 } | 1813 } |
| 1803 } | 1814 } |
| 1804 /** | 1815 /** |
| 1805 * The interface `SourceEntry` defines the behavior of objects that maintain the
information | 1816 * The interface `SourceEntry` defines the behavior of objects that maintain the
information |
| 1806 * cached by an analysis context about an individual source, no matter what kind
of source it is. | 1817 * cached by an analysis context about an individual source, no matter what kind
of source it is. |
| 1807 * | 1818 * |
| 1808 * Source entries should be treated as if they were immutable unless a writable
copy of the entry | 1819 * Source entries should be treated as if they were immutable unless a writable
copy of the entry |
| 1809 * has been obtained and has not yet been made visible to other threads. | 1820 * has been obtained and has not yet been made visible to other threads. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); | 2012 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); |
| 2002 | 2013 |
| 2003 /** | 2014 /** |
| 2004 * A list containing the most recently accessed sources with the most recently
used at the end of | 2015 * A list containing the most recently accessed sources with the most recently
used at the end of |
| 2005 * the list. When more sources are added than the maximum allowed then the lea
st recently used | 2016 * the list. When more sources are added than the maximum allowed then the lea
st recently used |
| 2006 * source will be removed and will have it's cached AST structure flushed. | 2017 * source will be removed and will have it's cached AST structure flushed. |
| 2007 */ | 2018 */ |
| 2008 List<Source> _recentlyUsed = new List<Source>(); | 2019 List<Source> _recentlyUsed = new List<Source>(); |
| 2009 | 2020 |
| 2010 /** | 2021 /** |
| 2022 * The number of times that the flushing of information from the cache has bee
n disabled without |
| 2023 * being re-enabled. |
| 2024 */ |
| 2025 int _cacheRemovalCount = 0; |
| 2026 |
| 2027 /** |
| 2011 * The object used to synchronize access to all of the caches. | 2028 * The object used to synchronize access to all of the caches. |
| 2012 */ | 2029 */ |
| 2013 Object _cacheLock = new Object(); | 2030 Object _cacheLock = new Object(); |
| 2014 | 2031 |
| 2015 /** | 2032 /** |
| 2016 * The maximum number of sources for which data should be kept in the cache. | 2033 * The maximum number of sources for which data should be kept in the cache. |
| 2017 */ | 2034 */ |
| 2018 static int _MAX_CACHE_SIZE = 64; | 2035 static int _MAX_CACHE_SIZE = 64; |
| 2019 | 2036 |
| 2020 /** | 2037 /** |
| 2021 * The name of the 'src' attribute in a HTML tag. | 2038 * The name of the 'src' attribute in a HTML tag. |
| 2022 */ | 2039 */ |
| 2023 static String _ATTRIBUTE_SRC = "src"; | 2040 static String _ATTRIBUTE_SRC = "src"; |
| 2024 | 2041 |
| 2025 /** | 2042 /** |
| 2026 * The name of the 'type' attribute in a HTML tag. | 2043 * The name of the 'type' attribute in a HTML tag. |
| 2027 */ | 2044 */ |
| 2028 static String _ATTRIBUTE_TYPE = "type"; | 2045 static String _ATTRIBUTE_TYPE = "type"; |
| 2029 | 2046 |
| 2030 /** | 2047 /** |
| 2031 * The name of the 'script' tag in an HTML file. | 2048 * The name of the 'script' tag in an HTML file. |
| 2032 */ | 2049 */ |
| 2033 static String _TAG_SCRIPT = "script"; | 2050 static String _TAG_SCRIPT = "script"; |
| 2034 | 2051 |
| 2035 /** | 2052 /** |
| 2036 * The value of the 'type' attribute of a 'script' tag that indicates that the
script is written | 2053 * The value of the 'type' attribute of a 'script' tag that indicates that the
script is written |
| 2037 * in Dart. | 2054 * in Dart. |
| 2038 */ | 2055 */ |
| 2039 static String _TYPE_DART = "application/dart"; | 2056 static String _TYPE_DART = "application/dart"; |
| 2040 | |
| 2041 /** | |
| 2042 * The number of times that the flushing of information from the cache has bee
n disabled without | |
| 2043 * being re-enabled. | |
| 2044 */ | |
| 2045 int _cacheRemovalCount = 0; | |
| 2046 void addSourceInfo(Source source, SourceEntry info) { | 2057 void addSourceInfo(Source source, SourceEntry info) { |
| 2047 _sourceMap[source] = info; | 2058 _sourceMap[source] = info; |
| 2048 } | 2059 } |
| 2049 void applyChanges(ChangeSet changeSet) { | 2060 void applyChanges(ChangeSet changeSet) { |
| 2050 if (changeSet.isEmpty) { | 2061 if (changeSet.isEmpty) { |
| 2051 return; | 2062 return; |
| 2052 } | 2063 } |
| 2053 { | 2064 { |
| 2054 List<Source> removedSources = new List<Source>.from(changeSet.removed); | 2065 List<Source> removedSources = new List<Source>.from(changeSet.removed); |
| 2055 for (SourceContainer container in changeSet.removedContainers) { | 2066 for (SourceContainer container in changeSet.removedContainers) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2161 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { | 2172 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { |
| 2162 return null; | 2173 return null; |
| 2163 } | 2174 } |
| 2164 { | 2175 { |
| 2165 HtmlEntry htmlEntry = getHtmlEntry(source); | 2176 HtmlEntry htmlEntry = getHtmlEntry(source); |
| 2166 if (htmlEntry == null) { | 2177 if (htmlEntry == null) { |
| 2167 return null; | 2178 return null; |
| 2168 } | 2179 } |
| 2169 HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT); | 2180 HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT); |
| 2170 if (element == null) { | 2181 if (element == null) { |
| 2171 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2182 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
| 2172 if (unit == null) { | 2183 if (unit == null) { |
| 2173 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); | 2184 unit = parseHtmlUnit(source); |
| 2174 if (unit == null) { | |
| 2175 unit = parseHtmlUnit(source); | |
| 2176 } | |
| 2177 } | 2185 } |
| 2178 HtmlUnitBuilder builder = new HtmlUnitBuilder(this); | 2186 HtmlUnitBuilder builder = new HtmlUnitBuilder(this); |
| 2179 element = builder.buildHtmlElement2(source, unit); | 2187 element = builder.buildHtmlElement2(source, unit); |
| 2180 List<AnalysisError> resolutionErrors = builder.errorListener.getErrors2(
source); | 2188 List<AnalysisError> resolutionErrors = builder.errorListener.getErrors2(
source); |
| 2181 HtmlEntryImpl htmlCopy = getHtmlEntry(source).writableCopy; | 2189 HtmlEntryImpl htmlCopy = getHtmlEntry(source).writableCopy; |
| 2182 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, unit); | |
| 2183 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors); | 2190 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors); |
| 2184 htmlCopy.setValue(HtmlEntry.ELEMENT, element); | 2191 htmlCopy.setValue(HtmlEntry.ELEMENT, element); |
| 2185 _sourceMap[source] = htmlCopy; | 2192 _sourceMap[source] = htmlCopy; |
| 2186 getNotice(source).setErrors(htmlCopy.allErrors, htmlCopy.getValue(Source
Entry.LINE_INFO)); | 2193 getNotice(source).setErrors(htmlCopy.allErrors, htmlCopy.getValue(Source
Entry.LINE_INFO)); |
| 2187 } | 2194 } |
| 2188 return element; | 2195 return element; |
| 2189 } | 2196 } |
| 2190 } | 2197 } |
| 2191 List<Source> computeImportedLibraries(Source source) { | 2198 List<Source> computeImportedLibraries(Source source) { |
| 2192 { | 2199 { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2292 if (container.contains(source)) { | 2299 if (container.contains(source)) { |
| 2293 sourcesToRemove.add(source); | 2300 sourcesToRemove.add(source); |
| 2294 newContext.addSourceInfo(source, entry.getValue().writableCopy); | 2301 newContext.addSourceInfo(source, entry.getValue().writableCopy); |
| 2295 } | 2302 } |
| 2296 } | 2303 } |
| 2297 } | 2304 } |
| 2298 return newContext; | 2305 return newContext; |
| 2299 } | 2306 } |
| 2300 AnalysisOptions get analysisOptions => _options; | 2307 AnalysisOptions get analysisOptions => _options; |
| 2301 Element getElement(ElementLocation location) { | 2308 Element getElement(ElementLocation location) { |
| 2302 List<String> components = ((location as ElementLocationImpl)).components; | 2309 try { |
| 2303 ElementImpl element; | 2310 List<String> components = ((location as ElementLocationImpl)).components; |
| 2304 { | 2311 Source librarySource = computeSourceFromEncoding(components[0]); |
| 2305 Source librarySource = _sourceFactory.fromEncoding(components[0]); | 2312 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; |
| 2306 try { | 2313 for (int i = 1; i < components.length; i++) { |
| 2307 element = computeLibraryElement(librarySource) as ElementImpl; | 2314 if (element == null) { |
| 2308 } on AnalysisException catch (exception) { | 2315 return null; |
| 2309 return null; | 2316 } |
| 2317 element = element.getChild(components[i]); |
| 2310 } | 2318 } |
| 2319 return element; |
| 2320 } on AnalysisException catch (exception) { |
| 2321 return null; |
| 2311 } | 2322 } |
| 2312 for (int i = 1; i < components.length; i++) { | |
| 2313 if (element == null) { | |
| 2314 return null; | |
| 2315 } | |
| 2316 element = element.getChild(components[i]); | |
| 2317 } | |
| 2318 return element; | |
| 2319 } | 2323 } |
| 2320 AnalysisErrorInfo getErrors(Source source) { | 2324 AnalysisErrorInfo getErrors(Source source) { |
| 2321 SourceEntry sourceEntry = getReadableSourceEntry(source); | 2325 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 2322 if (sourceEntry is DartEntry) { | 2326 if (sourceEntry is DartEntry) { |
| 2323 DartEntry dartEntry = sourceEntry as DartEntry; | 2327 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2324 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue(S
ourceEntry.LINE_INFO)); | 2328 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue(S
ourceEntry.LINE_INFO)); |
| 2325 } else if (sourceEntry is HtmlEntry) { | 2329 } else if (sourceEntry is HtmlEntry) { |
| 2326 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 2330 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 2327 return new AnalysisErrorInfoImpl(htmlEntry.allErrors, htmlEntry.getValue(S
ourceEntry.LINE_INFO)); | 2331 return new AnalysisErrorInfoImpl(htmlEntry.allErrors, htmlEntry.getValue(S
ourceEntry.LINE_INFO)); |
| 2328 } | 2332 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2450 Source source = library.definingCompilationUnit.source; | 2454 Source source = library.definingCompilationUnit.source; |
| 2451 { | 2455 { |
| 2452 DartEntry dartEntry = getDartEntry(source); | 2456 DartEntry dartEntry = getDartEntry(source); |
| 2453 if (dartEntry == null) { | 2457 if (dartEntry == null) { |
| 2454 return null; | 2458 return null; |
| 2455 } | 2459 } |
| 2456 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 2460 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 2457 if (namespace == null) { | 2461 if (namespace == null) { |
| 2458 NamespaceBuilder builder = new NamespaceBuilder(); | 2462 NamespaceBuilder builder = new NamespaceBuilder(); |
| 2459 namespace = builder.createPublicNamespace(library); | 2463 namespace = builder.createPublicNamespace(library); |
| 2460 DartEntryImpl dartCopy = dartEntry.writableCopy; | 2464 DartEntryImpl dartCopy = getDartEntry(source).writableCopy; |
| 2461 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 2465 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 2462 _sourceMap[source] = dartCopy; | 2466 _sourceMap[source] = dartCopy; |
| 2463 } | 2467 } |
| 2464 return namespace; | 2468 return namespace; |
| 2465 } | 2469 } |
| 2466 } | 2470 } |
| 2467 Namespace getPublicNamespace2(Source source) { | 2471 Namespace getPublicNamespace2(Source source) { |
| 2468 { | 2472 { |
| 2469 DartEntry dartEntry = getDartEntry(source); | 2473 DartEntry dartEntry = getDartEntry(source); |
| 2470 if (dartEntry == null) { | 2474 if (dartEntry == null) { |
| 2471 return null; | 2475 return null; |
| 2472 } | 2476 } |
| 2473 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 2477 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 2474 if (namespace == null) { | 2478 if (namespace == null) { |
| 2475 LibraryElement library = computeLibraryElement(source); | 2479 LibraryElement library = computeLibraryElement(source); |
| 2476 if (library == null) { | 2480 if (library == null) { |
| 2477 return null; | 2481 return null; |
| 2478 } | 2482 } |
| 2479 NamespaceBuilder builder = new NamespaceBuilder(); | 2483 NamespaceBuilder builder = new NamespaceBuilder(); |
| 2480 namespace = builder.createPublicNamespace(library); | 2484 namespace = builder.createPublicNamespace(library); |
| 2481 DartEntryImpl dartCopy = dartEntry.writableCopy; | 2485 DartEntryImpl dartCopy = getDartEntry(source).writableCopy; |
| 2482 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 2486 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 2483 _sourceMap[source] = dartCopy; | 2487 _sourceMap[source] = dartCopy; |
| 2484 } | 2488 } |
| 2485 return namespace; | 2489 return namespace; |
| 2486 } | 2490 } |
| 2487 } | 2491 } |
| 2488 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { | 2492 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { |
| 2489 if (library == null) { | 2493 if (library == null) { |
| 2490 return null; | 2494 return null; |
| 2491 } | 2495 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 return unit; | 2547 return unit; |
| 2544 } | 2548 } |
| 2545 } | 2549 } |
| 2546 HtmlUnit parseHtmlUnit(Source source) { | 2550 HtmlUnit parseHtmlUnit(Source source) { |
| 2547 { | 2551 { |
| 2548 accessed(source); | 2552 accessed(source); |
| 2549 HtmlEntry htmlEntry = getHtmlEntry(source); | 2553 HtmlEntry htmlEntry = getHtmlEntry(source); |
| 2550 if (htmlEntry == null) { | 2554 if (htmlEntry == null) { |
| 2551 return null; | 2555 return null; |
| 2552 } | 2556 } |
| 2553 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2557 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
| 2554 if (unit == null) { | 2558 if (unit == null) { |
| 2555 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); | 2559 try { |
| 2556 if (unit == null) { | 2560 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(source)
); |
| 2557 try { | 2561 unit = result.htmlUnit; |
| 2558 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(sourc
e)); | 2562 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 2559 unit = result.htmlUnit; | 2563 htmlCopy.setValue(SourceEntry.LINE_INFO, new LineInfo(result.lineStart
s)); |
| 2560 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 2564 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); |
| 2561 htmlCopy.setValue(SourceEntry.LINE_INFO, new LineInfo(result.lineSta
rts)); | 2565 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2(s
ource, unit)); |
| 2562 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); | 2566 _sourceMap[source] = htmlCopy; |
| 2563 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2
(source, unit)); | 2567 } on AnalysisException catch (exception) { |
| 2564 _sourceMap[source] = htmlCopy; | 2568 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 2565 } on AnalysisException catch (exception) { | 2569 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 2566 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 2570 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); |
| 2567 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); | 2571 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); |
| 2568 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); | 2572 _sourceMap[source] = htmlCopy; |
| 2569 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); | 2573 throw exception; |
| 2570 _sourceMap[source] = htmlCopy; | |
| 2571 throw exception; | |
| 2572 } | |
| 2573 } | 2574 } |
| 2574 } | 2575 } |
| 2575 return unit; | 2576 return unit; |
| 2576 } | 2577 } |
| 2577 } | 2578 } |
| 2578 List<ChangeNotice> performAnalysisTask() { | 2579 List<ChangeNotice> performAnalysisTask() { |
| 2579 { | 2580 { |
| 2580 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { | 2581 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { |
| 2581 return null; | 2582 return null; |
| 2582 } | 2583 } |
| 2583 if (_pendingNotices.isEmpty) { | 2584 if (_pendingNotices.isEmpty) { |
| 2584 return ChangeNoticeImpl.EMPTY_ARRAY; | 2585 return ChangeNoticeImpl.EMPTY_ARRAY; |
| 2585 } | 2586 } |
| 2586 List<ChangeNotice> notices = new List.from(_pendingNotices.values); | 2587 List<ChangeNotice> notices = new List.from(_pendingNotices.values); |
| 2587 _pendingNotices.clear(); | 2588 _pendingNotices.clear(); |
| 2588 return notices; | 2589 return notices; |
| 2589 } | 2590 } |
| 2590 } | 2591 } |
| 2591 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 2592 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 2592 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); | |
| 2593 { | 2593 { |
| 2594 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
| 2594 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ | 2595 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ |
| 2595 Source librarySource = entry.getKey(); | 2596 Source librarySource = entry.getKey(); |
| 2596 LibraryElement library = entry.getValue(); | 2597 LibraryElement library = entry.getValue(); |
| 2597 DartEntry dartEntry = getDartEntry(librarySource); | 2598 DartEntry dartEntry = getDartEntry(librarySource); |
| 2598 if (dartEntry != null) { | 2599 if (dartEntry != null) { |
| 2599 DartEntryImpl dartCopy = dartEntry.writableCopy; | 2600 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 2600 recordElementData(dartCopy, library, htmlSource); | 2601 recordElementData(dartCopy, library, htmlSource); |
| 2601 _sourceMap[librarySource] = dartCopy; | 2602 _sourceMap[librarySource] = dartCopy; |
| 2602 } | 2603 } |
| 2603 } | 2604 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2645 _sourceMap[unitSource] = dartCopy; | 2646 _sourceMap[unitSource] = dartCopy; |
| 2646 unit = unitAST; | 2647 unit = unitAST; |
| 2647 } | 2648 } |
| 2648 } finally { | 2649 } finally { |
| 2649 enableCacheRemoval(); | 2650 enableCacheRemoval(); |
| 2650 } | 2651 } |
| 2651 } | 2652 } |
| 2652 return unit; | 2653 return unit; |
| 2653 } | 2654 } |
| 2654 } | 2655 } |
| 2655 HtmlUnit resolveHtmlUnit(Source unitSource) { | 2656 HtmlUnit resolveHtmlUnit(Source source) => parseHtmlUnit(source); |
| 2656 { | |
| 2657 accessed(unitSource); | |
| 2658 HtmlEntry htmlEntry = getHtmlEntry(unitSource); | |
| 2659 if (htmlEntry == null) { | |
| 2660 return null; | |
| 2661 } | |
| 2662 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | |
| 2663 if (unit == null) { | |
| 2664 disableCacheRemoval(); | |
| 2665 try { | |
| 2666 computeHtmlElement(unitSource); | |
| 2667 unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | |
| 2668 if (unit == null) { | |
| 2669 unit = parseHtmlUnit(unitSource); | |
| 2670 } | |
| 2671 } on AnalysisException catch (exception) { | |
| 2672 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | |
| 2673 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); | |
| 2674 _sourceMap[unitSource] = htmlCopy; | |
| 2675 throw exception; | |
| 2676 } finally { | |
| 2677 enableCacheRemoval(); | |
| 2678 } | |
| 2679 } | |
| 2680 return unit; | |
| 2681 } | |
| 2682 } | |
| 2683 void set analysisOptions(AnalysisOptions options2) { | 2657 void set analysisOptions(AnalysisOptions options2) { |
| 2684 { | 2658 { |
| 2685 this._options = options2; | 2659 this._options = options2; |
| 2686 invalidateAllResults(); | 2660 invalidateAllResults(); |
| 2687 } | 2661 } |
| 2688 } | 2662 } |
| 2689 void set analysisPriorityOrder(List<Source> sources) { | 2663 void set analysisPriorityOrder(List<Source> sources) { |
| 2690 { | 2664 { |
| 2691 if (sources == null || sources.isEmpty) { | 2665 if (sources == null || sources.isEmpty) { |
| 2692 _priorityOrder = Source.EMPTY_ARRAY; | 2666 _priorityOrder = Source.EMPTY_ARRAY; |
| 2693 } else { | 2667 } else { |
| 2694 _priorityOrder = new List.from(sources); | 2668 _priorityOrder = new List.from(sources); |
| 2695 } | 2669 } |
| 2696 } | 2670 } |
| 2697 } | 2671 } |
| 2698 void setContents(Source source, String contents) { | 2672 void setContents(Source source, String contents) { |
| 2699 { | 2673 { |
| 2700 _sourceFactory.setContents(source, contents); | 2674 _sourceFactory.setContents(source, contents); |
| 2701 sourceChanged(source); | 2675 sourceChanged(source); |
| 2702 } | 2676 } |
| 2703 } | 2677 } |
| 2704 void set sourceFactory(SourceFactory factory) { | 2678 void set sourceFactory(SourceFactory factory) { |
| 2705 if (identical(_sourceFactory, factory)) { | |
| 2706 return; | |
| 2707 } else if (factory.context != null) { | |
| 2708 throw new IllegalStateException("Source factories cannot be shared between
contexts"); | |
| 2709 } | |
| 2710 { | 2679 { |
| 2680 if (identical(_sourceFactory, factory)) { |
| 2681 return; |
| 2682 } else if (factory.context != null) { |
| 2683 throw new IllegalStateException("Source factories cannot be shared betwe
en contexts"); |
| 2684 } |
| 2711 if (_sourceFactory != null) { | 2685 if (_sourceFactory != null) { |
| 2712 _sourceFactory.context = null; | 2686 _sourceFactory.context = null; |
| 2713 } | 2687 } |
| 2714 factory.context = this; | 2688 factory.context = this; |
| 2715 _sourceFactory = factory; | 2689 _sourceFactory = factory; |
| 2716 invalidateAllResults(); | 2690 invalidateAllResults(); |
| 2717 } | 2691 } |
| 2718 } | 2692 } |
| 2719 Iterable<Source> sourcesToResolve(List<Source> changedSources) { | 2693 Iterable<Source> sourcesToResolve(List<Source> changedSources) { |
| 2720 List<Source> librarySources = new List<Source>(); | 2694 List<Source> librarySources = new List<Source>(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2740 if (sourceEntry is DartEntry) { | 2714 if (sourceEntry is DartEntry) { |
| 2741 DartEntry dartEntry = sourceEntry as DartEntry; | 2715 DartEntry dartEntry = sourceEntry as DartEntry; |
| 2742 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT)
; | 2716 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT)
; |
| 2743 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); | 2717 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
| 2744 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen
tState, CacheState.INVALID)) { | 2718 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen
tState, CacheState.INVALID)) { |
| 2745 sources.add(entry.getKey()); | 2719 sources.add(entry.getKey()); |
| 2746 } | 2720 } |
| 2747 } else if (sourceEntry is HtmlEntry) { | 2721 } else if (sourceEntry is HtmlEntry) { |
| 2748 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 2722 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 2749 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT)
; | 2723 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT)
; |
| 2750 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_U
NIT); | 2724 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT); |
| 2751 if (identical(parsedUnitState, CacheState.INVALID) || identical(resolv
edUnitState, CacheState.INVALID)) { | 2725 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen
tState, CacheState.INVALID)) { |
| 2752 sources.add(entry.getKey()); | 2726 sources.add(entry.getKey()); |
| 2753 } | 2727 } |
| 2754 } | 2728 } |
| 2755 } | 2729 } |
| 2756 } | 2730 } |
| 2757 return sources; | 2731 return sources; |
| 2758 } | 2732 } |
| 2759 | 2733 |
| 2760 /** | 2734 /** |
| 2761 * Record that the given source was just accessed for some unspecified purpose
. | 2735 * Record that the given source was just accessed for some unspecified purpose
. |
| 2762 * | 2736 * |
| 2763 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. | 2737 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 2764 * | 2738 * |
| 2765 * @param source the source that was accessed | 2739 * @param source the source that was accessed |
| 2766 */ | 2740 */ |
| 2767 void accessed(Source source) { | 2741 void accessed(Source source) { |
| 2768 if (_recentlyUsed.contains(source)) { | 2742 if (_recentlyUsed.remove(source)) { |
| 2769 _recentlyUsed.remove(source); | |
| 2770 _recentlyUsed.add(source); | 2743 _recentlyUsed.add(source); |
| 2771 return; | 2744 return; |
| 2772 } | 2745 } |
| 2773 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { | 2746 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { |
| 2774 Source removedSource = _recentlyUsed.removeAt(0); | 2747 flushAstFromCache(); |
| 2775 SourceEntry sourceEntry = _sourceMap[removedSource]; | |
| 2776 if (sourceEntry is HtmlEntry) { | |
| 2777 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; | |
| 2778 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); | |
| 2779 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.FLUSHED); | |
| 2780 _sourceMap[removedSource] = htmlCopy; | |
| 2781 } else if (sourceEntry is DartEntry) { | |
| 2782 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; | |
| 2783 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | |
| 2784 for (Source librarySource in getLibrariesContaining(source)) { | |
| 2785 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
FLUSHED); | |
| 2786 } | |
| 2787 _sourceMap[removedSource] = dartCopy; | |
| 2788 } | |
| 2789 } | 2748 } |
| 2790 _recentlyUsed.add(source); | 2749 _recentlyUsed.add(source); |
| 2791 } | 2750 } |
| 2792 | 2751 |
| 2793 /** | 2752 /** |
| 2794 * Add all of the sources contained in the given source container to the given
list of sources. | 2753 * Add all of the sources contained in the given source container to the given
list of sources. |
| 2795 * | 2754 * |
| 2796 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. | 2755 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 2797 * | 2756 * |
| 2798 * @param sources the list to which sources are to be added | 2757 * @param sources the list to which sources are to be added |
| 2799 * @param container the source container containing the sources to be added to
the list | 2758 * @param container the source container containing the sources to be added to
the list |
| 2800 */ | 2759 */ |
| 2801 void addSourcesInContainer(List<Source> sources, SourceContainer container) { | 2760 void addSourcesInContainer(List<Source> sources, SourceContainer container) { |
| 2802 for (Source source in _sourceMap.keys.toSet()) { | 2761 for (Source source in _sourceMap.keys.toSet()) { |
| 2803 if (container.contains(source)) { | 2762 if (container.contains(source)) { |
| 2804 sources.add(source); | 2763 sources.add(source); |
| 2805 } | 2764 } |
| 2806 } | 2765 } |
| 2807 } | 2766 } |
| 2808 | 2767 |
| 2809 /** | 2768 /** |
| 2769 * Given the encoded form of a source, use the source factory to reconstitute
the original source. |
| 2770 * |
| 2771 * @param encoding the encoded form of a source |
| 2772 * @return the source represented by the encoding |
| 2773 */ |
| 2774 Source computeSourceFromEncoding(String encoding) { |
| 2775 { |
| 2776 return _sourceFactory.fromEncoding(encoding); |
| 2777 } |
| 2778 } |
| 2779 |
| 2780 /** |
| 2810 * Return `true` if the given array of sources contains the given source. | 2781 * Return `true` if the given array of sources contains the given source. |
| 2811 * | 2782 * |
| 2812 * @param sources the sources being searched | 2783 * @param sources the sources being searched |
| 2813 * @param targetSource the source being searched for | 2784 * @param targetSource the source being searched for |
| 2814 * @return `true` if the given source is in the array | 2785 * @return `true` if the given source is in the array |
| 2815 */ | 2786 */ |
| 2816 bool contains(List<Source> sources, Source targetSource) { | 2787 bool contains(List<Source> sources, Source targetSource) { |
| 2817 for (Source source in sources) { | 2788 for (Source source in sources) { |
| 2818 if (source == targetSource) { | 2789 if (source == targetSource) { |
| 2819 return true; | 2790 return true; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2841 /** | 2812 /** |
| 2842 * Create a source information object suitable for the given source. Return th
e source information | 2813 * Create a source information object suitable for the given source. Return th
e source information |
| 2843 * object that was created, or `null` if the source should not be tracked by t
his context. | 2814 * object that was created, or `null` if the source should not be tracked by t
his context. |
| 2844 * | 2815 * |
| 2845 * @param source the source for which an information object is being created | 2816 * @param source the source for which an information object is being created |
| 2846 * @return the source information object that was created | 2817 * @return the source information object that was created |
| 2847 */ | 2818 */ |
| 2848 SourceEntry createSourceEntry(Source source) { | 2819 SourceEntry createSourceEntry(Source source) { |
| 2849 String name = source.shortName; | 2820 String name = source.shortName; |
| 2850 if (AnalysisEngine.isHtmlFileName(name)) { | 2821 if (AnalysisEngine.isHtmlFileName(name)) { |
| 2851 HtmlEntry htmlEntry = new HtmlEntryImpl(); | 2822 HtmlEntryImpl htmlEntry = new HtmlEntryImpl(); |
| 2823 htmlEntry.modificationTime = source.modificationStamp; |
| 2852 _sourceMap[source] = htmlEntry; | 2824 _sourceMap[source] = htmlEntry; |
| 2853 return htmlEntry; | 2825 return htmlEntry; |
| 2854 } else { | 2826 } else { |
| 2855 DartEntry dartEntry = new DartEntryImpl(); | 2827 DartEntryImpl dartEntry = new DartEntryImpl(); |
| 2828 dartEntry.modificationTime = source.modificationStamp; |
| 2856 _sourceMap[source] = dartEntry; | 2829 _sourceMap[source] = dartEntry; |
| 2857 return dartEntry; | 2830 return dartEntry; |
| 2858 } | 2831 } |
| 2859 } | 2832 } |
| 2860 | 2833 |
| 2861 /** | 2834 /** |
| 2862 * Disable flushing information from the cache until [enableCacheRemoval] has
been | 2835 * Disable flushing information from the cache until [enableCacheRemoval] has
been |
| 2863 * called. | 2836 * called. |
| 2864 */ | 2837 */ |
| 2865 void disableCacheRemoval() { | 2838 void disableCacheRemoval() { |
| 2866 _cacheRemovalCount++; | 2839 _cacheRemovalCount++; |
| 2867 } | 2840 } |
| 2868 | 2841 |
| 2869 /** | 2842 /** |
| 2870 * Re-enable flushing information from the cache. | 2843 * Re-enable flushing information from the cache. |
| 2871 */ | 2844 */ |
| 2872 void enableCacheRemoval() { | 2845 void enableCacheRemoval() { |
| 2873 if (_cacheRemovalCount > 0) { | 2846 if (_cacheRemovalCount > 0) { |
| 2874 _cacheRemovalCount--; | 2847 _cacheRemovalCount--; |
| 2875 } | 2848 } |
| 2876 if (_cacheRemovalCount == 0) { | 2849 if (_cacheRemovalCount == 0) { |
| 2877 while (_recentlyUsed.length >= _MAX_CACHE_SIZE) { | 2850 while (_recentlyUsed.length >= _MAX_CACHE_SIZE) { |
| 2878 Source removedSource = _recentlyUsed.removeAt(0); | 2851 flushAstFromCache(); |
| 2879 SourceEntry sourceEntry = _sourceMap[removedSource]; | |
| 2880 if (sourceEntry is HtmlEntry) { | |
| 2881 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; | |
| 2882 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); | |
| 2883 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.FLUSHED); | |
| 2884 _sourceMap[removedSource] = htmlCopy; | |
| 2885 } else if (sourceEntry is DartEntry) { | |
| 2886 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; | |
| 2887 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | |
| 2888 for (Source librarySource in getLibrariesContaining(removedSource)) { | |
| 2889 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat
e.FLUSHED); | |
| 2890 } | |
| 2891 _sourceMap[removedSource] = dartCopy; | |
| 2892 } | |
| 2893 } | 2852 } |
| 2894 } | 2853 } |
| 2895 } | 2854 } |
| 2896 | 2855 |
| 2897 /** | 2856 /** |
| 2898 * Search the compilation units that are part of the given library and return
the element | 2857 * Search the compilation units that are part of the given library and return
the element |
| 2899 * representing the compilation unit with the given source. Return `null` if t
here is no | 2858 * representing the compilation unit with the given source. Return `null` if t
here is no |
| 2900 * such compilation unit. | 2859 * such compilation unit. |
| 2901 * | 2860 * |
| 2902 * @param libraryElement the element representing the library being searched t
hrough | 2861 * @param libraryElement the element representing the library being searched t
hrough |
| 2903 * @param unitSource the source for the compilation unit whose element is to b
e returned | 2862 * @param unitSource the source for the compilation unit whose element is to b
e returned |
| 2904 * @return the element representing the compilation unit | 2863 * @return the element representing the compilation unit |
| 2905 */ | 2864 */ |
| 2906 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ | 2865 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ |
| 2907 CompilationUnitElement element = libraryElement.definingCompilationUnit; | 2866 CompilationUnitElement element = libraryElement.definingCompilationUnit; |
| 2908 if (element.source == unitSource) { | 2867 if (element.source == unitSource) { |
| 2909 return element; | 2868 return element; |
| 2910 } | 2869 } |
| 2911 for (CompilationUnitElement partElement in libraryElement.parts) { | 2870 for (CompilationUnitElement partElement in libraryElement.parts) { |
| 2912 if (partElement.source == unitSource) { | 2871 if (partElement.source == unitSource) { |
| 2913 return partElement; | 2872 return partElement; |
| 2914 } | 2873 } |
| 2915 } | 2874 } |
| 2916 return null; | 2875 return null; |
| 2917 } | 2876 } |
| 2918 | 2877 |
| 2919 /** | 2878 /** |
| 2879 * Flush one AST structure from the cache. |
| 2880 * |
| 2881 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 2882 */ |
| 2883 void flushAstFromCache() { |
| 2884 Source removedSource = _recentlyUsed.removeAt(0); |
| 2885 SourceEntry sourceEntry = _sourceMap[removedSource]; |
| 2886 if (sourceEntry is HtmlEntry) { |
| 2887 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 2888 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 2889 _sourceMap[removedSource] = htmlCopy; |
| 2890 } else if (sourceEntry is DartEntry) { |
| 2891 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| 2892 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 2893 for (Source librarySource in getLibrariesContaining(removedSource)) { |
| 2894 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.FL
USHED); |
| 2895 } |
| 2896 _sourceMap[removedSource] = dartCopy; |
| 2897 } |
| 2898 } |
| 2899 |
| 2900 /** |
| 2920 * Return the compilation unit information associated with the given source, o
r `null` if | 2901 * Return the compilation unit information associated with the given source, o
r `null` if |
| 2921 * the source is not known to this context. This method should be used to acce
ss the compilation | 2902 * the source is not known to this context. This method should be used to acce
ss the compilation |
| 2922 * unit information rather than accessing the compilation unit map directly be
cause sources in the | 2903 * unit information rather than accessing the compilation unit map directly be
cause sources in the |
| 2923 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when | 2904 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when |
| 2924 * first accessed. | 2905 * first accessed. |
| 2925 * | 2906 * |
| 2926 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 2907 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 2927 * | 2908 * |
| 2928 * @param source the source for which information is being sought | 2909 * @param source the source for which information is being sought |
| 2929 * @return the compilation unit information associated with the given source | 2910 * @return the compilation unit information associated with the given source |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2989 ChangeNoticeImpl getNotice(Source source) { | 2970 ChangeNoticeImpl getNotice(Source source) { |
| 2990 ChangeNoticeImpl notice = _pendingNotices[source]; | 2971 ChangeNoticeImpl notice = _pendingNotices[source]; |
| 2991 if (notice == null) { | 2972 if (notice == null) { |
| 2992 notice = new ChangeNoticeImpl(source); | 2973 notice = new ChangeNoticeImpl(source); |
| 2993 _pendingNotices[source] = notice; | 2974 _pendingNotices[source] = notice; |
| 2994 } | 2975 } |
| 2995 return notice; | 2976 return notice; |
| 2996 } | 2977 } |
| 2997 | 2978 |
| 2998 /** | 2979 /** |
| 2980 * Return the cache entry associated with the given source, or `null` if the s
ource is not a |
| 2981 * Dart file. |
| 2982 * |
| 2983 * @param source the source for which a cache entry is being sought |
| 2984 * @return the source cache entry associated with the given source |
| 2985 */ |
| 2986 DartEntry getReadableDartEntry(Source source) { |
| 2987 { |
| 2988 SourceEntry sourceEntry = _sourceMap[source]; |
| 2989 if (sourceEntry == null) { |
| 2990 sourceEntry = createSourceEntry(source); |
| 2991 } |
| 2992 if (sourceEntry is DartEntry) { |
| 2993 accessed(source); |
| 2994 return sourceEntry as DartEntry; |
| 2995 } |
| 2996 return null; |
| 2997 } |
| 2998 } |
| 2999 |
| 3000 /** |
| 3001 * Return the cache entry associated with the given source, or `null` if the s
ource is not |
| 3002 * an HTML file. |
| 3003 * |
| 3004 * @param source the source for which a cache entry is being sought |
| 3005 * @return the source cache entry associated with the given source |
| 3006 */ |
| 3007 HtmlEntry getReadableHtmlEntry(Source source) { |
| 3008 { |
| 3009 SourceEntry sourceEntry = _sourceMap[source]; |
| 3010 if (sourceEntry == null) { |
| 3011 sourceEntry = createSourceEntry(source); |
| 3012 } |
| 3013 if (sourceEntry is HtmlEntry) { |
| 3014 accessed(source); |
| 3015 return sourceEntry as HtmlEntry; |
| 3016 } |
| 3017 return null; |
| 3018 } |
| 3019 } |
| 3020 |
| 3021 /** |
| 2999 * Return the cache entry associated with the given source, or `null` if there
is no entry | 3022 * Return the cache entry associated with the given source, or `null` if there
is no entry |
| 3000 * associated with the source. | 3023 * associated with the source. |
| 3001 * | 3024 * |
| 3002 * @param source the source for which a cache entry is being sought | 3025 * @param source the source for which a cache entry is being sought |
| 3003 * @return the source cache entry associated with the given source | 3026 * @return the source cache entry associated with the given source |
| 3004 */ | 3027 */ |
| 3005 SourceEntry getReadableSourceEntry(Source source) { | 3028 SourceEntry getReadableSourceEntry(Source source) { |
| 3006 { | 3029 { |
| 3007 return _sourceMap[source]; | 3030 SourceEntry sourceEntry = _sourceMap[source]; |
| 3031 if (sourceEntry == null) { |
| 3032 sourceEntry = createSourceEntry(source); |
| 3033 } |
| 3034 if (sourceEntry != null) { |
| 3035 accessed(source); |
| 3036 } |
| 3037 return sourceEntry; |
| 3008 } | 3038 } |
| 3009 } | 3039 } |
| 3010 | 3040 |
| 3011 /** | 3041 /** |
| 3012 * Return the source information associated with the given source, or `null` i
f the source | 3042 * Return the source information associated with the given source, or `null` i
f the source |
| 3013 * is not known to this context. This method should be used to access the sour
ce information | 3043 * is not known to this context. This method should be used to access the sour
ce information |
| 3014 * rather than accessing the source map directly because sources in the SDK ar
e implicitly part of | 3044 * rather than accessing the source map directly because sources in the SDK ar
e implicitly part of |
| 3015 * every analysis context and are therefore only added to the map when first a
ccessed. | 3045 * every analysis context and are therefore only added to the map when first a
ccessed. |
| 3016 * | 3046 * |
| 3017 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3047 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3176 /** | 3206 /** |
| 3177 * Invalidate all of the results computed by this context. | 3207 * Invalidate all of the results computed by this context. |
| 3178 * | 3208 * |
| 3179 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3209 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3180 */ | 3210 */ |
| 3181 void invalidateAllResults() { | 3211 void invalidateAllResults() { |
| 3182 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) { | 3212 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) { |
| 3183 SourceEntry sourceEntry = mapEntry.getValue(); | 3213 SourceEntry sourceEntry = mapEntry.getValue(); |
| 3184 if (sourceEntry is HtmlEntry) { | 3214 if (sourceEntry is HtmlEntry) { |
| 3185 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; | 3215 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 3186 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); | 3216 htmlCopy.invalidateAllResolutionInformation(); |
| 3187 mapEntry.setValue(htmlCopy); | 3217 mapEntry.setValue(htmlCopy); |
| 3188 } else if (sourceEntry is DartEntry) { | 3218 } else if (sourceEntry is DartEntry) { |
| 3189 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; | 3219 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| 3190 dartCopy.invalidateAllResolutionInformation(); | 3220 dartCopy.invalidateAllResolutionInformation(); |
| 3191 mapEntry.setValue(dartCopy); | 3221 mapEntry.setValue(dartCopy); |
| 3192 } | 3222 } |
| 3193 } | 3223 } |
| 3194 } | 3224 } |
| 3195 | 3225 |
| 3196 /** | 3226 /** |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3264 return true; | 3294 return true; |
| 3265 } else if (identical(dartEntry.getState(DartEntry.RESOLVED_UNIT), CacheS
tate.INVALID)) { | 3295 } else if (identical(dartEntry.getState(DartEntry.RESOLVED_UNIT), CacheS
tate.INVALID)) { |
| 3266 safelyResolveCompilationUnit(source); | 3296 safelyResolveCompilationUnit(source); |
| 3267 return true; | 3297 return true; |
| 3268 } | 3298 } |
| 3269 } else if (sourceEntry is HtmlEntry) { | 3299 } else if (sourceEntry is HtmlEntry) { |
| 3270 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 3300 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 3271 if (identical(htmlEntry.getState(HtmlEntry.PARSED_UNIT), CacheState.INVA
LID)) { | 3301 if (identical(htmlEntry.getState(HtmlEntry.PARSED_UNIT), CacheState.INVA
LID)) { |
| 3272 safelyParseHtmlUnit(source); | 3302 safelyParseHtmlUnit(source); |
| 3273 return true; | 3303 return true; |
| 3274 } else if (identical(htmlEntry.getState(HtmlEntry.RESOLVED_UNIT), CacheS
tate.INVALID)) { | 3304 } else if (identical(htmlEntry.getState(HtmlEntry.ELEMENT), CacheState.I
NVALID)) { |
| 3275 safelyResolveHtmlUnit(source); | 3305 safelyResolveHtmlUnit(source); |
| 3276 return true; | 3306 return true; |
| 3277 } | 3307 } |
| 3278 } | 3308 } |
| 3279 } | 3309 } |
| 3280 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 3310 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 3281 SourceEntry sourceEntry = entry.getValue(); | 3311 SourceEntry sourceEntry = entry.getValue(); |
| 3282 if (sourceEntry is DartEntry) { | 3312 if (sourceEntry is DartEntry) { |
| 3283 DartEntry dartEntry = sourceEntry as DartEntry; | 3313 DartEntry dartEntry = sourceEntry as DartEntry; |
| 3284 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT); | 3314 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.INVA
LID)) { |
| 3285 if (identical(parsedUnitState, CacheState.INVALID)) { | |
| 3286 safelyParseCompilationUnit(entry.getKey(), dartEntry); | 3315 safelyParseCompilationUnit(entry.getKey(), dartEntry); |
| 3287 return true; | 3316 return true; |
| 3288 } | 3317 } |
| 3289 } else if (sourceEntry is HtmlEntry) { | 3318 } else if (sourceEntry is HtmlEntry) { |
| 3290 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 3319 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 3291 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); | 3320 if (identical(htmlEntry.getState(HtmlEntry.PARSED_UNIT), CacheState.INVA
LID)) { |
| 3292 if (identical(parsedUnitState, CacheState.INVALID)) { | |
| 3293 safelyParseHtmlUnit(entry.getKey()); | 3321 safelyParseHtmlUnit(entry.getKey()); |
| 3294 return true; | 3322 return true; |
| 3295 } | 3323 } |
| 3296 } | 3324 } |
| 3297 } | 3325 } |
| 3298 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { | 3326 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 3299 SourceEntry sourceEntry = entry.getValue(); | 3327 SourceEntry sourceEntry = entry.getValue(); |
| 3300 if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.LIB
RARY)) { | 3328 if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.LIB
RARY)) { |
| 3301 DartEntry dartEntry = sourceEntry as DartEntry; | 3329 DartEntry dartEntry = sourceEntry as DartEntry; |
| 3302 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); | 3330 if (identical(dartEntry.getState(DartEntry.ELEMENT), CacheState.INVALID)
) { |
| 3303 if (identical(elementState, CacheState.INVALID)) { | |
| 3304 safelyResolveCompilationUnit(entry.getKey()); | 3331 safelyResolveCompilationUnit(entry.getKey()); |
| 3305 return true; | 3332 return true; |
| 3306 } | 3333 } |
| 3307 } else if (sourceEntry is HtmlEntry) { | 3334 } else if (sourceEntry is HtmlEntry) { |
| 3308 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; | 3335 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 3309 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNI
T); | 3336 if (identical(htmlEntry.getState(HtmlEntry.ELEMENT), CacheState.INVALID)
) { |
| 3310 if (identical(resolvedUnitState, CacheState.INVALID)) { | |
| 3311 safelyResolveHtmlUnit(entry.getKey()); | 3337 safelyResolveHtmlUnit(entry.getKey()); |
| 3312 return true; | 3338 return true; |
| 3313 } | 3339 } |
| 3314 } | 3340 } |
| 3315 } | 3341 } |
| 3316 return false; | 3342 return false; |
| 3317 } | 3343 } |
| 3318 | 3344 |
| 3319 /** | 3345 /** |
| 3320 * Given a cache entry and a library element, record the library element and o
ther information | 3346 * Given a cache entry and a library element, record the library element and o
ther information |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3476 * | 3502 * |
| 3477 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3503 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3478 * | 3504 * |
| 3479 * @param source the source that has been added | 3505 * @param source the source that has been added |
| 3480 * @return `true` if the new source is a Dart file | 3506 * @return `true` if the new source is a Dart file |
| 3481 */ | 3507 */ |
| 3482 bool sourceAvailable(Source source) { | 3508 bool sourceAvailable(Source source) { |
| 3483 SourceEntry sourceEntry = _sourceMap[source]; | 3509 SourceEntry sourceEntry = _sourceMap[source]; |
| 3484 if (sourceEntry == null) { | 3510 if (sourceEntry == null) { |
| 3485 sourceEntry = createSourceEntry(source); | 3511 sourceEntry = createSourceEntry(source); |
| 3512 } else { |
| 3513 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 3514 sourceCopy.modificationTime = source.modificationStamp; |
| 3515 _sourceMap[source] = sourceCopy; |
| 3486 } | 3516 } |
| 3487 return sourceEntry is DartEntry; | 3517 return sourceEntry is DartEntry; |
| 3488 } | 3518 } |
| 3489 | 3519 |
| 3490 /** | 3520 /** |
| 3491 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3521 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3492 * | 3522 * |
| 3493 * @param source the source that has been changed | 3523 * @param source the source that has been changed |
| 3494 */ | 3524 */ |
| 3495 void sourceChanged(Source source) { | 3525 void sourceChanged(Source source) { |
| 3496 SourceEntry sourceEntry = _sourceMap[source]; | 3526 SourceEntry sourceEntry = _sourceMap[source]; |
| 3497 if (sourceEntry is HtmlEntry) { | 3527 if (sourceEntry is HtmlEntry) { |
| 3498 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; | 3528 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; |
| 3529 htmlCopy.modificationTime = source.modificationStamp; |
| 3499 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); | 3530 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
| 3500 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 3531 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 3501 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); | 3532 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); |
| 3502 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); | 3533 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); |
| 3503 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); | 3534 htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.INVALID); |
| 3504 _sourceMap[source] = htmlCopy; | 3535 _sourceMap[source] = htmlCopy; |
| 3505 } else if (sourceEntry is DartEntry) { | 3536 } else if (sourceEntry is DartEntry) { |
| 3506 List<Source> containingLibraries = getLibrariesContaining(source); | 3537 List<Source> containingLibraries = getLibrariesContaining(source); |
| 3507 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; | 3538 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; |
| 3539 dartCopy.modificationTime = source.modificationStamp; |
| 3508 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 3540 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 3509 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); | 3541 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); |
| 3510 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); | 3542 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); |
| 3511 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); | 3543 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); |
| 3512 _sourceMap[source] = dartCopy; | 3544 _sourceMap[source] = dartCopy; |
| 3513 for (Source library in containingLibraries) { | 3545 for (Source library in containingLibraries) { |
| 3514 invalidateLibraryResolution(library); | 3546 invalidateLibraryResolution(library); |
| 3515 } | 3547 } |
| 3516 } | 3548 } |
| 3517 } | 3549 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3551 } | 3583 } |
| 3552 return new List.from(sources); | 3584 return new List.from(sources); |
| 3553 } | 3585 } |
| 3554 } | 3586 } |
| 3555 /** | 3587 /** |
| 3556 * Instances of the class `ScanResult` represent the results of scanning a sourc
e. | 3588 * Instances of the class `ScanResult` represent the results of scanning a sourc
e. |
| 3557 */ | 3589 */ |
| 3558 class AnalysisContextImpl_ScanResult { | 3590 class AnalysisContextImpl_ScanResult { |
| 3559 | 3591 |
| 3560 /** | 3592 /** |
| 3561 * The time at which the contents of the source were last set. | 3593 * The time at which the contents of the source were last modified. |
| 3562 */ | 3594 */ |
| 3563 int _modificationTime = 0; | 3595 int _modificationTime = 0; |
| 3564 | 3596 |
| 3565 /** | 3597 /** |
| 3566 * The first token in the token stream. | 3598 * The first token in the token stream. |
| 3567 */ | 3599 */ |
| 3568 Token _token; | 3600 Token _token; |
| 3569 | 3601 |
| 3570 /** | 3602 /** |
| 3571 * The line start information that was produced. | 3603 * The line start information that was produced. |
| 3572 */ | 3604 */ |
| 3573 List<int> _lineStarts; | 3605 List<int> _lineStarts; |
| 3606 |
| 3607 /** |
| 3608 * Return the time at which the contents of the source were last modified. |
| 3609 * |
| 3610 * @return the time at which the contents of the source were last modified |
| 3611 */ |
| 3612 int get modificationTime => _modificationTime; |
| 3574 } | 3613 } |
| 3575 class RecursiveXmlVisitor_6 extends RecursiveXmlVisitor<Object> { | 3614 class RecursiveXmlVisitor_6 extends RecursiveXmlVisitor<Object> { |
| 3576 final AnalysisContextImpl AnalysisContextImpl_this; | 3615 final AnalysisContextImpl AnalysisContextImpl_this; |
| 3577 Source htmlSource; | 3616 Source htmlSource; |
| 3578 List<Source> libraries; | 3617 List<Source> libraries; |
| 3579 RecursiveXmlVisitor_6(this.AnalysisContextImpl_this, this.htmlSource, this.lib
raries) : super(); | 3618 RecursiveXmlVisitor_6(this.AnalysisContextImpl_this, this.htmlSource, this.lib
raries) : super(); |
| 3580 Object visitXmlTagNode(XmlTagNode node) { | 3619 Object visitXmlTagNode(XmlTagNode node) { |
| 3581 if (javaStringEqualsIgnoreCase(node.tag.lexeme, AnalysisContextImpl._TAG_SCR
IPT)) { | 3620 if (javaStringEqualsIgnoreCase(node.tag.lexeme, AnalysisContextImpl._TAG_SCR
IPT)) { |
| 3582 bool isDartScript = false; | 3621 bool isDartScript = false; |
| 3583 XmlAttributeNode scriptAttribute = null; | 3622 XmlAttributeNode scriptAttribute = null; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3672 */ | 3711 */ |
| 3673 class AnalysisOptionsImpl implements AnalysisOptions { | 3712 class AnalysisOptionsImpl implements AnalysisOptions { |
| 3674 | 3713 |
| 3675 /** | 3714 /** |
| 3676 * A flag indicating whether analysis is to use strict mode. In strict mode, e
rror reporting is | 3715 * A flag indicating whether analysis is to use strict mode. In strict mode, e
rror reporting is |
| 3677 * based exclusively on the static type information. | 3716 * based exclusively on the static type information. |
| 3678 */ | 3717 */ |
| 3679 bool _strictMode = false; | 3718 bool _strictMode = false; |
| 3680 | 3719 |
| 3681 /** | 3720 /** |
| 3682 * A flag indicating whether analysis is to generate audit results (e.g. type
inference based | 3721 * A flag indicating whether analysis is to generate hint results (e.g. type i
nference based |
| 3683 * information and pub best practices). | 3722 * information and pub best practices). |
| 3684 */ | 3723 */ |
| 3685 bool _audit = true; | 3724 bool _hint = true; |
| 3686 bool get audit => _audit; | 3725 bool get hint => _hint; |
| 3687 | 3726 |
| 3688 /** | 3727 /** |
| 3689 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based | 3728 * Return `true` if analysis is to use strict mode. In strict mode, error repo
rting is based |
| 3690 * exclusively on the static type information. | 3729 * exclusively on the static type information. |
| 3691 * | 3730 * |
| 3692 * @return `true` if analysis is to use strict mode | 3731 * @return `true` if analysis is to use strict mode |
| 3693 */ | 3732 */ |
| 3694 bool get strictMode => _strictMode; | 3733 bool get strictMode => _strictMode; |
| 3695 | 3734 |
| 3696 /** | 3735 /** |
| 3697 * Set whether analysis is to generate audit results (e.g. type inference base
d information and | 3736 * Set whether analysis is to generate hint results (e.g. type inference based
information and pub |
| 3698 * pub best practices). | 3737 * best practices). |
| 3699 * | 3738 * |
| 3700 * @param audit `true` if analysis is to generate audit results | 3739 * @param hint `true` if analysis is to generate hint results |
| 3701 */ | 3740 */ |
| 3702 void set audit(bool audit2) { | 3741 void set hint(bool hint2) { |
| 3703 this._audit = audit2; | 3742 this._hint = hint2; |
| 3704 } | 3743 } |
| 3705 | 3744 |
| 3706 /** | 3745 /** |
| 3707 * Set whether analysis is to use strict mode to the given value. In strict mo
de, error reporting | 3746 * Set whether analysis is to use strict mode to the given value. In strict mo
de, error reporting |
| 3708 * is based exclusively on the static type information. | 3747 * is based exclusively on the static type information. |
| 3709 * | 3748 * |
| 3710 * @param isStrict `true` if analysis is to use strict mode | 3749 * @param isStrict `true` if analysis is to use strict mode |
| 3711 */ | 3750 */ |
| 3712 void set strictMode(bool isStrict) { | 3751 void set strictMode(bool isStrict) { |
| 3713 _strictMode = isStrict; | 3752 _strictMode = isStrict; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3772 * | 3811 * |
| 3773 */ | 3812 */ |
| 3774 static final CacheState VALID = new CacheState('VALID', 4); | 3813 static final CacheState VALID = new CacheState('VALID', 4); |
| 3775 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V
ALID]; | 3814 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V
ALID]; |
| 3776 | 3815 |
| 3777 /// The name of this enum constant, as declared in the enum declaration. | 3816 /// The name of this enum constant, as declared in the enum declaration. |
| 3778 final String name; | 3817 final String name; |
| 3779 | 3818 |
| 3780 /// The position in the enum declaration. | 3819 /// The position in the enum declaration. |
| 3781 final int ordinal; | 3820 final int ordinal; |
| 3782 CacheState(this.name, this.ordinal) { | 3821 CacheState(this.name, this.ordinal); |
| 3783 } | |
| 3784 int compareTo(CacheState other) => ordinal - other.ordinal; | 3822 int compareTo(CacheState other) => ordinal - other.ordinal; |
| 3785 int get hashCode => ordinal; | 3823 int get hashCode => ordinal; |
| 3786 String toString() => name; | 3824 String toString() => name; |
| 3787 } | 3825 } |
| 3788 /** | 3826 /** |
| 3789 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results | 3827 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results |
| 3790 * associated with a given source. | 3828 * associated with a given source. |
| 3791 * | 3829 * |
| 3792 * @coverage dart.engine | 3830 * @coverage dart.engine |
| 3793 */ | 3831 */ |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4154 | 4192 |
| 4155 /** | 4193 /** |
| 4156 * The analysis context to which all of the non-instrumentation work is delega
ted. | 4194 * The analysis context to which all of the non-instrumentation work is delega
ted. |
| 4157 */ | 4195 */ |
| 4158 InternalAnalysisContext _basis; | 4196 InternalAnalysisContext _basis; |
| 4159 | 4197 |
| 4160 /** | 4198 /** |
| 4161 * Create a new [InstrumentedAnalysisContextImpl] which wraps a new | 4199 * Create a new [InstrumentedAnalysisContextImpl] which wraps a new |
| 4162 * [AnalysisContextImpl] as the basis context. | 4200 * [AnalysisContextImpl] as the basis context. |
| 4163 */ | 4201 */ |
| 4164 InstrumentedAnalysisContextImpl() { | 4202 InstrumentedAnalysisContextImpl() : this.con1(new AnalysisContextImpl()); |
| 4165 _jtd_constructor_185_impl(); | |
| 4166 } | |
| 4167 _jtd_constructor_185_impl() { | |
| 4168 _jtd_constructor_186_impl(new AnalysisContextImpl()); | |
| 4169 } | |
| 4170 | 4203 |
| 4171 /** | 4204 /** |
| 4172 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte
xt, aka the | 4205 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte
xt, aka the |
| 4173 * context to wrap and instrument. | 4206 * context to wrap and instrument. |
| 4174 * | 4207 * |
| 4175 * @param context some [InstrumentedAnalysisContext] to wrap and instrument | 4208 * @param context some [InstrumentedAnalysisContext] to wrap and instrument |
| 4176 */ | 4209 */ |
| 4177 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { | 4210 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { |
| 4178 _jtd_constructor_186_impl(context); | |
| 4179 } | |
| 4180 _jtd_constructor_186_impl(InternalAnalysisContext context) { | |
| 4181 _basis = context; | 4211 _basis = context; |
| 4182 } | 4212 } |
| 4183 void addSourceInfo(Source source, SourceEntry info) { | 4213 void addSourceInfo(Source source, SourceEntry info) { |
| 4184 _basis.addSourceInfo(source, info); | 4214 _basis.addSourceInfo(source, info); |
| 4185 } | 4215 } |
| 4186 void applyChanges(ChangeSet changeSet) { | 4216 void applyChanges(ChangeSet changeSet) { |
| 4187 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
applyChanges"); | 4217 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
applyChanges"); |
| 4188 try { | 4218 try { |
| 4189 instrumentation.metric3("contextId", _contextId); | 4219 instrumentation.metric3("contextId", _contextId); |
| 4190 _basis.applyChanges(changeSet); | 4220 _basis.applyChanges(changeSet); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4914 } | 4944 } |
| 4915 void logError2(String message, Exception exception) { | 4945 void logError2(String message, Exception exception) { |
| 4916 } | 4946 } |
| 4917 void logError3(Exception exception) { | 4947 void logError3(Exception exception) { |
| 4918 } | 4948 } |
| 4919 void logInformation(String message) { | 4949 void logInformation(String message) { |
| 4920 } | 4950 } |
| 4921 void logInformation2(String message, Exception exception) { | 4951 void logInformation2(String message, Exception exception) { |
| 4922 } | 4952 } |
| 4923 } | 4953 } |
| OLD | NEW |