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

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

Issue 766323002: Compressed/optimized navigation notification. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updates for review comments. Created 6 years 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 | editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/NavigationTarget.java » ('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/NavigationRegion.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/NavigationRegion.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/NavigationRegion.java
index 8da8dbafe01681c939c221db98da99c1250999fb..a968156fc87410df4703e73d4034c19ceafd6e9e 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/NavigationRegion.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/NavigationRegion.java
@@ -54,15 +54,17 @@ public class NavigationRegion {
private final int length;
/**
- * The elements to which the given region is bound. By opening the declaration of the elements,
- * clients can implement one form of navigation.
+ * The indexes of the targets (in the enclosing navigation response) to which the given region is
+ * bound. By opening the target, clients can implement one form of navigation.
*/
- private final List<Element> targets;
+ private final int[] targets;
+
+ private final List<NavigationTarget> targetObjects = Lists.newArrayList();
/**
* Constructor for {@link NavigationRegion}.
*/
- public NavigationRegion(int offset, int length, List<Element> targets) {
+ public NavigationRegion(int offset, int length, int[] targets) {
this.offset = offset;
this.length = length;
this.targets = targets;
@@ -79,7 +81,7 @@ public class NavigationRegion {
return
other.offset == offset &&
other.length == length &&
- ObjectUtilities.equals(other.targets, targets);
+ Arrays.equals(other.targets, targets);
}
return false;
}
@@ -87,7 +89,7 @@ public class NavigationRegion {
public static NavigationRegion fromJson(JsonObject jsonObject) {
int offset = jsonObject.get("offset").getAsInt();
int length = jsonObject.get("length").getAsInt();
- List<Element> targets = Element.fromJsonArray(jsonObject.get("targets").getAsJsonArray());
+ int[] targets = JsonUtilities.decodeIntArray(jsonObject.get("targets").getAsJsonArray());
return new NavigationRegion(offset, length, targets);
}
@@ -103,6 +105,10 @@ public class NavigationRegion {
return list;
}
+ public List<NavigationTarget> getTargetObjects() {
+ return targetObjects;
+ }
+
/**
* The length of the region from which the user can navigate.
*/
@@ -118,10 +124,10 @@ public class NavigationRegion {
}
/**
- * The elements to which the given region is bound. By opening the declaration of the elements,
- * clients can implement one form of navigation.
+ * The indexes of the targets (in the enclosing navigation response) to which the given region is
+ * bound. By opening the target, clients can implement one form of navigation.
*/
- public List<Element> getTargets() {
+ public int[] getTargets() {
return targets;
}
@@ -134,13 +140,21 @@ public class NavigationRegion {
return builder.toHashCode();
}
+ public void lookupTargets(List<NavigationTarget> allTargets) {
+ for (int i = 0; i < targets.length; i++) {
+ int targetIndex = targets[i];
+ NavigationTarget target = allTargets.get(targetIndex);
+ targetObjects.add(target);
+ }
+ }
+
public JsonObject toJson() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("offset", offset);
jsonObject.addProperty("length", length);
JsonArray jsonArrayTargets = new JsonArray();
- for (Element elt : targets) {
- jsonArrayTargets.add(elt.toJson());
+ for (int elt : targets) {
+ jsonArrayTargets.add(new JsonPrimitive(elt));
}
jsonObject.add("targets", jsonArrayTargets);
return jsonObject;
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/NavigationTarget.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698