Invalidate both hints and lints on incremental resolution.
We don't have new LINTS result descriptor yet, once we have, we need to update the new AnalysisContext implementation. R=brianwilkerson@google.com BUG= Review URL: https://codereview.chromium.org//1222433003.
This commit is contained in:
@@ -2222,7 +2222,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
||||
// Prepare sources to invalidate hints in.
|
||||
List<Source> sources = <Source>[librarySource];
|
||||
sources.addAll(dartEntry.getValue(DartEntry.INCLUDED_PARTS));
|
||||
// Invalidate hints.
|
||||
// Invalidate hints and lints.
|
||||
for (Source source in sources) {
|
||||
DartEntry dartEntry = _cache.get(source);
|
||||
if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) ==
|
||||
@@ -2230,6 +2230,11 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
||||
dartEntry.setStateInLibrary(
|
||||
DartEntry.HINTS, librarySource, CacheState.INVALID);
|
||||
}
|
||||
if (dartEntry.getStateInLibrary(DartEntry.LINTS, librarySource) ==
|
||||
CacheState.VALID) {
|
||||
dartEntry.setStateInLibrary(
|
||||
DartEntry.LINTS, librarySource, CacheState.INVALID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -899,7 +899,6 @@ class IncrementalResolver {
|
||||
|
||||
List<AnalysisError> _resolveErrors = AnalysisError.NO_ERRORS;
|
||||
List<AnalysisError> _verifyErrors = AnalysisError.NO_ERRORS;
|
||||
List<AnalysisError> _lints = AnalysisError.NO_ERRORS;
|
||||
|
||||
/**
|
||||
* Initialize a newly created incremental resolver to resolve a node in the
|
||||
@@ -941,7 +940,6 @@ class IncrementalResolver {
|
||||
// verify
|
||||
_verify(rootNode);
|
||||
_context.invalidateLibraryHints(_librarySource);
|
||||
_generateLints(rootNode);
|
||||
// update entry errors
|
||||
_updateEntry();
|
||||
// notify unit
|
||||
@@ -1053,24 +1051,6 @@ class IncrementalResolver {
|
||||
throw new AnalysisException("Cannot resolve node: no resolvable node");
|
||||
}
|
||||
|
||||
void _generateLints(AstNode node) {
|
||||
LoggingTimer timer = logger.startTimer();
|
||||
try {
|
||||
if (_context.analysisOptions.lint) {
|
||||
RecordingErrorListener errorListener = new RecordingErrorListener();
|
||||
CompilationUnit unit = node.getAncestor((n) => n is CompilationUnit);
|
||||
LintGenerator lintGenerator =
|
||||
new LintGenerator(<CompilationUnit>[unit], errorListener);
|
||||
lintGenerator.generate();
|
||||
_lints = errorListener.getErrorsForSource(_source);
|
||||
} else {
|
||||
_lints = AnalysisError.NO_ERRORS;
|
||||
}
|
||||
} finally {
|
||||
timer.stop('generate lints');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the element defined by [node], or `null` if the node does not
|
||||
* define an element.
|
||||
@@ -1201,21 +1181,8 @@ class IncrementalResolver {
|
||||
}
|
||||
|
||||
void _updateEntry_OLD() {
|
||||
{
|
||||
List<AnalysisError> oldErrors = oldEntry.getValueInLibrary(
|
||||
DartEntry.RESOLUTION_ERRORS, _librarySource);
|
||||
List<AnalysisError> errors = _updateErrors(oldErrors, _resolveErrors);
|
||||
oldEntry.setValueInLibrary(
|
||||
DartEntry.RESOLUTION_ERRORS, _librarySource, errors);
|
||||
}
|
||||
{
|
||||
List<AnalysisError> oldErrors = oldEntry.getValueInLibrary(
|
||||
DartEntry.VERIFICATION_ERRORS, _librarySource);
|
||||
List<AnalysisError> errors = _updateErrors(oldErrors, _verifyErrors);
|
||||
oldEntry.setValueInLibrary(
|
||||
DartEntry.VERIFICATION_ERRORS, _librarySource, errors);
|
||||
}
|
||||
oldEntry.setValueInLibrary(DartEntry.LINTS, _librarySource, _lints);
|
||||
_updateErrors_OLD(DartEntry.RESOLUTION_ERRORS, _resolveErrors);
|
||||
_updateErrors_OLD(DartEntry.VERIFICATION_ERRORS, _verifyErrors);
|
||||
}
|
||||
|
||||
List<AnalysisError> _updateErrors(
|
||||
@@ -1249,6 +1216,14 @@ class IncrementalResolver {
|
||||
newUnitEntry.setValueIncremental(descriptor, errors);
|
||||
}
|
||||
|
||||
void _updateErrors_OLD(DataDescriptor<List<AnalysisError>> descriptor,
|
||||
List<AnalysisError> newErrors) {
|
||||
List<AnalysisError> oldErrors =
|
||||
oldEntry.getValueInLibrary(descriptor, _librarySource);
|
||||
List<AnalysisError> errors = _updateErrors(oldErrors, newErrors);
|
||||
oldEntry.setValueInLibrary(descriptor, _librarySource, errors);
|
||||
}
|
||||
|
||||
void _verify(AstNode node) {
|
||||
LoggingTimer timer = logger.startTimer();
|
||||
try {
|
||||
|
||||
@@ -2486,7 +2486,7 @@ class IncrementalResolverTest extends ResolverTestCase {
|
||||
void resetWithOptions(AnalysisOptions options) {
|
||||
if (AnalysisEngine.instance.useTaskModel) {
|
||||
analysisContext2 =
|
||||
AnalysisContextFactory.contextWithCoreAndOptions(options);
|
||||
AnalysisContextFactory.contextWithCoreAndOptions(options);
|
||||
} else {
|
||||
analysisContext2 =
|
||||
AnalysisContextFactory.oldContextWithCoreAndOptions(options);
|
||||
@@ -3711,7 +3711,7 @@ class A {
|
||||
expect(errors, isEmpty);
|
||||
}
|
||||
|
||||
void test_updateErrors_addNew_hint() {
|
||||
void test_updateErrors_addNew_hint1() {
|
||||
_resolveUnit(r'''
|
||||
int main() {
|
||||
return 42;
|
||||
@@ -3723,7 +3723,7 @@ int main() {
|
||||
''');
|
||||
}
|
||||
|
||||
void test_updateErrors_addNew_hints() {
|
||||
void test_updateErrors_addNew_hint2() {
|
||||
_resolveUnit(r'''
|
||||
main() {
|
||||
int v = 0;
|
||||
|
||||
Reference in New Issue
Block a user