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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2455843002: Several tests for AnalysisDriver and an elements.dart tweak. (Closed)
Patch Set: Created 4 years, 2 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
Index: pkg/analyzer/lib/src/dart/analysis/driver.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 6c696b4a3ed74e24a86c0810cd7303599f306ae7..599d0c9eb6a32c699ea47260e007e973e858e608 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -242,9 +242,12 @@ class AnalysisDriver {
if (_requestedFiles.isNotEmpty) {
String path = _requestedFiles.keys.first;
AnalysisResult result = _computeAnalysisResult(path, withUnit: true);
+ // Notify the completers.
_requestedFiles.remove(path).forEach((completer) {
completer.complete(result);
});
+ // Remove from to be analyzed and produce it now.
+ _filesToAnalyze.remove(path);
yield result;
// Repeat the processing loop.
_hasWork.notify();
@@ -430,8 +433,9 @@ class AnalysisDriver {
try {
analysisContext.setContents(file.source, file.content);
// TODO(scheglov) Add support for parts.
- CompilationUnit resolvedUnit =
- analysisContext.resolveCompilationUnit2(file.source, file.source);
+ CompilationUnit resolvedUnit = withUnit
+ ? analysisContext.resolveCompilationUnit2(file.source, file.source)
+ : null;
List<AnalysisError> errors = analysisContext.computeErrors(file.source);
// Store the result into the cache.
@@ -450,10 +454,15 @@ class AnalysisDriver {
_byteStore.put(key, bytes);
}
- // Return the full result.
+ // Return the result, full or partial.
_logger.writeln('Computed new analysis result.');
- return new AnalysisResult(file.path, file.uri, file.content,
- file.contentHash, resolvedUnit, errors);
+ return new AnalysisResult(
+ file.path,
+ file.uri,
+ withUnit ? file.content : null,
+ file.contentHash,
+ resolvedUnit,
+ errors);
} finally {
analysisContext.dispose();
}
@@ -1151,7 +1160,7 @@ class _Monitor {
*/
void notify() {
if (!_completer.isCompleted) {
- _completer.complete(true);
+ _completer.complete(null);
}
}
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698