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

Unified Diff: pkg/analyzer_plugin/lib/plugin/plugin.dart

Issue 2861373005: Improve default support provided for plugins (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | pkg/analyzer_plugin/lib/protocol/protocol.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_plugin/lib/plugin/plugin.dart
diff --git a/pkg/analyzer_plugin/lib/plugin/plugin.dart b/pkg/analyzer_plugin/lib/plugin/plugin.dart
index a6475ff41bd8559834040c0dbf71c835723a57f3..405ea038be3093a0101460ee23d4442960b21ab6 100644
--- a/pkg/analyzer_plugin/lib/plugin/plugin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/plugin.dart
@@ -178,15 +178,58 @@ abstract class ServerPlugin {
* Handle an 'analysis.handleWatchEvents' request.
*/
AnalysisHandleWatchEventsResult handleAnalysisHandleWatchEvents(
- AnalysisHandleWatchEventsParams parameters) =>
- null;
+ AnalysisHandleWatchEventsParams parameters) {
+ for (WatchEvent event in parameters.events) {
+ switch (event.type) {
+ case WatchEventType.ADD:
+ // TODO(brianwilkerson) Handle the event.
+ break;
+ case WatchEventType.MODIFY:
+ contentChanged(event.path);
+ break;
+ case WatchEventType.REMOVE:
+ // TODO(brianwilkerson) Handle the event.
+ break;
+ default:
+ // Ignore unhandled watch event types.
+ break;
+ }
+ }
+ return new AnalysisHandleWatchEventsResult();
+ }
/**
* Handle an 'analysis.reanalyze' request.
*/
AnalysisReanalyzeResult handleAnalysisReanalyze(
- AnalysisReanalyzeParams parameters) =>
- null;
+ AnalysisReanalyzeParams parameters) {
+ var rootPaths = parameters.roots;
+ if (rootPaths == null) {
+ //
+ // Reanalyze everything.
+ //
+ List<ContextRoot> roots = driverMap.keys.toList();
+ for (ContextRoot contextRoot in roots) {
scheglov 2017/05/08 16:45:43 Do we want to handle this as "reanalyze contexts"
Brian Wilkerson 2017/05/08 17:01:10 Interesting question. My intuition is that (a) cha
+ AnalysisDriverGeneric driver = driverMap[contextRoot];
+ driver.dispose();
+ driver = createAnalysisDriver(contextRoot);
+ driverMap[contextRoot] = driver;
+ }
+ return new AnalysisReanalyzeResult();
+ } else {
+ //
+ // Reanalyze a specific set of files.
+ //
+ // TODO(brianwilkerson) There is no API for telling a driver that we need
+ // to have some files reanalyzed.
+// for (String rootPath in rootPaths) {
+// ContextRoot contextRoot = contextRootContaining(rootPath);
+// AnalysisDriverGeneric driver = driverMap[contextRoot];
+// driver.reanalyze(rootPath);
+// }
+ return null;
+ }
+ }
/**
* Handle an 'analysis.setContextBuilderOptions' request.
@@ -250,8 +293,9 @@ abstract class ServerPlugin {
AnalysisSetSubscriptionsResult handleAnalysisSetSubscriptions(
AnalysisSetSubscriptionsParams parameters) {
Map<AnalysisService, List<String>> subscriptions = parameters.subscriptions;
- subscriptionManager.setSubscriptions(subscriptions);
- // TODO(brianwilkerson) Cause any newly subscribed for notifications to be sent.
+ Map<String, List<AnalysisService>> newSubscriptions =
+ subscriptionManager.setSubscriptions(subscriptions);
+ sendNotificationsForSubscriptions(newSubscriptions);
return new AnalysisSetSubscriptionsResult();
}
@@ -276,16 +320,14 @@ abstract class ServerPlugin {
if (oldContents == null) {
// The server should only send a ChangeContentOverlay if there is
// already an existing overlay for the source.
- throw new RequestFailure(new RequestError(
- RequestErrorCode.INVALID_OVERLAY_CHANGE,
- 'Invalid overlay change: no content to change'));
+ throw new RequestFailure(
+ RequestErrorFactory.invalidOverlayChangeNoContent());
}
try {
newContents = SourceEdit.applySequence(oldContents, overlay.edits);
} on RangeError {
- throw new RequestFailure(new RequestError(
- RequestErrorCode.INVALID_OVERLAY_CHANGE,
- 'Invalid overlay change: invalid edit'));
+ throw new RequestFailure(
+ RequestErrorFactory.invalidOverlayChangeInvalidEdit());
}
fileContentOverlay[fileName] = newContents;
} else if (overlay is RemoveContentOverlay) {
@@ -377,6 +419,15 @@ abstract class ServerPlugin {
void onError(Object exception, StackTrace stackTrace) {}
/**
+ * Send notifications corresponding to the given description of subscriptions.
+ * The map is keyed by the path of each file for which notifications should be
+ * send and has values representing the list of services associated with the
+ * notifications to send.
+ */
+ void sendNotificationsForSubscriptions(
+ Map<String, List<AnalysisService>> subscriptions);
+
+ /**
* Start this plugin by listening to the given communication [channel].
*/
void start(PluginCommunicationChannel channel) {
« no previous file with comments | « no previous file | pkg/analyzer_plugin/lib/protocol/protocol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698