Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
LibraryPathSet.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 list of associations between paths and the libraries that should be included for code
28 * completion when editing a file beneath that path.
29 *
30 * @coverage dart.server.generated.types
31 */
32@SuppressWarnings("unused")
33public class LibraryPathSet {
34
35 public static final LibraryPathSet[] EMPTY_ARRAY = new LibraryPathSet[0];
36
37 public static final List<LibraryPathSet> EMPTY_LIST = Lists.newArrayList();
38
39 /**
40 * The filepath for which this request's libraries should be active in completion suggestions. This
41 * object associates filesystem regions to libraries and library directories of interest to the
42 * client.
43 */
44 private final String scope;
45
46 /**
47 * The paths of the libraries of interest to the client for completion suggestions.
48 */
49 private final List<String> libraryPaths;
50
51 /**
52 * Constructor for {@link LibraryPathSet}.
53 */
54 public LibraryPathSet(String scope, List<String> libraryPaths) {
55 this.scope = scope;
56 this.libraryPaths = libraryPaths;
57 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (obj instanceof LibraryPathSet) {
62 LibraryPathSet other = (LibraryPathSet) obj;
63 return
64 ObjectUtilities.equals(other.scope, scope) &&
65 ObjectUtilities.equals(other.libraryPaths, libraryPaths);
66 }
67 return false;
68 }
69
70 public static LibraryPathSet fromJson(JsonObject jsonObject) {
71 String scope = jsonObject.get("scope").getAsString();
72 List<String> libraryPaths = JsonUtilities.decodeStringList(jsonObject.get("libraryPaths").getAsJsonArray());
73 return new LibraryPathSet(scope, libraryPaths);
74 }
75
76 public static List<LibraryPathSet> fromJsonArray(JsonArray jsonArray) {
77 if (jsonArray == null) {
78 return EMPTY_LIST;
79 }
80 ArrayList<LibraryPathSet> list = new ArrayList<LibraryPathSet>(jsonArray.size());
81 Iterator<JsonElement> iterator = jsonArray.iterator();
82 while (iterator.hasNext()) {
83 list.add(fromJson(iterator.next().getAsJsonObject()));
84 }
85 return list;
86 }
87
88 /**
89 * The paths of the libraries of interest to the client for completion suggestions.
90 */
92 return libraryPaths;
93 }
94
95 /**
96 * The filepath for which this request's libraries should be active in completion suggestions. This
97 * object associates filesystem regions to libraries and library directories of interest to the
98 * client.
99 */
100 public String getScope() {
101 return scope;
102 }
103
104 @Override
105 public int hashCode() {
106 HashCodeBuilder builder = new HashCodeBuilder();
107 builder.append(scope);
108 builder.append(libraryPaths);
109 return builder.toHashCode();
110 }
111
112 public JsonObject toJson() {
113 JsonObject jsonObject = new JsonObject();
114 jsonObject.addProperty("scope", scope);
115 JsonArray jsonArrayLibraryPaths = new JsonArray();
116 for (String elt : libraryPaths) {
117 jsonArrayLibraryPaths.add(new JsonPrimitive(elt));
118 }
119 jsonObject.add("libraryPaths", jsonArrayLibraryPaths);
120 return jsonObject;
121 }
122
123 @Override
124 public String toString() {
125 StringBuilder builder = new StringBuilder();
126 builder.append("[");
127 builder.append("scope=");
128 builder.append(scope + ", ");
129 builder.append("libraryPaths=");
130 builder.append(StringUtils.join(libraryPaths, ", "));
131 builder.append("]");
132 return builder.toString();
133 }
134
135}
static List< LibraryPathSet > fromJsonArray(JsonArray jsonArray)
static LibraryPathSet fromJson(JsonObject jsonObject)
LibraryPathSet(String scope, List< String > libraryPaths)