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

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

Issue 332993006: Implemented analysis.setPrioritySource (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 6 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
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 c6086ace2a4a8ae9167795faa9f5938bd6732308..d9ede460d01115e9772c932644228848a8e77ea9 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -147,6 +147,17 @@ class AnalysisServer {
}
/**
+ * Schedules execution of the given [ServerOperation].
+ */
+ void scheduleOperation(ServerOperation operation) {
+ bool wasEmpty = operationQueue.isEmpty;
+ addOperation(operation);
+ if (wasEmpty) {
+ _schedulePerformOperation();
+ }
+ }
+
+ /**
* Schedules analysis of the given context.
*/
void schedulePerformAnalysisOperation(AnalysisContext context) {
@@ -154,14 +165,46 @@ class AnalysisServer {
}
/**
- * Schedules execution of the given [ServerOperation].
+ * Send the given [notification] to the client.
*/
- void scheduleOperation(ServerOperation operation) {
- bool wasEmpty = operationQueue.isEmpty;
- addOperation(operation);
- if (wasEmpty) {
- _schedulePerformOperation();
+ void sendNotification(Notification notification) {
+ channel.sendNotification(notification);
+ }
+
+ /**
+ * Set the priority files to the given [files].
+ */
+ void setPriorityFiles(Request request, List<String> files) {
+ Map<AnalysisContext, List<Source>> sourceMap =
+ new HashMap<AnalysisContext, List<Source>>();
+ List<String> unanalyzed = new List<String>();
+ files.forEach((file) {
+ AnalysisContext analysisContext = _getAnalysisContext(file);
+ if (analysisContext == null) {
+ unanalyzed.add(file);
+ } else {
+ List<Source> sourceList = sourceMap[analysisContext];
+ if (sourceList == null) {
+ sourceList = <Source>[];
+ sourceMap[analysisContext] = sourceList;
+ }
+ sourceList.add(_getSource(file));
+ }
+ });
+ if (unanalyzed.isNotEmpty) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.writeAll(unanalyzed, ', ');
+ throw new RequestFailure(new Response.unanalyzedPriorityFiles(request,
+ buffer.toString()));
}
+ folderMap.forEach((Folder folder, ContextDirectory directory) {
+ AnalysisContext context = directory.context;
+ List<Source> sourceList = sourceMap[context];
+ if (sourceList == null) {
+ sourceList = Source.EMPTY_ARRAY;
+ }
+ context.analysisPriorityOrder = sourceList;
+ });
}
/**
@@ -187,6 +230,23 @@ class AnalysisServer {
running = false;
}
+// TODO(brianwilkerson) Add the following method after 'prioritySources' has
+// been added to InternalAnalysisContext.
+// /**
+// * Return a list containing the full names of all of the sources that are
+// * priority sources.
+// */
+// List<String> getPriorityFiles() {
+// List<String> priorityFiles = new List<String>();
+// folderMap.values.forEach((ContextDirectory directory) {
+// InternalAnalysisContext context = directory.context;
+// context.prioritySources.forEach((Source source) {
+// priorityFiles.add(source.fullName);
+// });
+// });
+// return priorityFiles;
+// }
+
/**
* Handle a [request] that was read from the communication channel.
*/
@@ -411,13 +471,6 @@ class AnalysisServer {
}
/**
- * Send the given [notification] to the client.
- */
- void sendNotification(Notification notification) {
- channel.sendNotification(notification);
- }
-
- /**
* Schedules [performOperation] exection.
*/
void _schedulePerformOperation() {

Powered by Google App Engine
This is Rietveld 408576698