| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.incremental_resolver; | 5 library engine.incremental_resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/context/cache.dart' | 10 import 'package:analyzer/src/context/cache.dart' |
| 11 show CacheEntry, TargetedResult; | 11 show CacheEntry, Delta, DeltaResult; |
| 12 import 'package:analyzer/src/generated/constant.dart'; | 12 import 'package:analyzer/src/generated/constant.dart'; |
| 13 import 'package:analyzer/src/task/dart.dart' | 13 import 'package:analyzer/src/task/dart.dart'; |
| 14 show | 14 import 'package:analyzer/task/dart.dart'; |
| 15 HINTS, | 15 import 'package:analyzer/task/general.dart' show CONTENT, LINE_INFO; |
| 16 PARSE_ERRORS, | 16 import 'package:analyzer/task/model.dart' |
| 17 RESOLVE_REFERENCES_ERRORS, | 17 show AnalysisTarget, ResultDescriptor, TargetedResult, TaskDescriptor; |
| 18 RESOLVE_TYPE_NAMES_ERRORS, | |
| 19 SCAN_ERRORS, | |
| 20 USED_IMPORTED_ELEMENTS, | |
| 21 USED_LOCAL_ELEMENTS, | |
| 22 VARIABLE_REFERENCE_ERRORS, | |
| 23 VERIFY_ERRORS; | |
| 24 import 'package:analyzer/task/dart.dart' | |
| 25 show DART_ERRORS, LibrarySpecificUnit, PARSED_UNIT, TOKEN_STREAM; | |
| 26 import 'package:analyzer/task/general.dart' show CONTENT; | |
| 27 import 'package:analyzer/task/model.dart' show ResultDescriptor; | |
| 28 | 18 |
| 29 import 'ast.dart'; | 19 import 'ast.dart'; |
| 30 import 'element.dart'; | 20 import 'element.dart'; |
| 31 import 'engine.dart'; | 21 import 'engine.dart' |
| 22 show |
| 23 AnalysisContext, |
| 24 AnalysisOptions, |
| 25 CacheState, |
| 26 DartEntry, |
| 27 DataDescriptor, |
| 28 InternalAnalysisContext, |
| 29 RecordingErrorListener, |
| 30 SourceEntry; |
| 32 import 'error.dart'; | 31 import 'error.dart'; |
| 33 import 'error_verifier.dart'; | 32 import 'error_verifier.dart'; |
| 34 import 'incremental_logger.dart' show logger, LoggingTimer; | 33 import 'incremental_logger.dart' show logger, LoggingTimer; |
| 35 import 'java_engine.dart'; | 34 import 'java_engine.dart'; |
| 36 import 'parser.dart'; | 35 import 'parser.dart'; |
| 37 import 'resolver.dart'; | 36 import 'resolver.dart'; |
| 38 import 'scanner.dart'; | 37 import 'scanner.dart'; |
| 39 import 'source.dart'; | 38 import 'source.dart'; |
| 40 import 'utilities_dart.dart'; | 39 import 'utilities_dart.dart'; |
| 41 | 40 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 if (node is DefaultFormalParameter) { | 486 if (node is DefaultFormalParameter) { |
| 488 Expression nodeDefault = node.defaultValue; | 487 Expression nodeDefault = node.defaultValue; |
| 489 if (nodeDefault == null) { | 488 if (nodeDefault == null) { |
| 490 _assertNull(element.defaultValueCode); | 489 _assertNull(element.defaultValueCode); |
| 491 } else { | 490 } else { |
| 492 _assertEquals(nodeDefault.toSource(), element.defaultValueCode); | 491 _assertEquals(nodeDefault.toSource(), element.defaultValueCode); |
| 493 } | 492 } |
| 494 _assertCompatibleParameter(node.parameter, element); | 493 _assertCompatibleParameter(node.parameter, element); |
| 495 } else if (node is FieldFormalParameter) { | 494 } else if (node is FieldFormalParameter) { |
| 496 _assertTrue(element.isInitializingFormal); | 495 _assertTrue(element.isInitializingFormal); |
| 496 DartType parameterType = element.type; |
| 497 if (node.type == null && node.parameters == null) { |
| 498 FieldFormalParameterElement parameterElement = element; |
| 499 if (!parameterElement.hasImplicitType) { |
| 500 _assertTrue(parameterType == null || parameterType.isDynamic); |
| 501 } |
| 502 if (parameterElement.field != null) { |
| 503 _assertEquals(node.identifier.name, element.name); |
| 504 } |
| 505 } else { |
| 506 if (node.parameters != null) { |
| 507 _assertTrue(parameterType is FunctionType); |
| 508 FunctionType parameterFunctionType = parameterType; |
| 509 _assertSameType(node.type, parameterFunctionType.returnType); |
| 510 } else { |
| 511 _assertSameType(node.type, parameterType); |
| 512 } |
| 513 } |
| 497 _assertCompatibleParameters(node.parameters, element.parameters); | 514 _assertCompatibleParameters(node.parameters, element.parameters); |
| 498 } else if (node is FunctionTypedFormalParameter) { | 515 } else if (node is FunctionTypedFormalParameter) { |
| 499 _assertFalse(element.isInitializingFormal); | 516 _assertFalse(element.isInitializingFormal); |
| 500 _assertTrue(element.type is FunctionType); | 517 _assertTrue(element.type is FunctionType); |
| 501 FunctionType elementType = element.type; | 518 FunctionType elementType = element.type; |
| 502 _assertCompatibleParameters(node.parameters, element.parameters); | 519 _assertCompatibleParameters(node.parameters, element.parameters); |
| 503 _assertSameType(node.returnType, elementType.returnType); | 520 _assertSameType(node.returnType, elementType.returnType); |
| 504 } else if (node is SimpleFormalParameter) { | 521 } else if (node is SimpleFormalParameter) { |
| 505 _assertFalse(element.isInitializingFormal); | 522 _assertFalse(element.isInitializingFormal); |
| 506 _assertSameType(node.type, element.type); | 523 _assertSameType(node.type, element.type); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 837 |
| 821 final String name; | 838 final String name; |
| 822 | 839 |
| 823 const DeclarationMatchKind(this.name); | 840 const DeclarationMatchKind(this.name); |
| 824 | 841 |
| 825 @override | 842 @override |
| 826 String toString() => name; | 843 String toString() => name; |
| 827 } | 844 } |
| 828 | 845 |
| 829 /** | 846 /** |
| 847 * The [Delta] implementation used by incremental resolver. |
| 848 * It keeps Dart results that are either don't change or are updated. |
| 849 */ |
| 850 class IncrementalBodyDelta extends Delta { |
| 851 /** |
| 852 * The offset of the changed contents. |
| 853 */ |
| 854 final int updateOffset; |
| 855 |
| 856 /** |
| 857 * The end of the changed contents in the old unit. |
| 858 */ |
| 859 final int updateEndOld; |
| 860 |
| 861 /** |
| 862 * The end of the changed contents in the new unit. |
| 863 */ |
| 864 final int updateEndNew; |
| 865 |
| 866 /** |
| 867 * The delta between [updateEndNew] and [updateEndOld]. |
| 868 */ |
| 869 final int updateDelta; |
| 870 |
| 871 IncrementalBodyDelta(Source source, this.updateOffset, this.updateEndOld, |
| 872 this.updateEndNew, this.updateDelta) |
| 873 : super(source); |
| 874 |
| 875 @override |
| 876 DeltaResult validate(InternalAnalysisContext context, AnalysisTarget target, |
| 877 ResultDescriptor descriptor) { |
| 878 // A body change delta should never leak outside its source. |
| 879 // It can cause invalidation of results (e.g. hints) in other sources, |
| 880 // but only when a result in the updated source is INVALIDATE_NO_DELTA. |
| 881 if (target.source != source) { |
| 882 return DeltaResult.STOP; |
| 883 } |
| 884 // don't invalidate results of standard Dart tasks |
| 885 bool isByTask(TaskDescriptor taskDescriptor) { |
| 886 return taskDescriptor.results.contains(descriptor); |
| 887 } |
| 888 if (descriptor == CONTENT) { |
| 889 return DeltaResult.KEEP_CONTINUE; |
| 890 } |
| 891 if (target is LibrarySpecificUnit && target.unit != source) { |
| 892 if (isByTask(GatherUsedLocalElementsTask.DESCRIPTOR) || |
| 893 isByTask(GatherUsedImportedElementsTask.DESCRIPTOR)) { |
| 894 return DeltaResult.KEEP_CONTINUE; |
| 895 } |
| 896 } |
| 897 if (isByTask(BuildCompilationUnitElementTask.DESCRIPTOR) || |
| 898 isByTask(BuildDirectiveElementsTask.DESCRIPTOR) || |
| 899 isByTask(BuildEnumMemberElementsTask.DESCRIPTOR) || |
| 900 isByTask(BuildExportNamespaceTask.DESCRIPTOR) || |
| 901 isByTask(BuildLibraryElementTask.DESCRIPTOR) || |
| 902 isByTask(BuildPublicNamespaceTask.DESCRIPTOR) || |
| 903 isByTask(BuildSourceExportClosureTask.DESCRIPTOR) || |
| 904 isByTask(BuildSourceImportExportClosureTask.DESCRIPTOR) || |
| 905 isByTask(ComputeConstantDependenciesTask.DESCRIPTOR) || |
| 906 isByTask(ComputeConstantValueTask.DESCRIPTOR) || |
| 907 isByTask(ComputeLibraryCycleTask.DESCRIPTOR) || |
| 908 isByTask(DartErrorsTask.DESCRIPTOR) || |
| 909 isByTask(EvaluateUnitConstantsTask.DESCRIPTOR) || |
| 910 isByTask(GenerateHintsTask.DESCRIPTOR) || |
| 911 isByTask(InferInstanceMembersInUnitTask.DESCRIPTOR) || |
| 912 isByTask(InferStaticVariableTypesInUnitTask.DESCRIPTOR) || |
| 913 isByTask(LibraryErrorsReadyTask.DESCRIPTOR) || |
| 914 isByTask(LibraryUnitErrorsTask.DESCRIPTOR) || |
| 915 isByTask(ParseDartTask.DESCRIPTOR) || |
| 916 isByTask(PartiallyResolveUnitReferencesTask.DESCRIPTOR) || |
| 917 isByTask(ScanDartTask.DESCRIPTOR) || |
| 918 isByTask(ResolveInstanceFieldsInUnitTask.DESCRIPTOR) || |
| 919 isByTask(ResolveLibraryReferencesTask.DESCRIPTOR) || |
| 920 isByTask(ResolveLibraryTypeNamesTask.DESCRIPTOR) || |
| 921 isByTask(ResolveUnitTask.DESCRIPTOR) || |
| 922 isByTask(ResolveUnitTypeNamesTask.DESCRIPTOR) || |
| 923 isByTask(ResolveVariableReferencesTask.DESCRIPTOR) || |
| 924 isByTask(VerifyUnitTask.DESCRIPTOR)) { |
| 925 return DeltaResult.KEEP_CONTINUE; |
| 926 } |
| 927 // invalidate all the other results |
| 928 return DeltaResult.INVALIDATE_NO_DELTA; |
| 929 } |
| 930 } |
| 931 |
| 932 /** |
| 830 * Instances of the class [IncrementalResolver] resolve the smallest portion of | 933 * Instances of the class [IncrementalResolver] resolve the smallest portion of |
| 831 * an AST structure that we currently know how to resolve. | 934 * an AST structure that we currently know how to resolve. |
| 832 */ | 935 */ |
| 833 class IncrementalResolver { | 936 class IncrementalResolver { |
| 834 /** | 937 /** |
| 835 * The element of the compilation unit being resolved. | 938 * The element of the compilation unit being resolved. |
| 836 */ | 939 */ |
| 837 final CompilationUnitElementImpl _definingUnit; | 940 final CompilationUnitElementImpl _definingUnit; |
| 838 | 941 |
| 839 /** | 942 /** |
| 840 * The context the compilation unit being resolved in. | 943 * The context the compilation unit being resolved in. |
| 841 */ | 944 */ |
| 842 AnalysisContext _context; | 945 AnalysisContext _context; |
| 843 | 946 |
| 844 /** | 947 /** |
| 845 * The object used to access the types from the core library. | 948 * The object used to access the types from the core library. |
| 846 */ | 949 */ |
| 847 TypeProvider _typeProvider; | 950 TypeProvider _typeProvider; |
| 848 | 951 |
| 849 /** | 952 /** |
| 953 * The type system primitives. |
| 954 */ |
| 955 TypeSystem _typeSystem; |
| 956 |
| 957 /** |
| 850 * The element for the library containing the compilation unit being resolved. | 958 * The element for the library containing the compilation unit being resolved. |
| 851 */ | 959 */ |
| 852 LibraryElementImpl _definingLibrary; | 960 LibraryElementImpl _definingLibrary; |
| 853 | 961 |
| 854 /** | 962 /** |
| 855 * The [DartEntry] corresponding to the source being resolved. | 963 * The [DartEntry] corresponding to the source being resolved. |
| 856 */ | 964 */ |
| 857 DartEntry oldEntry; | 965 DartEntry oldEntry; |
| 858 | 966 |
| 859 /** | 967 /** |
| (...skipping 24 matching lines...) Expand all Loading... |
| 884 /** | 992 /** |
| 885 * The end of the changed contents in the old unit. | 993 * The end of the changed contents in the old unit. |
| 886 */ | 994 */ |
| 887 final int _updateEndOld; | 995 final int _updateEndOld; |
| 888 | 996 |
| 889 /** | 997 /** |
| 890 * The end of the changed contents in the new unit. | 998 * The end of the changed contents in the new unit. |
| 891 */ | 999 */ |
| 892 final int _updateEndNew; | 1000 final int _updateEndNew; |
| 893 | 1001 |
| 1002 /** |
| 1003 * The delta between [_updateEndNew] and [_updateEndOld]. |
| 1004 */ |
| 894 int _updateDelta; | 1005 int _updateDelta; |
| 895 | 1006 |
| 1007 /** |
| 1008 * The set of [AnalysisError]s that have been already shifted. |
| 1009 */ |
| 1010 Set<AnalysisError> _alreadyShiftedErrors = new HashSet.identity(); |
| 1011 |
| 896 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1012 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 897 ResolutionContext _resolutionContext; | 1013 ResolutionContext _resolutionContext; |
| 898 | 1014 |
| 899 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS; | 1015 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS; |
| 900 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS; | 1016 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS; |
| 901 | 1017 |
| 902 /** | 1018 /** |
| 903 * Initialize a newly created incremental resolver to resolve a node in the | 1019 * Initialize a newly created incremental resolver to resolve a node in the |
| 904 * given source in the given library. | 1020 * given source in the given library. |
| 905 */ | 1021 */ |
| 906 IncrementalResolver(this.oldEntry, this.newSourceEntry, this.newUnitEntry, | 1022 IncrementalResolver( |
| 907 this._definingUnit, this._updateOffset, this._updateEndOld, | 1023 this.oldEntry, |
| 1024 this.newSourceEntry, |
| 1025 this.newUnitEntry, |
| 1026 this._definingUnit, |
| 1027 this._updateOffset, |
| 1028 this._updateEndOld, |
| 908 this._updateEndNew) { | 1029 this._updateEndNew) { |
| 909 _updateDelta = _updateEndNew - _updateEndOld; | 1030 _updateDelta = _updateEndNew - _updateEndOld; |
| 910 _definingLibrary = _definingUnit.library; | 1031 _definingLibrary = _definingUnit.library; |
| 911 _librarySource = _definingLibrary.source; | 1032 _librarySource = _definingLibrary.source; |
| 912 _source = _definingUnit.source; | 1033 _source = _definingUnit.source; |
| 913 _context = _definingUnit.context; | 1034 _context = _definingUnit.context; |
| 914 _typeProvider = _context.typeProvider; | 1035 _typeProvider = _context.typeProvider; |
| 1036 _typeSystem = _context.typeSystem; |
| 915 } | 1037 } |
| 916 | 1038 |
| 917 /** | 1039 /** |
| 918 * Resolve [node], reporting any errors or warnings to the given listener. | 1040 * Resolve [node], reporting any errors or warnings to the given listener. |
| 919 * | 1041 * |
| 920 * [node] - the root of the AST structure to be resolved. | 1042 * [node] - the root of the AST structure to be resolved. |
| 921 * | 1043 * |
| 922 * Returns `true` if resolution was successful. | 1044 * Returns `true` if resolution was successful. |
| 923 */ | 1045 */ |
| 924 bool resolve(AstNode node) { | 1046 bool resolve(AstNode node) { |
| 925 logger.enter('resolve: $_definingUnit'); | 1047 logger.enter('resolve: $_definingUnit'); |
| 926 try { | 1048 try { |
| 927 AstNode rootNode = _findResolutionRoot(node); | 1049 AstNode rootNode = _findResolutionRoot(node); |
| 928 _prepareResolutionContext(rootNode); | 1050 _prepareResolutionContext(rootNode); |
| 929 // update elements | 1051 // update elements |
| 1052 _updateCache(); |
| 930 _updateElementNameOffsets(); | 1053 _updateElementNameOffsets(); |
| 931 _buildElements(rootNode); | 1054 _buildElements(rootNode); |
| 932 if (!_canBeIncrementallyResolved(rootNode)) { | 1055 if (!_canBeIncrementallyResolved(rootNode)) { |
| 933 return false; | 1056 return false; |
| 934 } | 1057 } |
| 935 // resolve | 1058 // resolve |
| 936 _resolveReferences(rootNode); | 1059 _resolveReferences(rootNode); |
| 937 _computeConstants(rootNode); | 1060 _computeConstants(rootNode); |
| 938 _resolveErrors = errorListener.getErrorsForSource(_source); | 1061 _resolveErrors = errorListener.getErrorsForSource(_source); |
| 939 // verify | 1062 // verify |
| 940 _verify(rootNode); | 1063 _verify(rootNode); |
| 941 _context.invalidateLibraryHints(_librarySource); | 1064 _context.invalidateLibraryHints(_librarySource); |
| 942 // update entry errors | 1065 // update entry errors |
| 943 _updateEntry(); | 1066 _updateEntry(); |
| 944 // notify unit | |
| 945 _definingUnit.afterIncrementalResolution(); | |
| 946 // OK | 1067 // OK |
| 947 return true; | 1068 return true; |
| 948 } finally { | 1069 } finally { |
| 949 logger.exit(); | 1070 logger.exit(); |
| 950 } | 1071 } |
| 951 } | 1072 } |
| 952 | 1073 |
| 953 void _buildElements(AstNode node) { | 1074 void _buildElements(AstNode node) { |
| 954 LoggingTimer timer = logger.startTimer(); | 1075 LoggingTimer timer = logger.startTimer(); |
| 955 try { | 1076 try { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 node is MethodDeclaration || | 1132 node is MethodDeclaration || |
| 1012 node is TopLevelVariableDeclaration; | 1133 node is TopLevelVariableDeclaration; |
| 1013 | 1134 |
| 1014 /** | 1135 /** |
| 1015 * Compute a value for all of the constants in the given [node]. | 1136 * Compute a value for all of the constants in the given [node]. |
| 1016 */ | 1137 */ |
| 1017 void _computeConstants(AstNode node) { | 1138 void _computeConstants(AstNode node) { |
| 1018 // compute values | 1139 // compute values |
| 1019 { | 1140 { |
| 1020 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); | 1141 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); |
| 1021 ConstantValueComputer computer = new ConstantValueComputer( | 1142 ConstantValueComputer computer = new ConstantValueComputer(_context, |
| 1022 _context, _typeProvider, _context.declaredVariables); | 1143 _typeProvider, _context.declaredVariables, null, _typeSystem); |
| 1023 computer.add(unit, _source, _librarySource); | 1144 computer.add(unit, _source, _librarySource); |
| 1024 computer.computeValues(); | 1145 computer.computeValues(); |
| 1025 } | 1146 } |
| 1026 // validate | 1147 // validate |
| 1027 { | 1148 { |
| 1028 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); | 1149 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); |
| 1029 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, | 1150 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, |
| 1030 _definingLibrary, _typeProvider, _context.declaredVariables); | 1151 _definingLibrary, _typeProvider, _context.declaredVariables); |
| 1031 node.accept(constantVerifier); | 1152 node.accept(constantVerifier); |
| 1032 } | 1153 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 void _shiftEntryErrors() { | 1234 void _shiftEntryErrors() { |
| 1114 if (oldEntry != null) { | 1235 if (oldEntry != null) { |
| 1115 _shiftEntryErrors_OLD(); | 1236 _shiftEntryErrors_OLD(); |
| 1116 } else { | 1237 } else { |
| 1117 _shiftEntryErrors_NEW(); | 1238 _shiftEntryErrors_NEW(); |
| 1118 } | 1239 } |
| 1119 } | 1240 } |
| 1120 | 1241 |
| 1121 void _shiftEntryErrors_NEW() { | 1242 void _shiftEntryErrors_NEW() { |
| 1122 _shiftErrors_NEW(HINTS); | 1243 _shiftErrors_NEW(HINTS); |
| 1123 _shiftErrors_NEW(RESOLVE_REFERENCES_ERRORS); | 1244 _shiftErrors_NEW(LINTS); |
| 1245 _shiftErrors_NEW(LIBRARY_UNIT_ERRORS); |
| 1124 _shiftErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS); | 1246 _shiftErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS); |
| 1247 _shiftErrors_NEW(RESOLVE_UNIT_ERRORS); |
| 1125 _shiftErrors_NEW(VARIABLE_REFERENCE_ERRORS); | 1248 _shiftErrors_NEW(VARIABLE_REFERENCE_ERRORS); |
| 1126 _shiftErrors_NEW(VERIFY_ERRORS); | 1249 _shiftErrors_NEW(VERIFY_ERRORS); |
| 1127 } | 1250 } |
| 1128 | 1251 |
| 1129 void _shiftEntryErrors_OLD() { | 1252 void _shiftEntryErrors_OLD() { |
| 1130 _shiftErrors_OLD(DartEntry.RESOLUTION_ERRORS); | 1253 _shiftErrors_OLD(DartEntry.RESOLUTION_ERRORS); |
| 1131 _shiftErrors_OLD(DartEntry.VERIFICATION_ERRORS); | 1254 _shiftErrors_OLD(DartEntry.VERIFICATION_ERRORS); |
| 1132 _shiftErrors_OLD(DartEntry.HINTS); | 1255 _shiftErrors_OLD(DartEntry.HINTS); |
| 1133 _shiftErrors_OLD(DartEntry.LINTS); | 1256 _shiftErrors_OLD(DartEntry.LINTS); |
| 1134 } | 1257 } |
| 1135 | 1258 |
| 1136 void _shiftErrors(List<AnalysisError> errors) { | 1259 void _shiftErrors(List<AnalysisError> errors) { |
| 1137 for (AnalysisError error in errors) { | 1260 for (AnalysisError error in errors) { |
| 1138 int errorOffset = error.offset; | 1261 if (_alreadyShiftedErrors.add(error)) { |
| 1139 if (errorOffset > _updateOffset) { | 1262 int errorOffset = error.offset; |
| 1140 error.offset += _updateDelta; | 1263 if (errorOffset > _updateOffset) { |
| 1264 error.offset += _updateDelta; |
| 1265 } |
| 1141 } | 1266 } |
| 1142 } | 1267 } |
| 1143 } | 1268 } |
| 1144 | 1269 |
| 1145 void _shiftErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor) { | 1270 void _shiftErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor) { |
| 1146 List<AnalysisError> errors = newUnitEntry.getValue(descriptor); | 1271 List<AnalysisError> errors = newUnitEntry.getValue(descriptor); |
| 1147 _shiftErrors(errors); | 1272 _shiftErrors(errors); |
| 1148 } | 1273 } |
| 1149 | 1274 |
| 1150 void _shiftErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor) { | 1275 void _shiftErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor) { |
| 1151 List<AnalysisError> errors = | 1276 List<AnalysisError> errors = |
| 1152 oldEntry.getValueInLibrary(descriptor, _librarySource); | 1277 oldEntry.getValueInLibrary(descriptor, _librarySource); |
| 1153 _shiftErrors(errors); | 1278 _shiftErrors(errors); |
| 1154 } | 1279 } |
| 1155 | 1280 |
| 1281 void _updateCache() { |
| 1282 if (newSourceEntry != null) { |
| 1283 LoggingTimer timer = logger.startTimer(); |
| 1284 try { |
| 1285 newSourceEntry.setState(CONTENT, CacheState.INVALID, |
| 1286 delta: new IncrementalBodyDelta(_source, _updateOffset, |
| 1287 _updateEndOld, _updateEndNew, _updateDelta)); |
| 1288 } finally { |
| 1289 timer.stop('invalidate cache with delta'); |
| 1290 } |
| 1291 } |
| 1292 } |
| 1293 |
| 1156 void _updateElementNameOffsets() { | 1294 void _updateElementNameOffsets() { |
| 1157 LoggingTimer timer = logger.startTimer(); | 1295 LoggingTimer timer = logger.startTimer(); |
| 1158 try { | 1296 try { |
| 1159 _definingUnit | 1297 _definingUnit |
| 1160 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta)); | 1298 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta)); |
| 1299 _definingUnit.afterIncrementalResolution(); |
| 1161 } finally { | 1300 } finally { |
| 1162 timer.stop('update element offsets'); | 1301 timer.stop('update element offsets'); |
| 1163 } | 1302 } |
| 1164 } | 1303 } |
| 1165 | 1304 |
| 1166 void _updateEntry() { | 1305 void _updateEntry() { |
| 1167 if (oldEntry != null) { | 1306 if (oldEntry != null) { |
| 1168 _updateEntry_OLD(); | 1307 _updateEntry_OLD(); |
| 1169 } else { | 1308 } else { |
| 1170 _updateEntry_NEW(); | 1309 _updateEntry_NEW(); |
| 1171 } | 1310 } |
| 1172 } | 1311 } |
| 1173 | 1312 |
| 1174 void _updateEntry_NEW() { | 1313 void _updateEntry_NEW() { |
| 1175 _updateErrors_NEW(RESOLVE_REFERENCES_ERRORS, _resolveErrors); | |
| 1176 _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []); | 1314 _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []); |
| 1315 _updateErrors_NEW(RESOLVE_UNIT_ERRORS, _resolveErrors); |
| 1177 _updateErrors_NEW(VARIABLE_REFERENCE_ERRORS, []); | 1316 _updateErrors_NEW(VARIABLE_REFERENCE_ERRORS, []); |
| 1178 _updateErrors_NEW(VERIFY_ERRORS, _verifyErrors); | 1317 _updateErrors_NEW(VERIFY_ERRORS, _verifyErrors); |
| 1179 // invalidate results we don't update incrementally | 1318 // invalidate results we don't update incrementally |
| 1180 newUnitEntry.setState(USED_IMPORTED_ELEMENTS, CacheState.INVALID); | 1319 newUnitEntry.setState(USED_IMPORTED_ELEMENTS, CacheState.INVALID); |
| 1181 newUnitEntry.setState(USED_LOCAL_ELEMENTS, CacheState.INVALID); | 1320 newUnitEntry.setState(USED_LOCAL_ELEMENTS, CacheState.INVALID); |
| 1182 newUnitEntry.setState(HINTS, CacheState.INVALID); | 1321 newUnitEntry.setState(HINTS, CacheState.INVALID); |
| 1322 newUnitEntry.setState(LINTS, CacheState.INVALID); |
| 1183 } | 1323 } |
| 1184 | 1324 |
| 1185 void _updateEntry_OLD() { | 1325 void _updateEntry_OLD() { |
| 1186 _updateErrors_OLD(DartEntry.RESOLUTION_ERRORS, _resolveErrors); | 1326 _updateErrors_OLD(DartEntry.RESOLUTION_ERRORS, _resolveErrors); |
| 1187 _updateErrors_OLD(DartEntry.VERIFICATION_ERRORS, _verifyErrors); | 1327 _updateErrors_OLD(DartEntry.VERIFICATION_ERRORS, _verifyErrors); |
| 1188 } | 1328 } |
| 1189 | 1329 |
| 1190 List<AnalysisError> _updateErrors( | 1330 List<AnalysisError> _updateErrors( |
| 1191 List<AnalysisError> oldErrors, List<AnalysisError> newErrors) { | 1331 List<AnalysisError> oldErrors, List<AnalysisError> newErrors) { |
| 1192 List<AnalysisError> errors = new List<AnalysisError>(); | 1332 List<AnalysisError> errors = new List<AnalysisError>(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1208 } | 1348 } |
| 1209 } | 1349 } |
| 1210 // done | 1350 // done |
| 1211 return errors; | 1351 return errors; |
| 1212 } | 1352 } |
| 1213 | 1353 |
| 1214 void _updateErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor, | 1354 void _updateErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor, |
| 1215 List<AnalysisError> newErrors) { | 1355 List<AnalysisError> newErrors) { |
| 1216 List<AnalysisError> oldErrors = newUnitEntry.getValue(descriptor); | 1356 List<AnalysisError> oldErrors = newUnitEntry.getValue(descriptor); |
| 1217 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors); | 1357 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors); |
| 1218 newUnitEntry.setValueIncremental(descriptor, errors); | 1358 newUnitEntry.setValueIncremental(descriptor, errors, true); |
| 1219 } | 1359 } |
| 1220 | 1360 |
| 1221 void _updateErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor, | 1361 void _updateErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor, |
| 1222 List<AnalysisError> newErrors) { | 1362 List<AnalysisError> newErrors) { |
| 1223 List<AnalysisError> oldErrors = | 1363 List<AnalysisError> oldErrors = |
| 1224 oldEntry.getValueInLibrary(descriptor, _librarySource); | 1364 oldEntry.getValueInLibrary(descriptor, _librarySource); |
| 1225 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors); | 1365 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors); |
| 1226 oldEntry.setValueInLibrary(descriptor, _librarySource, errors); | 1366 oldEntry.setValueInLibrary(descriptor, _librarySource, errors); |
| 1227 } | 1367 } |
| 1228 | 1368 |
| 1229 void _verify(AstNode node) { | 1369 void _verify(AstNode node) { |
| 1230 LoggingTimer timer = logger.startTimer(); | 1370 LoggingTimer timer = logger.startTimer(); |
| 1231 try { | 1371 try { |
| 1232 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1372 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1233 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); | 1373 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); |
| 1234 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, | 1374 ErrorVerifier errorVerifier = new ErrorVerifier( |
| 1235 _definingLibrary, _typeProvider, | 1375 errorReporter, |
| 1236 new InheritanceManager(_definingLibrary)); | 1376 _definingLibrary, |
| 1377 _typeProvider, |
| 1378 new InheritanceManager(_definingLibrary), |
| 1379 _context.analysisOptions.enableSuperMixins); |
| 1237 if (_resolutionContext.enclosingClassDeclaration != null) { | 1380 if (_resolutionContext.enclosingClassDeclaration != null) { |
| 1238 errorVerifier.visitClassDeclarationIncrementally( | 1381 errorVerifier.visitClassDeclarationIncrementally( |
| 1239 _resolutionContext.enclosingClassDeclaration); | 1382 _resolutionContext.enclosingClassDeclaration); |
| 1240 } | 1383 } |
| 1241 node.accept(errorVerifier); | 1384 node.accept(errorVerifier); |
| 1242 _verifyErrors = errorListener.getErrorsForSource(_source); | 1385 _verifyErrors = errorListener.getErrorsForSource(_source); |
| 1243 } finally { | 1386 } finally { |
| 1244 timer.stop('verify'); | 1387 timer.stop('verify'); |
| 1245 } | 1388 } |
| 1246 } | 1389 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1259 * The [CacheEntry] corresponding to the source being resolved. | 1402 * The [CacheEntry] corresponding to the source being resolved. |
| 1260 */ | 1403 */ |
| 1261 CacheEntry _newSourceEntry; | 1404 CacheEntry _newSourceEntry; |
| 1262 | 1405 |
| 1263 /** | 1406 /** |
| 1264 * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved. | 1407 * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved. |
| 1265 */ | 1408 */ |
| 1266 CacheEntry _newUnitEntry; | 1409 CacheEntry _newUnitEntry; |
| 1267 | 1410 |
| 1268 final CompilationUnit _oldUnit; | 1411 final CompilationUnit _oldUnit; |
| 1269 final AnalysisOptions _options; | |
| 1270 CompilationUnitElement _unitElement; | 1412 CompilationUnitElement _unitElement; |
| 1271 | 1413 |
| 1272 int _updateOffset; | 1414 int _updateOffset; |
| 1273 int _updateDelta; | 1415 int _updateDelta; |
| 1274 int _updateEndOld; | 1416 int _updateEndOld; |
| 1275 int _updateEndNew; | 1417 int _updateEndNew; |
| 1276 | 1418 |
| 1419 LineInfo _newLineInfo; |
| 1277 List<AnalysisError> _newScanErrors = <AnalysisError>[]; | 1420 List<AnalysisError> _newScanErrors = <AnalysisError>[]; |
| 1278 List<AnalysisError> _newParseErrors = <AnalysisError>[]; | 1421 List<AnalysisError> _newParseErrors = <AnalysisError>[]; |
| 1279 | 1422 |
| 1280 PoorMansIncrementalResolver(this._typeProvider, this._unitSource, | 1423 PoorMansIncrementalResolver( |
| 1281 this._oldEntry, this._newSourceEntry, this._newUnitEntry, this._oldUnit, | 1424 this._typeProvider, |
| 1282 bool resolveApiChanges, this._options) { | 1425 this._unitSource, |
| 1426 this._oldEntry, |
| 1427 this._newSourceEntry, |
| 1428 this._newUnitEntry, |
| 1429 this._oldUnit, |
| 1430 bool resolveApiChanges) { |
| 1283 _resolveApiChanges = resolveApiChanges; | 1431 _resolveApiChanges = resolveApiChanges; |
| 1284 } | 1432 } |
| 1285 | 1433 |
| 1286 /** | 1434 /** |
| 1287 * Attempts to update [_oldUnit] to the state corresponding to [newCode]. | 1435 * Attempts to update [_oldUnit] to the state corresponding to [newCode]. |
| 1288 * Returns `true` if success, or `false` otherwise. | 1436 * Returns `true` if success, or `false` otherwise. |
| 1289 * The [_oldUnit] might be damaged. | 1437 * The [_oldUnit] might be damaged. |
| 1290 */ | 1438 */ |
| 1291 bool resolve(String newCode) { | 1439 bool resolve(String newCode) { |
| 1292 logger.enter('diff/resolve $_unitSource'); | 1440 logger.enter('diff/resolve $_unitSource'); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 bool success = _resolveCommentDoc(newUnit, firstPair); | 1477 bool success = _resolveCommentDoc(newUnit, firstPair); |
| 1330 logger.log('Documentation comment resolved: $success'); | 1478 logger.log('Documentation comment resolved: $success'); |
| 1331 return success; | 1479 return success; |
| 1332 } | 1480 } |
| 1333 // A pure whitespace change. | 1481 // A pure whitespace change. |
| 1334 if (firstPair.kind == _TokenDifferenceKind.OFFSET) { | 1482 if (firstPair.kind == _TokenDifferenceKind.OFFSET) { |
| 1335 logger.log('Whitespace change.'); | 1483 logger.log('Whitespace change.'); |
| 1336 _shiftTokens(firstPair.oldToken); | 1484 _shiftTokens(firstPair.oldToken); |
| 1337 { | 1485 { |
| 1338 IncrementalResolver incrementalResolver = new IncrementalResolver( | 1486 IncrementalResolver incrementalResolver = new IncrementalResolver( |
| 1339 _oldEntry, _newSourceEntry, _newUnitEntry, _unitElement, | 1487 _oldEntry, |
| 1340 _updateOffset, _updateEndOld, _updateEndNew); | 1488 _newSourceEntry, |
| 1489 _newUnitEntry, |
| 1490 _unitElement, |
| 1491 _updateOffset, |
| 1492 _updateEndOld, |
| 1493 _updateEndNew); |
| 1494 incrementalResolver._updateCache(); |
| 1341 incrementalResolver._updateElementNameOffsets(); | 1495 incrementalResolver._updateElementNameOffsets(); |
| 1342 incrementalResolver._shiftEntryErrors(); | 1496 incrementalResolver._shiftEntryErrors(); |
| 1343 } | 1497 } |
| 1344 _updateEntry(); | 1498 _updateEntry(); |
| 1345 logger.log('Success.'); | 1499 logger.log('Success.'); |
| 1346 return true; | 1500 return true; |
| 1347 } | 1501 } |
| 1348 // fall-through, end-of-line comment | 1502 // fall-through, end-of-line comment |
| 1349 } | 1503 } |
| 1350 // Find nodes covering the "old" and "new" token ranges. | 1504 // Find nodes covering the "old" and "new" token ranges. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1376 oldParent is ConstructorDeclaration && | 1530 oldParent is ConstructorDeclaration && |
| 1377 newParent is ConstructorDeclaration) { | 1531 newParent is ConstructorDeclaration) { |
| 1378 Element oldElement = (oldParent as Declaration).element; | 1532 Element oldElement = (oldParent as Declaration).element; |
| 1379 if (new DeclarationMatcher().matches(newParent, oldElement) == | 1533 if (new DeclarationMatcher().matches(newParent, oldElement) == |
| 1380 DeclarationMatchKind.MATCH) { | 1534 DeclarationMatchKind.MATCH) { |
| 1381 oldNode = oldParent; | 1535 oldNode = oldParent; |
| 1382 newNode = newParent; | 1536 newNode = newParent; |
| 1383 found = true; | 1537 found = true; |
| 1384 } | 1538 } |
| 1385 } | 1539 } |
| 1386 if (oldParent is FunctionBody && newParent is FunctionBody) { | 1540 if (oldParent is BlockFunctionBody && |
| 1541 newParent is BlockFunctionBody) { |
| 1387 oldNode = oldParent; | 1542 oldNode = oldParent; |
| 1388 newNode = newParent; | 1543 newNode = newParent; |
| 1389 found = true; | 1544 found = true; |
| 1390 break; | 1545 break; |
| 1391 } | 1546 } |
| 1392 } | 1547 } |
| 1393 if (!found) { | 1548 if (!found) { |
| 1394 logger.log('Failure: no enclosing function body or executable.'); | 1549 logger.log('Failure: no enclosing function body or executable.'); |
| 1395 return false; | 1550 return false; |
| 1396 } | 1551 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1419 if (oldBeginToken.previous.type == TokenType.EOF) { | 1574 if (oldBeginToken.previous.type == TokenType.EOF) { |
| 1420 _oldUnit.beginToken = newBeginToken; | 1575 _oldUnit.beginToken = newBeginToken; |
| 1421 } else { | 1576 } else { |
| 1422 oldBeginToken.previous.setNext(newBeginToken); | 1577 oldBeginToken.previous.setNext(newBeginToken); |
| 1423 } | 1578 } |
| 1424 newNode.endToken.setNext(oldNode.endToken.next); | 1579 newNode.endToken.setNext(oldNode.endToken.next); |
| 1425 _shiftTokens(oldNode.endToken.next); | 1580 _shiftTokens(oldNode.endToken.next); |
| 1426 } | 1581 } |
| 1427 // perform incremental resolution | 1582 // perform incremental resolution |
| 1428 IncrementalResolver incrementalResolver = new IncrementalResolver( | 1583 IncrementalResolver incrementalResolver = new IncrementalResolver( |
| 1429 _oldEntry, _newSourceEntry, _newUnitEntry, _unitElement, | 1584 _oldEntry, |
| 1430 _updateOffset, _updateEndOld, _updateEndNew); | 1585 _newSourceEntry, |
| 1586 _newUnitEntry, |
| 1587 _unitElement, |
| 1588 _updateOffset, |
| 1589 _updateEndOld, |
| 1590 _updateEndNew); |
| 1431 bool success = incrementalResolver.resolve(newNode); | 1591 bool success = incrementalResolver.resolve(newNode); |
| 1432 // check if success | 1592 // check if success |
| 1433 if (!success) { | 1593 if (!success) { |
| 1434 logger.log('Failure: element model changed.'); | 1594 logger.log('Failure: element model changed.'); |
| 1435 return false; | 1595 return false; |
| 1436 } | 1596 } |
| 1437 // update DartEntry | 1597 // update DartEntry |
| 1438 _updateEntry(); | 1598 _updateEntry(); |
| 1439 logger.log('Success.'); | 1599 logger.log('Success.'); |
| 1440 return true; | 1600 return true; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 Comment newComment = _findNodeCovering(newUnit, offset, offset); | 1644 Comment newComment = _findNodeCovering(newUnit, offset, offset); |
| 1485 logger.log('oldComment.beginToken: ${oldComment.beginToken}'); | 1645 logger.log('oldComment.beginToken: ${oldComment.beginToken}'); |
| 1486 logger.log('newComment.beginToken: ${newComment.beginToken}'); | 1646 logger.log('newComment.beginToken: ${newComment.beginToken}'); |
| 1487 _updateOffset = oldToken.offset - 1; | 1647 _updateOffset = oldToken.offset - 1; |
| 1488 // update token references | 1648 // update token references |
| 1489 _shiftTokens(firstPair.oldToken); | 1649 _shiftTokens(firstPair.oldToken); |
| 1490 _setPrecedingComments(oldToken, newComment.tokens.first); | 1650 _setPrecedingComments(oldToken, newComment.tokens.first); |
| 1491 // replace node | 1651 // replace node |
| 1492 NodeReplacer.replace(oldComment, newComment); | 1652 NodeReplacer.replace(oldComment, newComment); |
| 1493 // update elements | 1653 // update elements |
| 1494 IncrementalResolver incrementalResolver = new IncrementalResolver(_oldEntry, | 1654 IncrementalResolver incrementalResolver = new IncrementalResolver( |
| 1495 _newSourceEntry, _newUnitEntry, _unitElement, _updateOffset, | 1655 _oldEntry, |
| 1496 _updateEndOld, _updateEndNew); | 1656 _newSourceEntry, |
| 1657 _newUnitEntry, |
| 1658 _unitElement, |
| 1659 _updateOffset, |
| 1660 _updateEndOld, |
| 1661 _updateEndNew); |
| 1662 incrementalResolver._updateCache(); |
| 1497 incrementalResolver._updateElementNameOffsets(); | 1663 incrementalResolver._updateElementNameOffsets(); |
| 1498 incrementalResolver._shiftEntryErrors(); | 1664 incrementalResolver._shiftEntryErrors(); |
| 1499 _updateEntry(); | 1665 _updateEntry(); |
| 1500 // resolve references in the comment | 1666 // resolve references in the comment |
| 1501 incrementalResolver._resolveReferences(newComment); | 1667 incrementalResolver._resolveReferences(newComment); |
| 1502 // OK | 1668 // OK |
| 1503 return true; | 1669 return true; |
| 1504 } | 1670 } |
| 1505 | 1671 |
| 1506 Token _scan(String code) { | 1672 Token _scan(String code) { |
| 1507 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1673 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1508 CharSequenceReader reader = new CharSequenceReader(code); | 1674 CharSequenceReader reader = new CharSequenceReader(code); |
| 1509 Scanner scanner = new Scanner(_unitSource, reader, errorListener); | 1675 Scanner scanner = new Scanner(_unitSource, reader, errorListener); |
| 1510 Token token = scanner.tokenize(); | 1676 Token token = scanner.tokenize(); |
| 1677 _newLineInfo = new LineInfo(scanner.lineStarts); |
| 1511 _newScanErrors = errorListener.errors; | 1678 _newScanErrors = errorListener.errors; |
| 1512 return token; | 1679 return token; |
| 1513 } | 1680 } |
| 1514 | 1681 |
| 1515 /** | 1682 /** |
| 1516 * Set the given [comment] as a "precedingComments" for [token]. | 1683 * Set the given [comment] as a "precedingComments" for [token]. |
| 1517 */ | 1684 */ |
| 1518 void _setPrecedingComments(Token token, CommentToken comment) { | 1685 void _setPrecedingComments(Token token, CommentToken comment) { |
| 1519 if (token is BeginTokenWithComment) { | 1686 if (token is BeginTokenWithComment) { |
| 1520 token.precedingComments = comment; | 1687 token.precedingComments = comment; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 | 1719 |
| 1553 void _updateEntry() { | 1720 void _updateEntry() { |
| 1554 if (_oldEntry != null) { | 1721 if (_oldEntry != null) { |
| 1555 _updateEntry_OLD(); | 1722 _updateEntry_OLD(); |
| 1556 } else { | 1723 } else { |
| 1557 _updateEntry_NEW(); | 1724 _updateEntry_NEW(); |
| 1558 } | 1725 } |
| 1559 } | 1726 } |
| 1560 | 1727 |
| 1561 void _updateEntry_NEW() { | 1728 void _updateEntry_NEW() { |
| 1562 _newSourceEntry.setState(DART_ERRORS, CacheState.INVALID); | |
| 1563 // scan results | 1729 // scan results |
| 1564 _newSourceEntry.setState(SCAN_ERRORS, CacheState.INVALID); | 1730 _newSourceEntry.setValueIncremental(SCAN_ERRORS, _newScanErrors, true); |
| 1565 List<TargetedResult> scanDeps = | 1731 _newSourceEntry.setValueIncremental(LINE_INFO, _newLineInfo, false); |
| 1566 <TargetedResult>[new TargetedResult(_unitSource, CONTENT)]; | |
| 1567 _newSourceEntry.setValue(SCAN_ERRORS, _newScanErrors, scanDeps); | |
| 1568 // parse results | 1732 // parse results |
| 1569 List<TargetedResult> parseDeps = | 1733 _newSourceEntry.setValueIncremental(PARSE_ERRORS, _newParseErrors, true); |
| 1570 <TargetedResult>[new TargetedResult(_unitSource, TOKEN_STREAM)]; | 1734 _newSourceEntry.setValueIncremental(PARSED_UNIT, _oldUnit, false); |
| 1571 _newSourceEntry.setState(PARSE_ERRORS, CacheState.INVALID); | |
| 1572 _newSourceEntry.setValue(PARSE_ERRORS, _newParseErrors, parseDeps); | |
| 1573 _newSourceEntry.setValue(PARSED_UNIT, _oldUnit, parseDeps); | |
| 1574 } | 1735 } |
| 1575 | 1736 |
| 1576 void _updateEntry_OLD() { | 1737 void _updateEntry_OLD() { |
| 1738 _oldEntry.setValue(SourceEntry.LINE_INFO, _newLineInfo); |
| 1577 _oldEntry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors); | 1739 _oldEntry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors); |
| 1578 _oldEntry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors); | 1740 _oldEntry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors); |
| 1579 } | 1741 } |
| 1580 | 1742 |
| 1581 /** | 1743 /** |
| 1582 * Checks if [token] has a balanced number of open and closed curly brackets. | 1744 * Checks if [token] has a balanced number of open and closed curly brackets. |
| 1583 */ | 1745 */ |
| 1584 static bool _areCurlyBracketsBalanced(Token token) { | 1746 static bool _areCurlyBracketsBalanced(Token token) { |
| 1585 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET); | 1747 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET); |
| 1586 int numOpen2 = | 1748 int numOpen2 = |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 @override | 2141 @override |
| 1980 String toString() => name; | 2142 String toString() => name; |
| 1981 } | 2143 } |
| 1982 | 2144 |
| 1983 class _TokenPair { | 2145 class _TokenPair { |
| 1984 final _TokenDifferenceKind kind; | 2146 final _TokenDifferenceKind kind; |
| 1985 final Token oldToken; | 2147 final Token oldToken; |
| 1986 final Token newToken; | 2148 final Token newToken; |
| 1987 _TokenPair(this.kind, this.oldToken, this.newToken); | 2149 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 1988 } | 2150 } |
| OLD | NEW |