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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/TypeHierarchyItem.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/TypeHierarchyItem.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/TypeHierarchyItem.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/TypeHierarchyItem.java
index b7b05df45b97d45602ebfe3a66ef9dfce59fc55e..af1370e0a89b6a5ec77af1deb5b0c7d41229e205 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/TypeHierarchyItem.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/TypeHierarchyItem.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;
/**
@@ -58,30 +61,30 @@ public class TypeHierarchyItem {
* The index of the item representing the superclass of this class. This field will be omitted if
* this item represents the class Object.
*/
- private final int superclass;
+ private final Integer superclass;
/**
* The indexes of the items representing the interfaces implemented by this class. The list will be
* empty if there are no implemented interfaces.
*/
- private final int[] interfaces;
+ private final Integer[] interfaces;
/**
* The indexes of the items representing the mixins referenced by this class. The list will be
* empty if there are no classes mixed in to this class.
*/
- private final int[] mixins;
+ private final Integer[] mixins;
/**
* The indexes of the items representing the subtypes of this class. The list will be empty if
* there are no subtypes or if this item represents a supertype of the pivot type.
*/
- private final int[] subclasses;
+ private final Integer[] subclasses;
/**
* Constructor for {@link TypeHierarchyItem}.
*/
- public TypeHierarchyItem(Element classElement, String displayName, Element memberElement, int superclass, int[] interfaces, int[] mixins, int[] subclasses) {
+ public TypeHierarchyItem(Element classElement, String displayName, Element memberElement, Integer superclass, Integer[] interfaces, Integer[] mixins, Integer[] subclasses) {
this.classElement = classElement;
this.displayName = displayName;
this.memberElement = memberElement;
@@ -127,7 +130,7 @@ public class TypeHierarchyItem {
* The indexes of the items representing the interfaces implemented by this class. The list will be
* empty if there are no implemented interfaces.
*/
- public int[] getInterfaces() {
+ public Integer[] getInterfaces() {
return interfaces;
}
@@ -144,7 +147,7 @@ public class TypeHierarchyItem {
* The indexes of the items representing the mixins referenced by this class. The list will be
* empty if there are no classes mixed in to this class.
*/
- public int[] getMixins() {
+ public Integer[] getMixins() {
return mixins;
}
@@ -152,7 +155,7 @@ public class TypeHierarchyItem {
* The indexes of the items representing the subtypes of this class. The list will be empty if
* there are no subtypes or if this item represents a supertype of the pivot type.
*/
- public int[] getSubclasses() {
+ public Integer[] getSubclasses() {
return subclasses;
}
@@ -160,10 +163,45 @@ public class TypeHierarchyItem {
* The index of the item representing the superclass of this class. This field will be omitted if
* this item represents the class Object.
*/
- public int getSuperclass() {
+ public Integer getSuperclass() {
return superclass;
}
+ public JsonObject toJson() {
+ // Create a JsonObject
+ JsonObject jsonObject = new JsonObject();
+
+ // classElement
+ jsonObject.add("classElement", classElement.toJson());
+
+ // displayName
+ if (displayName != null) {
+ jsonObject.addProperty("displayName", displayName);
+ }
+
+ // memberElement
+ if (memberElement != null) {
+ jsonObject.add("memberElement", memberElement.toJson());
+ }
+
+ // superclass
+ if (superclass != null) {
+ jsonObject.addProperty("superclass", superclass);
+ }
+
+ // interfaces
+ // the type Object cannot be represented in JsonObject
+
+ // mixins
+ // the type Object cannot be represented in JsonObject
+
+ // subclasses
+ // the type Object cannot be represented in JsonObject
+
+ // Return the JsonObject
+ return jsonObject;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();

Powered by Google App Engine
This is Rietveld 408576698