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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceEdit.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/SourceEdit.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceEdit.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceEdit.java
index a2a3699cd88c0b0520657a731e005b7b7c84ab44..d7141c38fd9462fe67d3fa8a1d908d6e127d9f4b 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceEdit.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceEdit.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;
/**
@@ -38,12 +41,12 @@ public class SourceEdit {
/**
* The offset of the region to be modified.
*/
- private final int offset;
+ private final Integer offset;
/**
* The length of the region to be modified.
*/
- private final int length;
+ private final Integer length;
/**
* The code that is to replace the specified region in the original code.
@@ -64,7 +67,7 @@ public class SourceEdit {
/**
* Constructor for {@link SourceEdit}.
*/
- public SourceEdit(int offset, int length, String replacement, String id) {
+ public SourceEdit(Integer offset, Integer length, String replacement, String id) {
this.offset = offset;
this.length = length;
this.replacement = replacement;
@@ -100,14 +103,14 @@ public class SourceEdit {
/**
* The length of the region to be modified.
*/
- public int getLength() {
+ public Integer getLength() {
return length;
}
/**
* The offset of the region to be modified.
*/
- public int getOffset() {
+ public Integer getOffset() {
return offset;
}
@@ -118,6 +121,28 @@ public class SourceEdit {
return replacement;
}
+ public JsonObject toJson() {
+ // Create a JsonObject
+ JsonObject jsonObject = new JsonObject();
+
+ // offset
+ jsonObject.addProperty("offset", offset);
+
+ // length
+ jsonObject.addProperty("length", length);
+
+ // replacement
+ jsonObject.addProperty("replacement", replacement);
+
+ // id
+ if (id != null) {
+ jsonObject.addProperty("id", id);
+ }
+
+ // Return the JsonObject
+ return jsonObject;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();

Powered by Google App Engine
This is Rietveld 408576698