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

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

Issue 544273003: Initial support for execution domain (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed formatting Created 6 years, 3 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 | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/lib/src/constants.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 2f40fb0e766223e5f014275ed714804fc09d2166..affbda459c11800154f7a61fefcb89ff96a82a0e 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -207,6 +207,11 @@ class AnalysisServer {
new HashMap<AnalysisContext, Completer<AnalysisDoneReason>>();
/**
+ * The listeners that are listening for lifecycle events from this server.
+ */
+ List<AnalysisServerListener> listeners = <AnalysisServerListener>[];
+
+ /**
* True if any exceptions thrown by analysis should be propagated up the call
* stack.
*/
@@ -327,6 +332,16 @@ class AnalysisServer {
}
/**
+ * Add the given [listener] to the list of listeners that are listening for
+ * lifecycle events from this server.
+ */
+ void addAnalysisServerListener(AnalysisServerListener listener) {
+ if (!listeners.contains(listener)) {
+ listeners.add(listener);
+ }
+ }
+
+ /**
* Adds the given [ServerOperation] to the queue, but does not schedule
* operations execution.
*/
@@ -408,6 +423,13 @@ class AnalysisServer {
}
/**
+ * Return `true` if analysis is complete.
+ */
+ bool isAnalysisComplete() {
+ return operationQueue.isEmpty;
+ }
+
+ /**
* Returns `true` if the given [AnalysisContext] is a priority one.
*/
bool isPriorityContext(AnalysisContext context) {
@@ -446,11 +468,20 @@ class AnalysisServer {
_schedulePerformOperation();
} else {
sendStatusNotification(null);
+ _notifyAnalysisComplete();
}
}
}
/**
+ * Remove the given [listener] from the list of listeners that are listening
+ * for lifecycle events from this server.
+ */
+ void removeAnalysisServerListener(AnalysisServerListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
* Send status notification to the client. The `operation` is the operation
* being performed or `null` if analysis is complete.
*/
@@ -582,6 +613,14 @@ class AnalysisServer {
}
/**
+ * Return the [AnalysisContext]s that are being used to analyze the analysis
+ * roots.
+ */
+ Iterable<AnalysisContext> getAnalysisContexts() {
+ return folderMap.values;
+ }
+
+ /**
* Return the [AnalysisContext] that is used to analyze the given [path].
* Return `null` if there is no such context.
*/
@@ -593,13 +632,11 @@ class AnalysisServer {
}
}
// check if there is a context that analyzed this source
- {
- Source source = getSource(path);
- for (AnalysisContext context in folderMap.values) {
- SourceKind kind = context.getKindOf(source);
- if (kind != null) {
- return context;
- }
+ Source source = getSource(path);
+ for (AnalysisContext context in folderMap.values) {
+ SourceKind kind = context.getKindOf(source);
+ if (kind != null) {
+ return context;
}
}
return null;
@@ -832,6 +869,15 @@ class AnalysisServer {
}
/**
+ * Notify all listeners that analysis is complete.
+ */
+ void _notifyAnalysisComplete() {
+ listeners.forEach((AnalysisServerListener listener) {
+ listener.analysisComplete();
+ });
+ }
+
+ /**
* Schedules [performOperation] exection.
*/
void _schedulePerformOperation() {
@@ -862,5 +908,14 @@ class AnalysisServer {
}
}
+/**
+ * An object that is listening for lifecycle events from an analysis server.
+ */
+abstract class AnalysisServerListener {
+ /**
+ * Analysis is complete.
+ */
+ void analysisComplete();
+}
typedef void OptionUpdater(AnalysisOptionsImpl options);
« no previous file with comments | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698