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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Outline.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/Outline.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Outline.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Outline.java
index 8f09848a5d7f381d0c26758d834b0aacacc4dfa7..014ece6ce49566551d2361b992892f5a1397d218 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Outline.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Outline.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;
/**
@@ -45,12 +48,12 @@ public class Outline {
* Element, which if the offset of the name of the element. It can be used, for example, to map
* locations in the file back to an outline.
*/
- private final int offset;
+ private final Integer offset;
/**
* The length of the element.
*/
- private final int length;
+ private final Integer length;
/**
* The children of the node. The field will be omitted if the node has no children.
@@ -60,7 +63,7 @@ public class Outline {
/**
* Constructor for {@link Outline}.
*/
- public Outline(Element element, int offset, int length, List<Outline> children) {
+ public Outline(Element element, Integer offset, Integer length, List<Outline> children) {
this.element = element;
this.offset = offset;
this.length = length;
@@ -97,7 +100,7 @@ public class Outline {
/**
* The length of the element.
*/
- public int getLength() {
+ public Integer getLength() {
return length;
}
@@ -106,10 +109,30 @@ public class Outline {
* Element, which if the offset of the name of the element. It can be used, for example, to map
* locations in the file back to an outline.
*/
- public int getOffset() {
+ public Integer getOffset() {
return offset;
}
+ public JsonObject toJson() {
+ // Create a JsonObject
+ JsonObject jsonObject = new JsonObject();
+
+ // element
+ jsonObject.add("element", element.toJson());
+
+ // offset
+ jsonObject.addProperty("offset", offset);
+
+ // length
+ jsonObject.addProperty("length", length);
+
+ // children
+ // 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