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

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

Issue 214933002: Clean-up and progress on analysis server (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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/lib/src/channel.dart ('k') | pkg/analysis_server/lib/src/get_handler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/domain_context.dart
diff --git a/pkg/analysis_server/lib/src/domain_context.dart b/pkg/analysis_server/lib/src/domain_context.dart
index acadd6fabdf721b1067250ff0c010d1b174a2472..0fc87591bde79f9c334c3a52885e73bbea201359 100644
--- a/pkg/analysis_server/lib/src/domain_context.dart
+++ b/pkg/analysis_server/lib/src/domain_context.dart
@@ -20,6 +20,11 @@ class ContextDomainHandler implements RequestHandler {
static const String APPLY_CHANGES_NAME = 'context.applyChanges';
/**
+ * The name of the context.getFixes request.
+ */
+ static const String GET_FIXES_NAME = 'context.getFixes';
+
+ /**
* The name of the context.setOptions request.
*/
static const String SET_OPTIONS_NAME = 'context.setOptions';
@@ -30,6 +35,11 @@ class ContextDomainHandler implements RequestHandler {
static const String SET_PRIORITY_SOURCES_NAME = 'context.setPrioritySources';
/**
+ * The name of the added parameter.
+ */
+ static const String ADDED_PARAM = "added";
+
+ /**
* The name of the changes parameter.
*/
static const String CHANGES_PARAM = 'changes';
@@ -40,11 +50,21 @@ class ContextDomainHandler implements RequestHandler {
static const String CONTEXT_ID_PARAM = 'contextId';
/**
+ * The name of the modified parameter.
+ */
+ static const String MODIFIED_PARAM = "modified";
+
+ /**
* The name of the options parameter.
*/
static const String OPTIONS_PARAM = 'options';
/**
+ * The name of the removed parameter.
+ */
+ static const String REMOVED_PARAM = "removed";
+
+ /**
* The name of the sources parameter.
*/
static const String SOURCES_PARAM = 'sources';
@@ -95,6 +115,8 @@ class ContextDomainHandler implements RequestHandler {
String requestName = request.method;
if (requestName == APPLY_CHANGES_NAME) {
return applyChanges(request);
+ } else if (requestName == GET_FIXES_NAME) {
+ return getFixes(request);
} else if (requestName == SET_OPTIONS_NAME) {
return setOptions(request);
} else if (requestName == SET_PRIORITY_SOURCES_NAME) {
@@ -114,7 +136,10 @@ class ContextDomainHandler implements RequestHandler {
Response applyChanges(Request request) {
AnalysisContext context = getAnalysisContext(request);
Map<String, Object> changesData = request.getRequiredParameter(CHANGES_PARAM);
- ChangeSet changeSet = createChangeSet(changesData);
+ ChangeSet changeSet = createChangeSet(
+ request,
+ context.sourceFactory,
+ changesData);
context.applyChanges(changeSet);
Response response = new Response(request.id);
@@ -122,11 +147,44 @@ class ContextDomainHandler implements RequestHandler {
}
/**
- * Convert the given JSON object into a [ChangeSet].
+ * Convert the given JSON object into a [ChangeSet], using the given
+ * [sourceFactory] to convert the embedded strings into sources.
+ */
+ ChangeSet createChangeSet(Request request, SourceFactory sourceFactory, Map<String, Object> jsonData) {
+ ChangeSet changeSet = new ChangeSet();
+ convertSources(request, sourceFactory, jsonData[ADDED_PARAM], (Source source) {
+ changeSet.addedSource(source);
+ });
+ convertSources(request, sourceFactory, jsonData[MODIFIED_PARAM], (Source source) {
+ changeSet.changedSource(source);
+ });
+ convertSources(request, sourceFactory, jsonData[REMOVED_PARAM], (Source source) {
+ changeSet.removedSource(source);
+ });
+ return changeSet;
+ }
+
+ /**
+ * If the given [sources] is a list of strings, use the given [sourceFactory]
+ * to convert each string into a source and pass the source to the given
+ * [handler]. Otherwise, throw an exception indicating that the data in the
+ * request was not valid.
*/
- ChangeSet createChangeSet(Map<String, Object> jsonData) {
+ void convertSources(Request request, SourceFactory sourceFactory, Object sources, void handler(Source source)) {
+ if (sources is! List<String>) {
+ throw new RequestFailure(new Response(request.id, new RequestError(1, 'Invalid sources')));
+ }
+ convertToSources(sourceFactory, sources).forEach(handler);
+ }
+
+ /**
+ * Return the list of fixes that are available for problems related to the
+ * given error in the specified context.
+ */
+ Response getFixes(Request request) {
// TODO(brianwilkerson) Implement this.
- return new ChangeSet();
+ Response response = new Response(request.id);
+ return response;
}
/**
« no previous file with comments | « pkg/analysis_server/lib/src/channel.dart ('k') | pkg/analysis_server/lib/src/get_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698