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

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

Issue 757613002: new onPriorityChanged event stream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix test Created 6 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 145c000d09a215624e9d7fcf452aafccd4a04233..fe370927919c770f5e6524f6f47b223e9ad275b7 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -163,6 +163,11 @@ class AnalysisServer {
StreamController<ChangeNotice> _onFileAnalyzedController;
/**
+ * The controller used to notify others when priority sources change.
+ */
+ StreamController<PriorityChangeEvent> _onPriorityChangeController;
+
+ /**
* True if any exceptions thrown by analysis should be propagated up the call
* stack.
*/
@@ -195,6 +200,8 @@ class AnalysisServer {
_onAnalysisStartedController = new StreamController.broadcast();
_onAnalysisCompleteController = new StreamController.broadcast();
_onFileAnalyzedController = new StreamController.broadcast();
+ _onPriorityChangeController =
+ new StreamController<PriorityChangeEvent>.broadcast();
running = true;
Notification notification = new ServerConnectedParams().toNotification();
channel.sendNotification(notification);
@@ -219,6 +226,12 @@ class AnalysisServer {
Stream get onFileAnalyzed => _onFileAnalyzedController.stream;
/**
+ * The stream that is notified when priority sources change.
+ */
+ Stream<PriorityChangeEvent> get onPriorityChange =>
+ _onPriorityChangeController.stream;
+
+ /**
* Adds the given [ServerOperation] to the queue, but does not schedule
* operations execution.
*/
@@ -346,23 +359,6 @@ class AnalysisServer {
return context.getErrors(source);
}
- /**
- * Returns resolved [AstNode]s at the given [offset] of the given [file].
- *
- * May be empty, but not `null`.
- */
- List<AstNode> getNodesAtOffset(String file, int offset) {
- List<CompilationUnit> units = getResolvedCompilationUnits(file);
- List<AstNode> nodes = <AstNode>[];
- for (CompilationUnit unit in units) {
- AstNode node = new NodeLocator.con1(offset).searchWithin(unit);
- if (node != null) {
- nodes.add(node);
- }
- }
- return nodes;
- }
-
// TODO(brianwilkerson) Add the following method after 'prioritySources' has
// been added to InternalAnalysisContext.
// /**
@@ -381,29 +377,20 @@ class AnalysisServer {
// }
/**
- * Returns resolved [CompilationUnit]s of the Dart file with the given [path].
+ * Returns resolved [AstNode]s at the given [offset] of the given [file].
*
* May be empty, but not `null`.
*/
- List<CompilationUnit> getResolvedCompilationUnits(String path) {
- List<CompilationUnit> units = <CompilationUnit>[];
- // prepare AnalysisContext
- AnalysisContext context = getAnalysisContext(path);
- if (context == null) {
- return units;
- }
- // add a unit for each unit/library combination
- Source unitSource = getSource(path);
- List<Source> librarySources = context.getLibrariesContaining(unitSource);
- for (Source librarySource in librarySources) {
- CompilationUnit unit =
- context.resolveCompilationUnit2(unitSource, librarySource);
- if (unit != null) {
- units.add(unit);
+ List<AstNode> getNodesAtOffset(String file, int offset) {
+ List<CompilationUnit> units = getResolvedCompilationUnits(file);
+ List<AstNode> nodes = <AstNode>[];
+ for (CompilationUnit unit in units) {
+ AstNode node = new NodeLocator.con1(offset).searchWithin(unit);
+ if (node != null) {
+ nodes.add(node);
}
}
- // done
- return units;
+ return nodes;
}
/**
@@ -434,6 +421,32 @@ class AnalysisServer {
}
/**
+ * Returns resolved [CompilationUnit]s of the Dart file with the given [path].
+ *
+ * May be empty, but not `null`.
+ */
+ List<CompilationUnit> getResolvedCompilationUnits(String path) {
+ List<CompilationUnit> units = <CompilationUnit>[];
+ // prepare AnalysisContext
+ AnalysisContext context = getAnalysisContext(path);
+ if (context == null) {
+ return units;
+ }
+ // add a unit for each unit/library combination
+ Source unitSource = getSource(path);
+ List<Source> librarySources = context.getLibrariesContaining(unitSource);
+ for (Source librarySource in librarySources) {
+ CompilationUnit unit =
+ context.resolveCompilationUnit2(unitSource, librarySource);
+ if (unit != null) {
+ units.add(unit);
+ }
+ }
+ // done
+ return units;
+ }
+
+ /**
* Return the [Source] of the Dart file with the given [path].
*/
Source getSource(String path) {
@@ -741,7 +754,7 @@ class AnalysisServer {
/**
* Set the priority files to the given [files].
*/
- void setPriorityFiles(Request request, List<String> files) {
+ void setPriorityFiles(String requestId, List<String> files) {
Map<AnalysisContext, List<Source>> sourceMap =
new HashMap<AnalysisContext, List<Source>>();
List<String> unanalyzed = new List<String>();
@@ -762,7 +775,7 @@ class AnalysisServer {
StringBuffer buffer = new StringBuffer();
buffer.writeAll(unanalyzed, ', ');
throw new RequestFailure(
- new Response.unanalyzedPriorityFiles(request, buffer.toString()));
+ new Response.unanalyzedPriorityFiles(requestId, buffer.toString()));
}
folderMap.forEach((Folder folder, AnalysisContext context) {
List<Source> sourceList = sourceMap[context];
@@ -771,6 +784,8 @@ class AnalysisServer {
}
context.analysisPriorityOrder = sourceList;
});
+ Source firstSource = files.length > 0 ? getSource(files[0]) : null;
+ _onPriorityChangeController.add(new PriorityChangeEvent(firstSource));
}
/**
@@ -926,6 +941,16 @@ class ContextsChangedEvent {
AnalysisContext.EMPTY_LIST, this.removed: AnalysisContext.EMPTY_LIST});
}
+/**
+ * A [PriorityChangeEvent] indicates which sources are currently prioritized
Brian Wilkerson 2014/11/24 16:17:11 I think it indicates that the list of priority cha
danrubel 2014/11/24 17:54:06 Cleaned up.
+ * and should be analyzed before other sources.
+ */
+class PriorityChangeEvent {
+ final Source firstSource;
Brian Wilkerson 2014/11/24 16:17:11 Shouldn't this be a List<Source>? Or possibly a Ma
danrubel 2014/11/24 17:54:05 I only need the first source if there is one and I
Brian Wilkerson 2014/11/24 18:14:38 Understood, and in general I agree with only doing
+
+ PriorityChangeEvent(this.firstSource);
+}
+
class ServerContextManager extends ContextManager {
final AnalysisServer analysisServer;
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698