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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/utilities/RequestUtilities.java

Issue 474193003: Make more use of generated code in Java analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/utilities/RequestUtilities.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/utilities/RequestUtilities.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/utilities/RequestUtilities.java
index d0df409b2e47a0e0aaf468ecb72262742ceadc91..16000d42ab7cfa1337a872ec9fc30feeeb93f694 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/utilities/RequestUtilities.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/utilities/RequestUtilities.java
@@ -14,12 +14,13 @@
package com.google.dart.server.internal.remote.utilities;
import com.google.common.annotations.VisibleForTesting;
-import com.google.dart.server.AnalysisOptions;
-import com.google.dart.server.AnalysisService;
-import com.google.dart.server.ContentChange;
import com.google.dart.server.Parameter;
+import com.google.dart.server.generated.types.AddContentOverlay;
import com.google.dart.server.generated.types.AnalysisError;
+import com.google.dart.server.generated.types.AnalysisOptions;
+import com.google.dart.server.generated.types.ChangeContentOverlay;
import com.google.dart.server.generated.types.Location;
+import com.google.dart.server.generated.types.RemoveContentOverlay;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -108,8 +109,6 @@ public class RequestUtilities {
String keyString;
if (key instanceof String) {
keyString = (String) key;
- } else if (key instanceof AnalysisService) {
- keyString = ((AnalysisService) key).name();
} else {
throw new IllegalArgumentException("Unable to convert to string: " + getClassName(key));
}
@@ -122,12 +121,16 @@ public class RequestUtilities {
}
}
return jsonObject;
- } else if (object instanceof ContentChange) {
- return buildJsonObjectContentChange((ContentChange) object);
} else if (object instanceof AnalysisError) {
return buildJsonObjectAnalysisError((AnalysisError) object);
+ } else if (object instanceof AddContentOverlay) {
+ return ((AddContentOverlay) object).toJson();
+ } else if (object instanceof ChangeContentOverlay) {
+ return ((ChangeContentOverlay) object).toJson();
+ } else if (object instanceof RemoveContentOverlay) {
+ return ((RemoveContentOverlay) object).toJson();
} else if (object instanceof AnalysisOptions) {
- return buildJsonObjectAnalysisOptions((AnalysisOptions) object);
+ return ((AnalysisOptions) object).toJson();
} else if (object instanceof Location) {
return buildJsonObjectLocation((Location) object);
}
@@ -243,7 +246,7 @@ public class RequestUtilities {
* </pre>
*/
public static JsonObject generateAnalysisSetSubscriptions(String id,
- Map<AnalysisService, List<String>> subscriptions) {
+ Map<String, List<String>> subscriptions) {
JsonObject params = new JsonObject();
params.add("subscriptions", buildJsonElement(subscriptions));
return buildJsonObjectRequest(id, METHOD_ANALYSIS_SET_SUBSCRIPTIONS, params);
@@ -262,8 +265,7 @@ public class RequestUtilities {
* }
* </pre>
*/
- public static JsonObject generateAnalysisUpdateContent(String idValue,
- Map<String, ContentChange> files) {
+ public static JsonObject generateAnalysisUpdateContent(String idValue, Map<String, Object> files) {
JsonObject params = new JsonObject();
params.add("files", buildJsonElement(files));
return buildJsonObjectRequest(idValue, METHOD_ANALYSIS_UPDATE_CONTENT, params);
@@ -678,51 +680,6 @@ public class RequestUtilities {
return errorJsonObject;
}
- private static JsonElement buildJsonObjectAnalysisOptions(AnalysisOptions options) {
- JsonObject optionsJsonObject = new JsonObject();
- Boolean analyzeAngular = options.getAnalyzeAngular();
- Boolean analyzePolymer = options.getAnalyzePolymer();
- Boolean enableAsync = options.getEnableAsync();
- Boolean enableDeferredLoading = options.getEnableDeferredLoading();
- Boolean enableEnums = options.getEnableEnums();
- Boolean generateDart2jsHints = options.getGenerateDart2jsHints();
- Boolean generateHints = options.getGenerateHints();
-
- if (analyzeAngular != null) {
- optionsJsonObject.addProperty("analyzeAngular", options.getAnalyzeAngular());
- }
- if (analyzePolymer != null) {
- optionsJsonObject.addProperty("analyzePolymer", options.getAnalyzePolymer());
- }
- if (enableAsync != null) {
- optionsJsonObject.addProperty("enableAsync", options.getEnableAsync());
- }
- if (enableDeferredLoading != null) {
- optionsJsonObject.addProperty("enableDeferredLoading", options.getEnableDeferredLoading());
- }
- if (enableEnums != null) {
- optionsJsonObject.addProperty("enableEnums", options.getEnableEnums());
- }
- if (generateDart2jsHints != null) {
- optionsJsonObject.addProperty("generateDart2jsHints", options.getGenerateDart2jsHints());
- }
- if (generateHints != null) {
- optionsJsonObject.addProperty("generateHints", options.getGenerateHints());
- }
- return optionsJsonObject;
- }
-
- private static JsonObject buildJsonObjectContentChange(ContentChange change) {
- JsonObject errorJsonObject = new JsonObject();
- errorJsonObject.addProperty("content", change.getContent());
- if (change.isIncremental()) {
- errorJsonObject.addProperty(OFFSET, change.getOffset());
- errorJsonObject.addProperty("oldLength", change.getOldLength());
- errorJsonObject.addProperty("newLength", change.getNewLength());
- }
- return errorJsonObject;
- }
-
private static JsonObject buildJsonObjectLocation(Location location) {
JsonObject locationJsonObject = new JsonObject();
locationJsonObject.addProperty("file", location.getFile());

Powered by Google App Engine
This is Rietveld 408576698