| Index: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/ExtractLocalVariableFeedback.java
|
| diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Occurrences.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/ExtractLocalVariableFeedback.java
|
| similarity index 50%
|
| copy from editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Occurrences.java
|
| copy to editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/ExtractLocalVariableFeedback.java
|
| index ca01d7c905e940b08bff08f007e579f5810c95c2..df19546dcc3abf882abe3671268ba5c11af68992 100644
|
| --- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/Occurrences.java
|
| +++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/ExtractLocalVariableFeedback.java
|
| @@ -32,74 +32,65 @@ import java.util.Iterator;
|
| import org.apache.commons.lang3.StringUtils;
|
|
|
| /**
|
| - * A description of the references to a single element within a single file.
|
| - *
|
| * @coverage dart.server.generated.types
|
| */
|
| @SuppressWarnings("unused")
|
| -public class Occurrences {
|
| +public class ExtractLocalVariableFeedback {
|
|
|
| - public static final Occurrences[] EMPTY_ARRAY = new Occurrences[0];
|
| + public static final ExtractLocalVariableFeedback[] EMPTY_ARRAY = new ExtractLocalVariableFeedback[0];
|
|
|
| - public static final List<Occurrences> EMPTY_LIST = Lists.newArrayList();
|
| + public static final List<ExtractLocalVariableFeedback> EMPTY_LIST = Lists.newArrayList();
|
|
|
| /**
|
| - * The element that was referenced.
|
| + * The proposed names for the local variable.
|
| */
|
| - private final Element element;
|
| + private final List<String> names;
|
|
|
| /**
|
| - * The offsets of the name of the referenced element within the file.
|
| + * The offsets of the expressions that would be replaced by a reference to the variable.
|
| */
|
| private final Integer[] offsets;
|
|
|
| /**
|
| - * The length of the name of the referenced element.
|
| + * The lengths of the expressions that would be replaced by a reference to the variable. The
|
| + * lengths correspond to the offsets. In other words, for a given expression, if the offset of that
|
| + * expression is offsets[i], then the length of that expression is lengths[i].
|
| */
|
| - private final Integer length;
|
| + private final Integer[] lengths;
|
|
|
| /**
|
| - * Constructor for {@link Occurrences}.
|
| + * Constructor for {@link ExtractLocalVariableFeedback}.
|
| */
|
| - public Occurrences(Element element, Integer[] offsets, Integer length) {
|
| - this.element = element;
|
| + public ExtractLocalVariableFeedback(List<String> names, Integer[] offsets, Integer[] lengths) {
|
| + this.names = names;
|
| this.offsets = offsets;
|
| - this.length = length;
|
| - }
|
| -
|
| - public boolean contains(int x) {
|
| - for (int offset : offsets) {
|
| - if (offset <= x && x < offset + length) {
|
| - return true;
|
| - }
|
| - }
|
| - return false;
|
| + this.lengths = lengths;
|
| }
|
|
|
| @Override
|
| public boolean equals(Object obj) {
|
| - if (obj instanceof Occurrences) {
|
| - Occurrences other = (Occurrences) obj;
|
| + if (obj instanceof ExtractLocalVariableFeedback) {
|
| + ExtractLocalVariableFeedback other = (ExtractLocalVariableFeedback) obj;
|
| return
|
| - ObjectUtilities.equals(other.element, element) &&
|
| + ObjectUtilities.equals(other.names, names) &&
|
| Arrays.equals(other.offsets, offsets) &&
|
| - other.length == length;
|
| + Arrays.equals(other.lengths, lengths);
|
| }
|
| return false;
|
| }
|
|
|
| - public static Occurrences fromJson(JsonObject jsonObject) {
|
| - Element element = Element.fromJson(jsonObject.get("element").getAsJsonObject());
|
| + public static ExtractLocalVariableFeedback fromJson(JsonObject jsonObject) {
|
| + List<String> names = JsonUtilities.decodeStringList(jsonObject.get("names").getAsJsonArray());
|
| Integer[] offsets = JsonUtilities.decodeIntegerArray(jsonObject.get("offsets").getAsJsonArray());
|
| - Integer length = jsonObject.get("length").getAsInt();
|
| - return new Occurrences(element, offsets, length);
|
| + Integer[] lengths = JsonUtilities.decodeIntegerArray(jsonObject.get("lengths").getAsJsonArray());
|
| + return new ExtractLocalVariableFeedback(names, offsets, lengths);
|
| }
|
|
|
| - public static List<Occurrences> fromJsonArray(JsonArray jsonArray) {
|
| + public static List<ExtractLocalVariableFeedback> fromJsonArray(JsonArray jsonArray) {
|
| if (jsonArray == null) {
|
| return EMPTY_LIST;
|
| }
|
| - ArrayList<Occurrences> list = new ArrayList<Occurrences>(jsonArray.size());
|
| + ArrayList<ExtractLocalVariableFeedback> list = new ArrayList<ExtractLocalVariableFeedback>(jsonArray.size());
|
| Iterator<JsonElement> iterator = jsonArray.iterator();
|
| while (iterator.hasNext()) {
|
| list.add(fromJson(iterator.next().getAsJsonObject()));
|
| @@ -108,21 +99,23 @@ public class Occurrences {
|
| }
|
|
|
| /**
|
| - * The element that was referenced.
|
| + * The lengths of the expressions that would be replaced by a reference to the variable. The
|
| + * lengths correspond to the offsets. In other words, for a given expression, if the offset of that
|
| + * expression is offsets[i], then the length of that expression is lengths[i].
|
| */
|
| - public Element getElement() {
|
| - return element;
|
| + public Integer[] getLengths() {
|
| + return lengths;
|
| }
|
|
|
| /**
|
| - * The length of the name of the referenced element.
|
| + * The proposed names for the local variable.
|
| */
|
| - public Integer getLength() {
|
| - return length;
|
| + public List<String> getNames() {
|
| + return names;
|
| }
|
|
|
| /**
|
| - * The offsets of the name of the referenced element within the file.
|
| + * The offsets of the expressions that would be replaced by a reference to the variable.
|
| */
|
| public Integer[] getOffsets() {
|
| return offsets;
|
| @@ -131,21 +124,29 @@ public class Occurrences {
|
| @Override
|
| public int hashCode() {
|
| HashCodeBuilder builder = new HashCodeBuilder();
|
| - builder.append(element);
|
| + builder.append(names);
|
| builder.append(offsets);
|
| - builder.append(length);
|
| + builder.append(lengths);
|
| return builder.toHashCode();
|
| }
|
|
|
| public JsonObject toJson() {
|
| JsonObject jsonObject = new JsonObject();
|
| - jsonObject.add("element", element.toJson());
|
| + JsonArray jsonArrayNames = new JsonArray();
|
| + for(String elt : names) {
|
| + jsonArrayNames.add(new JsonPrimitive(elt));
|
| + }
|
| + jsonObject.add("names", jsonArrayNames);
|
| JsonArray jsonArrayOffsets = new JsonArray();
|
| for(Integer elt : offsets) {
|
| jsonArrayOffsets.add(new JsonPrimitive(elt));
|
| }
|
| jsonObject.add("offsets", jsonArrayOffsets);
|
| - jsonObject.addProperty("length", length);
|
| + JsonArray jsonArrayLengths = new JsonArray();
|
| + for(Integer elt : lengths) {
|
| + jsonArrayLengths.add(new JsonPrimitive(elt));
|
| + }
|
| + jsonObject.add("lengths", jsonArrayLengths);
|
| return jsonObject;
|
| }
|
|
|
| @@ -153,12 +154,12 @@ public class Occurrences {
|
| public String toString() {
|
| StringBuilder builder = new StringBuilder();
|
| builder.append("[");
|
| - builder.append("element=");
|
| - builder.append(element + ", ");
|
| + builder.append("names=");
|
| + builder.append(StringUtils.join(names, ", ") + ", ");
|
| builder.append("offsets=");
|
| builder.append(StringUtils.join(offsets, ", ") + ", ");
|
| - builder.append("length=");
|
| - builder.append(length);
|
| + builder.append("lengths=");
|
| + builder.append(StringUtils.join(lengths, ", "));
|
| builder.append("]");
|
| return builder.toString();
|
| }
|
|
|