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

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

Issue 1490233007: Remove the old task model (Closed) Base URL: https://github.com/dart-lang/sdk.git@analyzer-breaking-0.27
Patch Set: Created 5 years 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' 10 import 'package:analyzer/src/context/cache.dart';
11 show CacheEntry, Delta, DeltaResult;
12 import 'package:analyzer/src/generated/constant.dart'; 11 import 'package:analyzer/src/generated/constant.dart';
13 import 'package:analyzer/src/task/dart.dart'; 12 import 'package:analyzer/src/task/dart.dart';
14 import 'package:analyzer/task/dart.dart'; 13 import 'package:analyzer/task/dart.dart';
15 import 'package:analyzer/task/general.dart' show CONTENT, LINE_INFO; 14 import 'package:analyzer/task/general.dart' show CONTENT, LINE_INFO;
16 import 'package:analyzer/task/model.dart' 15 import 'package:analyzer/task/model.dart';
17 show AnalysisTarget, ResultDescriptor, TargetedResult, TaskDescriptor;
18 16
19 import 'ast.dart'; 17 import 'ast.dart';
20 import 'element.dart'; 18 import 'element.dart';
21 import 'engine.dart' 19 import 'engine.dart';
22 show
23 AnalysisContext,
24 AnalysisOptions,
25 CacheState,
26 DartEntry,
27 DataDescriptor,
28 InternalAnalysisContext,
29 RecordingErrorListener,
30 SourceEntry;
31 import 'error.dart'; 20 import 'error.dart';
32 import 'error_verifier.dart'; 21 import 'error_verifier.dart';
33 import 'incremental_logger.dart' show logger, LoggingTimer; 22 import 'incremental_logger.dart' show logger, LoggingTimer;
34 import 'java_engine.dart'; 23 import 'java_engine.dart';
35 import 'parser.dart'; 24 import 'parser.dart';
36 import 'resolver.dart'; 25 import 'resolver.dart';
37 import 'scanner.dart'; 26 import 'scanner.dart';
38 import 'source.dart'; 27 import 'source.dart';
39 import 'utilities_dart.dart'; 28 import 'utilities_dart.dart';
40 29
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 * The type system primitives. 953 * The type system primitives.
965 */ 954 */
966 TypeSystem _typeSystem; 955 TypeSystem _typeSystem;
967 956
968 /** 957 /**
969 * The element for the library containing the compilation unit being resolved. 958 * The element for the library containing the compilation unit being resolved.
970 */ 959 */
971 LibraryElementImpl _definingLibrary; 960 LibraryElementImpl _definingLibrary;
972 961
973 /** 962 /**
974 * The [DartEntry] corresponding to the source being resolved.
975 */
976 DartEntry oldEntry;
977
978 /**
979 * The [CacheEntry] corresponding to the source being resolved. 963 * The [CacheEntry] corresponding to the source being resolved.
980 */ 964 */
981 CacheEntry newSourceEntry; 965 CacheEntry newSourceEntry;
982 966
983 /** 967 /**
984 * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved. 968 * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved.
985 */ 969 */
986 CacheEntry newUnitEntry; 970 CacheEntry newUnitEntry;
987 971
988 /** 972 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 ResolutionContext _resolutionContext; 1008 ResolutionContext _resolutionContext;
1025 1009
1026 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS; 1010 List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS;
1027 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS; 1011 List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS;
1028 1012
1029 /** 1013 /**
1030 * Initialize a newly created incremental resolver to resolve a node in the 1014 * Initialize a newly created incremental resolver to resolve a node in the
1031 * given source in the given library. 1015 * given source in the given library.
1032 */ 1016 */
1033 IncrementalResolver( 1017 IncrementalResolver(
1034 this.oldEntry,
1035 this.newSourceEntry, 1018 this.newSourceEntry,
1036 this.newUnitEntry, 1019 this.newUnitEntry,
1037 this._definingUnit, 1020 this._definingUnit,
1038 this._updateOffset, 1021 this._updateOffset,
1039 this._updateEndOld, 1022 this._updateEndOld,
1040 this._updateEndNew) { 1023 this._updateEndNew) {
1041 _updateDelta = _updateEndNew - _updateEndOld; 1024 _updateDelta = _updateEndNew - _updateEndOld;
1042 _definingLibrary = _definingUnit.library; 1025 _definingLibrary = _definingUnit.library;
1043 _librarySource = _definingLibrary.source; 1026 _librarySource = _definingLibrary.source;
1044 _source = _definingUnit.source; 1027 _source = _definingUnit.source;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 } 1219 }
1237 visitor.initForIncrementalResolution(); 1220 visitor.initForIncrementalResolution();
1238 node.accept(visitor); 1221 node.accept(visitor);
1239 } 1222 }
1240 } finally { 1223 } finally {
1241 timer.stop('resolve references'); 1224 timer.stop('resolve references');
1242 } 1225 }
1243 } 1226 }
1244 1227
1245 void _shiftEntryErrors() { 1228 void _shiftEntryErrors() {
1246 if (oldEntry != null) {
1247 _shiftEntryErrors_OLD();
1248 } else {
1249 _shiftEntryErrors_NEW();
1250 }
1251 }
1252
1253 void _shiftEntryErrors_NEW() {
1254 _shiftErrors_NEW(HINTS); 1229 _shiftErrors_NEW(HINTS);
1255 _shiftErrors_NEW(LINTS); 1230 _shiftErrors_NEW(LINTS);
1256 _shiftErrors_NEW(LIBRARY_UNIT_ERRORS); 1231 _shiftErrors_NEW(LIBRARY_UNIT_ERRORS);
1257 _shiftErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS); 1232 _shiftErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS);
1258 _shiftErrors_NEW(RESOLVE_UNIT_ERRORS); 1233 _shiftErrors_NEW(RESOLVE_UNIT_ERRORS);
1259 _shiftErrors_NEW(STRONG_MODE_ERRORS); 1234 _shiftErrors_NEW(STRONG_MODE_ERRORS);
1260 _shiftErrors_NEW(VARIABLE_REFERENCE_ERRORS); 1235 _shiftErrors_NEW(VARIABLE_REFERENCE_ERRORS);
1261 _shiftErrors_NEW(VERIFY_ERRORS); 1236 _shiftErrors_NEW(VERIFY_ERRORS);
1262 } 1237 }
1263 1238
1264 void _shiftEntryErrors_OLD() {
1265 _shiftErrors_OLD(DartEntry.RESOLUTION_ERRORS);
1266 _shiftErrors_OLD(DartEntry.VERIFICATION_ERRORS);
1267 _shiftErrors_OLD(DartEntry.HINTS);
1268 _shiftErrors_OLD(DartEntry.LINTS);
1269 }
1270
1271 void _shiftErrors(List<AnalysisError> errors) { 1239 void _shiftErrors(List<AnalysisError> errors) {
1272 for (AnalysisError error in errors) { 1240 for (AnalysisError error in errors) {
1273 if (_alreadyShiftedErrors.add(error)) { 1241 if (_alreadyShiftedErrors.add(error)) {
1274 int errorOffset = error.offset; 1242 int errorOffset = error.offset;
1275 if (errorOffset > _updateOffset) { 1243 if (errorOffset > _updateOffset) {
1276 error.offset += _updateDelta; 1244 error.offset += _updateDelta;
1277 } 1245 }
1278 } 1246 }
1279 } 1247 }
1280 } 1248 }
1281 1249
1282 void _shiftErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor) { 1250 void _shiftErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor) {
1283 List<AnalysisError> errors = newUnitEntry.getValue(descriptor); 1251 List<AnalysisError> errors = newUnitEntry.getValue(descriptor);
1284 _shiftErrors(errors); 1252 _shiftErrors(errors);
1285 } 1253 }
1286 1254
1287 void _shiftErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor) {
1288 List<AnalysisError> errors =
1289 oldEntry.getValueInLibrary(descriptor, _librarySource);
1290 _shiftErrors(errors);
1291 }
1292
1293 void _updateCache() { 1255 void _updateCache() {
1294 if (newSourceEntry != null) { 1256 if (newSourceEntry != null) {
1295 LoggingTimer timer = logger.startTimer(); 1257 LoggingTimer timer = logger.startTimer();
1296 try { 1258 try {
1297 newSourceEntry.setState(CONTENT, CacheState.INVALID, 1259 newSourceEntry.setState(CONTENT, CacheState.INVALID,
1298 delta: new IncrementalBodyDelta(_source, _updateOffset, 1260 delta: new IncrementalBodyDelta(_source, _updateOffset,
1299 _updateEndOld, _updateEndNew, _updateDelta)); 1261 _updateEndOld, _updateEndNew, _updateDelta));
1300 } finally { 1262 } finally {
1301 timer.stop('invalidate cache with delta'); 1263 timer.stop('invalidate cache with delta');
1302 } 1264 }
1303 } 1265 }
1304 } 1266 }
1305 1267
1306 void _updateElementNameOffsets() { 1268 void _updateElementNameOffsets() {
1307 LoggingTimer timer = logger.startTimer(); 1269 LoggingTimer timer = logger.startTimer();
1308 try { 1270 try {
1309 _definingUnit 1271 _definingUnit
1310 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta)); 1272 .accept(new _ElementNameOffsetUpdater(_updateOffset, _updateDelta));
1311 _definingUnit.afterIncrementalResolution(); 1273 _definingUnit.afterIncrementalResolution();
1312 } finally { 1274 } finally {
1313 timer.stop('update element offsets'); 1275 timer.stop('update element offsets');
1314 } 1276 }
1315 } 1277 }
1316 1278
1317 void _updateEntry() { 1279 void _updateEntry() {
1318 if (oldEntry != null) {
1319 _updateEntry_OLD();
1320 } else {
1321 _updateEntry_NEW();
1322 }
1323 }
1324
1325 void _updateEntry_NEW() {
1326 _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []); 1280 _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []);
1327 _updateErrors_NEW(RESOLVE_UNIT_ERRORS, _resolveErrors); 1281 _updateErrors_NEW(RESOLVE_UNIT_ERRORS, _resolveErrors);
1328 _updateErrors_NEW(VARIABLE_REFERENCE_ERRORS, []); 1282 _updateErrors_NEW(VARIABLE_REFERENCE_ERRORS, []);
1329 _updateErrors_NEW(VERIFY_ERRORS, _verifyErrors); 1283 _updateErrors_NEW(VERIFY_ERRORS, _verifyErrors);
1330 // invalidate results we don't update incrementally 1284 // invalidate results we don't update incrementally
1331 newUnitEntry.setState(STRONG_MODE_ERRORS, CacheState.INVALID); 1285 newUnitEntry.setState(STRONG_MODE_ERRORS, CacheState.INVALID);
1332 newUnitEntry.setState(USED_IMPORTED_ELEMENTS, CacheState.INVALID); 1286 newUnitEntry.setState(USED_IMPORTED_ELEMENTS, CacheState.INVALID);
1333 newUnitEntry.setState(USED_LOCAL_ELEMENTS, CacheState.INVALID); 1287 newUnitEntry.setState(USED_LOCAL_ELEMENTS, CacheState.INVALID);
1334 newUnitEntry.setState(HINTS, CacheState.INVALID); 1288 newUnitEntry.setState(HINTS, CacheState.INVALID);
1335 newUnitEntry.setState(LINTS, CacheState.INVALID); 1289 newUnitEntry.setState(LINTS, CacheState.INVALID);
1336 } 1290 }
1337 1291
1338 void _updateEntry_OLD() {
1339 _updateErrors_OLD(DartEntry.RESOLUTION_ERRORS, _resolveErrors);
1340 _updateErrors_OLD(DartEntry.VERIFICATION_ERRORS, _verifyErrors);
1341 }
1342
1343 List<AnalysisError> _updateErrors( 1292 List<AnalysisError> _updateErrors(
1344 List<AnalysisError> oldErrors, List<AnalysisError> newErrors) { 1293 List<AnalysisError> oldErrors, List<AnalysisError> newErrors) {
1345 List<AnalysisError> errors = new List<AnalysisError>(); 1294 List<AnalysisError> errors = new List<AnalysisError>();
1346 // add updated old errors 1295 // add updated old errors
1347 for (AnalysisError error in oldErrors) { 1296 for (AnalysisError error in oldErrors) {
1348 int errorOffset = error.offset; 1297 int errorOffset = error.offset;
1349 if (errorOffset < _updateOffset) { 1298 if (errorOffset < _updateOffset) {
1350 errors.add(error); 1299 errors.add(error);
1351 } else if (errorOffset > _updateEndOld) { 1300 } else if (errorOffset > _updateEndOld) {
1352 error.offset += _updateDelta; 1301 error.offset += _updateDelta;
(...skipping 11 matching lines...) Expand all
1364 return errors; 1313 return errors;
1365 } 1314 }
1366 1315
1367 void _updateErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor, 1316 void _updateErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor,
1368 List<AnalysisError> newErrors) { 1317 List<AnalysisError> newErrors) {
1369 List<AnalysisError> oldErrors = newUnitEntry.getValue(descriptor); 1318 List<AnalysisError> oldErrors = newUnitEntry.getValue(descriptor);
1370 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors); 1319 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors);
1371 newUnitEntry.setValueIncremental(descriptor, errors, true); 1320 newUnitEntry.setValueIncremental(descriptor, errors, true);
1372 } 1321 }
1373 1322
1374 void _updateErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor,
1375 List<AnalysisError> newErrors) {
1376 List<AnalysisError> oldErrors =
1377 oldEntry.getValueInLibrary(descriptor, _librarySource);
1378 List<AnalysisError> errors = _updateErrors(oldErrors, newErrors);
1379 oldEntry.setValueInLibrary(descriptor, _librarySource, errors);
1380 }
1381
1382 void _verify(AstNode node) { 1323 void _verify(AstNode node) {
1383 LoggingTimer timer = logger.startTimer(); 1324 LoggingTimer timer = logger.startTimer();
1384 try { 1325 try {
1385 RecordingErrorListener errorListener = new RecordingErrorListener(); 1326 RecordingErrorListener errorListener = new RecordingErrorListener();
1386 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); 1327 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source);
1387 ErrorVerifier errorVerifier = new ErrorVerifier( 1328 ErrorVerifier errorVerifier = new ErrorVerifier(
1388 errorReporter, 1329 errorReporter,
1389 _definingLibrary, 1330 _definingLibrary,
1390 _typeProvider, 1331 _typeProvider,
1391 new InheritanceManager(_definingLibrary), 1332 new InheritanceManager(_definingLibrary),
1392 _context.analysisOptions.enableSuperMixins, 1333 _context.analysisOptions.enableSuperMixins,
1393 _context.analysisOptions.enableAssertMessage); 1334 _context.analysisOptions.enableAssertMessage);
1394 if (_resolutionContext.enclosingClassDeclaration != null) { 1335 if (_resolutionContext.enclosingClassDeclaration != null) {
1395 errorVerifier.visitClassDeclarationIncrementally( 1336 errorVerifier.visitClassDeclarationIncrementally(
1396 _resolutionContext.enclosingClassDeclaration); 1337 _resolutionContext.enclosingClassDeclaration);
1397 } 1338 }
1398 node.accept(errorVerifier); 1339 node.accept(errorVerifier);
1399 _verifyErrors = errorListener.getErrorsForSource(_source); 1340 _verifyErrors = errorListener.getErrorsForSource(_source);
1400 } finally { 1341 } finally {
1401 timer.stop('verify'); 1342 timer.stop('verify');
1402 } 1343 }
1403 } 1344 }
1404 } 1345 }
1405 1346
1406 class PoorMansIncrementalResolver { 1347 class PoorMansIncrementalResolver {
1407 final TypeProvider _typeProvider; 1348 final TypeProvider _typeProvider;
1408 final Source _unitSource; 1349 final Source _unitSource;
1409 1350
1410 /** 1351 /**
1411 * The [DartEntry] corresponding to the source being resolved.
1412 */
1413 DartEntry _oldEntry;
1414
1415 /**
1416 * The [CacheEntry] corresponding to the source being resolved. 1352 * The [CacheEntry] corresponding to the source being resolved.
1417 */ 1353 */
1418 CacheEntry _newSourceEntry; 1354 CacheEntry _sourceEntry;
1419 1355
1420 /** 1356 /**
1421 * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved. 1357 * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved.
1422 */ 1358 */
1423 CacheEntry _newUnitEntry; 1359 CacheEntry _unitEntry;
1424 1360
1425 final CompilationUnit _oldUnit; 1361 final CompilationUnit _oldUnit;
1426 CompilationUnitElement _unitElement; 1362 CompilationUnitElement _unitElement;
1427 1363
1428 int _updateOffset; 1364 int _updateOffset;
1429 int _updateDelta; 1365 int _updateDelta;
1430 int _updateEndOld; 1366 int _updateEndOld;
1431 int _updateEndNew; 1367 int _updateEndNew;
1432 1368
1433 LineInfo _newLineInfo; 1369 LineInfo _newLineInfo;
1434 List<AnalysisError> _newScanErrors = <AnalysisError>[]; 1370 List<AnalysisError> _newScanErrors = <AnalysisError>[];
1435 List<AnalysisError> _newParseErrors = <AnalysisError>[]; 1371 List<AnalysisError> _newParseErrors = <AnalysisError>[];
1436 1372
1437 PoorMansIncrementalResolver( 1373 PoorMansIncrementalResolver(
1438 this._typeProvider, 1374 this._typeProvider,
1439 this._unitSource, 1375 this._unitSource,
1440 this._oldEntry, 1376 this._sourceEntry,
1441 this._newSourceEntry, 1377 this._unitEntry,
1442 this._newUnitEntry,
1443 this._oldUnit, 1378 this._oldUnit,
1444 bool resolveApiChanges) { 1379 bool resolveApiChanges) {
1445 _resolveApiChanges = resolveApiChanges; 1380 _resolveApiChanges = resolveApiChanges;
1446 } 1381 }
1447 1382
1448 /** 1383 /**
1449 * Attempts to update [_oldUnit] to the state corresponding to [newCode]. 1384 * Attempts to update [_oldUnit] to the state corresponding to [newCode].
1450 * Returns `true` if success, or `false` otherwise. 1385 * Returns `true` if success, or `false` otherwise.
1451 * The [_oldUnit] might be damaged. 1386 * The [_oldUnit] might be damaged.
1452 */ 1387 */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 bool success = _resolveCommentDoc(newUnit, firstPair); 1426 bool success = _resolveCommentDoc(newUnit, firstPair);
1492 logger.log('Documentation comment resolved: $success'); 1427 logger.log('Documentation comment resolved: $success');
1493 return success; 1428 return success;
1494 } 1429 }
1495 // A pure whitespace change. 1430 // A pure whitespace change.
1496 if (firstPair.kind == _TokenDifferenceKind.OFFSET) { 1431 if (firstPair.kind == _TokenDifferenceKind.OFFSET) {
1497 logger.log('Whitespace change.'); 1432 logger.log('Whitespace change.');
1498 _shiftTokens(firstPair.oldToken); 1433 _shiftTokens(firstPair.oldToken);
1499 { 1434 {
1500 IncrementalResolver incrementalResolver = new IncrementalResolver( 1435 IncrementalResolver incrementalResolver = new IncrementalResolver(
1501 _oldEntry, 1436 _sourceEntry,
1502 _newSourceEntry, 1437 _unitEntry,
1503 _newUnitEntry,
1504 _unitElement, 1438 _unitElement,
1505 _updateOffset, 1439 _updateOffset,
1506 _updateEndOld, 1440 _updateEndOld,
1507 _updateEndNew); 1441 _updateEndNew);
1508 incrementalResolver._updateCache(); 1442 incrementalResolver._updateCache();
1509 incrementalResolver._updateElementNameOffsets(); 1443 incrementalResolver._updateElementNameOffsets();
1510 incrementalResolver._shiftEntryErrors(); 1444 incrementalResolver._shiftEntryErrors();
1511 } 1445 }
1512 _updateEntry(); 1446 _updateEntry();
1513 logger.log('Success.'); 1447 logger.log('Success.');
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 if (oldBeginToken.previous.type == TokenType.EOF) { 1522 if (oldBeginToken.previous.type == TokenType.EOF) {
1589 _oldUnit.beginToken = newBeginToken; 1523 _oldUnit.beginToken = newBeginToken;
1590 } else { 1524 } else {
1591 oldBeginToken.previous.setNext(newBeginToken); 1525 oldBeginToken.previous.setNext(newBeginToken);
1592 } 1526 }
1593 newNode.endToken.setNext(oldNode.endToken.next); 1527 newNode.endToken.setNext(oldNode.endToken.next);
1594 _shiftTokens(oldNode.endToken.next); 1528 _shiftTokens(oldNode.endToken.next);
1595 } 1529 }
1596 // perform incremental resolution 1530 // perform incremental resolution
1597 IncrementalResolver incrementalResolver = new IncrementalResolver( 1531 IncrementalResolver incrementalResolver = new IncrementalResolver(
1598 _oldEntry, 1532 _sourceEntry,
1599 _newSourceEntry, 1533 _unitEntry,
1600 _newUnitEntry,
1601 _unitElement, 1534 _unitElement,
1602 _updateOffset, 1535 _updateOffset,
1603 _updateEndOld, 1536 _updateEndOld,
1604 _updateEndNew); 1537 _updateEndNew);
1605 bool success = incrementalResolver.resolve(newNode); 1538 bool success = incrementalResolver.resolve(newNode);
1606 // check if success 1539 // check if success
1607 if (!success) { 1540 if (!success) {
1608 logger.log('Failure: element model changed.'); 1541 logger.log('Failure: element model changed.');
1609 return false; 1542 return false;
1610 } 1543 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 logger.log('oldComment.beginToken: ${oldComment.beginToken}'); 1592 logger.log('oldComment.beginToken: ${oldComment.beginToken}');
1660 logger.log('newComment.beginToken: ${newComment.beginToken}'); 1593 logger.log('newComment.beginToken: ${newComment.beginToken}');
1661 _updateOffset = oldToken.offset - 1; 1594 _updateOffset = oldToken.offset - 1;
1662 // update token references 1595 // update token references
1663 _shiftTokens(firstPair.oldToken); 1596 _shiftTokens(firstPair.oldToken);
1664 _setPrecedingComments(oldToken, newComment.tokens.first); 1597 _setPrecedingComments(oldToken, newComment.tokens.first);
1665 // replace node 1598 // replace node
1666 NodeReplacer.replace(oldComment, newComment); 1599 NodeReplacer.replace(oldComment, newComment);
1667 // update elements 1600 // update elements
1668 IncrementalResolver incrementalResolver = new IncrementalResolver( 1601 IncrementalResolver incrementalResolver = new IncrementalResolver(
1669 _oldEntry, 1602 _sourceEntry,
1670 _newSourceEntry, 1603 _unitEntry,
1671 _newUnitEntry,
1672 _unitElement, 1604 _unitElement,
1673 _updateOffset, 1605 _updateOffset,
1674 _updateEndOld, 1606 _updateEndOld,
1675 _updateEndNew); 1607 _updateEndNew);
1676 incrementalResolver._updateCache(); 1608 incrementalResolver._updateCache();
1677 incrementalResolver._updateElementNameOffsets(); 1609 incrementalResolver._updateElementNameOffsets();
1678 incrementalResolver._shiftEntryErrors(); 1610 incrementalResolver._shiftEntryErrors();
1679 _updateEntry(); 1611 _updateEntry();
1680 // resolve references in the comment 1612 // resolve references in the comment
1681 incrementalResolver._resolveReferences(newComment); 1613 incrementalResolver._resolveReferences(newComment);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 } 1657 }
1726 // next 1658 // next
1727 if (token.type == TokenType.EOF) { 1659 if (token.type == TokenType.EOF) {
1728 break; 1660 break;
1729 } 1661 }
1730 token = token.next; 1662 token = token.next;
1731 } 1663 }
1732 } 1664 }
1733 1665
1734 void _updateEntry() { 1666 void _updateEntry() {
1735 if (_oldEntry != null) {
1736 _updateEntry_OLD();
1737 } else {
1738 _updateEntry_NEW();
1739 }
1740 }
1741
1742 void _updateEntry_NEW() {
1743 // scan results 1667 // scan results
1744 _newSourceEntry.setValueIncremental(SCAN_ERRORS, _newScanErrors, true); 1668 _sourceEntry.setValueIncremental(SCAN_ERRORS, _newScanErrors, true);
1745 _newSourceEntry.setValueIncremental(LINE_INFO, _newLineInfo, false); 1669 _sourceEntry.setValueIncremental(LINE_INFO, _newLineInfo, false);
1746 // parse results 1670 // parse results
1747 _newSourceEntry.setValueIncremental(PARSE_ERRORS, _newParseErrors, true); 1671 _sourceEntry.setValueIncremental(PARSE_ERRORS, _newParseErrors, true);
1748 _newSourceEntry.setValueIncremental(PARSED_UNIT, _oldUnit, false); 1672 _sourceEntry.setValueIncremental(PARSED_UNIT, _oldUnit, false);
1749 }
1750
1751 void _updateEntry_OLD() {
1752 _oldEntry.setValue(SourceEntry.LINE_INFO, _newLineInfo);
1753 _oldEntry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors);
1754 _oldEntry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors);
1755 } 1673 }
1756 1674
1757 /** 1675 /**
1758 * Checks if [token] has a balanced number of open and closed curly brackets. 1676 * Checks if [token] has a balanced number of open and closed curly brackets.
1759 */ 1677 */
1760 static bool _areCurlyBracketsBalanced(Token token) { 1678 static bool _areCurlyBracketsBalanced(Token token) {
1761 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET); 1679 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET);
1762 int numOpen2 = 1680 int numOpen2 =
1763 _getTokenCount(token, TokenType.STRING_INTERPOLATION_EXPRESSION); 1681 _getTokenCount(token, TokenType.STRING_INTERPOLATION_EXPRESSION);
1764 int numClosed = _getTokenCount(token, TokenType.CLOSE_CURLY_BRACKET); 1682 int numClosed = _getTokenCount(token, TokenType.CLOSE_CURLY_BRACKET);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 @override 2073 @override
2156 String toString() => name; 2074 String toString() => name;
2157 } 2075 }
2158 2076
2159 class _TokenPair { 2077 class _TokenPair {
2160 final _TokenDifferenceKind kind; 2078 final _TokenDifferenceKind kind;
2161 final Token oldToken; 2079 final Token oldToken;
2162 final Token newToken; 2080 final Token newToken;
2163 _TokenPair(this.kind, this.oldToken, this.newToken); 2081 _TokenPair(this.kind, this.oldToken, this.newToken);
2164 } 2082 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698