Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
RefactoringProblem.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 description of a problem related to a refactoring.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class RefactoringProblem {
33
34 public static final RefactoringProblem[] EMPTY_ARRAY = new RefactoringProblem[0];
35
36 public static final List<RefactoringProblem> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The severity of the problem being represented.
40 */
41 private final String severity;
42
43 /**
44 * A human-readable description of the problem being represented.
45 */
46 private final String message;
47
48 /**
49 * The location of the problem being represented. This field is omitted unless there is a specific
50 * location associated with the problem (such as a location where an element being renamed will be
51 * shadowed).
52 */
53 private final Location location;
54
55 /**
56 * Constructor for {@link RefactoringProblem}.
57 */
58 public RefactoringProblem(String severity, String message, Location location) {
59 this.severity = severity;
60 this.message = message;
61 this.location = location;
62 }
63
64 @Override
65 public boolean equals(Object obj) {
66 if (obj instanceof RefactoringProblem) {
68 return
69 ObjectUtilities.equals(other.severity, severity) &&
70 ObjectUtilities.equals(other.message, message) &&
71 ObjectUtilities.equals(other.location, location);
72 }
73 return false;
74 }
75
76 public static RefactoringProblem fromJson(JsonObject jsonObject) {
77 String severity = jsonObject.get("severity").getAsString();
78 String message = jsonObject.get("message").getAsString();
79 Location location = jsonObject.get("location") == null ? null : Location.fromJson(jsonObject.get("location").getAsJsonObject());
80 return new RefactoringProblem(severity, message, location);
81 }
82
83 public static List<RefactoringProblem> fromJsonArray(JsonArray jsonArray) {
84 if (jsonArray == null) {
85 return EMPTY_LIST;
86 }
87 ArrayList<RefactoringProblem> list = new ArrayList<RefactoringProblem>(jsonArray.size());
88 Iterator<JsonElement> iterator = jsonArray.iterator();
89 while (iterator.hasNext()) {
90 list.add(fromJson(iterator.next().getAsJsonObject()));
91 }
92 return list;
93 }
94
95 /**
96 * The location of the problem being represented. This field is omitted unless there is a specific
97 * location associated with the problem (such as a location where an element being renamed will be
98 * shadowed).
99 */
101 return location;
102 }
103
104 /**
105 * A human-readable description of the problem being represented.
106 */
107 public String getMessage() {
108 return message;
109 }
110
111 /**
112 * The severity of the problem being represented.
113 */
114 public String getSeverity() {
115 return severity;
116 }
117
118 @Override
119 public int hashCode() {
120 HashCodeBuilder builder = new HashCodeBuilder();
121 builder.append(severity);
122 builder.append(message);
123 builder.append(location);
124 return builder.toHashCode();
125 }
126
127 public JsonObject toJson() {
128 JsonObject jsonObject = new JsonObject();
129 jsonObject.addProperty("severity", severity);
130 jsonObject.addProperty("message", message);
131 if (location != null) {
132 jsonObject.add("location", location.toJson());
133 }
134 return jsonObject;
135 }
136
137 @Override
138 public String toString() {
139 StringBuilder builder = new StringBuilder();
140 builder.append("[");
141 builder.append("severity=");
142 builder.append(severity + ", ");
143 builder.append("message=");
144 builder.append(message + ", ");
145 builder.append("location=");
146 builder.append(location);
147 builder.append("]");
148 return builder.toString();
149 }
150
151}
static Location fromJson(JsonObject jsonObject)
static List< RefactoringProblem > fromJsonArray(JsonArray jsonArray)
static RefactoringProblem fromJson(JsonObject jsonObject)
RefactoringProblem(String severity, String message, Location location)
Win32Message message