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

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: Fixes for review comments. 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'
25 show LibrarySpecificUnit, PARSED_UNIT, TOKEN_STREAM;
26 import 'package:analyzer/task/general.dart' show CONTENT;
27 import 'package:analyzer/task/model.dart' show ResultDescriptor;
12 28
13 import 'ast.dart'; 29 import 'ast.dart';
14 import 'element.dart'; 30 import 'element.dart';
15 import 'engine.dart'; 31 import 'engine.dart';
16 import 'error.dart'; 32 import 'error.dart';
17 import 'error_verifier.dart'; 33 import 'error_verifier.dart';
18 import 'incremental_logger.dart' show logger, LoggingTimer; 34 import 'incremental_logger.dart' show logger, LoggingTimer;
19 import 'java_engine.dart'; 35 import 'java_engine.dart';
20 import 'parser.dart'; 36 import 'parser.dart';
21 import 'resolver.dart'; 37 import 'resolver.dart';
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 TypeProvider _typeProvider; 817 TypeProvider _typeProvider;
802 818
803 /** 819 /**
804 * The element for the library containing the compilation unit being resolved. 820 * The element for the library containing the compilation unit being resolved.
805 */ 821 */
806 LibraryElementImpl _definingLibrary; 822 LibraryElementImpl _definingLibrary;
807 823
808 /** 824 /**
809 * The [DartEntry] corresponding to the source being resolved. 825 * The [DartEntry] corresponding to the source being resolved.
810 */ 826 */
811 DartEntry entry; 827 DartEntry oldEntry;
828
829 /**
830 * The [CacheEntry] corresponding to the source being resolved.
831 */
832 CacheEntry newSourceEntry;
833
834 /**
835 * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved.
836 */
837 CacheEntry newUnitEntry;
812 838
813 /** 839 /**
814 * The source representing the compilation unit being visited. 840 * The source representing the compilation unit being visited.
815 */ 841 */
816 Source _source; 842 Source _source;
817 843
818 /** 844 /**
819 * The source representing the library of the compilation unit being visited. 845 * The source representing the library of the compilation unit being visited.
820 */ 846 */
821 Source _librarySource; 847 Source _librarySource;
(...skipping 19 matching lines...) Expand all
841 ResolutionContext _resolutionContext; 867 ResolutionContext _resolutionContext;
842 868
843 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS; 869 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS;
844 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS; 870 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS;
845 List<AnalysisError> _lints = AnalysisError.NO_ERRORS; 871 List<AnalysisError> _lints = AnalysisError.NO_ERRORS;
846 872
847 /** 873 /**
848 * Initialize a newly created incremental resolver to resolve a node in the 874 * Initialize a newly created incremental resolver to resolve a node in the
849 * given source in the given library. 875 * given source in the given library.
850 */ 876 */
851 IncrementalResolver(this._definingUnit, this._updateOffset, 877 IncrementalResolver(this.oldEntry, this.newSourceEntry, this.newUnitEntry,
852 this._updateEndOld, this._updateEndNew) { 878 this._definingUnit, this._updateOffset, this._updateEndOld,
879 this._updateEndNew) {
853 _updateDelta = _updateEndNew - _updateEndOld; 880 _updateDelta = _updateEndNew - _updateEndOld;
854 _definingLibrary = _definingUnit.library; 881 _definingLibrary = _definingUnit.library;
855 _librarySource = _definingLibrary.source; 882 _librarySource = _definingLibrary.source;
856 _source = _definingUnit.source; 883 _source = _definingUnit.source;
857 _context = _definingUnit.context; 884 _context = _definingUnit.context;
858 _typeProvider = _context.typeProvider; 885 _typeProvider = _context.typeProvider;
859 entry = _context.getReadableSourceEntryOrNull(_source);
860 } 886 }
861 887
862 /** 888 /**
863 * Resolve [node], reporting any errors or warnings to the given listener. 889 * Resolve [node], reporting any errors or warnings to the given listener.
864 * 890 *
865 * [node] - the root of the AST structure to be resolved. 891 * [node] - the root of the AST structure to be resolved.
866 * 892 *
867 * Returns `true` if resolution was successful. 893 * Returns `true` if resolution was successful.
868 */ 894 */
869 bool resolve(AstNode node) { 895 bool resolve(AstNode node) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 } 1091 }
1066 visitor.initForIncrementalResolution(); 1092 visitor.initForIncrementalResolution();
1067 node.accept(visitor); 1093 node.accept(visitor);
1068 } 1094 }
1069 } finally { 1095 } finally {
1070 timer.stop('resolve references'); 1096 timer.stop('resolve references');
1071 } 1097 }
1072 } 1098 }
1073 1099
1074 void _shiftEntryErrors() { 1100 void _shiftEntryErrors() {
1075 _shiftErrors(DartEntry.RESOLUTION_ERRORS); 1101 if (oldEntry != null) {
1076 _shiftErrors(DartEntry.VERIFICATION_ERRORS); 1102 _shiftEntryErrors_OLD();
1077 _shiftErrors(DartEntry.HINTS); 1103 } else {
1078 _shiftErrors(DartEntry.LINTS); 1104 _shiftEntryErrors_NEW();
1105 }
1079 } 1106 }
1080 1107
1081 void _shiftErrors(DataDescriptor<List<AnalysisError>> descriptor) { 1108 void _shiftEntryErrors_NEW() {
1082 List<AnalysisError> errors = 1109 _shiftErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS);
1083 entry.getValueInLibrary(descriptor, _librarySource); 1110 _shiftErrors_NEW(RESOLVE_REFERENCES_ERRORS);
1111 _shiftErrors_NEW(VERIFY_ERRORS);
1112 _shiftErrors_NEW(HINTS);
1113 }
1114
1115 void _shiftEntryErrors_OLD() {
1116 _shiftErrors_OLD(DartEntry.RESOLUTION_ERRORS);
1117 _shiftErrors_OLD(DartEntry.VERIFICATION_ERRORS);
1118 _shiftErrors_OLD(DartEntry.HINTS);
1119 _shiftErrors_OLD(DartEntry.LINTS);
1120 }
1121
1122 void _shiftErrors(List<AnalysisError> errors) {
1084 for (AnalysisError error in errors) { 1123 for (AnalysisError error in errors) {
1085 int errorOffset = error.offset; 1124 int errorOffset = error.offset;
1086 if (errorOffset > _updateOffset) { 1125 if (errorOffset > _updateOffset) {
1087 error.offset += _updateDelta; 1126 error.offset += _updateDelta;
1088 } 1127 }
1089 } 1128 }
1090 } 1129 }
1091 1130
1131 void _shiftErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor) {
1132 List<AnalysisError> errors = newUnitEntry.getValue(descriptor);
1133 _shiftErrors(errors);
1134 }
1135
1136 void _shiftErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor) {
1137 List<AnalysisError> errors =
1138 oldEntry.getValueInLibrary(descriptor, _librarySource);
1139 _shiftErrors(errors);
1140 }
1141
1092 void _updateElementNameOffsets() { 1142 void _updateElementNameOffsets() {
1093 LoggingTimer timer = logger.startTimer(); 1143 LoggingTimer timer = logger.startTimer();
1094 try { 1144 try {
1095 _definingUnit 1145 _definingUnit
1096 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta)); 1146 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta));
1097 } finally { 1147 } finally {
1098 timer.stop('update element offsets'); 1148 timer.stop('update element offsets');
1099 } 1149 }
1100 } 1150 }
1101 1151
1102 void _updateEntry() { 1152 void _updateEntry() {
1153 if (oldEntry != null) {
1154 _updateEntry_OLD();
1155 } else {
1156 _updateEntry_NEW();
1157 }
1158 }
1159
1160 void _updateEntry_NEW() {
1161 _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []);
1162 _updateErrors_NEW(RESOLVE_REFERENCES_ERRORS, _resolveErrors);
1163 _updateErrors_NEW(VERIFY_ERRORS, _verifyErrors);
1164 // invalidate results we don't update incrementally
1165 newUnitEntry.setState(USED_IMPORTED_ELEMENTS, CacheState.INVALID);
1166 newUnitEntry.setState(USED_LOCAL_ELEMENTS, CacheState.INVALID);
1167 newUnitEntry.setState(HINTS, CacheState.INVALID);
1168 }
1169
1170 void _updateEntry_OLD() {
1103 { 1171 {
1104 List<AnalysisError> oldErrors = 1172 List<AnalysisError> oldErrors = oldEntry.getValueInLibrary(
1105 entry.getValueInLibrary(DartEntry.RESOLUTION_ERRORS, _librarySource); 1173 DartEntry.RESOLUTION_ERRORS, _librarySource);
1106 List<AnalysisError> errors = _updateErrors(oldErrors, _resolveErrors); 1174 List<AnalysisError> errors = _updateErrors(oldErrors, _resolveErrors);
1107 entry.setValueInLibrary( 1175 oldEntry.setValueInLibrary(
1108 DartEntry.RESOLUTION_ERRORS, _librarySource, errors); 1176 DartEntry.RESOLUTION_ERRORS, _librarySource, errors);
1109 } 1177 }
1110 { 1178 {
1111 List<AnalysisError> oldErrors = entry.getValueInLibrary( 1179 List<AnalysisError> oldErrors = oldEntry.getValueInLibrary(
1112 DartEntry.VERIFICATION_ERRORS, _librarySource); 1180 DartEntry.VERIFICATION_ERRORS, _librarySource);
1113 List<AnalysisError> errors = _updateErrors(oldErrors, _verifyErrors); 1181 List<AnalysisError> errors = _updateErrors(oldErrors, _verifyErrors);
1114 entry.setValueInLibrary( 1182 oldEntry.setValueInLibrary(
1115 DartEntry.VERIFICATION_ERRORS, _librarySource, errors); 1183 DartEntry.VERIFICATION_ERRORS, _librarySource, errors);
1116 } 1184 }
1117 entry.setValueInLibrary(DartEntry.LINTS, _librarySource, _lints); 1185 oldEntry.setValueInLibrary(DartEntry.LINTS, _librarySource, _lints);
1118 } 1186 }
1119 1187
1120 List<AnalysisError> _updateErrors( 1188 List<AnalysisError> _updateErrors(
1121 List<AnalysisError> oldErrors, List<AnalysisError> newErrors) { 1189 List<AnalysisError> oldErrors, List<AnalysisError> newErrors) {
1122 List<AnalysisError> errors = new List<AnalysisError>(); 1190 List<AnalysisError> errors = new List<AnalysisError>();
1123 // add updated old errors 1191 // add updated old errors
1124 for (AnalysisError error in oldErrors) { 1192 for (AnalysisError error in oldErrors) {
1125 int errorOffset = error.offset; 1193 int errorOffset = error.offset;
1126 if (errorOffset < _updateOffset) { 1194 if (errorOffset < _updateOffset) {
1127 errors.add(error); 1195 errors.add(error);
1128 } else if (errorOffset > _updateEndOld) { 1196 } else if (errorOffset > _updateEndOld) {
1129 error.offset += _updateDelta; 1197 error.offset += _updateDelta;
1130 errors.add(error); 1198 errors.add(error);
1131 } 1199 }
1132 } 1200 }
1133 // add new errors 1201 // add new errors
1134 for (AnalysisError error in newErrors) { 1202 for (AnalysisError error in newErrors) {
1135 int errorOffset = error.offset; 1203 int errorOffset = error.offset;
1136 if (errorOffset > _updateOffset && errorOffset < _updateEndNew) { 1204 if (errorOffset > _updateOffset && errorOffset < _updateEndNew) {
1137 errors.add(error); 1205 errors.add(error);
1138 } 1206 }
1139 } 1207 }
1140 // done 1208 // done
1141 return errors; 1209 return errors;
1142 } 1210 }
1143 1211
1212 void _updateErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor,
1213 List<AnalysisError> newErrors) {
1214 List<AnalysisError> oldErrors = newUnitEntry.getValue(descriptor);
1215 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors);
1216 newUnitEntry.setValueIncremental(descriptor, errors);
1217 }
1218
1144 void _verify(AstNode node) { 1219 void _verify(AstNode node) {
1145 LoggingTimer timer = logger.startTimer(); 1220 LoggingTimer timer = logger.startTimer();
1146 try { 1221 try {
1147 RecordingErrorListener errorListener = new RecordingErrorListener(); 1222 RecordingErrorListener errorListener = new RecordingErrorListener();
1148 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); 1223 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source);
1149 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, 1224 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter,
1150 _definingLibrary, _typeProvider, 1225 _definingLibrary, _typeProvider,
1151 new InheritanceManager(_definingLibrary)); 1226 new InheritanceManager(_definingLibrary));
1152 if (_resolutionContext.enclosingClassDeclaration != null) { 1227 if (_resolutionContext.enclosingClassDeclaration != null) {
1153 errorVerifier.visitClassDeclarationIncrementally( 1228 errorVerifier.visitClassDeclarationIncrementally(
1154 _resolutionContext.enclosingClassDeclaration); 1229 _resolutionContext.enclosingClassDeclaration);
1155 } 1230 }
1156 node.accept(errorVerifier); 1231 node.accept(errorVerifier);
1157 _verifyErrors = errorListener.getErrorsForSource(_source); 1232 _verifyErrors = errorListener.getErrorsForSource(_source);
1158 } finally { 1233 } finally {
1159 timer.stop('verify'); 1234 timer.stop('verify');
1160 } 1235 }
1161 } 1236 }
1162 } 1237 }
1163 1238
1164 class PoorMansIncrementalResolver { 1239 class PoorMansIncrementalResolver {
1165 final TypeProvider _typeProvider; 1240 final TypeProvider _typeProvider;
1166 final Source _unitSource; 1241 final Source _unitSource;
1167 final DartEntry _entry; 1242
1243 /**
1244 * The [DartEntry] corresponding to the source being resolved.
1245 */
1246 DartEntry _oldEntry;
1247
1248 /**
1249 * The [CacheEntry] corresponding to the source being resolved.
1250 */
1251 CacheEntry _newSourceEntry;
1252
1253 /**
1254 * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved.
1255 */
1256 CacheEntry _newUnitEntry;
1257
1168 final CompilationUnit _oldUnit; 1258 final CompilationUnit _oldUnit;
1169 final AnalysisOptions _options; 1259 final AnalysisOptions _options;
1170 CompilationUnitElement _unitElement; 1260 CompilationUnitElement _unitElement;
1171 1261
1172 int _updateOffset; 1262 int _updateOffset;
1173 int _updateDelta; 1263 int _updateDelta;
1174 int _updateEndOld; 1264 int _updateEndOld;
1175 int _updateEndNew; 1265 int _updateEndNew;
1176 1266
1177 List<AnalysisError> _newScanErrors = <AnalysisError>[]; 1267 List<AnalysisError> _newScanErrors = <AnalysisError>[];
1178 List<AnalysisError> _newParseErrors = <AnalysisError>[]; 1268 List<AnalysisError> _newParseErrors = <AnalysisError>[];
1179 1269
1180 PoorMansIncrementalResolver(this._typeProvider, this._unitSource, this._entry, 1270 PoorMansIncrementalResolver(this._typeProvider, this._unitSource,
1181 this._oldUnit, bool resolveApiChanges, this._options) { 1271 this._oldEntry, this._newSourceEntry, this._newUnitEntry, this._oldUnit,
1272 bool resolveApiChanges, this._options) {
1182 _resolveApiChanges = resolveApiChanges; 1273 _resolveApiChanges = resolveApiChanges;
1183 } 1274 }
1184 1275
1185 /** 1276 /**
1186 * Attempts to update [_oldUnit] to the state corresponding to [newCode]. 1277 * Attempts to update [_oldUnit] to the state corresponding to [newCode].
1187 * Returns `true` if success, or `false` otherwise. 1278 * Returns `true` if success, or `false` otherwise.
1188 * The [_oldUnit] might be damaged. 1279 * The [_oldUnit] might be damaged.
1189 */ 1280 */
1190 bool resolve(String newCode) { 1281 bool resolve(String newCode) {
1191 logger.enter('diff/resolve $_unitSource'); 1282 logger.enter('diff/resolve $_unitSource');
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 bool success = _resolveCommentDoc(newUnit, firstPair); 1319 bool success = _resolveCommentDoc(newUnit, firstPair);
1229 logger.log('Documentation comment resolved: $success'); 1320 logger.log('Documentation comment resolved: $success');
1230 return success; 1321 return success;
1231 } 1322 }
1232 // A pure whitespace change. 1323 // A pure whitespace change.
1233 if (firstPair.kind == _TokenDifferenceKind.OFFSET) { 1324 if (firstPair.kind == _TokenDifferenceKind.OFFSET) {
1234 logger.log('Whitespace change.'); 1325 logger.log('Whitespace change.');
1235 _shiftTokens(firstPair.oldToken); 1326 _shiftTokens(firstPair.oldToken);
1236 { 1327 {
1237 IncrementalResolver incrementalResolver = new IncrementalResolver( 1328 IncrementalResolver incrementalResolver = new IncrementalResolver(
1238 _unitElement, _updateOffset, _updateEndOld, _updateEndNew); 1329 _oldEntry, _newSourceEntry, _newUnitEntry, _unitElement,
1330 _updateOffset, _updateEndOld, _updateEndNew);
1239 incrementalResolver._updateElementNameOffsets(); 1331 incrementalResolver._updateElementNameOffsets();
1240 incrementalResolver._shiftEntryErrors(); 1332 incrementalResolver._shiftEntryErrors();
1241 } 1333 }
1242 _updateEntry(); 1334 _updateEntry();
1243 logger.log('Success.'); 1335 logger.log('Success.');
1244 return true; 1336 return true;
1245 } 1337 }
1246 // fall-through, end-of-line comment 1338 // fall-through, end-of-line comment
1247 } 1339 }
1248 // Find nodes covering the "old" and "new" token ranges. 1340 // 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) { 1405 if (oldBeginToken.previous.type == TokenType.EOF) {
1314 _oldUnit.beginToken = newBeginToken; 1406 _oldUnit.beginToken = newBeginToken;
1315 } else { 1407 } else {
1316 oldBeginToken.previous.setNext(newBeginToken); 1408 oldBeginToken.previous.setNext(newBeginToken);
1317 } 1409 }
1318 newNode.endToken.setNext(oldNode.endToken.next); 1410 newNode.endToken.setNext(oldNode.endToken.next);
1319 _shiftTokens(oldNode.endToken.next); 1411 _shiftTokens(oldNode.endToken.next);
1320 } 1412 }
1321 // perform incremental resolution 1413 // perform incremental resolution
1322 IncrementalResolver incrementalResolver = new IncrementalResolver( 1414 IncrementalResolver incrementalResolver = new IncrementalResolver(
1323 _unitElement, _updateOffset, _updateEndOld, _updateEndNew); 1415 _oldEntry, _newSourceEntry, _newUnitEntry, _unitElement,
1416 _updateOffset, _updateEndOld, _updateEndNew);
1324 bool success = incrementalResolver.resolve(newNode); 1417 bool success = incrementalResolver.resolve(newNode);
1325 // check if success 1418 // check if success
1326 if (!success) { 1419 if (!success) {
1327 logger.log('Failure: element model changed.'); 1420 logger.log('Failure: element model changed.');
1328 return false; 1421 return false;
1329 } 1422 }
1330 // update DartEntry 1423 // update DartEntry
1331 _updateEntry(); 1424 _updateEntry();
1332 logger.log('Success.'); 1425 logger.log('Success.');
1333 return true; 1426 return true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 Comment newComment = _findNodeCovering(newUnit, offset, offset); 1468 Comment newComment = _findNodeCovering(newUnit, offset, offset);
1376 logger.log('oldComment.beginToken: ${oldComment.beginToken}'); 1469 logger.log('oldComment.beginToken: ${oldComment.beginToken}');
1377 logger.log('newComment.beginToken: ${newComment.beginToken}'); 1470 logger.log('newComment.beginToken: ${newComment.beginToken}');
1378 _updateOffset = oldToken.offset - 1; 1471 _updateOffset = oldToken.offset - 1;
1379 // update token references 1472 // update token references
1380 _shiftTokens(firstPair.oldToken); 1473 _shiftTokens(firstPair.oldToken);
1381 _setPrecedingComments(oldToken, newComment.tokens.first); 1474 _setPrecedingComments(oldToken, newComment.tokens.first);
1382 // replace node 1475 // replace node
1383 NodeReplacer.replace(oldComment, newComment); 1476 NodeReplacer.replace(oldComment, newComment);
1384 // update elements 1477 // update elements
1385 IncrementalResolver incrementalResolver = new IncrementalResolver( 1478 IncrementalResolver incrementalResolver = new IncrementalResolver(_oldEntry,
1386 _unitElement, _updateOffset, _updateEndOld, _updateEndNew); 1479 _newSourceEntry, _newUnitEntry, _unitElement, _updateOffset,
1480 _updateEndOld, _updateEndNew);
1387 incrementalResolver._updateElementNameOffsets(); 1481 incrementalResolver._updateElementNameOffsets();
1388 incrementalResolver._shiftEntryErrors(); 1482 incrementalResolver._shiftEntryErrors();
1389 _updateEntry(); 1483 _updateEntry();
1390 // resolve references in the comment 1484 // resolve references in the comment
1391 incrementalResolver._resolveReferences(newComment); 1485 incrementalResolver._resolveReferences(newComment);
1392 // OK 1486 // OK
1393 return true; 1487 return true;
1394 } 1488 }
1395 1489
1396 Token _scan(String code) { 1490 Token _scan(String code) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 } 1529 }
1436 // next 1530 // next
1437 if (token.type == TokenType.EOF) { 1531 if (token.type == TokenType.EOF) {
1438 break; 1532 break;
1439 } 1533 }
1440 token = token.next; 1534 token = token.next;
1441 } 1535 }
1442 } 1536 }
1443 1537
1444 void _updateEntry() { 1538 void _updateEntry() {
1445 _entry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors); 1539 if (_oldEntry != null) {
1446 _entry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors); 1540 _updateEntry_OLD();
1541 } else {
1542 _updateEntry_NEW();
1543 }
1544 }
1545
1546 void _updateEntry_NEW() {
1547 // scan results
1548 _newSourceEntry.setState(SCAN_ERRORS, CacheState.INVALID);
1549 List<TargetedResult> scanDeps =
1550 <TargetedResult>[new TargetedResult(_unitSource, CONTENT)];
1551 _newSourceEntry.setValue(SCAN_ERRORS, _newScanErrors, scanDeps);
1552 // parse results
1553 List<TargetedResult> parseDeps =
1554 <TargetedResult>[new TargetedResult(_unitSource, TOKEN_STREAM)];
1555 _newSourceEntry.setState(PARSE_ERRORS, CacheState.INVALID);
1556 _newSourceEntry.setValue(PARSE_ERRORS, _newParseErrors, parseDeps);
1557 _newSourceEntry.setValue(PARSED_UNIT, _oldUnit, parseDeps);
1558 }
1559
1560 void _updateEntry_OLD() {
1561 _oldEntry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors);
1562 _oldEntry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors);
1447 } 1563 }
1448 1564
1449 /** 1565 /**
1450 * Checks if [token] has a balanced number of open and closed curly brackets. 1566 * Checks if [token] has a balanced number of open and closed curly brackets.
1451 */ 1567 */
1452 static bool _areCurlyBracketsBalanced(Token token) { 1568 static bool _areCurlyBracketsBalanced(Token token) {
1453 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET); 1569 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET);
1454 int numOpen2 = 1570 int numOpen2 =
1455 _getTokenCount(token, TokenType.STRING_INTERPOLATION_EXPRESSION); 1571 _getTokenCount(token, TokenType.STRING_INTERPOLATION_EXPRESSION);
1456 int numClosed = _getTokenCount(token, TokenType.CLOSE_CURLY_BRACKET); 1572 int numClosed = _getTokenCount(token, TokenType.CLOSE_CURLY_BRACKET);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 @override 1963 @override
1848 String toString() => name; 1964 String toString() => name;
1849 } 1965 }
1850 1966
1851 class _TokenPair { 1967 class _TokenPair {
1852 final _TokenDifferenceKind kind; 1968 final _TokenDifferenceKind kind;
1853 final Token oldToken; 1969 final Token oldToken;
1854 final Token newToken; 1970 final Token newToken;
1855 _TokenPair(this.kind, this.oldToken, this.newToken); 1971 _TokenPair(this.kind, this.oldToken, this.newToken);
1856 } 1972 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/task/dart_work_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698