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

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

Issue 1144023009: Adapt the existing incremental resolution implementation to the new model. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 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'
11 show CacheEntry, TargetedResult;
10 import 'package:analyzer/src/generated/constant.dart'; 12 import 'package:analyzer/src/generated/constant.dart';
11 import 'package:analyzer/src/services/lint.dart'; 13 import 'package:analyzer/src/services/lint.dart';
14 import 'package:analyzer/src/task/dart.dart'
15 show
16 HINTS,
17 PARSE_ERRORS,
18 RESOLVE_REFERENCES_ERRORS,
19 RESOLVE_TYPE_NAMES_ERRORS,
20 SCAN_ERRORS,
21 USED_IMPORTED_ELEMENTS,
22 USED_LOCAL_ELEMENTS,
23 VERIFY_ERRORS;
24 import 'package:analyzer/task/dart.dart' show PARSED_UNIT, TOKEN_STREAM;
25 import 'package:analyzer/task/general.dart' show CONTENT;
26 import 'package:analyzer/task/model.dart' show ResultDescriptor;
12 27
13 import 'ast.dart'; 28 import 'ast.dart';
14 import 'element.dart'; 29 import 'element.dart';
15 import 'engine.dart'; 30 import 'engine.dart';
16 import 'error.dart'; 31 import 'error.dart';
17 import 'error_verifier.dart'; 32 import 'error_verifier.dart';
18 import 'incremental_logger.dart' show logger, LoggingTimer; 33 import 'incremental_logger.dart' show logger, LoggingTimer;
19 import 'java_engine.dart'; 34 import 'java_engine.dart';
20 import 'parser.dart'; 35 import 'parser.dart';
21 import 'resolver.dart'; 36 import 'resolver.dart';
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 TypeProvider _typeProvider; 816 TypeProvider _typeProvider;
802 817
803 /** 818 /**
804 * The element for the library containing the compilation unit being resolved. 819 * The element for the library containing the compilation unit being resolved.
805 */ 820 */
806 LibraryElementImpl _definingLibrary; 821 LibraryElementImpl _definingLibrary;
807 822
808 /** 823 /**
809 * The [DartEntry] corresponding to the source being resolved. 824 * The [DartEntry] corresponding to the source being resolved.
810 */ 825 */
811 DartEntry entry; 826 DartEntry oldEntry;
827
828 CacheEntry newSourceEntry;
Brian Wilkerson 2015/05/23 15:58:44 Missing comments.
829 CacheEntry newUnitEntry;
812 830
813 /** 831 /**
814 * The source representing the compilation unit being visited. 832 * The source representing the compilation unit being visited.
815 */ 833 */
816 Source _source; 834 Source _source;
817 835
818 /** 836 /**
819 * The source representing the library of the compilation unit being visited. 837 * The source representing the library of the compilation unit being visited.
820 */ 838 */
821 Source _librarySource; 839 Source _librarySource;
(...skipping 19 matching lines...) Expand all
841 ResolutionContext _resolutionContext; 859 ResolutionContext _resolutionContext;
842 860
843 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS; 861 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS;
844 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS; 862 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS;
845 List<AnalysisError> _lints = AnalysisError.NO_ERRORS; 863 List<AnalysisError> _lints = AnalysisError.NO_ERRORS;
846 864
847 /** 865 /**
848 * Initialize a newly created incremental resolver to resolve a node in the 866 * Initialize a newly created incremental resolver to resolve a node in the
849 * given source in the given library. 867 * given source in the given library.
850 */ 868 */
851 IncrementalResolver(this._definingUnit, this._updateOffset, 869 IncrementalResolver(this.oldEntry, this.newSourceEntry, this.newUnitEntry,
852 this._updateEndOld, this._updateEndNew) { 870 this._definingUnit, this._updateOffset, this._updateEndOld,
871 this._updateEndNew) {
853 _updateDelta = _updateEndNew - _updateEndOld; 872 _updateDelta = _updateEndNew - _updateEndOld;
854 _definingLibrary = _definingUnit.library; 873 _definingLibrary = _definingUnit.library;
855 _librarySource = _definingLibrary.source; 874 _librarySource = _definingLibrary.source;
856 _source = _definingUnit.source; 875 _source = _definingUnit.source;
857 _context = _definingUnit.context; 876 _context = _definingUnit.context;
858 _typeProvider = _context.typeProvider; 877 _typeProvider = _context.typeProvider;
859 entry = _context.getReadableSourceEntryOrNull(_source);
860 } 878 }
861 879
862 /** 880 /**
863 * Resolve [node], reporting any errors or warnings to the given listener. 881 * Resolve [node], reporting any errors or warnings to the given listener.
864 * 882 *
865 * [node] - the root of the AST structure to be resolved. 883 * [node] - the root of the AST structure to be resolved.
866 * 884 *
867 * Returns `true` if resolution was successful. 885 * Returns `true` if resolution was successful.
868 */ 886 */
869 bool resolve(AstNode node) { 887 bool resolve(AstNode node) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 } 1083 }
1066 visitor.initForIncrementalResolution(); 1084 visitor.initForIncrementalResolution();
1067 node.accept(visitor); 1085 node.accept(visitor);
1068 } 1086 }
1069 } finally { 1087 } finally {
1070 timer.stop('resolve references'); 1088 timer.stop('resolve references');
1071 } 1089 }
1072 } 1090 }
1073 1091
1074 void _shiftEntryErrors() { 1092 void _shiftEntryErrors() {
1075 _shiftErrors(DartEntry.RESOLUTION_ERRORS); 1093 if (oldEntry != null) {
1076 _shiftErrors(DartEntry.VERIFICATION_ERRORS); 1094 _shiftEntryErrors_OLD();
1077 _shiftErrors(DartEntry.HINTS); 1095 } else {
1078 _shiftErrors(DartEntry.LINTS); 1096 _shiftEntryErrors_NEW();
1097 }
1079 } 1098 }
1080 1099
1081 void _shiftErrors(DataDescriptor<List<AnalysisError>> descriptor) { 1100 void _shiftEntryErrors_NEW() {
1082 List<AnalysisError> errors = 1101 _shiftErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS);
1083 entry.getValueInLibrary(descriptor, _librarySource); 1102 _shiftErrors_NEW(RESOLVE_REFERENCES_ERRORS);
1103 _shiftErrors_NEW(VERIFY_ERRORS);
1104 _shiftErrors_NEW(HINTS);
1105 }
1106
1107 void _shiftEntryErrors_OLD() {
1108 _shiftErrors_OLD(DartEntry.RESOLUTION_ERRORS);
1109 _shiftErrors_OLD(DartEntry.VERIFICATION_ERRORS);
1110 _shiftErrors_OLD(DartEntry.HINTS);
1111 _shiftErrors_OLD(DartEntry.LINTS);
1112 }
1113
1114 void _shiftErrors(List<AnalysisError> errors) {
1084 for (AnalysisError error in errors) { 1115 for (AnalysisError error in errors) {
1085 int errorOffset = error.offset; 1116 int errorOffset = error.offset;
1086 if (errorOffset > _updateOffset) { 1117 if (errorOffset > _updateOffset) {
1087 error.offset += _updateDelta; 1118 error.offset += _updateDelta;
1088 } 1119 }
1089 } 1120 }
1090 } 1121 }
1091 1122
1123 void _shiftErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor) {
1124 List<AnalysisError> errors = newUnitEntry.getValue(descriptor);
1125 _shiftErrors(errors);
1126 }
1127
1128 void _shiftErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor) {
1129 List<AnalysisError> errors =
1130 oldEntry.getValueInLibrary(descriptor, _librarySource);
1131 _shiftErrors(errors);
1132 }
1133
1092 void _updateElementNameOffsets() { 1134 void _updateElementNameOffsets() {
1093 LoggingTimer timer = logger.startTimer(); 1135 LoggingTimer timer = logger.startTimer();
1094 try { 1136 try {
1095 _definingUnit 1137 _definingUnit
1096 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta)); 1138 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta));
1097 } finally { 1139 } finally {
1098 timer.stop('update element offsets'); 1140 timer.stop('update element offsets');
1099 } 1141 }
1100 } 1142 }
1101 1143
1102 void _updateEntry() { 1144 void _updateEntry() {
1145 if (oldEntry != null) {
1146 _updateEntry_OLD();
1147 } else {
1148 _updateEntry_NEW();
1149 }
1150 }
1151
1152 void _updateEntry_NEW() {
1153 _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []);
1154 _updateErrors_NEW(RESOLVE_REFERENCES_ERRORS, _resolveErrors);
1155 _updateErrors_NEW(VERIFY_ERRORS, _verifyErrors);
1156 // invalidate results we don't update incrementally
1157 newUnitEntry.setState(USED_IMPORTED_ELEMENTS, CacheState.INVALID);
1158 newUnitEntry.setState(USED_LOCAL_ELEMENTS, CacheState.INVALID);
1159 newUnitEntry.setState(HINTS, CacheState.INVALID);
1160 }
1161
1162 void _updateEntry_OLD() {
1103 { 1163 {
1104 List<AnalysisError> oldErrors = 1164 List<AnalysisError> oldErrors = oldEntry.getValueInLibrary(
1105 entry.getValueInLibrary(DartEntry.RESOLUTION_ERRORS, _librarySource); 1165 DartEntry.RESOLUTION_ERRORS, _librarySource);
1106 List<AnalysisError> errors = _updateErrors(oldErrors, _resolveErrors); 1166 List<AnalysisError> errors = _updateErrors(oldErrors, _resolveErrors);
1107 entry.setValueInLibrary( 1167 oldEntry.setValueInLibrary(
1108 DartEntry.RESOLUTION_ERRORS, _librarySource, errors); 1168 DartEntry.RESOLUTION_ERRORS, _librarySource, errors);
1109 } 1169 }
1110 { 1170 {
1111 List<AnalysisError> oldErrors = entry.getValueInLibrary( 1171 List<AnalysisError> oldErrors = oldEntry.getValueInLibrary(
1112 DartEntry.VERIFICATION_ERRORS, _librarySource); 1172 DartEntry.VERIFICATION_ERRORS, _librarySource);
1113 List<AnalysisError> errors = _updateErrors(oldErrors, _verifyErrors); 1173 List<AnalysisError> errors = _updateErrors(oldErrors, _verifyErrors);
1114 entry.setValueInLibrary( 1174 oldEntry.setValueInLibrary(
1115 DartEntry.VERIFICATION_ERRORS, _librarySource, errors); 1175 DartEntry.VERIFICATION_ERRORS, _librarySource, errors);
1116 } 1176 }
1117 entry.setValueInLibrary(DartEntry.LINTS, _librarySource, _lints); 1177 oldEntry.setValueInLibrary(DartEntry.LINTS, _librarySource, _lints);
1118 } 1178 }
1119 1179
1120 List<AnalysisError> _updateErrors( 1180 List<AnalysisError> _updateErrors(
1121 List<AnalysisError> oldErrors, List<AnalysisError> newErrors) { 1181 List<AnalysisError> oldErrors, List<AnalysisError> newErrors) {
1122 List<AnalysisError> errors = new List<AnalysisError>(); 1182 List<AnalysisError> errors = new List<AnalysisError>();
1123 // add updated old errors 1183 // add updated old errors
1124 for (AnalysisError error in oldErrors) { 1184 for (AnalysisError error in oldErrors) {
1125 int errorOffset = error.offset; 1185 int errorOffset = error.offset;
1126 if (errorOffset < _updateOffset) { 1186 if (errorOffset < _updateOffset) {
1127 errors.add(error); 1187 errors.add(error);
1128 } else if (errorOffset > _updateEndOld) { 1188 } else if (errorOffset > _updateEndOld) {
1129 error.offset += _updateDelta; 1189 error.offset += _updateDelta;
1130 errors.add(error); 1190 errors.add(error);
1131 } 1191 }
1132 } 1192 }
1133 // add new errors 1193 // add new errors
1134 for (AnalysisError error in newErrors) { 1194 for (AnalysisError error in newErrors) {
1135 int errorOffset = error.offset; 1195 int errorOffset = error.offset;
1136 if (errorOffset > _updateOffset && errorOffset < _updateEndNew) { 1196 if (errorOffset > _updateOffset && errorOffset < _updateEndNew) {
1137 errors.add(error); 1197 errors.add(error);
1138 } 1198 }
1139 } 1199 }
1140 // done 1200 // done
1141 return errors; 1201 return errors;
1142 } 1202 }
1143 1203
1204 void _updateErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor,
1205 List<AnalysisError> newErrors) {
1206 List<AnalysisError> oldErrors = newUnitEntry.getValue(descriptor);
1207 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors);
1208 newUnitEntry.setValueIncremental(descriptor, errors);
1209 }
1210
1144 void _verify(AstNode node) { 1211 void _verify(AstNode node) {
1145 LoggingTimer timer = logger.startTimer(); 1212 LoggingTimer timer = logger.startTimer();
1146 try { 1213 try {
1147 RecordingErrorListener errorListener = new RecordingErrorListener(); 1214 RecordingErrorListener errorListener = new RecordingErrorListener();
1148 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); 1215 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source);
1149 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, 1216 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter,
1150 _definingLibrary, _typeProvider, 1217 _definingLibrary, _typeProvider,
1151 new InheritanceManager(_definingLibrary)); 1218 new InheritanceManager(_definingLibrary));
1152 if (_resolutionContext.enclosingClassDeclaration != null) { 1219 if (_resolutionContext.enclosingClassDeclaration != null) {
1153 errorVerifier.visitClassDeclarationIncrementally( 1220 errorVerifier.visitClassDeclarationIncrementally(
1154 _resolutionContext.enclosingClassDeclaration); 1221 _resolutionContext.enclosingClassDeclaration);
1155 } 1222 }
1156 node.accept(errorVerifier); 1223 node.accept(errorVerifier);
1157 _verifyErrors = errorListener.getErrorsForSource(_source); 1224 _verifyErrors = errorListener.getErrorsForSource(_source);
1158 } finally { 1225 } finally {
1159 timer.stop('verify'); 1226 timer.stop('verify');
1160 } 1227 }
1161 } 1228 }
1162 } 1229 }
1163 1230
1164 class PoorMansIncrementalResolver { 1231 class PoorMansIncrementalResolver {
1165 final TypeProvider _typeProvider; 1232 final TypeProvider _typeProvider;
1166 final Source _unitSource; 1233 final Source _unitSource;
1167 final DartEntry _entry; 1234 final DartEntry _oldEntry;
1235 final CacheEntry _newSourceEntry;
1236 final CacheEntry _newUnitEntry;
1168 final CompilationUnit _oldUnit; 1237 final CompilationUnit _oldUnit;
1169 final AnalysisOptions _options; 1238 final AnalysisOptions _options;
1170 CompilationUnitElement _unitElement; 1239 CompilationUnitElement _unitElement;
1171 1240
1172 int _updateOffset; 1241 int _updateOffset;
1173 int _updateDelta; 1242 int _updateDelta;
1174 int _updateEndOld; 1243 int _updateEndOld;
1175 int _updateEndNew; 1244 int _updateEndNew;
1176 1245
1177 List<AnalysisError> _newScanErrors = <AnalysisError>[]; 1246 List<AnalysisError> _newScanErrors = <AnalysisError>[];
1178 List<AnalysisError> _newParseErrors = <AnalysisError>[]; 1247 List<AnalysisError> _newParseErrors = <AnalysisError>[];
1179 1248
1180 PoorMansIncrementalResolver(this._typeProvider, this._unitSource, this._entry, 1249 PoorMansIncrementalResolver(this._typeProvider, this._unitSource,
1181 this._oldUnit, bool resolveApiChanges, this._options) { 1250 this._oldEntry, this._newSourceEntry, this._newUnitEntry, this._oldUnit,
1251 bool resolveApiChanges, this._options) {
1182 _resolveApiChanges = resolveApiChanges; 1252 _resolveApiChanges = resolveApiChanges;
1183 } 1253 }
1184 1254
1185 /** 1255 /**
1186 * Attempts to update [_oldUnit] to the state corresponding to [newCode]. 1256 * Attempts to update [_oldUnit] to the state corresponding to [newCode].
1187 * Returns `true` if success, or `false` otherwise. 1257 * Returns `true` if success, or `false` otherwise.
1188 * The [_oldUnit] might be damaged. 1258 * The [_oldUnit] might be damaged.
1189 */ 1259 */
1190 bool resolve(String newCode) { 1260 bool resolve(String newCode) {
1191 logger.enter('diff/resolve $_unitSource'); 1261 logger.enter('diff/resolve $_unitSource');
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 bool success = _resolveCommentDoc(newUnit, firstPair); 1298 bool success = _resolveCommentDoc(newUnit, firstPair);
1229 logger.log('Documentation comment resolved: $success'); 1299 logger.log('Documentation comment resolved: $success');
1230 return success; 1300 return success;
1231 } 1301 }
1232 // A pure whitespace change. 1302 // A pure whitespace change.
1233 if (firstPair.kind == _TokenDifferenceKind.OFFSET) { 1303 if (firstPair.kind == _TokenDifferenceKind.OFFSET) {
1234 logger.log('Whitespace change.'); 1304 logger.log('Whitespace change.');
1235 _shiftTokens(firstPair.oldToken); 1305 _shiftTokens(firstPair.oldToken);
1236 { 1306 {
1237 IncrementalResolver incrementalResolver = new IncrementalResolver( 1307 IncrementalResolver incrementalResolver = new IncrementalResolver(
1238 _unitElement, _updateOffset, _updateEndOld, _updateEndNew); 1308 _oldEntry, _newSourceEntry, _newUnitEntry, _unitElement,
1309 _updateOffset, _updateEndOld, _updateEndNew);
1239 incrementalResolver._updateElementNameOffsets(); 1310 incrementalResolver._updateElementNameOffsets();
1240 incrementalResolver._shiftEntryErrors(); 1311 incrementalResolver._shiftEntryErrors();
1241 } 1312 }
1242 _updateEntry(); 1313 _updateEntry();
1243 logger.log('Success.'); 1314 logger.log('Success.');
1244 return true; 1315 return true;
1245 } 1316 }
1246 // fall-through, end-of-line comment 1317 // fall-through, end-of-line comment
1247 } 1318 }
1248 // Find nodes covering the "old" and "new" token ranges. 1319 // Find nodes covering the "old" and "new" token ranges.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 if (oldBeginToken.previous.type == TokenType.EOF) { 1384 if (oldBeginToken.previous.type == TokenType.EOF) {
1314 _oldUnit.beginToken = newBeginToken; 1385 _oldUnit.beginToken = newBeginToken;
1315 } else { 1386 } else {
1316 oldBeginToken.previous.setNext(newBeginToken); 1387 oldBeginToken.previous.setNext(newBeginToken);
1317 } 1388 }
1318 newNode.endToken.setNext(oldNode.endToken.next); 1389 newNode.endToken.setNext(oldNode.endToken.next);
1319 _shiftTokens(oldNode.endToken.next); 1390 _shiftTokens(oldNode.endToken.next);
1320 } 1391 }
1321 // perform incremental resolution 1392 // perform incremental resolution
1322 IncrementalResolver incrementalResolver = new IncrementalResolver( 1393 IncrementalResolver incrementalResolver = new IncrementalResolver(
1323 _unitElement, _updateOffset, _updateEndOld, _updateEndNew); 1394 _oldEntry, _newSourceEntry, _newUnitEntry, _unitElement,
1395 _updateOffset, _updateEndOld, _updateEndNew);
1324 bool success = incrementalResolver.resolve(newNode); 1396 bool success = incrementalResolver.resolve(newNode);
1325 // check if success 1397 // check if success
1326 if (!success) { 1398 if (!success) {
1327 logger.log('Failure: element model changed.'); 1399 logger.log('Failure: element model changed.');
1328 return false; 1400 return false;
1329 } 1401 }
1330 // update DartEntry 1402 // update DartEntry
1331 _updateEntry(); 1403 _updateEntry();
1332 logger.log('Success.'); 1404 logger.log('Success.');
1333 return true; 1405 return true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 Comment newComment = _findNodeCovering(newUnit, offset, offset); 1447 Comment newComment = _findNodeCovering(newUnit, offset, offset);
1376 logger.log('oldComment.beginToken: ${oldComment.beginToken}'); 1448 logger.log('oldComment.beginToken: ${oldComment.beginToken}');
1377 logger.log('newComment.beginToken: ${newComment.beginToken}'); 1449 logger.log('newComment.beginToken: ${newComment.beginToken}');
1378 _updateOffset = oldToken.offset - 1; 1450 _updateOffset = oldToken.offset - 1;
1379 // update token references 1451 // update token references
1380 _shiftTokens(firstPair.oldToken); 1452 _shiftTokens(firstPair.oldToken);
1381 _setPrecedingComments(oldToken, newComment.tokens.first); 1453 _setPrecedingComments(oldToken, newComment.tokens.first);
1382 // replace node 1454 // replace node
1383 NodeReplacer.replace(oldComment, newComment); 1455 NodeReplacer.replace(oldComment, newComment);
1384 // update elements 1456 // update elements
1385 IncrementalResolver incrementalResolver = new IncrementalResolver( 1457 IncrementalResolver incrementalResolver = new IncrementalResolver(_oldEntry,
1386 _unitElement, _updateOffset, _updateEndOld, _updateEndNew); 1458 _newSourceEntry, _newUnitEntry, _unitElement, _updateOffset,
1459 _updateEndOld, _updateEndNew);
1387 incrementalResolver._updateElementNameOffsets(); 1460 incrementalResolver._updateElementNameOffsets();
1388 incrementalResolver._shiftEntryErrors(); 1461 incrementalResolver._shiftEntryErrors();
1389 _updateEntry(); 1462 _updateEntry();
1390 // resolve references in the comment 1463 // resolve references in the comment
1391 incrementalResolver._resolveReferences(newComment); 1464 incrementalResolver._resolveReferences(newComment);
1392 // OK 1465 // OK
1393 return true; 1466 return true;
1394 } 1467 }
1395 1468
1396 Token _scan(String code) { 1469 Token _scan(String code) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 } 1508 }
1436 // next 1509 // next
1437 if (token.type == TokenType.EOF) { 1510 if (token.type == TokenType.EOF) {
1438 break; 1511 break;
1439 } 1512 }
1440 token = token.next; 1513 token = token.next;
1441 } 1514 }
1442 } 1515 }
1443 1516
1444 void _updateEntry() { 1517 void _updateEntry() {
1445 _entry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors); 1518 if (_oldEntry != null) {
1446 _entry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors); 1519 _updateEntry_OLD();
1520 } else {
1521 _updateEntry_NEW();
1522 }
1523 }
1524
1525 void _updateEntry_NEW() {
1526 // scan results
1527 _newSourceEntry.setState(SCAN_ERRORS, CacheState.INVALID);
1528 List<TargetedResult> scanDeps =
1529 <TargetedResult>[new TargetedResult(_unitSource, CONTENT)];
1530 _newSourceEntry.setValue(SCAN_ERRORS, _newScanErrors, scanDeps);
1531 // parse results
1532 List<TargetedResult> parseDeps =
1533 <TargetedResult>[new TargetedResult(_unitSource, TOKEN_STREAM)];
1534 _newSourceEntry.setState(PARSE_ERRORS, CacheState.INVALID);
1535 _newSourceEntry.setValue(PARSE_ERRORS, _newParseErrors, parseDeps);
1536 _newSourceEntry.setValue(PARSED_UNIT, _oldUnit, parseDeps);
1537 }
1538
1539 void _updateEntry_OLD() {
1540 _oldEntry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors);
1541 _oldEntry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors);
1447 } 1542 }
1448 1543
1449 /** 1544 /**
1450 * Checks if [token] has a balanced number of open and closed curly brackets. 1545 * Checks if [token] has a balanced number of open and closed curly brackets.
1451 */ 1546 */
1452 static bool _areCurlyBracketsBalanced(Token token) { 1547 static bool _areCurlyBracketsBalanced(Token token) {
1453 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET); 1548 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET);
1454 int numOpen2 = 1549 int numOpen2 =
1455 _getTokenCount(token, TokenType.STRING_INTERPOLATION_EXPRESSION); 1550 _getTokenCount(token, TokenType.STRING_INTERPOLATION_EXPRESSION);
1456 int numClosed = _getTokenCount(token, TokenType.CLOSE_CURLY_BRACKET); 1551 int numClosed = _getTokenCount(token, TokenType.CLOSE_CURLY_BRACKET);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 @override 1942 @override
1848 String toString() => name; 1943 String toString() => name;
1849 } 1944 }
1850 1945
1851 class _TokenPair { 1946 class _TokenPair {
1852 final _TokenDifferenceKind kind; 1947 final _TokenDifferenceKind kind;
1853 final Token oldToken; 1948 final Token oldToken;
1854 final Token newToken; 1949 final Token newToken;
1855 _TokenPair(this.kind, this.oldToken, this.newToken); 1950 _TokenPair(this.kind, this.oldToken, this.newToken);
1856 } 1951 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698