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/generated/constant.dart'; | 10 import 'package:analyzer/src/generated/constant.dart'; |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 timer.stop('verify'); | 1158 timer.stop('verify'); |
1159 } | 1159 } |
1160 } | 1160 } |
1161 } | 1161 } |
1162 | 1162 |
1163 class PoorMansIncrementalResolver { | 1163 class PoorMansIncrementalResolver { |
1164 final TypeProvider _typeProvider; | 1164 final TypeProvider _typeProvider; |
1165 final Source _unitSource; | 1165 final Source _unitSource; |
1166 final DartEntry _entry; | 1166 final DartEntry _entry; |
1167 final CompilationUnit _oldUnit; | 1167 final CompilationUnit _oldUnit; |
| 1168 final AnalysisOptions _options; |
1168 CompilationUnitElement _unitElement; | 1169 CompilationUnitElement _unitElement; |
1169 | 1170 |
1170 int _updateOffset; | 1171 int _updateOffset; |
1171 int _updateDelta; | 1172 int _updateDelta; |
1172 int _updateEndOld; | 1173 int _updateEndOld; |
1173 int _updateEndNew; | 1174 int _updateEndNew; |
1174 | 1175 |
1175 List<AnalysisError> _newScanErrors = <AnalysisError>[]; | 1176 List<AnalysisError> _newScanErrors = <AnalysisError>[]; |
1176 List<AnalysisError> _newParseErrors = <AnalysisError>[]; | 1177 List<AnalysisError> _newParseErrors = <AnalysisError>[]; |
1177 | 1178 |
1178 PoorMansIncrementalResolver(this._typeProvider, this._unitSource, this._entry, | 1179 PoorMansIncrementalResolver(this._typeProvider, this._unitSource, this._entry, |
1179 this._oldUnit, bool resolveApiChanges) { | 1180 this._oldUnit, bool resolveApiChanges, this._options) { |
1180 _resolveApiChanges = resolveApiChanges; | 1181 _resolveApiChanges = resolveApiChanges; |
1181 } | 1182 } |
1182 | 1183 |
1183 /** | 1184 /** |
1184 * Attempts to update [_oldUnit] to the state corresponding to [newCode]. | 1185 * Attempts to update [_oldUnit] to the state corresponding to [newCode]. |
1185 * Returns `true` if success, or `false` otherwise. | 1186 * Returns `true` if success, or `false` otherwise. |
1186 * The [_oldUnit] might be damaged. | 1187 * The [_oldUnit] might be damaged. |
1187 */ | 1188 */ |
1188 bool resolve(String newCode) { | 1189 bool resolve(String newCode) { |
1189 logger.enter('diff/resolve $_unitSource'); | 1190 logger.enter('diff/resolve $_unitSource'); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 // resolve references in the comment | 1383 // resolve references in the comment |
1383 incrementalResolver._resolveReferences(newComment); | 1384 incrementalResolver._resolveReferences(newComment); |
1384 // OK | 1385 // OK |
1385 return true; | 1386 return true; |
1386 } | 1387 } |
1387 | 1388 |
1388 Token _scan(String code) { | 1389 Token _scan(String code) { |
1389 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1390 RecordingErrorListener errorListener = new RecordingErrorListener(); |
1390 CharSequenceReader reader = new CharSequenceReader(code); | 1391 CharSequenceReader reader = new CharSequenceReader(code); |
1391 Scanner scanner = new Scanner(_unitSource, reader, errorListener); | 1392 Scanner scanner = new Scanner(_unitSource, reader, errorListener); |
| 1393 scanner.enableNullAwareOperators = _options.enableNullAwareOperators; |
1392 Token token = scanner.tokenize(); | 1394 Token token = scanner.tokenize(); |
1393 _newScanErrors = errorListener.errors; | 1395 _newScanErrors = errorListener.errors; |
1394 return token; | 1396 return token; |
1395 } | 1397 } |
1396 | 1398 |
1397 /** | 1399 /** |
1398 * Set the given [comment] as a "precedingComments" for [token]. | 1400 * Set the given [comment] as a "precedingComments" for [token]. |
1399 */ | 1401 */ |
1400 void _setPrecedingComments(Token token, CommentToken comment) { | 1402 void _setPrecedingComments(Token token, CommentToken comment) { |
1401 if (token is BeginTokenWithComment) { | 1403 if (token is BeginTokenWithComment) { |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 @override | 1840 @override |
1839 String toString() => name; | 1841 String toString() => name; |
1840 } | 1842 } |
1841 | 1843 |
1842 class _TokenPair { | 1844 class _TokenPair { |
1843 final _TokenDifferenceKind kind; | 1845 final _TokenDifferenceKind kind; |
1844 final Token oldToken; | 1846 final Token oldToken; |
1845 final Token newToken; | 1847 final Token newToken; |
1846 _TokenPair(this.kind, this.oldToken, this.newToken); | 1848 _TokenPair(this.kind, this.oldToken, this.newToken); |
1847 } | 1849 } |
OLD | NEW |