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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Element.java

Issue 485213004: Generate a toJson method onto our generated types, int is now represented as the wrapped Integer in… (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/generated/types/Element.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Element.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Element.java
index bfd72fcf75f06e8a579480b17f91c8d7cf4b661e..5a2d19f6690cab6bffc96edc4ad5d926a7a4c1cc 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Element.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Element.java
@@ -20,6 +20,9 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import com.google.dart.server.utilities.general.ObjectUtilities;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
import org.apache.commons.lang3.StringUtils;
/**
@@ -72,7 +75,7 @@ public class Element {
* - 0x10 - set if the element is private
* - 0x20 - set if the element is deprecated
*/
- private final int flags;
+ private final Integer flags;
/**
* The parameter list for the element. If the element is not a method or function this field will
@@ -90,7 +93,7 @@ public class Element {
/**
* Constructor for {@link Element}.
*/
- public Element(String kind, String name, Location location, int flags, String parameters, String returnType) {
+ public Element(String kind, String name, Location location, Integer flags, String parameters, String returnType) {
this.kind = kind;
this.name = name;
this.location = location;
@@ -124,7 +127,7 @@ public class Element {
* - 0x10 - set if the element is private
* - 0x20 - set if the element is deprecated
*/
- public int getFlags() {
+ public Integer getFlags() {
return flags;
}
@@ -190,6 +193,38 @@ public class Element {
return (flags & TOP_LEVEL_STATIC) != 0;
}
+ public JsonObject toJson() {
+ // Create a JsonObject
+ JsonObject jsonObject = new JsonObject();
+
+ // kind
+ jsonObject.addProperty("kind", kind);
+
+ // name
+ jsonObject.addProperty("name", name);
+
+ // location
+ if (location != null) {
+ jsonObject.add("location", location.toJson());
+ }
+
+ // flags
+ jsonObject.addProperty("flags", flags);
+
+ // parameters
+ if (parameters != null) {
+ jsonObject.addProperty("parameters", parameters);
+ }
+
+ // returnType
+ if (returnType != null) {
+ jsonObject.addProperty("returnType", returnType);
+ }
+
+ // Return the JsonObject
+ return jsonObject;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();

Powered by Google App Engine
This is Rietveld 408576698