| Index: pkg/analyzer/lib/src/generated/incremental_resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/incremental_resolver.dart b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
|
| index 6dd488c51571f252c14eea7188d7cd99823c4d70..828949ae69c982e5d0df0c8efefa37c219c3ea9a 100644
|
| --- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
|
| @@ -7,8 +7,24 @@ library engine.incremental_resolver;
|
| import 'dart:collection';
|
| import 'dart:math' as math;
|
|
|
| +import 'package:analyzer/src/context/cache.dart'
|
| + show CacheEntry, TargetedResult;
|
| import 'package:analyzer/src/generated/constant.dart';
|
| import 'package:analyzer/src/services/lint.dart';
|
| +import 'package:analyzer/src/task/dart.dart'
|
| + show
|
| + HINTS,
|
| + PARSE_ERRORS,
|
| + RESOLVE_REFERENCES_ERRORS,
|
| + RESOLVE_TYPE_NAMES_ERRORS,
|
| + SCAN_ERRORS,
|
| + USED_IMPORTED_ELEMENTS,
|
| + USED_LOCAL_ELEMENTS,
|
| + VERIFY_ERRORS;
|
| +import 'package:analyzer/task/dart.dart'
|
| + show LibrarySpecificUnit, PARSED_UNIT, TOKEN_STREAM;
|
| +import 'package:analyzer/task/general.dart' show CONTENT;
|
| +import 'package:analyzer/task/model.dart' show ResultDescriptor;
|
|
|
| import 'ast.dart';
|
| import 'element.dart';
|
| @@ -808,7 +824,17 @@ class IncrementalResolver {
|
| /**
|
| * The [DartEntry] corresponding to the source being resolved.
|
| */
|
| - DartEntry entry;
|
| + DartEntry oldEntry;
|
| +
|
| + /**
|
| + * The [CacheEntry] corresponding to the source being resolved.
|
| + */
|
| + CacheEntry newSourceEntry;
|
| +
|
| + /**
|
| + * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved.
|
| + */
|
| + CacheEntry newUnitEntry;
|
|
|
| /**
|
| * The source representing the compilation unit being visited.
|
| @@ -848,15 +874,15 @@ class IncrementalResolver {
|
| * Initialize a newly created incremental resolver to resolve a node in the
|
| * given source in the given library.
|
| */
|
| - IncrementalResolver(this._definingUnit, this._updateOffset,
|
| - this._updateEndOld, this._updateEndNew) {
|
| + IncrementalResolver(this.oldEntry, this.newSourceEntry, this.newUnitEntry,
|
| + this._definingUnit, this._updateOffset, this._updateEndOld,
|
| + this._updateEndNew) {
|
| _updateDelta = _updateEndNew - _updateEndOld;
|
| _definingLibrary = _definingUnit.library;
|
| _librarySource = _definingLibrary.source;
|
| _source = _definingUnit.source;
|
| _context = _definingUnit.context;
|
| _typeProvider = _context.typeProvider;
|
| - entry = _context.getReadableSourceEntryOrNull(_source);
|
| }
|
|
|
| /**
|
| @@ -1072,15 +1098,28 @@ class IncrementalResolver {
|
| }
|
|
|
| void _shiftEntryErrors() {
|
| - _shiftErrors(DartEntry.RESOLUTION_ERRORS);
|
| - _shiftErrors(DartEntry.VERIFICATION_ERRORS);
|
| - _shiftErrors(DartEntry.HINTS);
|
| - _shiftErrors(DartEntry.LINTS);
|
| + if (oldEntry != null) {
|
| + _shiftEntryErrors_OLD();
|
| + } else {
|
| + _shiftEntryErrors_NEW();
|
| + }
|
| }
|
|
|
| - void _shiftErrors(DataDescriptor<List<AnalysisError>> descriptor) {
|
| - List<AnalysisError> errors =
|
| - entry.getValueInLibrary(descriptor, _librarySource);
|
| + void _shiftEntryErrors_NEW() {
|
| + _shiftErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS);
|
| + _shiftErrors_NEW(RESOLVE_REFERENCES_ERRORS);
|
| + _shiftErrors_NEW(VERIFY_ERRORS);
|
| + _shiftErrors_NEW(HINTS);
|
| + }
|
| +
|
| + void _shiftEntryErrors_OLD() {
|
| + _shiftErrors_OLD(DartEntry.RESOLUTION_ERRORS);
|
| + _shiftErrors_OLD(DartEntry.VERIFICATION_ERRORS);
|
| + _shiftErrors_OLD(DartEntry.HINTS);
|
| + _shiftErrors_OLD(DartEntry.LINTS);
|
| + }
|
| +
|
| + void _shiftErrors(List<AnalysisError> errors) {
|
| for (AnalysisError error in errors) {
|
| int errorOffset = error.offset;
|
| if (errorOffset > _updateOffset) {
|
| @@ -1089,6 +1128,17 @@ class IncrementalResolver {
|
| }
|
| }
|
|
|
| + void _shiftErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor) {
|
| + List<AnalysisError> errors = newUnitEntry.getValue(descriptor);
|
| + _shiftErrors(errors);
|
| + }
|
| +
|
| + void _shiftErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor) {
|
| + List<AnalysisError> errors =
|
| + oldEntry.getValueInLibrary(descriptor, _librarySource);
|
| + _shiftErrors(errors);
|
| + }
|
| +
|
| void _updateElementNameOffsets() {
|
| LoggingTimer timer = logger.startTimer();
|
| try {
|
| @@ -1100,21 +1150,39 @@ class IncrementalResolver {
|
| }
|
|
|
| void _updateEntry() {
|
| + if (oldEntry != null) {
|
| + _updateEntry_OLD();
|
| + } else {
|
| + _updateEntry_NEW();
|
| + }
|
| + }
|
| +
|
| + void _updateEntry_NEW() {
|
| + _updateErrors_NEW(RESOLVE_TYPE_NAMES_ERRORS, []);
|
| + _updateErrors_NEW(RESOLVE_REFERENCES_ERRORS, _resolveErrors);
|
| + _updateErrors_NEW(VERIFY_ERRORS, _verifyErrors);
|
| + // invalidate results we don't update incrementally
|
| + newUnitEntry.setState(USED_IMPORTED_ELEMENTS, CacheState.INVALID);
|
| + newUnitEntry.setState(USED_LOCAL_ELEMENTS, CacheState.INVALID);
|
| + newUnitEntry.setState(HINTS, CacheState.INVALID);
|
| + }
|
| +
|
| + void _updateEntry_OLD() {
|
| {
|
| - List<AnalysisError> oldErrors =
|
| - entry.getValueInLibrary(DartEntry.RESOLUTION_ERRORS, _librarySource);
|
| + List<AnalysisError> oldErrors = oldEntry.getValueInLibrary(
|
| + DartEntry.RESOLUTION_ERRORS, _librarySource);
|
| List<AnalysisError> errors = _updateErrors(oldErrors, _resolveErrors);
|
| - entry.setValueInLibrary(
|
| + oldEntry.setValueInLibrary(
|
| DartEntry.RESOLUTION_ERRORS, _librarySource, errors);
|
| }
|
| {
|
| - List<AnalysisError> oldErrors = entry.getValueInLibrary(
|
| + List<AnalysisError> oldErrors = oldEntry.getValueInLibrary(
|
| DartEntry.VERIFICATION_ERRORS, _librarySource);
|
| List<AnalysisError> errors = _updateErrors(oldErrors, _verifyErrors);
|
| - entry.setValueInLibrary(
|
| + oldEntry.setValueInLibrary(
|
| DartEntry.VERIFICATION_ERRORS, _librarySource, errors);
|
| }
|
| - entry.setValueInLibrary(DartEntry.LINTS, _librarySource, _lints);
|
| + oldEntry.setValueInLibrary(DartEntry.LINTS, _librarySource, _lints);
|
| }
|
|
|
| List<AnalysisError> _updateErrors(
|
| @@ -1141,6 +1209,13 @@ class IncrementalResolver {
|
| return errors;
|
| }
|
|
|
| + void _updateErrors_NEW(ResultDescriptor<List<AnalysisError>> descriptor,
|
| + List<AnalysisError> newErrors) {
|
| + List<AnalysisError> oldErrors = newUnitEntry.getValue(descriptor);
|
| + List<AnalysisError> errors = _updateErrors(oldErrors, newErrors);
|
| + newUnitEntry.setValueIncremental(descriptor, errors);
|
| + }
|
| +
|
| void _verify(AstNode node) {
|
| LoggingTimer timer = logger.startTimer();
|
| try {
|
| @@ -1164,7 +1239,22 @@ class IncrementalResolver {
|
| class PoorMansIncrementalResolver {
|
| final TypeProvider _typeProvider;
|
| final Source _unitSource;
|
| - final DartEntry _entry;
|
| +
|
| + /**
|
| + * The [DartEntry] corresponding to the source being resolved.
|
| + */
|
| + DartEntry _oldEntry;
|
| +
|
| + /**
|
| + * The [CacheEntry] corresponding to the source being resolved.
|
| + */
|
| + CacheEntry _newSourceEntry;
|
| +
|
| + /**
|
| + * The [CacheEntry] corresponding to the [LibrarySpecificUnit] being resolved.
|
| + */
|
| + CacheEntry _newUnitEntry;
|
| +
|
| final CompilationUnit _oldUnit;
|
| final AnalysisOptions _options;
|
| CompilationUnitElement _unitElement;
|
| @@ -1177,8 +1267,9 @@ class PoorMansIncrementalResolver {
|
| List<AnalysisError> _newScanErrors = <AnalysisError>[];
|
| List<AnalysisError> _newParseErrors = <AnalysisError>[];
|
|
|
| - PoorMansIncrementalResolver(this._typeProvider, this._unitSource, this._entry,
|
| - this._oldUnit, bool resolveApiChanges, this._options) {
|
| + PoorMansIncrementalResolver(this._typeProvider, this._unitSource,
|
| + this._oldEntry, this._newSourceEntry, this._newUnitEntry, this._oldUnit,
|
| + bool resolveApiChanges, this._options) {
|
| _resolveApiChanges = resolveApiChanges;
|
| }
|
|
|
| @@ -1235,7 +1326,8 @@ class PoorMansIncrementalResolver {
|
| _shiftTokens(firstPair.oldToken);
|
| {
|
| IncrementalResolver incrementalResolver = new IncrementalResolver(
|
| - _unitElement, _updateOffset, _updateEndOld, _updateEndNew);
|
| + _oldEntry, _newSourceEntry, _newUnitEntry, _unitElement,
|
| + _updateOffset, _updateEndOld, _updateEndNew);
|
| incrementalResolver._updateElementNameOffsets();
|
| incrementalResolver._shiftEntryErrors();
|
| }
|
| @@ -1320,7 +1412,8 @@ class PoorMansIncrementalResolver {
|
| }
|
| // perform incremental resolution
|
| IncrementalResolver incrementalResolver = new IncrementalResolver(
|
| - _unitElement, _updateOffset, _updateEndOld, _updateEndNew);
|
| + _oldEntry, _newSourceEntry, _newUnitEntry, _unitElement,
|
| + _updateOffset, _updateEndOld, _updateEndNew);
|
| bool success = incrementalResolver.resolve(newNode);
|
| // check if success
|
| if (!success) {
|
| @@ -1382,8 +1475,9 @@ class PoorMansIncrementalResolver {
|
| // replace node
|
| NodeReplacer.replace(oldComment, newComment);
|
| // update elements
|
| - IncrementalResolver incrementalResolver = new IncrementalResolver(
|
| - _unitElement, _updateOffset, _updateEndOld, _updateEndNew);
|
| + IncrementalResolver incrementalResolver = new IncrementalResolver(_oldEntry,
|
| + _newSourceEntry, _newUnitEntry, _unitElement, _updateOffset,
|
| + _updateEndOld, _updateEndNew);
|
| incrementalResolver._updateElementNameOffsets();
|
| incrementalResolver._shiftEntryErrors();
|
| _updateEntry();
|
| @@ -1442,8 +1536,30 @@ class PoorMansIncrementalResolver {
|
| }
|
|
|
| void _updateEntry() {
|
| - _entry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors);
|
| - _entry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors);
|
| + if (_oldEntry != null) {
|
| + _updateEntry_OLD();
|
| + } else {
|
| + _updateEntry_NEW();
|
| + }
|
| + }
|
| +
|
| + void _updateEntry_NEW() {
|
| + // scan results
|
| + _newSourceEntry.setState(SCAN_ERRORS, CacheState.INVALID);
|
| + List<TargetedResult> scanDeps =
|
| + <TargetedResult>[new TargetedResult(_unitSource, CONTENT)];
|
| + _newSourceEntry.setValue(SCAN_ERRORS, _newScanErrors, scanDeps);
|
| + // parse results
|
| + List<TargetedResult> parseDeps =
|
| + <TargetedResult>[new TargetedResult(_unitSource, TOKEN_STREAM)];
|
| + _newSourceEntry.setState(PARSE_ERRORS, CacheState.INVALID);
|
| + _newSourceEntry.setValue(PARSE_ERRORS, _newParseErrors, parseDeps);
|
| + _newSourceEntry.setValue(PARSED_UNIT, _oldUnit, parseDeps);
|
| + }
|
| +
|
| + void _updateEntry_OLD() {
|
| + _oldEntry.setValue(DartEntry.SCAN_ERRORS, _newScanErrors);
|
| + _oldEntry.setValue(DartEntry.PARSE_ERRORS, _newParseErrors);
|
| }
|
|
|
| /**
|
|
|