| 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 'ast.dart'; | 10 import 'ast.dart'; |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 String toString() => name; | 768 String toString() => name; |
| 769 } | 769 } |
| 770 | 770 |
| 771 | 771 |
| 772 /** | 772 /** |
| 773 * Instances of the class [IncrementalResolver] resolve the smallest portion of | 773 * Instances of the class [IncrementalResolver] resolve the smallest portion of |
| 774 * an AST structure that we currently know how to resolve. | 774 * an AST structure that we currently know how to resolve. |
| 775 */ | 775 */ |
| 776 class IncrementalResolver { | 776 class IncrementalResolver { |
| 777 /** | 777 /** |
| 778 * All resolved units of the [_definingLibrary]. |
| 779 */ |
| 780 final Map<Source, CompilationUnit> _units; |
| 781 |
| 782 /** |
| 778 * The element of the compilation unit being resolved. | 783 * The element of the compilation unit being resolved. |
| 779 */ | 784 */ |
| 780 final CompilationUnitElement _definingUnit; | 785 final CompilationUnitElement _definingUnit; |
| 781 | 786 |
| 782 /** | 787 /** |
| 783 * The context the compilation unit being resolved in. | 788 * The context the compilation unit being resolved in. |
| 784 */ | 789 */ |
| 785 AnalysisContextImpl _context; | 790 AnalysisContextImpl _context; |
| 786 | 791 |
| 787 /** | 792 /** |
| (...skipping 10 matching lines...) Expand all Loading... |
| 798 * The [DartEntry] corresponding to the source being resolved. | 803 * The [DartEntry] corresponding to the source being resolved. |
| 799 */ | 804 */ |
| 800 DartEntry entry; | 805 DartEntry entry; |
| 801 | 806 |
| 802 /** | 807 /** |
| 803 * The source representing the compilation unit being visited. | 808 * The source representing the compilation unit being visited. |
| 804 */ | 809 */ |
| 805 Source _source; | 810 Source _source; |
| 806 | 811 |
| 807 /** | 812 /** |
| 813 * The source representing the library of the compilation unit being visited. |
| 814 */ |
| 815 Source _librarySource; |
| 816 |
| 817 /** |
| 808 * The offset of the changed contents. | 818 * The offset of the changed contents. |
| 809 */ | 819 */ |
| 810 final int _updateOffset; | 820 final int _updateOffset; |
| 811 | 821 |
| 812 /** | 822 /** |
| 813 * The end of the changed contents in the old unit. | 823 * The end of the changed contents in the old unit. |
| 814 */ | 824 */ |
| 815 final int _updateEndOld; | 825 final int _updateEndOld; |
| 816 | 826 |
| 817 /** | 827 /** |
| 818 * The end of the changed contents in the new unit. | 828 * The end of the changed contents in the new unit. |
| 819 */ | 829 */ |
| 820 final int _updateEndNew; | 830 final int _updateEndNew; |
| 821 | 831 |
| 822 int _updateDelta; | 832 int _updateDelta; |
| 823 | 833 |
| 824 RecordingErrorListener errorListener = new RecordingErrorListener(); | 834 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 825 ResolutionContext _resolutionContext; | 835 ResolutionContext _resolutionContext; |
| 826 | 836 |
| 827 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS; | 837 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS; |
| 828 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS; | 838 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS; |
| 829 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; | |
| 830 List<AnalysisError> _lints = AnalysisError.NO_ERRORS; | 839 List<AnalysisError> _lints = AnalysisError.NO_ERRORS; |
| 831 | 840 |
| 832 /** | 841 /** |
| 833 * The elements that should be resolved because of API changes. | 842 * The elements that should be resolved because of API changes. |
| 834 */ | 843 */ |
| 835 HashSet<Element> _resolutionQueue = new HashSet<Element>(); | 844 HashSet<Element> _resolutionQueue = new HashSet<Element>(); |
| 836 | 845 |
| 837 /** | 846 /** |
| 838 * Initialize a newly created incremental resolver to resolve a node in the | 847 * Initialize a newly created incremental resolver to resolve a node in the |
| 839 * given source in the given library. | 848 * given source in the given library. |
| 840 */ | 849 */ |
| 841 IncrementalResolver(this._definingUnit, this._updateOffset, | 850 IncrementalResolver(this._units, this._definingUnit, this._updateOffset, |
| 842 this._updateEndOld, this._updateEndNew) { | 851 this._updateEndOld, this._updateEndNew) { |
| 843 _updateDelta = _updateEndNew - _updateEndOld; | 852 _updateDelta = _updateEndNew - _updateEndOld; |
| 844 _definingLibrary = _definingUnit.library; | 853 _definingLibrary = _definingUnit.library; |
| 854 _librarySource = _definingLibrary.source; |
| 845 _source = _definingUnit.source; | 855 _source = _definingUnit.source; |
| 846 _context = _definingUnit.context; | 856 _context = _definingUnit.context; |
| 847 _typeProvider = _context.typeProvider; | 857 _typeProvider = _context.typeProvider; |
| 848 entry = _context.getReadableSourceEntryOrNull(_source); | 858 entry = _context.getReadableSourceEntryOrNull(_source); |
| 849 } | 859 } |
| 850 | 860 |
| 851 /** | 861 /** |
| 852 * Resolve [node], reporting any errors or warnings to the given listener. | 862 * Resolve [node], reporting any errors or warnings to the given listener. |
| 853 * | 863 * |
| 854 * [node] - the root of the AST structure to be resolved. | 864 * [node] - the root of the AST structure to be resolved. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 } | 991 } |
| 982 node = node.parent; | 992 node = node.parent; |
| 983 } | 993 } |
| 984 throw new AnalysisException("Cannot resolve node: no resolvable node"); | 994 throw new AnalysisException("Cannot resolve node: no resolvable node"); |
| 985 } | 995 } |
| 986 | 996 |
| 987 void _generateHints(AstNode node) { | 997 void _generateHints(AstNode node) { |
| 988 LoggingTimer timer = logger.startTimer(); | 998 LoggingTimer timer = logger.startTimer(); |
| 989 try { | 999 try { |
| 990 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1000 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 991 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); | 1001 // prepare a list of the library units |
| 1002 List<CompilationUnit> units; |
| 1003 { |
| 1004 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); |
| 1005 _units[_source] = unit; |
| 1006 units = _units.values.toList(); |
| 1007 } |
| 1008 // run the generator |
| 992 AnalysisContext analysisContext = _definingLibrary.context; | 1009 AnalysisContext analysisContext = _definingLibrary.context; |
| 993 HintGenerator hintGenerator = | 1010 HintGenerator hintGenerator = |
| 994 new HintGenerator(<CompilationUnit>[unit], analysisContext, errorListe
ner); | 1011 new HintGenerator(units, analysisContext, errorListener); |
| 995 hintGenerator.generateForLibrary(); | 1012 hintGenerator.generateForLibrary(); |
| 996 _hints = errorListener.getErrorsForSource(_source); | 1013 // remember hints |
| 1014 for (Source source in _units.keys) { |
| 1015 List<AnalysisError> hints = errorListener.getErrorsForSource(source); |
| 1016 DartEntry entry = _context.getReadableSourceEntryOrNull(source); |
| 1017 entry.setValueInLibrary(DartEntry.HINTS, _librarySource, hints); |
| 1018 } |
| 997 } finally { | 1019 } finally { |
| 998 timer.stop('generate hints'); | 1020 timer.stop('generate hints'); |
| 999 } | 1021 } |
| 1000 } | 1022 } |
| 1001 | 1023 |
| 1002 void _generateLints(AstNode node) { | 1024 void _generateLints(AstNode node) { |
| 1003 LoggingTimer timer = logger.startTimer(); | 1025 LoggingTimer timer = logger.startTimer(); |
| 1004 try { | 1026 try { |
| 1005 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1027 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1006 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); | 1028 CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 logger.log('${_resolutionQueue.length} elements in the resolution queue'); | 1066 logger.log('${_resolutionQueue.length} elements in the resolution queue'); |
| 1045 for (Element element in _resolutionQueue) { | 1067 for (Element element in _resolutionQueue) { |
| 1046 // TODO(scheglov) in general, we should not call Element.node, it | 1068 // TODO(scheglov) in general, we should not call Element.node, it |
| 1047 // might perform complete unit resolution. | 1069 // might perform complete unit resolution. |
| 1048 logger.enter('resolve $element'); | 1070 logger.enter('resolve $element'); |
| 1049 try { | 1071 try { |
| 1050 AstNode node = element.node; | 1072 AstNode node = element.node; |
| 1051 CompilationUnitElement unit = | 1073 CompilationUnitElement unit = |
| 1052 element.getAncestor((e) => e is CompilationUnitElement); | 1074 element.getAncestor((e) => e is CompilationUnitElement); |
| 1053 IncrementalResolver resolver = | 1075 IncrementalResolver resolver = |
| 1054 new IncrementalResolver(unit, node.offset, node.end, node.end); | 1076 new IncrementalResolver(_units, unit, node.offset, node.end, node.en
d); |
| 1055 resolver._resolveReferences(node); | 1077 resolver._resolveReferences(node); |
| 1056 resolver._verify(node); | 1078 resolver._verify(node); |
| 1057 resolver._generateHints(node); | 1079 resolver._generateHints(node); |
| 1058 resolver._generateLints(node); | 1080 resolver._generateLints(node); |
| 1059 resolver._updateEntry(); | 1081 resolver._updateEntry(); |
| 1060 } finally { | 1082 } finally { |
| 1061 logger.exit(); | 1083 logger.exit(); |
| 1062 } | 1084 } |
| 1063 } | 1085 } |
| 1064 } | 1086 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 } | 1137 } |
| 1116 | 1138 |
| 1117 void _shiftEntryErrors() { | 1139 void _shiftEntryErrors() { |
| 1118 _shiftErrors(DartEntry.RESOLUTION_ERRORS); | 1140 _shiftErrors(DartEntry.RESOLUTION_ERRORS); |
| 1119 _shiftErrors(DartEntry.VERIFICATION_ERRORS); | 1141 _shiftErrors(DartEntry.VERIFICATION_ERRORS); |
| 1120 _shiftErrors(DartEntry.HINTS); | 1142 _shiftErrors(DartEntry.HINTS); |
| 1121 _shiftErrors(DartEntry.LINTS); | 1143 _shiftErrors(DartEntry.LINTS); |
| 1122 } | 1144 } |
| 1123 | 1145 |
| 1124 void _shiftErrors(DataDescriptor<List<AnalysisError>> descriptor) { | 1146 void _shiftErrors(DataDescriptor<List<AnalysisError>> descriptor) { |
| 1125 Source librarySource = _definingLibrary.source; | |
| 1126 List<AnalysisError> errors = | 1147 List<AnalysisError> errors = |
| 1127 entry.getValueInLibrary(descriptor, librarySource); | 1148 entry.getValueInLibrary(descriptor, _librarySource); |
| 1128 for (AnalysisError error in errors) { | 1149 for (AnalysisError error in errors) { |
| 1129 int errorOffset = error.offset; | 1150 int errorOffset = error.offset; |
| 1130 if (errorOffset > _updateOffset) { | 1151 if (errorOffset > _updateOffset) { |
| 1131 error.offset += _updateDelta; | 1152 error.offset += _updateDelta; |
| 1132 } | 1153 } |
| 1133 } | 1154 } |
| 1134 } | 1155 } |
| 1135 | 1156 |
| 1136 void _updateElementNameOffsets() { | 1157 void _updateElementNameOffsets() { |
| 1137 LoggingTimer timer = logger.startTimer(); | 1158 LoggingTimer timer = logger.startTimer(); |
| 1138 try { | 1159 try { |
| 1139 _definingUnit.accept( | 1160 _definingUnit.accept( |
| 1140 new _ElementNameOffsetUpdater(_updateOffset, _updateDelta)); | 1161 new _ElementNameOffsetUpdater(_updateOffset, _updateDelta)); |
| 1141 } finally { | 1162 } finally { |
| 1142 timer.stop('update element offsets'); | 1163 timer.stop('update element offsets'); |
| 1143 } | 1164 } |
| 1144 } | 1165 } |
| 1145 | 1166 |
| 1146 void _updateEntry() { | 1167 void _updateEntry() { |
| 1147 Source librarySource = _definingLibrary.source; | |
| 1148 { | 1168 { |
| 1149 List<AnalysisError> oldErrors = | 1169 List<AnalysisError> oldErrors = |
| 1150 entry.getValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource); | 1170 entry.getValueInLibrary(DartEntry.RESOLUTION_ERRORS, _librarySource); |
| 1151 List<AnalysisError> errors = _updateErrors(oldErrors, _resolveErrors); | 1171 List<AnalysisError> errors = _updateErrors(oldErrors, _resolveErrors); |
| 1152 entry.setValueInLibrary( | 1172 entry.setValueInLibrary( |
| 1153 DartEntry.RESOLUTION_ERRORS, | 1173 DartEntry.RESOLUTION_ERRORS, |
| 1154 librarySource, | 1174 _librarySource, |
| 1155 errors); | 1175 errors); |
| 1156 } | 1176 } |
| 1157 { | 1177 { |
| 1158 List<AnalysisError> oldErrors = | 1178 List<AnalysisError> oldErrors = |
| 1159 entry.getValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource); | 1179 entry.getValueInLibrary(DartEntry.VERIFICATION_ERRORS, _librarySource)
; |
| 1160 List<AnalysisError> errors = _updateErrors(oldErrors, _verifyErrors); | 1180 List<AnalysisError> errors = _updateErrors(oldErrors, _verifyErrors); |
| 1161 entry.setValueInLibrary( | 1181 entry.setValueInLibrary( |
| 1162 DartEntry.VERIFICATION_ERRORS, | 1182 DartEntry.VERIFICATION_ERRORS, |
| 1163 librarySource, | 1183 _librarySource, |
| 1164 errors); | 1184 errors); |
| 1165 } | 1185 } |
| 1166 entry.setValueInLibrary(DartEntry.HINTS, librarySource, _hints); | 1186 entry.setValueInLibrary(DartEntry.LINTS, _librarySource, _lints); |
| 1167 entry.setValueInLibrary(DartEntry.LINTS, librarySource, _lints); | |
| 1168 } | 1187 } |
| 1169 | 1188 |
| 1170 List<AnalysisError> _updateErrors(List<AnalysisError> oldErrors, | 1189 List<AnalysisError> _updateErrors(List<AnalysisError> oldErrors, |
| 1171 List<AnalysisError> newErrors) { | 1190 List<AnalysisError> newErrors) { |
| 1172 List<AnalysisError> errors = new List<AnalysisError>(); | 1191 List<AnalysisError> errors = new List<AnalysisError>(); |
| 1173 // add updated old errors | 1192 // add updated old errors |
| 1174 for (AnalysisError error in oldErrors) { | 1193 for (AnalysisError error in oldErrors) { |
| 1175 int errorOffset = error.offset; | 1194 int errorOffset = error.offset; |
| 1176 if (errorOffset < _updateOffset) { | 1195 if (errorOffset < _updateOffset) { |
| 1177 errors.add(error); | 1196 errors.add(error); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 _verifyErrors = errorListener.getErrorsForSource(_source); | 1228 _verifyErrors = errorListener.getErrorsForSource(_source); |
| 1210 } finally { | 1229 } finally { |
| 1211 timer.stop('verify'); | 1230 timer.stop('verify'); |
| 1212 } | 1231 } |
| 1213 } | 1232 } |
| 1214 } | 1233 } |
| 1215 | 1234 |
| 1216 | 1235 |
| 1217 class PoorMansIncrementalResolver { | 1236 class PoorMansIncrementalResolver { |
| 1218 final TypeProvider _typeProvider; | 1237 final TypeProvider _typeProvider; |
| 1238 final Map<Source, CompilationUnit> _units; |
| 1219 final Source _unitSource; | 1239 final Source _unitSource; |
| 1220 final DartEntry _entry; | 1240 final DartEntry _entry; |
| 1221 CompilationUnitElement _unitElement; | 1241 CompilationUnitElement _unitElement; |
| 1222 | 1242 |
| 1223 int _updateOffset; | 1243 int _updateOffset; |
| 1224 int _updateDelta; | 1244 int _updateDelta; |
| 1225 int _updateEndOld; | 1245 int _updateEndOld; |
| 1226 int _updateEndNew; | 1246 int _updateEndNew; |
| 1227 | 1247 |
| 1228 List<AnalysisError> _newScanErrors = <AnalysisError>[]; | 1248 List<AnalysisError> _newScanErrors = <AnalysisError>[]; |
| 1229 List<AnalysisError> _newParseErrors = <AnalysisError>[]; | 1249 List<AnalysisError> _newParseErrors = <AnalysisError>[]; |
| 1230 | 1250 |
| 1231 PoorMansIncrementalResolver(this._typeProvider, this._unitSource, this._entry, | 1251 PoorMansIncrementalResolver(this._typeProvider, this._units, this._unitSource, |
| 1232 bool resolveApiChanges) { | 1252 this._entry, bool resolveApiChanges) { |
| 1233 _resolveApiChanges = resolveApiChanges; | 1253 _resolveApiChanges = resolveApiChanges; |
| 1234 } | 1254 } |
| 1235 | 1255 |
| 1236 /** | 1256 /** |
| 1237 * Attempts to update [oldUnit] to the state corresponding to [newCode]. | 1257 * Attempts to update [oldUnit] to the state corresponding to [newCode]. |
| 1238 * Returns `true` if success, or `false` otherwise. | 1258 * Returns `true` if success, or `false` otherwise. |
| 1239 * The [oldUnit] might be damaged. | 1259 * The [oldUnit] might be damaged. |
| 1240 */ | 1260 */ |
| 1241 bool resolve(CompilationUnit oldUnit, String newCode) { | 1261 bool resolve(String newCode) { |
| 1242 logger.enter('diff/resolve $_unitSource'); | 1262 logger.enter('diff/resolve $_unitSource'); |
| 1243 try { | 1263 try { |
| 1264 CompilationUnit oldUnit = _units[_unitSource]; |
| 1244 _unitElement = oldUnit.element; | 1265 _unitElement = oldUnit.element; |
| 1245 CompilationUnit newUnit = _parseUnit(newCode); | 1266 CompilationUnit newUnit = _parseUnit(newCode); |
| 1246 _TokenPair firstPair = | 1267 _TokenPair firstPair = |
| 1247 _findFirstDifferentToken(oldUnit.beginToken, newUnit.beginToken); | 1268 _findFirstDifferentToken(oldUnit.beginToken, newUnit.beginToken); |
| 1248 _TokenPair lastPair = | 1269 _TokenPair lastPair = |
| 1249 _findLastDifferentToken(oldUnit.endToken, newUnit.endToken); | 1270 _findLastDifferentToken(oldUnit.endToken, newUnit.endToken); |
| 1250 if (firstPair != null && lastPair != null) { | 1271 if (firstPair != null && lastPair != null) { |
| 1251 int firstOffsetOld = firstPair.oldToken.offset; | 1272 int firstOffsetOld = firstPair.oldToken.offset; |
| 1252 int firstOffsetNew = firstPair.newToken.offset; | 1273 int firstOffsetNew = firstPair.newToken.offset; |
| 1253 int lastOffsetOld = lastPair.oldToken.end; | 1274 int lastOffsetOld = lastPair.oldToken.end; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1268 bool success = _resolveComment(oldUnit, newUnit, firstPair); | 1289 bool success = _resolveComment(oldUnit, newUnit, firstPair); |
| 1269 logger.log('Documentation comment resolved: $success'); | 1290 logger.log('Documentation comment resolved: $success'); |
| 1270 return success; | 1291 return success; |
| 1271 } | 1292 } |
| 1272 // A pure whitespace change. | 1293 // A pure whitespace change. |
| 1273 if (firstPair.kind == _TokenDifferenceKind.OFFSET) { | 1294 if (firstPair.kind == _TokenDifferenceKind.OFFSET) { |
| 1274 logger.log('Whitespace change.'); | 1295 logger.log('Whitespace change.'); |
| 1275 _shiftTokens(firstPair.oldToken); | 1296 _shiftTokens(firstPair.oldToken); |
| 1276 { | 1297 { |
| 1277 IncrementalResolver incrementalResolver = new IncrementalResolver( | 1298 IncrementalResolver incrementalResolver = new IncrementalResolver( |
| 1299 _units, |
| 1278 _unitElement, | 1300 _unitElement, |
| 1279 _updateOffset, | 1301 _updateOffset, |
| 1280 _updateEndOld, | 1302 _updateEndOld, |
| 1281 _updateEndNew); | 1303 _updateEndNew); |
| 1282 incrementalResolver._updateElementNameOffsets(); | 1304 incrementalResolver._updateElementNameOffsets(); |
| 1283 incrementalResolver._shiftEntryErrors(); | 1305 incrementalResolver._shiftEntryErrors(); |
| 1284 } | 1306 } |
| 1285 _updateEntry(); | 1307 _updateEntry(); |
| 1286 logger.log('Success.'); | 1308 logger.log('Success.'); |
| 1287 return true; | 1309 return true; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 if (oldBeginToken.previous.type == TokenType.EOF) { | 1362 if (oldBeginToken.previous.type == TokenType.EOF) { |
| 1341 oldUnit.beginToken = newBeginToken; | 1363 oldUnit.beginToken = newBeginToken; |
| 1342 } else { | 1364 } else { |
| 1343 oldBeginToken.previous.setNext(newBeginToken); | 1365 oldBeginToken.previous.setNext(newBeginToken); |
| 1344 } | 1366 } |
| 1345 newNode.endToken.setNext(oldNode.endToken.next); | 1367 newNode.endToken.setNext(oldNode.endToken.next); |
| 1346 _shiftTokens(oldNode.endToken.next); | 1368 _shiftTokens(oldNode.endToken.next); |
| 1347 } | 1369 } |
| 1348 // perform incremental resolution | 1370 // perform incremental resolution |
| 1349 IncrementalResolver incrementalResolver = new IncrementalResolver( | 1371 IncrementalResolver incrementalResolver = new IncrementalResolver( |
| 1372 _units, |
| 1350 _unitElement, | 1373 _unitElement, |
| 1351 _updateOffset, | 1374 _updateOffset, |
| 1352 _updateEndOld, | 1375 _updateEndOld, |
| 1353 _updateEndNew); | 1376 _updateEndNew); |
| 1354 bool success = incrementalResolver.resolve(newNode); | 1377 bool success = incrementalResolver.resolve(newNode); |
| 1355 // check if success | 1378 // check if success |
| 1356 if (!success) { | 1379 if (!success) { |
| 1357 logger.log('Failure: element model changed.'); | 1380 logger.log('Failure: element model changed.'); |
| 1358 return false; | 1381 return false; |
| 1359 } | 1382 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 logger.log('oldComment.beginToken: ${oldComment.beginToken}'); | 1430 logger.log('oldComment.beginToken: ${oldComment.beginToken}'); |
| 1408 logger.log('newComment.beginToken: ${newComment.beginToken}'); | 1431 logger.log('newComment.beginToken: ${newComment.beginToken}'); |
| 1409 _updateOffset = oldToken.offset - 1; | 1432 _updateOffset = oldToken.offset - 1; |
| 1410 // update token references | 1433 // update token references |
| 1411 _shiftTokens(firstPair.oldToken); | 1434 _shiftTokens(firstPair.oldToken); |
| 1412 _setPrecedingComments(oldToken, newComment.tokens.first); | 1435 _setPrecedingComments(oldToken, newComment.tokens.first); |
| 1413 // replace node | 1436 // replace node |
| 1414 NodeReplacer.replace(oldComment, newComment); | 1437 NodeReplacer.replace(oldComment, newComment); |
| 1415 // update elements | 1438 // update elements |
| 1416 IncrementalResolver incrementalResolver = new IncrementalResolver( | 1439 IncrementalResolver incrementalResolver = new IncrementalResolver( |
| 1440 _units, |
| 1417 _unitElement, | 1441 _unitElement, |
| 1418 _updateOffset, | 1442 _updateOffset, |
| 1419 _updateEndOld, | 1443 _updateEndOld, |
| 1420 _updateEndNew); | 1444 _updateEndNew); |
| 1421 incrementalResolver._updateElementNameOffsets(); | 1445 incrementalResolver._updateElementNameOffsets(); |
| 1422 incrementalResolver._shiftEntryErrors(); | 1446 incrementalResolver._shiftEntryErrors(); |
| 1423 _updateEntry(); | 1447 _updateEntry(); |
| 1424 // resolve references in the comment | 1448 // resolve references in the comment |
| 1425 incrementalResolver._resolveReferences(newComment); | 1449 incrementalResolver._resolveReferences(newComment); |
| 1426 // OK | 1450 // OK |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 String toString() => name; | 1881 String toString() => name; |
| 1858 } | 1882 } |
| 1859 | 1883 |
| 1860 | 1884 |
| 1861 class _TokenPair { | 1885 class _TokenPair { |
| 1862 final _TokenDifferenceKind kind; | 1886 final _TokenDifferenceKind kind; |
| 1863 final Token oldToken; | 1887 final Token oldToken; |
| 1864 final Token newToken; | 1888 final Token newToken; |
| 1865 _TokenPair(this.kind, this.oldToken, this.newToken); | 1889 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 1866 } | 1890 } |
| OLD | NEW |