| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.incremental_resolver; | 5 library engine.incremental_resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/context/cache.dart' | 10 import 'package:analyzer/src/context/cache.dart' |
| 11 show CacheEntry, TargetedResult; | 11 show CacheEntry, TargetedResult; |
| 12 import 'package:analyzer/src/generated/constant.dart'; | 12 import 'package:analyzer/src/generated/constant.dart'; |
| 13 import 'package:analyzer/src/task/dart.dart' | 13 import 'package:analyzer/src/task/dart.dart' |
| 14 show | 14 show |
| 15 HINTS, | 15 HINTS, |
| 16 PARSE_ERRORS, | 16 PARSE_ERRORS, |
| 17 RESOLVE_REFERENCES_ERRORS, | 17 RESOLVE_REFERENCES_ERRORS, |
| 18 RESOLVE_TYPE_NAMES_ERRORS, | 18 RESOLVE_TYPE_NAMES_ERRORS, |
| 19 SCAN_ERRORS, | 19 SCAN_ERRORS, |
| 20 USED_IMPORTED_ELEMENTS, | 20 USED_IMPORTED_ELEMENTS, |
| 21 USED_LOCAL_ELEMENTS, | 21 USED_LOCAL_ELEMENTS, |
| 22 VARIABLE_REFERENCE_ERRORS, | 22 VARIABLE_REFERENCE_ERRORS, |
| 23 VERIFY_ERRORS; | 23 VERIFY_ERRORS; |
| 24 import 'package:analyzer/task/dart.dart' | 24 import 'package:analyzer/task/dart.dart' |
| 25 show DART_ERRORS, LibrarySpecificUnit, PARSED_UNIT, TOKEN_STREAM; | 25 show DART_ERRORS, LibrarySpecificUnit, PARSED_UNIT, TOKEN_STREAM; |
| 26 import 'package:analyzer/task/general.dart' show CONTENT; | 26 import 'package:analyzer/task/general.dart' show CONTENT, LINE_INFO; |
| 27 import 'package:analyzer/task/model.dart' show ResultDescriptor; | 27 import 'package:analyzer/task/model.dart' show ResultDescriptor; |
| 28 | 28 |
| 29 import 'ast.dart'; | 29 import 'ast.dart'; |
| 30 import 'element.dart'; | 30 import 'element.dart'; |
| 31 import 'engine.dart'; | 31 import 'engine.dart'; |
| 32 import 'error.dart'; | 32 import 'error.dart'; |
| 33 import 'error_verifier.dart'; | 33 import 'error_verifier.dart'; |
| 34 import 'incremental_logger.dart' show logger, LoggingTimer; | 34 import 'incremental_logger.dart' show logger, LoggingTimer; |
| 35 import 'java_engine.dart'; | 35 import 'java_engine.dart'; |
| 36 import 'parser.dart'; | 36 import 'parser.dart'; |
| (...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 | 1268 |
| 1269 final CompilationUnit _oldUnit; | 1269 final CompilationUnit _oldUnit; |
| 1270 final AnalysisOptions _options; | 1270 final AnalysisOptions _options; |
| 1271 CompilationUnitElement _unitElement; | 1271 CompilationUnitElement _unitElement; |
| 1272 | 1272 |
| 1273 int _updateOffset; | 1273 int _updateOffset; |
| 1274 int _updateDelta; | 1274 int _updateDelta; |
| 1275 int _updateEndOld; | 1275 int _updateEndOld; |
| 1276 int _updateEndNew; | 1276 int _updateEndNew; |
| 1277 | 1277 |
| 1278 LineInfo _newLineInfo; |
| 1278 List<AnalysisError> _newScanErrors = <AnalysisError>[]; | 1279 List<AnalysisError> _newScanErrors = <AnalysisError>[]; |
| 1279 List<AnalysisError> _newParseErrors = <AnalysisError>[]; | 1280 List<AnalysisError> _newParseErrors = <AnalysisError>[]; |
| 1280 | 1281 |
| 1281 PoorMansIncrementalResolver(this._typeProvider, this._unitSource, | 1282 PoorMansIncrementalResolver(this._typeProvider, this._unitSource, |
| 1282 this._oldEntry, this._newSourceEntry, this._newUnitEntry, this._oldUnit, | 1283 this._oldEntry, this._newSourceEntry, this._newUnitEntry, this._oldUnit, |
| 1283 bool resolveApiChanges, this._options) { | 1284 bool resolveApiChanges, this._options) { |
| 1284 _resolveApiChanges = resolveApiChanges; | 1285 _resolveApiChanges = resolveApiChanges; |
| 1285 } | 1286 } |
| 1286 | 1287 |
| 1287 /** | 1288 /** |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 incrementalResolver._resolveReferences(newComment); | 1503 incrementalResolver._resolveReferences(newComment); |
| 1503 // OK | 1504 // OK |
| 1504 return true; | 1505 return true; |
| 1505 } | 1506 } |
| 1506 | 1507 |
| 1507 Token _scan(String code) { | 1508 Token _scan(String code) { |
| 1508 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1509 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1509 CharSequenceReader reader = new CharSequenceReader(code); | 1510 CharSequenceReader reader = new CharSequenceReader(code); |
| 1510 Scanner scanner = new Scanner(_unitSource, reader, errorListener); | 1511 Scanner scanner = new Scanner(_unitSource, reader, errorListener); |
| 1511 Token token = scanner.tokenize(); | 1512 Token token = scanner.tokenize(); |
| 1513 _newLineInfo = new LineInfo(scanner.lineStarts); |
| 1512 _newScanErrors = errorListener.errors; | 1514 _newScanErrors = errorListener.errors; |
| 1513 return token; | 1515 return token; |
| 1514 } | 1516 } |
| 1515 | 1517 |
| 1516 /** | 1518 /** |
| 1517 * Set the given [comment] as a "precedingComments" for [token]. | 1519 * Set the given [comment] as a "precedingComments" for [token]. |
| 1518 */ | 1520 */ |
| 1519 void _setPrecedingComments(Token token, CommentToken comment) { | 1521 void _setPrecedingComments(Token token, CommentToken comment) { |
| 1520 if (token is BeginTokenWithComment) { | 1522 if (token is BeginTokenWithComment) { |
| 1521 token.precedingComments = comment; | 1523 token.precedingComments = comment; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 _updateEntry_NEW(); | 1560 _updateEntry_NEW(); |
| 1559 } | 1561 } |
| 1560 } | 1562 } |
| 1561 | 1563 |
| 1562 void _updateEntry_NEW() { | 1564 void _updateEntry_NEW() { |
| 1563 _newSourceEntry.setState(DART_ERRORS, CacheState.INVALID); | 1565 _newSourceEntry.setState(DART_ERRORS, CacheState.INVALID); |
| 1564 // scan results | 1566 // scan results |
| 1565 _newSourceEntry.setState(SCAN_ERRORS, CacheState.INVALID); | 1567 _newSourceEntry.setState(SCAN_ERRORS, CacheState.INVALID); |
| 1566 List<TargetedResult> scanDeps = | 1568 List<TargetedResult> scanDeps = |
| 1567 <TargetedResult>[new TargetedResult(_unitSource, CONTENT)]; | 1569 <TargetedResult>[new TargetedResult(_unitSource, CONTENT)]; |
| 1570 _newSourceEntry.setValue(LINE_INFO, _newLineInfo, scanDeps); |
| 1568 _newSourceEntry.setValue(SCAN_ERRORS, _newScanErrors, scanDeps); | 1571 _newSourceEntry.setValue(SCAN_ERRORS, _newScanErrors, scanDeps); |
| 1569 // parse results | 1572 // parse results |
| 1570 List<TargetedResult> parseDeps = | 1573 List<TargetedResult> parseDeps = |
| 1571 <TargetedResult>[new TargetedResult(_unitSource, TOKEN_STREAM)]; | 1574 <TargetedResult>[new TargetedResult(_unitSource, TOKEN_STREAM)]; |
| 1572 _newSourceEntry.setState(PARSE_ERRORS, CacheState.INVALID); | 1575 _newSourceEntry.setState(PARSE_ERRORS, CacheState.INVALID); |
| 1573 _newSourceEntry.setValue(PARSE_ERRORS, _newParseErrors, parseDeps); | 1576 _newSourceEntry.setValue(PARSE_ERRORS, _newParseErrors, parseDeps); |
| 1574 _newSourceEntry.setValue(PARSED_UNIT, _oldUnit, parseDeps); | 1577 _newSourceEntry.setValue(PARSED_UNIT, _oldUnit, parseDeps); |
| 1575 } | 1578 } |
| 1576 | 1579 |
| 1577 void _updateEntry_OLD() { | 1580 void _updateEntry_OLD() { |
| 1581 _oldEntry.setValue(SourceEntry.LINE_INFO, _newLineInfo); |
| 1578 _oldEntry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors); | 1582 _oldEntry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors); |
| 1579 _oldEntry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors); | 1583 _oldEntry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors); |
| 1580 } | 1584 } |
| 1581 | 1585 |
| 1582 /** | 1586 /** |
| 1583 * Checks if [token] has a balanced number of open and closed curly brackets. | 1587 * Checks if [token] has a balanced number of open and closed curly brackets. |
| 1584 */ | 1588 */ |
| 1585 static bool _areCurlyBracketsBalanced(Token token) { | 1589 static bool _areCurlyBracketsBalanced(Token token) { |
| 1586 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET); | 1590 int numOpen = _getTokenCount(token, TokenType.OPEN_CURLY_BRACKET); |
| 1587 int numOpen2 = | 1591 int numOpen2 = |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 @override | 1984 @override |
| 1981 String toString() => name; | 1985 String toString() => name; |
| 1982 } | 1986 } |
| 1983 | 1987 |
| 1984 class _TokenPair { | 1988 class _TokenPair { |
| 1985 final _TokenDifferenceKind kind; | 1989 final _TokenDifferenceKind kind; |
| 1986 final Token oldToken; | 1990 final Token oldToken; |
| 1987 final Token newToken; | 1991 final Token newToken; |
| 1988 _TokenPair(this.kind, this.oldToken, this.newToken); | 1992 _TokenPair(this.kind, this.oldToken, this.newToken); |
| 1989 } | 1993 } |
| OLD | NEW |