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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/processor/NotificationAnalysisOccurrencesProcessor.java

Issue 474193003: Make more use of generated code in Java analysis server. (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/internal/remote/processor/NotificationAnalysisOccurrencesProcessor.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/processor/NotificationAnalysisOccurrencesProcessor.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/processor/NotificationAnalysisOccurrencesProcessor.java
index 8d17c7a8cf08b3d8b55e2a64f6b64626ceac9fab..57c5305b8c7ade1607d25ca63170537e304eabdd 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/processor/NotificationAnalysisOccurrencesProcessor.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/remote/processor/NotificationAnalysisOccurrencesProcessor.java
@@ -13,16 +13,11 @@
*/
package com.google.dart.server.internal.remote.processor;
-import com.google.common.collect.Lists;
import com.google.dart.server.AnalysisServerListener;
-import com.google.dart.server.Occurrences;
-import com.google.dart.server.generated.types.Element;
-import com.google.dart.server.internal.OccurrencesImpl;
+import com.google.dart.server.generated.types.Occurrences;
import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import java.util.Iterator;
import java.util.List;
/**
@@ -44,23 +39,10 @@ public class NotificationAnalysisOccurrencesProcessor extends NotificationProces
JsonObject paramsObject = response.get("params").getAsJsonObject();
String file = paramsObject.get("file").getAsString();
JsonArray occurrencesJsonArray = paramsObject.get("occurrences").getAsJsonArray();
- // compute occurrences and notify listener
- getListener().computedOccurrences(file, constructOccurrencesArray(occurrencesJsonArray));
- }
-
- private Occurrences[] constructOccurrencesArray(JsonArray occurrencesJsonArray) {
- Iterator<JsonElement> occurrencesIterator = occurrencesJsonArray.iterator();
- List<Occurrences> occurrencesList = Lists.newArrayList();
- while (occurrencesIterator.hasNext()) {
- JsonObject occurrencesObject = occurrencesIterator.next().getAsJsonObject();
- JsonObject elementObject = occurrencesObject.get("element").getAsJsonObject();
- Element element = constructElement(elementObject);
- int length = occurrencesObject.get("length").getAsInt();
- int[] offsets = constructIntArray(occurrencesObject.get("offsets").getAsJsonArray());
- occurrencesList.add(new OccurrencesImpl(element, length, offsets));
- }
-
- // create outline object
- return occurrencesList.toArray(new Occurrences[occurrencesList.size()]);
+ // construct occurrences and notify listener
+ List<Occurrences> occurrencesList = Occurrences.fromJsonArray(occurrencesJsonArray);
+ getListener().computedOccurrences(
+ file,
+ occurrencesList.toArray(new Occurrences[occurrencesList.size()]));
}
}

Powered by Google App Engine
This is Rietveld 408576698