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

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

Issue 515953002: Fixes in the Outline type generation and some cleanup in codegen_java_types.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: review 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
« no previous file with comments | « no previous file | pkg/analysis_server/tool/spec/codegen_java_types.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c917001e0a1140846576125d2e9282fea17dd78c..816c37953360d7f6e9780c0b2591fdb578aad30f 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
@@ -60,19 +60,18 @@ public class Outline {
*/
private final Integer length;
- /**
- * The children of the node. The field will be omitted if the node has no children.
- */
- private final List<Outline> children;
+ private final Outline parent;
+
+ private List<Outline> children;
/**
* Constructor for {@link Outline}.
*/
- public Outline(Element element, Integer offset, Integer length, List<Outline> children) {
+ public Outline(Outline parent, Element element, Integer offset, Integer length) {
+ this.parent = parent;
this.element = element;
this.offset = offset;
this.length = length;
- this.children = children;
}
public boolean containsInclusive(int x) {
@@ -92,25 +91,28 @@ public class Outline {
return false;
}
- public static Outline fromJson(JsonObject jsonObject) {
- Element element = Element.fromJson(jsonObject.get("element").getAsJsonObject());
- Integer offset = jsonObject.get("offset").getAsInt();
- Integer length = jsonObject.get("length").getAsInt();
- List<Outline> children = jsonObject.get("children") == null ? null : Outline.fromJsonArray(jsonObject.get("children").getAsJsonArray());
- return new Outline(element, offset, length, children);
- }
-
- public static List<Outline> fromJsonArray(JsonArray jsonArray) {
- if (jsonArray == null) {
- return EMPTY_LIST;
- }
- ArrayList<Outline> list = new ArrayList<Outline>(jsonArray.size());
- Iterator<JsonElement> iterator = jsonArray.iterator();
- while (iterator.hasNext()) {
- list.add(fromJson(iterator.next().getAsJsonObject()));
+ private Outline fromJson(Outline parent, JsonObject outlineObject) {
+ JsonObject elementObject = outlineObject.get("element").getAsJsonObject();
+ Element element = Element.fromJson(elementObject);
+ int offset = outlineObject.get("offset").getAsInt();
+ int length = outlineObject.get("length").getAsInt();
+
+ // create outline object
+ Outline outline = new Outline(parent, element, offset, length);
+
+ // compute children recursively
+ List<Outline> childrenList = Lists.newArrayList();
+ JsonElement childrenJsonArray = outlineObject.get("children");
+ if (childrenJsonArray instanceof JsonArray) {
+ Iterator<JsonElement> childrenElementIterator = ((JsonArray) childrenJsonArray).iterator();
+ while (childrenElementIterator.hasNext()) {
+ JsonObject childObject = childrenElementIterator.next().getAsJsonObject();
+ childrenList.add(fromJson(outline, childObject));
+ }
+ }
+ outline.setChildren(childrenList);
+ return outline;
}
- return list;
- }
/**
* The children of the node. The field will be omitted if the node has no children.
@@ -152,20 +154,9 @@ public class Outline {
return builder.toHashCode();
}
- public JsonObject toJson() {
- JsonObject jsonObject = new JsonObject();
- jsonObject.add("element", element.toJson());
- jsonObject.addProperty("offset", offset);
- jsonObject.addProperty("length", length);
- if (children != null) {
- JsonArray jsonArrayChildren = new JsonArray();
- for(Outline elt : children) {
- jsonArrayChildren.add(elt.toJson());
- }
- jsonObject.add("children", jsonArrayChildren);
+ public void setChildren(List<Outline> children) {
+ this.children = children;
}
- return jsonObject;
- }
@Override
public String toString() {
« no previous file with comments | « no previous file | pkg/analysis_server/tool/spec/codegen_java_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698