Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
DiagnosticMessage.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 message associated with a diagnostic.
28 *
29 * For example, if the diagnostic is reporting that a variable has been referenced before it was
30 * declared, it might have a diagnostic message that indicates where the variable is declared.
31 *
32 * @coverage dart.server.generated.types
33 */
34@SuppressWarnings("unused")
35public class DiagnosticMessage {
36
37 public static final DiagnosticMessage[] EMPTY_ARRAY = new DiagnosticMessage[0];
38
39 public static final List<DiagnosticMessage> EMPTY_LIST = Lists.newArrayList();
40
41 /**
42 * The message to be displayed to the user.
43 */
44 private final String message;
45
46 /**
47 * The location associated with or referenced by the message. Clients should provide the ability to
48 * navigate to the location.
49 */
50 private final Location location;
51
52 /**
53 * Constructor for {@link DiagnosticMessage}.
54 */
55 public DiagnosticMessage(String message, Location location) {
56 this.message = message;
57 this.location = location;
58 }
59
60 @Override
61 public boolean equals(Object obj) {
62 if (obj instanceof DiagnosticMessage) {
64 return
65 ObjectUtilities.equals(other.message, message) &&
66 ObjectUtilities.equals(other.location, location);
67 }
68 return false;
69 }
70
71 public static DiagnosticMessage fromJson(JsonObject jsonObject) {
72 String message = jsonObject.get("message").getAsString();
73 Location location = Location.fromJson(jsonObject.get("location").getAsJsonObject());
74 return new DiagnosticMessage(message, location);
75 }
76
77 public static List<DiagnosticMessage> fromJsonArray(JsonArray jsonArray) {
78 if (jsonArray == null) {
79 return EMPTY_LIST;
80 }
81 ArrayList<DiagnosticMessage> list = new ArrayList<DiagnosticMessage>(jsonArray.size());
82 Iterator<JsonElement> iterator = jsonArray.iterator();
83 while (iterator.hasNext()) {
84 list.add(fromJson(iterator.next().getAsJsonObject()));
85 }
86 return list;
87 }
88
89 /**
90 * The location associated with or referenced by the message. Clients should provide the ability to
91 * navigate to the location.
92 */
94 return location;
95 }
96
97 /**
98 * The message to be displayed to the user.
99 */
100 public String getMessage() {
101 return message;
102 }
103
104 @Override
105 public int hashCode() {
106 HashCodeBuilder builder = new HashCodeBuilder();
107 builder.append(message);
108 builder.append(location);
109 return builder.toHashCode();
110 }
111
112 public JsonObject toJson() {
113 JsonObject jsonObject = new JsonObject();
114 jsonObject.addProperty("message", message);
115 jsonObject.add("location", location.toJson());
116 return jsonObject;
117 }
118
119 @Override
120 public String toString() {
121 StringBuilder builder = new StringBuilder();
122 builder.append("[");
123 builder.append("message=");
124 builder.append(message + ", ");
125 builder.append("location=");
126 builder.append(location);
127 builder.append("]");
128 return builder.toString();
129 }
130
131}
static List< DiagnosticMessage > fromJsonArray(JsonArray jsonArray)
static DiagnosticMessage fromJson(JsonObject jsonObject)
static Location fromJson(JsonObject jsonObject)
Win32Message message