Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ChangeContentOverlay.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 * A directive to modify an existing file content overlay. One or more ranges of text are deleted
28 * from the old file content overlay and replaced with new text.
29 *
30 * The edits are applied in the order in which they occur in the list. This means that the offset
31 * of each edit must be correct under the assumption that all previous edits have been applied.
32 *
33 * It is an error to use this overlay on a file that does not yet have a file content overlay or
34 * that has had its overlay removed via RemoveContentOverlay.
35 *
36 * If any of the edits cannot be applied due to its offset or length being out of range, an
37 * INVALID_OVERLAY_CHANGE error will be reported.
38 *
39 * @coverage dart.server.generated.types
40 */
41@SuppressWarnings("unused")
43
44 public static final ChangeContentOverlay[] EMPTY_ARRAY = new ChangeContentOverlay[0];
45
46 public static final List<ChangeContentOverlay> EMPTY_LIST = Lists.newArrayList();
47
48 private final String type;
49
50 /**
51 * The edits to be applied to the file.
52 */
53 private final List<SourceEdit> edits;
54
55 /**
56 * Constructor for {@link ChangeContentOverlay}.
57 */
59 this.type = "change";
60 this.edits = edits;
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (obj instanceof ChangeContentOverlay) {
67 return
68 ObjectUtilities.equals(other.type, type) &&
69 ObjectUtilities.equals(other.edits, edits);
70 }
71 return false;
72 }
73
74 public static ChangeContentOverlay fromJson(JsonObject jsonObject) {
75 String type = jsonObject.get("type").getAsString();
76 List<SourceEdit> edits = SourceEdit.fromJsonArray(jsonObject.get("edits").getAsJsonArray());
77 return new ChangeContentOverlay(edits);
78 }
79
80 public static List<ChangeContentOverlay> fromJsonArray(JsonArray jsonArray) {
81 if (jsonArray == null) {
82 return EMPTY_LIST;
83 }
84 ArrayList<ChangeContentOverlay> list = new ArrayList<ChangeContentOverlay>(jsonArray.size());
85 Iterator<JsonElement> iterator = jsonArray.iterator();
86 while (iterator.hasNext()) {
87 list.add(fromJson(iterator.next().getAsJsonObject()));
88 }
89 return list;
90 }
91
92 /**
93 * The edits to be applied to the file.
94 */
96 return edits;
97 }
98
99 public String getType() {
100 return type;
101 }
102
103 @Override
104 public int hashCode() {
105 HashCodeBuilder builder = new HashCodeBuilder();
106 builder.append(type);
107 builder.append(edits);
108 return builder.toHashCode();
109 }
110
111 public JsonObject toJson() {
112 JsonObject jsonObject = new JsonObject();
113 jsonObject.addProperty("type", type);
114 JsonArray jsonArrayEdits = new JsonArray();
115 for (SourceEdit elt : edits) {
116 jsonArrayEdits.add(elt.toJson());
117 }
118 jsonObject.add("edits", jsonArrayEdits);
119 return jsonObject;
120 }
121
122 @Override
123 public String toString() {
124 StringBuilder builder = new StringBuilder();
125 builder.append("[");
126 builder.append("type=");
127 builder.append(type + ", ");
128 builder.append("edits=");
129 builder.append(StringUtils.join(edits, ", "));
130 builder.append("]");
131 return builder.toString();
132 }
133
134}
static List< ChangeContentOverlay > fromJsonArray(JsonArray jsonArray)
static ChangeContentOverlay fromJson(JsonObject jsonObject)
static List< SourceEdit > fromJsonArray(JsonArray jsonArray)