Flutter Engine
The Flutter Engine
RenameFeedback.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file.
5 *
6 * This file has been automatically generated. Please do not edit it manually.
7 * To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files".
8 */
9package org.dartlang.analysis.server.protocol;
10
11import java.util.Arrays;
12import java.util.List;
13import java.util.Map;
14import com.google.common.collect.Lists;
15import com.google.dart.server.utilities.general.JsonUtilities;
16import com.google.dart.server.utilities.general.ObjectUtilities;
17import com.google.gson.JsonArray;
18import com.google.gson.JsonElement;
19import com.google.gson.JsonObject;
20import com.google.gson.JsonPrimitive;
21import org.apache.commons.lang3.builder.HashCodeBuilder;
22import java.util.ArrayList;
23import java.util.Iterator;
24import org.apache.commons.lang3.StringUtils;
25
26/**
27 * @coverage dart.server.generated.types
28 */
29@SuppressWarnings("unused")
30public class RenameFeedback extends RefactoringFeedback {
31
32 public static final RenameFeedback[] EMPTY_ARRAY = new RenameFeedback[0];
33
34 public static final List<RenameFeedback> EMPTY_LIST = Lists.newArrayList();
35
36 /**
37 * The offset to the beginning of the name selected to be renamed, or -1 if the name does not exist
38 * yet.
39 */
40 private final int offset;
41
42 /**
43 * The length of the name selected to be renamed.
44 */
45 private final int length;
46
47 /**
48 * The human-readable description of the kind of element being renamed (such as "class" or
49 * "function type alias").
50 */
51 private final String elementKindName;
52
53 /**
54 * The old name of the element before the refactoring.
55 */
56 private final String oldName;
57
58 /**
59 * Constructor for {@link RenameFeedback}.
60 */
61 public RenameFeedback(int offset, int length, String elementKindName, String oldName) {
62 this.offset = offset;
63 this.length = length;
64 this.elementKindName = elementKindName;
65 this.oldName = oldName;
66 }
67
68 @Override
69 public boolean equals(Object obj) {
70 if (obj instanceof RenameFeedback) {
71 RenameFeedback other = (RenameFeedback) obj;
72 return
73 other.offset == offset &&
74 other.length == length &&
75 ObjectUtilities.equals(other.elementKindName, elementKindName) &&
76 ObjectUtilities.equals(other.oldName, oldName);
77 }
78 return false;
79 }
80
81 public static RenameFeedback fromJson(JsonObject jsonObject) {
82 int offset = jsonObject.get("offset").getAsInt();
83 int length = jsonObject.get("length").getAsInt();
84 String elementKindName = jsonObject.get("elementKindName").getAsString();
85 String oldName = jsonObject.get("oldName").getAsString();
86 return new RenameFeedback(offset, length, elementKindName, oldName);
87 }
88
89 public static List<RenameFeedback> fromJsonArray(JsonArray jsonArray) {
90 if (jsonArray == null) {
91 return EMPTY_LIST;
92 }
93 ArrayList<RenameFeedback> list = new ArrayList<RenameFeedback>(jsonArray.size());
94 Iterator<JsonElement> iterator = jsonArray.iterator();
95 while (iterator.hasNext()) {
96 list.add(fromJson(iterator.next().getAsJsonObject()));
97 }
98 return list;
99 }
100
101 /**
102 * The human-readable description of the kind of element being renamed (such as "class" or
103 * "function type alias").
104 */
105 public String getElementKindName() {
106 return elementKindName;
107 }
108
109 /**
110 * The length of the name selected to be renamed.
111 */
112 public int getLength() {
113 return length;
114 }
115
116 /**
117 * The offset to the beginning of the name selected to be renamed, or -1 if the name does not exist
118 * yet.
119 */
120 public int getOffset() {
121 return offset;
122 }
123
124 /**
125 * The old name of the element before the refactoring.
126 */
127 public String getOldName() {
128 return oldName;
129 }
130
131 @Override
132 public int hashCode() {
133 HashCodeBuilder builder = new HashCodeBuilder();
134 builder.append(offset);
135 builder.append(length);
136 builder.append(elementKindName);
137 builder.append(oldName);
138 return builder.toHashCode();
139 }
140
141 public JsonObject toJson() {
142 JsonObject jsonObject = new JsonObject();
143 jsonObject.addProperty("offset", offset);
144 jsonObject.addProperty("length", length);
145 jsonObject.addProperty("elementKindName", elementKindName);
146 jsonObject.addProperty("oldName", oldName);
147 return jsonObject;
148 }
149
150 @Override
151 public String toString() {
152 StringBuilder builder = new StringBuilder();
153 builder.append("[");
154 builder.append("offset=");
155 builder.append(offset + ", ");
156 builder.append("length=");
157 builder.append(length + ", ");
158 builder.append("elementKindName=");
159 builder.append(elementKindName + ", ");
160 builder.append("oldName=");
161 builder.append(oldName);
162 builder.append("]");
163 return builder.toString();
164 }
165
166}
static RenameFeedback fromJson(JsonObject jsonObject)
static List< RenameFeedback > fromJsonArray(JsonArray jsonArray)
RenameFeedback(int offset, int length, String elementKindName, String oldName)
size_t length
SeparatedVector2 offset