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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 2480843002: Support for Quick Assists with the new analysis driver. (Closed)
Patch Set: Created 4 years, 1 month 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/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index bf7ee7307c22c2c3404a14abec42a980a405a63a..5c73edf239025614800aa9382c38f4fbcf233696 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -322,6 +322,16 @@ class AnalysisServer {
ByteStore byteStore;
/**
+ * The set of the files that are currently priority.
+ */
+ final Set<String> priorityFiles = new Set<String>();
+
+ /**
+ * The cached results units for [priorityFiles].
+ */
+ final Map<String, nd.AnalysisResult> priorityFileResults = {};
+
+ /**
* Initialize a newly created server to receive requests from and send
* responses to the given [channel].
*
@@ -574,6 +584,18 @@ class AnalysisServer {
return null;
}
+ /**
+ * Return the analysis result for the file with the given [path].
+ */
+ Future<nd.AnalysisResult> getAnalysisResult(String path) async {
+ nd.AnalysisResult result = priorityFileResults[path];
+ if (result != null) {
+ return result;
+ }
+ nd.AnalysisDriver driver = getAnalysisDriver(path);
+ return driver.getResult(path);
+ }
+
CompilationUnitElement getCompilationUnitElement(String file) {
ContextSourcePair pair = getContextSourcePair(file);
if (pair == null) {
@@ -1231,6 +1253,13 @@ class AnalysisServer {
*/
void setPriorityFiles(String requestId, List<String> files) {
if (options.enableNewAnalysisDriver) {
+ // Flush results for files that are not priority anymore.
+ priorityFiles
+ .difference(files.toSet())
+ .forEach(priorityFileResults.remove);
+ priorityFiles.clear();
+ priorityFiles.addAll(files);
+ // Set priority files in drivers.
driverMap.values.forEach((driver) {
driver.priorityFiles = files;
});
@@ -1357,6 +1386,8 @@ class AnalysisServer {
void updateContent(String id, Map<String, dynamic> changes) {
if (options.enableNewAnalysisDriver) {
changes.forEach((file, change) {
+ priorityFileResults.remove(file);
+
// Prepare the new contents.
String oldContents = fileContentOverlay[file];
String newContents;
@@ -1728,6 +1759,9 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
// TODO(scheglov) send server status
});
analysisDriver.results.listen((result) {
+ if (analysisServer.priorityFiles.contains(result.path)) {
+ analysisServer.priorityFileResults[result.path] = result;
+ }
new_sendErrorNotification(analysisServer, result);
CompilationUnit unit = result.unit;
if (unit != null) {
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698