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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 2099053002: Keep more analysis results that don't change when a source is changed. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index 3e0b4fb7d26992a58db8776ad48a1acb19c76bd5..040050a83e375c072074709befd37c2ad33adf0f 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -439,7 +439,7 @@ final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 =
/**
* The partial [LibraryElement] associated with a library.
*
- * In addition to [LIBRARY_ELEMENT1] [LibraryElement.imports] and
+ * In addition to [LIBRARY_ELEMENT1] also [LibraryElement.imports] and
* [LibraryElement.exports] are set.
*
* The result is only available for [Source]s representing a library.
@@ -2228,6 +2228,7 @@ class ComputeLibraryCycleTask extends SourceBasedAnalysisTask {
* given [target].
*/
static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
+ // TODO(scheglov) Why the target is LibrarySpecificUnit?
Brian Wilkerson 2016/06/27 13:59:00 This is addressed by another CL.
LibrarySpecificUnit unit = target;
return <String, TaskInput>{
LIBRARY_ELEMENT_INPUT: LIBRARY_ELEMENT2.of(unit.library),
@@ -2548,25 +2549,32 @@ class DartDelta extends Delta {
if (target is Element) {
targetSource = target.source;
}
- // Keep results that are updated incrementally.
- // If we want to analyze only some references to the source being changed,
- // we need to keep the same instances of CompilationUnitElement and
- // LibraryElement.
+ // Keep results that don't change: any library.
+ if (_isTaskResult(BuildLibraryElementTask.DESCRIPTOR, descriptor) ||
+ _isTaskResult(BuildDirectiveElementsTask.DESCRIPTOR, descriptor) ||
+ _isTaskResult(ResolveDirectiveElementsTask.DESCRIPTOR, descriptor) ||
+ _isTaskResult(BuildEnumMemberElementsTask.DESCRIPTOR, descriptor) ||
+ _isTaskResult(BuildSourceExportClosureTask.DESCRIPTOR, descriptor) ||
+ _isTaskResult(ReadyLibraryElement2Task.DESCRIPTOR, descriptor) ||
+ _isTaskResult(ComputeLibraryCycleTask.DESCRIPTOR, descriptor)) {
+ return DeltaResult.KEEP_CONTINUE;
+ }
+ // Keep results that don't change: changed library.
if (targetSource == source) {
- if (ScanDartTask.DESCRIPTOR.results.contains(descriptor)) {
- return DeltaResult.KEEP_CONTINUE;
- }
- if (ParseDartTask.DESCRIPTOR.results.contains(descriptor)) {
- return DeltaResult.KEEP_CONTINUE;
- }
- if (BuildCompilationUnitElementTask.DESCRIPTOR.results
- .contains(descriptor)) {
+ if (_isTaskResult(ScanDartTask.DESCRIPTOR, descriptor) ||
+ _isTaskResult(ParseDartTask.DESCRIPTOR, descriptor) ||
+ _isTaskResult(
+ BuildCompilationUnitElementTask.DESCRIPTOR, descriptor) ||
+ _isTaskResult(BuildLibraryElementTask.DESCRIPTOR, descriptor)) {
return DeltaResult.KEEP_CONTINUE;
}
- if (BuildLibraryElementTask.DESCRIPTOR.results.contains(descriptor)) {
+ return DeltaResult.INVALIDATE;
+ }
+ // Keep results that don't change: dependent library.
+ if (targetSource != source) {
+ if (_isTaskResult(BuildPublicNamespaceTask.DESCRIPTOR, descriptor)) {
return DeltaResult.KEEP_CONTINUE;
}
- return DeltaResult.INVALIDATE;
}
// Use the target library dependency information to decide whether
// the delta affects the library.
@@ -2594,6 +2602,11 @@ class DartDelta extends Delta {
}
static bool _isPrivateName(String name) => name.startsWith('_');
+
+ static bool _isTaskResult(
+ TaskDescriptor taskDescriptor, ResultDescriptor result) {
+ return taskDescriptor.results.contains(result);
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698