diff --git a/pkg/analysis_server/doc/api.html b/pkg/analysis_server/doc/api.html index e8e7e184acf..59d6ae528d4 100644 --- a/pkg/analysis_server/doc/api.html +++ b/pkg/analysis_server/doc/api.html @@ -2534,6 +2534,7 @@ a:focus, a:hover { +

Types

This section contains descriptions of the data types referenced @@ -2567,6 +2568,8 @@ a:focus, a:hover { + + @@ -3500,7 +3503,72 @@ a:focus, a:hover {

The names of the elements imported from the library.

-
LinkedEditGroup: object
+
KytheEntry: object
+

+ This object matches the format and documentation of the Entry object documented in the + Kythe Storage Model. +

+ +
source: KytheVName
+ +

+ The ticket of the source node (must not be empty). +

+
kind: String
+ +

+ An edge label (may be empty). The schema defines which labels are meaningful. +

+
target: KytheVName
+ +

+ The ticket of the target node (may be empty). +

+
fact: String
+ +

+ A fact label (must not be empty). The schema defines which fact labels are meaningful. +

+
value: List<int>
+ +

+ The String value of the fact (may be empty). +

+
KytheVName: object
+

+ This object matches the format and documentation of the Vector-Name object documented in the + Kythe Storage Model. +

+ +
signature: String
+ +

+ An opaque signature generated by the analyzer. +

+
corpus: String
+ +

+ The corpus of source code this KytheVName belongs to. Loosely, a corpus is a + collection of related files, such as the contents of a given source repository. +

+
root: String
+ +

+ A corpus-specific root label, typically a directory path or project identifier, denoting a + distinct subset of the corpus. This may also be used to designate virtual collections like generated files. +

+
path: String
+ +

+ A path-structured label describing the “location” of the named object relative to the corpus + and the root. +

+
language: String
+ +

+ The language this name belongs to. +

+
LinkedEditGroup: object

A collection of positions that should be linked (edited simultaneously) for the purposes of updating code after a source change. For example, if a @@ -4679,7 +4747,7 @@ a:focus, a:hover { TODO: TBD

Index

-

Domains

server ()

Requests
Notifications

analysis ()

Requests
Notifications

completion ()

Requests
Notifications

search ()

Requests
Notifications

edit ()

Requests

execution ()

Requests
Notifications

diagnostic ()

Requests

Types ()

Refactorings ()

+

Domains

server ()

Requests
Notifications

analysis ()

Requests
Notifications

completion ()

Requests
Notifications

search ()

Requests
Notifications

edit ()

Requests

execution ()

Requests
Notifications

diagnostic ()

Requests

Types ()

Refactorings ()

\ No newline at end of file diff --git a/pkg/analysis_server/lib/protocol/protocol_constants.dart b/pkg/analysis_server/lib/protocol/protocol_constants.dart index 1f494ff4b8b..c28d2f0e360 100644 --- a/pkg/analysis_server/lib/protocol/protocol_constants.dart +++ b/pkg/analysis_server/lib/protocol/protocol_constants.dart @@ -206,6 +206,10 @@ const String EXECUTION_REQUEST_SET_SUBSCRIPTIONS_SUBSCRIPTIONS = const String EXECUTION_RESPONSE_CREATE_CONTEXT_ID = 'id'; const String EXECUTION_RESPONSE_MAP_URI_FILE = 'file'; const String EXECUTION_RESPONSE_MAP_URI_URI = 'uri'; +const String KYTHE_REQUEST_GET_KYTHE_ENTRIES = 'kythe.getKytheEntries'; +const String KYTHE_REQUEST_GET_KYTHE_ENTRIES_FILE = 'file'; +const String KYTHE_RESPONSE_GET_KYTHE_ENTRIES_ENTRIES = 'entries'; +const String KYTHE_RESPONSE_GET_KYTHE_ENTRIES_FILES = 'files'; const String SEARCH_NOTIFICATION_RESULTS = 'search.results'; const String SEARCH_NOTIFICATION_RESULTS_ID = 'id'; const String SEARCH_NOTIFICATION_RESULTS_IS_LAST = 'isLast'; diff --git a/pkg/analysis_server/lib/protocol/protocol_generated.dart b/pkg/analysis_server/lib/protocol/protocol_generated.dart index df57b5bd625..9b5e585562a 100644 --- a/pkg/analysis_server/lib/protocol/protocol_generated.dart +++ b/pkg/analysis_server/lib/protocol/protocol_generated.dart @@ -11772,6 +11772,592 @@ class InlineMethodOptions extends RefactoringOptions { } } +/** + * KytheEntry + * + * { + * "source": KytheVName + * "kind": String + * "target": KytheVName + * "fact": String + * "value": List + * } + * + * Clients may not extend, implement or mix-in this class. + */ +class KytheEntry implements HasToJson { + KytheVName _source; + + String _kind; + + KytheVName _target; + + String _fact; + + List _value; + + /** + * The ticket of the source node (must not be empty). + */ + KytheVName get source => _source; + + /** + * The ticket of the source node (must not be empty). + */ + void set source(KytheVName value) { + assert(value != null); + this._source = value; + } + + /** + * An edge label (may be empty). The schema defines which labels are + * meaningful. + */ + String get kind => _kind; + + /** + * An edge label (may be empty). The schema defines which labels are + * meaningful. + */ + void set kind(String value) { + assert(value != null); + this._kind = value; + } + + /** + * The ticket of the target node (may be empty). + */ + KytheVName get target => _target; + + /** + * The ticket of the target node (may be empty). + */ + void set target(KytheVName value) { + assert(value != null); + this._target = value; + } + + /** + * A fact label (must not be empty). The schema defines which fact labels are + * meaningful. + */ + String get fact => _fact; + + /** + * A fact label (must not be empty). The schema defines which fact labels are + * meaningful. + */ + void set fact(String value) { + assert(value != null); + this._fact = value; + } + + /** + * The String value of the fact (may be empty). + */ + List get value => _value; + + /** + * The String value of the fact (may be empty). + */ + void set value(List value) { + assert(value != null); + this._value = value; + } + + KytheEntry(KytheVName source, String kind, KytheVName target, String fact, + List value) { + this.source = source; + this.kind = kind; + this.target = target; + this.fact = fact; + this.value = value; + } + + factory KytheEntry.fromJson( + JsonDecoder jsonDecoder, String jsonPath, Object json) { + if (json == null) { + json = {}; + } + if (json is Map) { + KytheVName source; + if (json.containsKey("source")) { + source = new KytheVName.fromJson( + jsonDecoder, jsonPath + ".source", json["source"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "source"); + } + String kind; + if (json.containsKey("kind")) { + kind = jsonDecoder.decodeString(jsonPath + ".kind", json["kind"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "kind"); + } + KytheVName target; + if (json.containsKey("target")) { + target = new KytheVName.fromJson( + jsonDecoder, jsonPath + ".target", json["target"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "target"); + } + String fact; + if (json.containsKey("fact")) { + fact = jsonDecoder.decodeString(jsonPath + ".fact", json["fact"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "fact"); + } + List value; + if (json.containsKey("value")) { + value = jsonDecoder.decodeList( + jsonPath + ".value", json["value"], jsonDecoder.decodeInt); + } else { + throw jsonDecoder.mismatch(jsonPath, "value"); + } + return new KytheEntry(source, kind, target, fact, value); + } else { + throw jsonDecoder.mismatch(jsonPath, "KytheEntry", json); + } + } + + @override + Map toJson() { + Map result = {}; + result["source"] = source.toJson(); + result["kind"] = kind; + result["target"] = target.toJson(); + result["fact"] = fact; + result["value"] = value; + return result; + } + + @override + String toString() => JSON.encode(toJson()); + + @override + bool operator ==(other) { + if (other is KytheEntry) { + return source == other.source && + kind == other.kind && + target == other.target && + fact == other.fact && + listEqual(value, other.value, (int a, int b) => a == b); + } + return false; + } + + @override + int get hashCode { + int hash = 0; + hash = JenkinsSmiHash.combine(hash, source.hashCode); + hash = JenkinsSmiHash.combine(hash, kind.hashCode); + hash = JenkinsSmiHash.combine(hash, target.hashCode); + hash = JenkinsSmiHash.combine(hash, fact.hashCode); + hash = JenkinsSmiHash.combine(hash, value.hashCode); + return JenkinsSmiHash.finish(hash); + } +} + +/** + * kythe.getKytheEntries params + * + * { + * "file": FilePath + * } + * + * Clients may not extend, implement or mix-in this class. + */ +class KytheGetKytheEntriesParams implements RequestParams { + String _file; + + /** + * The file containing the code for which the Kythe Entry objects are being + * requested. + */ + String get file => _file; + + /** + * The file containing the code for which the Kythe Entry objects are being + * requested. + */ + void set file(String value) { + assert(value != null); + this._file = value; + } + + KytheGetKytheEntriesParams(String file) { + this.file = file; + } + + factory KytheGetKytheEntriesParams.fromJson( + JsonDecoder jsonDecoder, String jsonPath, Object json) { + if (json == null) { + json = {}; + } + if (json is Map) { + String file; + if (json.containsKey("file")) { + file = jsonDecoder.decodeString(jsonPath + ".file", json["file"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "file"); + } + return new KytheGetKytheEntriesParams(file); + } else { + throw jsonDecoder.mismatch( + jsonPath, "kythe.getKytheEntries params", json); + } + } + + factory KytheGetKytheEntriesParams.fromRequest(Request request) { + return new KytheGetKytheEntriesParams.fromJson( + new RequestDecoder(request), "params", request.params); + } + + @override + Map toJson() { + Map result = {}; + result["file"] = file; + return result; + } + + @override + Request toRequest(String id) { + return new Request(id, "kythe.getKytheEntries", toJson()); + } + + @override + String toString() => JSON.encode(toJson()); + + @override + bool operator ==(other) { + if (other is KytheGetKytheEntriesParams) { + return file == other.file; + } + return false; + } + + @override + int get hashCode { + int hash = 0; + hash = JenkinsSmiHash.combine(hash, file.hashCode); + return JenkinsSmiHash.finish(hash); + } +} + +/** + * kythe.getKytheEntries result + * + * { + * "entries": List + * "files": List + * } + * + * Clients may not extend, implement or mix-in this class. + */ +class KytheGetKytheEntriesResult implements ResponseResult { + List _entries; + + List _files; + + /** + * The list of KytheEntry objects for the queried file. + */ + List get entries => _entries; + + /** + * The list of KytheEntry objects for the queried file. + */ + void set entries(List value) { + assert(value != null); + this._entries = value; + } + + /** + * The set of files paths that were required, but not in the file system, to + * give a complete and accurate Kythe graph for the file. This could be due + * to a referenced file that does not exist or generated files not being + * generated or passed before the call to "getKytheEntries". + */ + List get files => _files; + + /** + * The set of files paths that were required, but not in the file system, to + * give a complete and accurate Kythe graph for the file. This could be due + * to a referenced file that does not exist or generated files not being + * generated or passed before the call to "getKytheEntries". + */ + void set files(List value) { + assert(value != null); + this._files = value; + } + + KytheGetKytheEntriesResult(List entries, List files) { + this.entries = entries; + this.files = files; + } + + factory KytheGetKytheEntriesResult.fromJson( + JsonDecoder jsonDecoder, String jsonPath, Object json) { + if (json == null) { + json = {}; + } + if (json is Map) { + List entries; + if (json.containsKey("entries")) { + entries = jsonDecoder.decodeList( + jsonPath + ".entries", + json["entries"], + (String jsonPath, Object json) => + new KytheEntry.fromJson(jsonDecoder, jsonPath, json)); + } else { + throw jsonDecoder.mismatch(jsonPath, "entries"); + } + List files; + if (json.containsKey("files")) { + files = jsonDecoder.decodeList( + jsonPath + ".files", json["files"], jsonDecoder.decodeString); + } else { + throw jsonDecoder.mismatch(jsonPath, "files"); + } + return new KytheGetKytheEntriesResult(entries, files); + } else { + throw jsonDecoder.mismatch( + jsonPath, "kythe.getKytheEntries result", json); + } + } + + factory KytheGetKytheEntriesResult.fromResponse(Response response) { + return new KytheGetKytheEntriesResult.fromJson( + new ResponseDecoder(REQUEST_ID_REFACTORING_KINDS.remove(response.id)), + "result", + response.result); + } + + @override + Map toJson() { + Map result = {}; + result["entries"] = + entries.map((KytheEntry value) => value.toJson()).toList(); + result["files"] = files; + return result; + } + + @override + Response toResponse(String id) { + return new Response(id, result: toJson()); + } + + @override + String toString() => JSON.encode(toJson()); + + @override + bool operator ==(other) { + if (other is KytheGetKytheEntriesResult) { + return listEqual( + entries, other.entries, (KytheEntry a, KytheEntry b) => a == b) && + listEqual(files, other.files, (String a, String b) => a == b); + } + return false; + } + + @override + int get hashCode { + int hash = 0; + hash = JenkinsSmiHash.combine(hash, entries.hashCode); + hash = JenkinsSmiHash.combine(hash, files.hashCode); + return JenkinsSmiHash.finish(hash); + } +} + +/** + * KytheVName + * + * { + * "signature": String + * "corpus": String + * "root": String + * "path": String + * "language": String + * } + * + * Clients may not extend, implement or mix-in this class. + */ +class KytheVName implements HasToJson { + String _signature; + + String _corpus; + + String _root; + + String _path; + + String _language; + + /** + * An opaque signature generated by the analyzer. + */ + String get signature => _signature; + + /** + * An opaque signature generated by the analyzer. + */ + void set signature(String value) { + assert(value != null); + this._signature = value; + } + + /** + * The corpus of source code this KytheVName belongs to. Loosely, a corpus is + * a collection of related files, such as the contents of a given source + * repository. + */ + String get corpus => _corpus; + + /** + * The corpus of source code this KytheVName belongs to. Loosely, a corpus is + * a collection of related files, such as the contents of a given source + * repository. + */ + void set corpus(String value) { + assert(value != null); + this._corpus = value; + } + + /** + * A corpus-specific root label, typically a directory path or project + * identifier, denoting a distinct subset of the corpus. This may also be + * used to designate virtual collections like generated files. + */ + String get root => _root; + + /** + * A corpus-specific root label, typically a directory path or project + * identifier, denoting a distinct subset of the corpus. This may also be + * used to designate virtual collections like generated files. + */ + void set root(String value) { + assert(value != null); + this._root = value; + } + + /** + * A path-structured label describing the “location” of the named object + * relative to the corpus and the root. + */ + String get path => _path; + + /** + * A path-structured label describing the “location” of the named object + * relative to the corpus and the root. + */ + void set path(String value) { + assert(value != null); + this._path = value; + } + + /** + * The language this name belongs to. + */ + String get language => _language; + + /** + * The language this name belongs to. + */ + void set language(String value) { + assert(value != null); + this._language = value; + } + + KytheVName(String signature, String corpus, String root, String path, + String language) { + this.signature = signature; + this.corpus = corpus; + this.root = root; + this.path = path; + this.language = language; + } + + factory KytheVName.fromJson( + JsonDecoder jsonDecoder, String jsonPath, Object json) { + if (json == null) { + json = {}; + } + if (json is Map) { + String signature; + if (json.containsKey("signature")) { + signature = jsonDecoder.decodeString( + jsonPath + ".signature", json["signature"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "signature"); + } + String corpus; + if (json.containsKey("corpus")) { + corpus = jsonDecoder.decodeString(jsonPath + ".corpus", json["corpus"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "corpus"); + } + String root; + if (json.containsKey("root")) { + root = jsonDecoder.decodeString(jsonPath + ".root", json["root"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "root"); + } + String path; + if (json.containsKey("path")) { + path = jsonDecoder.decodeString(jsonPath + ".path", json["path"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "path"); + } + String language; + if (json.containsKey("language")) { + language = + jsonDecoder.decodeString(jsonPath + ".language", json["language"]); + } else { + throw jsonDecoder.mismatch(jsonPath, "language"); + } + return new KytheVName(signature, corpus, root, path, language); + } else { + throw jsonDecoder.mismatch(jsonPath, "KytheVName", json); + } + } + + @override + Map toJson() { + Map result = {}; + result["signature"] = signature; + result["corpus"] = corpus; + result["root"] = root; + result["path"] = path; + result["language"] = language; + return result; + } + + @override + String toString() => JSON.encode(toJson()); + + @override + bool operator ==(other) { + if (other is KytheVName) { + return signature == other.signature && + corpus == other.corpus && + root == other.root && + path == other.path && + language == other.language; + } + return false; + } + + @override + int get hashCode { + int hash = 0; + hash = JenkinsSmiHash.combine(hash, signature.hashCode); + hash = JenkinsSmiHash.combine(hash, corpus.hashCode); + hash = JenkinsSmiHash.combine(hash, root.hashCode); + hash = JenkinsSmiHash.combine(hash, path.hashCode); + hash = JenkinsSmiHash.combine(hash, language.hashCode); + return JenkinsSmiHash.finish(hash); + } +} + /** * moveFile feedback * diff --git a/pkg/analysis_server/test/integration/support/integration_test_methods.dart b/pkg/analysis_server/test/integration/support/integration_test_methods.dart index 93cb1d4abb2..a566054e606 100644 --- a/pkg/analysis_server/test/integration/support/integration_test_methods.dart +++ b/pkg/analysis_server/test/integration/support/integration_test_methods.dart @@ -2036,6 +2036,38 @@ abstract class IntegrationTestMixin { return null; } + /** + * Return the list of KytheEntry objects for some file, given the current + * state of the file system populated by "analysis.updateContent". + * + * Parameters + * + * file: FilePath + * + * The file containing the code for which the Kythe Entry objects are being + * requested. + * + * Returns + * + * entries: List + * + * The list of KytheEntry objects for the queried file. + * + * files: List + * + * The set of files paths that were required, but not in the file system, + * to give a complete and accurate Kythe graph for the file. This could be + * due to a referenced file that does not exist or generated files not + * being generated or passed before the call to "getKytheEntries". + */ + Future sendKytheGetKytheEntries( + String file) async { + var params = new KytheGetKytheEntriesParams(file).toJson(); + var result = await server.send("kythe.getKytheEntries", params); + ResponseDecoder decoder = new ResponseDecoder(null); + return new KytheGetKytheEntriesResult.fromJson(decoder, 'result', result); + } + /** * Initialize the fields in InttestMixin, and ensure that notifications will * be handled. diff --git a/pkg/analysis_server/test/integration/support/protocol_matchers.dart b/pkg/analysis_server/test/integration/support/protocol_matchers.dart index 4d455590cab..902a6a58e37 100644 --- a/pkg/analysis_server/test/integration/support/protocol_matchers.dart +++ b/pkg/analysis_server/test/integration/support/protocol_matchers.dart @@ -711,6 +711,46 @@ final Matcher isImportedElements = new LazyMatcher(() => new MatchesJsonObject( "ImportedElements", {"path": isFilePath, "prefix": isString, "elements": isListOf(isString)})); +/** + * KytheEntry + * + * { + * "source": KytheVName + * "kind": String + * "target": KytheVName + * "fact": String + * "value": List + * } + */ +final Matcher isKytheEntry = + new LazyMatcher(() => new MatchesJsonObject("KytheEntry", { + "source": isKytheVName, + "kind": isString, + "target": isKytheVName, + "fact": isString, + "value": isListOf(isInt) + })); + +/** + * KytheVName + * + * { + * "signature": String + * "corpus": String + * "root": String + * "path": String + * "language": String + * } + */ +final Matcher isKytheVName = + new LazyMatcher(() => new MatchesJsonObject("KytheVName", { + "signature": isString, + "corpus": isString, + "root": isString, + "path": isString, + "language": isString + })); + /** * LinkedEditGroup * @@ -2318,6 +2358,29 @@ final Matcher isInlineMethodOptions = new LazyMatcher(() => new MatchesJsonObject( "inlineMethod options", {"deleteSource": isBool, "inlineAll": isBool})); +/** + * kythe.getKytheEntries params + * + * { + * "file": FilePath + * } + */ +final Matcher isKytheGetKytheEntriesParams = new LazyMatcher(() => + new MatchesJsonObject( + "kythe.getKytheEntries params", {"file": isFilePath})); + +/** + * kythe.getKytheEntries result + * + * { + * "entries": List + * "files": List + * } + */ +final Matcher isKytheGetKytheEntriesResult = new LazyMatcher(() => + new MatchesJsonObject("kythe.getKytheEntries result", + {"entries": isListOf(isKytheEntry), "files": isListOf(isFilePath)})); + /** * moveFile feedback */ diff --git a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java index 857a9ad9d69..b70868c9ee7 100644 --- a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java +++ b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java @@ -631,6 +631,16 @@ public interface AnalysisServer { */ public boolean isSocketOpen(); + /** + * {@code kythe.getKytheEntries} + * + * Return the list of KytheEntry objects for some file, given the current state of the file system + * populated by "analysis.updateContent". + * + * @param file The file containing the code for which the Kythe Entry objects are being requested. + */ + public void kythe_getKytheEntries(String file, GetKytheEntriesConsumer consumer); + /** * Remove the given listener from the list of listeners that will receive notification when new * analysis results become available. diff --git a/pkg/analysis_server/tool/spec/generated/java/types/KytheEntry.java b/pkg/analysis_server/tool/spec/generated/java/types/KytheEntry.java new file mode 100644 index 00000000000..a224a70abf5 --- /dev/null +++ b/pkg/analysis_server/tool/spec/generated/java/types/KytheEntry.java @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2015, the Dart project authors. + * + * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * + * This file has been automatically generated. Please do not edit it manually. + * To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files". + */ +package org.dartlang.analysis.server.protocol; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import com.google.common.collect.Lists; +import com.google.dart.server.utilities.general.JsonUtilities; +import com.google.dart.server.utilities.general.ObjectUtilities; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import java.util.ArrayList; +import java.util.Iterator; +import org.apache.commons.lang3.StringUtils; + +/** + * This object matches the format and documentation of the Entry object documented in the Kythe + * Storage Model. + * + * @coverage dart.server.generated.types + */ +@SuppressWarnings("unused") +public class KytheEntry { + + public static final KytheEntry[] EMPTY_ARRAY = new KytheEntry[0]; + + public static final List EMPTY_LIST = Lists.newArrayList(); + + /** + * The ticket of the source node (must not be empty). + */ + private final KytheVName source; + + /** + * An edge label (may be empty). The schema defines which labels are meaningful. + */ + private final String kind; + + /** + * The ticket of the target node (may be empty). + */ + private final KytheVName target; + + /** + * A fact label (must not be empty). The schema defines which fact labels are meaningful. + */ + private final String fact; + + /** + * The String value of the fact (may be empty). + */ + private final int[] value; + + /** + * Constructor for {@link KytheEntry}. + */ + public KytheEntry(KytheVName source, String kind, KytheVName target, String fact, int[] value) { + this.source = source; + this.kind = kind; + this.target = target; + this.fact = fact; + this.value = value; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof KytheEntry) { + KytheEntry other = (KytheEntry) obj; + return + ObjectUtilities.equals(other.source, source) && + ObjectUtilities.equals(other.kind, kind) && + ObjectUtilities.equals(other.target, target) && + ObjectUtilities.equals(other.fact, fact) && + Arrays.equals(other.value, value); + } + return false; + } + + public static KytheEntry fromJson(JsonObject jsonObject) { + KytheVName source = KytheVName.fromJson(jsonObject.get("source").getAsJsonObject()); + String kind = jsonObject.get("kind").getAsString(); + KytheVName target = KytheVName.fromJson(jsonObject.get("target").getAsJsonObject()); + String fact = jsonObject.get("fact").getAsString(); + int[] value = JsonUtilities.decodeIntArray(jsonObject.get("value").getAsJsonArray()); + return new KytheEntry(source, kind, target, fact, value); + } + + public static List fromJsonArray(JsonArray jsonArray) { + if (jsonArray == null) { + return EMPTY_LIST; + } + ArrayList list = new ArrayList(jsonArray.size()); + Iterator iterator = jsonArray.iterator(); + while (iterator.hasNext()) { + list.add(fromJson(iterator.next().getAsJsonObject())); + } + return list; + } + + /** + * A fact label (must not be empty). The schema defines which fact labels are meaningful. + */ + public String getFact() { + return fact; + } + + /** + * An edge label (may be empty). The schema defines which labels are meaningful. + */ + public String getKind() { + return kind; + } + + /** + * The ticket of the source node (must not be empty). + */ + public KytheVName getSource() { + return source; + } + + /** + * The ticket of the target node (may be empty). + */ + public KytheVName getTarget() { + return target; + } + + /** + * The String value of the fact (may be empty). + */ + public int[] getValue() { + return value; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(source); + builder.append(kind); + builder.append(target); + builder.append(fact); + builder.append(value); + return builder.toHashCode(); + } + + public JsonObject toJson() { + JsonObject jsonObject = new JsonObject(); + jsonObject.add("source", source.toJson()); + jsonObject.addProperty("kind", kind); + jsonObject.add("target", target.toJson()); + jsonObject.addProperty("fact", fact); + JsonArray jsonArrayValue = new JsonArray(); + for (int elt : value) { + jsonArrayValue.add(new JsonPrimitive(elt)); + } + jsonObject.add("value", jsonArrayValue); + return jsonObject; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("["); + builder.append("source="); + builder.append(source + ", "); + builder.append("kind="); + builder.append(kind + ", "); + builder.append("target="); + builder.append(target + ", "); + builder.append("fact="); + builder.append(fact + ", "); + builder.append("value="); + builder.append(StringUtils.join(value, ", ")); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/pkg/analysis_server/tool/spec/generated/java/types/KytheVName.java b/pkg/analysis_server/tool/spec/generated/java/types/KytheVName.java new file mode 100644 index 00000000000..2c56a72d888 --- /dev/null +++ b/pkg/analysis_server/tool/spec/generated/java/types/KytheVName.java @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2015, the Dart project authors. + * + * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * + * This file has been automatically generated. Please do not edit it manually. + * To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files". + */ +package org.dartlang.analysis.server.protocol; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import com.google.common.collect.Lists; +import com.google.dart.server.utilities.general.JsonUtilities; +import com.google.dart.server.utilities.general.ObjectUtilities; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import java.util.ArrayList; +import java.util.Iterator; +import org.apache.commons.lang3.StringUtils; + +/** + * This object matches the format and documentation of the Vector-Name object documented in the + * Kythe Storage Model. + * + * @coverage dart.server.generated.types + */ +@SuppressWarnings("unused") +public class KytheVName { + + public static final KytheVName[] EMPTY_ARRAY = new KytheVName[0]; + + public static final List EMPTY_LIST = Lists.newArrayList(); + + /** + * An opaque signature generated by the analyzer. + */ + private final String signature; + + /** + * The corpus of source code this KytheVName belongs to. Loosely, a corpus is a collection of + * related files, such as the contents of a given source repository. + */ + private final String corpus; + + /** + * A corpus-specific root label, typically a directory path or project identifier, denoting a + * distinct subset of the corpus. This may also be used to designate virtual collections like + * generated files. + */ + private final String root; + + /** + * A path-structured label describing the “location” of the named object relative to the corpus and + * the root. + */ + private final String path; + + /** + * The language this name belongs to. + */ + private final String language; + + /** + * Constructor for {@link KytheVName}. + */ + public KytheVName(String signature, String corpus, String root, String path, String language) { + this.signature = signature; + this.corpus = corpus; + this.root = root; + this.path = path; + this.language = language; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof KytheVName) { + KytheVName other = (KytheVName) obj; + return + ObjectUtilities.equals(other.signature, signature) && + ObjectUtilities.equals(other.corpus, corpus) && + ObjectUtilities.equals(other.root, root) && + ObjectUtilities.equals(other.path, path) && + ObjectUtilities.equals(other.language, language); + } + return false; + } + + public static KytheVName fromJson(JsonObject jsonObject) { + String signature = jsonObject.get("signature").getAsString(); + String corpus = jsonObject.get("corpus").getAsString(); + String root = jsonObject.get("root").getAsString(); + String path = jsonObject.get("path").getAsString(); + String language = jsonObject.get("language").getAsString(); + return new KytheVName(signature, corpus, root, path, language); + } + + public static List fromJsonArray(JsonArray jsonArray) { + if (jsonArray == null) { + return EMPTY_LIST; + } + ArrayList list = new ArrayList(jsonArray.size()); + Iterator iterator = jsonArray.iterator(); + while (iterator.hasNext()) { + list.add(fromJson(iterator.next().getAsJsonObject())); + } + return list; + } + + /** + * The corpus of source code this KytheVName belongs to. Loosely, a corpus is a collection of + * related files, such as the contents of a given source repository. + */ + public String getCorpus() { + return corpus; + } + + /** + * The language this name belongs to. + */ + public String getLanguage() { + return language; + } + + /** + * A path-structured label describing the “location” of the named object relative to the corpus and + * the root. + */ + public String getPath() { + return path; + } + + /** + * A corpus-specific root label, typically a directory path or project identifier, denoting a + * distinct subset of the corpus. This may also be used to designate virtual collections like + * generated files. + */ + public String getRoot() { + return root; + } + + /** + * An opaque signature generated by the analyzer. + */ + public String getSignature() { + return signature; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(signature); + builder.append(corpus); + builder.append(root); + builder.append(path); + builder.append(language); + return builder.toHashCode(); + } + + public JsonObject toJson() { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("signature", signature); + jsonObject.addProperty("corpus", corpus); + jsonObject.addProperty("root", root); + jsonObject.addProperty("path", path); + jsonObject.addProperty("language", language); + return jsonObject; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("["); + builder.append("signature="); + builder.append(signature + ", "); + builder.append("corpus="); + builder.append(corpus + ", "); + builder.append("root="); + builder.append(root + ", "); + builder.append("path="); + builder.append(path + ", "); + builder.append("language="); + builder.append(language); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/pkg/analysis_server/tool/spec/spec_input.html b/pkg/analysis_server/tool/spec/spec_input.html index 531bedeaa04..931005bac4f 100644 --- a/pkg/analysis_server/tool/spec/spec_input.html +++ b/pkg/analysis_server/tool/spec/spec_input.html @@ -2528,6 +2528,41 @@ + +

+ The kythe domain contains APIs related to generating Dart content in the + Kythe format. +

+ +

Return the list of KytheEntry objects for some file, given the current state of the + file system populated by "analysis.updateContent".

+ + + FilePath +

+ The file containing the code for which the Kythe Entry objects are being requested. +

+
+
+ + + + KytheEntry + +

The list of KytheEntry objects for the queried file.

+
+ + + FilePath + +

The set of files paths that were required, but not in the file system, to give a complete + and accurate Kythe graph for the file. This could be due to a referenced file that does + not exist or generated files not being generated or passed before the call to + "getKytheEntries".

+
+
+
+

Types

@@ -2981,6 +3016,87 @@ + +

+ This object matches the format and documentation of the Entry object documented in the + Kythe Storage Model. +

+ + + KytheVName +

+ The ticket of the source node (must not be empty). +

+
+ + String +

+ An edge label (may be empty). The schema defines which labels are meaningful. +

+
+ + KytheVName +

+ The ticket of the target node (may be empty). +

+
+ + String +

+ A fact label (must not be empty). The schema defines which fact labels are meaningful. +

+
+ + + int + +

+ The String value of the fact (may be empty). +

+
+
+ + +

+ This object matches the format and documentation of the Vector-Name object documented in the + Kythe Storage Model. +

+ + + String +

+ An opaque signature generated by the analyzer. +

+
+ + String +

+ The corpus of source code this KytheVName belongs to. Loosely, a corpus is a + collection of related files, such as the contents of a given source repository. +

+
+ + String +

+ A corpus-specific root label, typically a directory path or project identifier, denoting a + distinct subset of the corpus. This may also be used to designate virtual collections like generated files. +

+
+ + String +

+ A path-structured label describing the “location” of the named object relative to the corpus + and the root. +

+
+ + String +

+ The language this name belongs to. +

+
+
+

A description of a member that overrides an inherited member.