mirror of
https://github.com/dart-lang/sdk
synced 2024-07-20 18:05:01 +00:00
Add optional elementUri field to CompletionSuggestion types in analysis server protocol
This will enable clients such as IntelliJ to display the package which code completions are being offered from in addition to the keyword or identifier that they're already getting from analysis server. R=brianwilkerson@google.com Change-Id: I30311451ad56b4eddbe73da20641ee0d14849293 Reviewed-on: https://dart-review.googlesource.com/c/88744 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Ari Aye <ariaye@google.com>
This commit is contained in:
parent
13a689f0fd
commit
b767744cfc
|
@ -109,7 +109,7 @@ a:focus, a:hover {
|
|||
<body>
|
||||
<h1>Analysis Server API Specification</h1>
|
||||
<h1 style="color:#999999">Version
|
||||
1.21.1
|
||||
1.22.1
|
||||
</h1>
|
||||
<p>
|
||||
This document contains a specification of the API provided by the
|
||||
|
@ -2918,6 +2918,12 @@ a:focus, a:hover {
|
|||
is only defined if the displayed text should be different than the
|
||||
completion. Otherwise it is omitted.
|
||||
</p>
|
||||
</dd><dt class="field"><b>elementUri: String<span style="color:#999999"> (optional)</span></b></dt><dd>
|
||||
|
||||
<p>
|
||||
The URI of the element corresponding to this suggestion. It will be
|
||||
set whenever analysis server is able to compute it.
|
||||
</p>
|
||||
</dd><dt class="field"><b>selectionOffset: int</b></dt><dd>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
const String PROTOCOL_VERSION = '1.21.1';
|
||||
const String PROTOCOL_VERSION = '1.22.1';
|
||||
|
||||
const String ANALYSIS_NOTIFICATION_ANALYZED_FILES = 'analysis.analyzedFiles';
|
||||
const String ANALYSIS_NOTIFICATION_ANALYZED_FILES_DIRECTORIES = 'directories';
|
||||
|
|
|
@ -202,6 +202,7 @@ final Matcher isCompletionId = isString;
|
|||
* "relevance": int
|
||||
* "completion": String
|
||||
* "displayText": optional String
|
||||
* "elementUri": optional String
|
||||
* "selectionOffset": int
|
||||
* "selectionLength": int
|
||||
* "isDeprecated": bool
|
||||
|
@ -233,6 +234,7 @@ final Matcher isCompletionSuggestion =
|
|||
"isPotential": isBool
|
||||
}, optionalFields: {
|
||||
"displayText": isString,
|
||||
"elementUri": isString,
|
||||
"docSummary": isString,
|
||||
"docComplete": isString,
|
||||
"declaringType": isString,
|
||||
|
|
|
@ -59,6 +59,12 @@ public class CompletionSuggestion {
|
|||
*/
|
||||
private final String displayText;
|
||||
|
||||
/**
|
||||
* The URI of the element corresponding to this suggestion. It will be set whenever analysis server
|
||||
* is able to compute it.
|
||||
*/
|
||||
private final String elementUri;
|
||||
|
||||
/**
|
||||
* The offset, relative to the beginning of the completion, of where the selection should be placed
|
||||
* after insertion.
|
||||
|
@ -169,11 +175,12 @@ public class CompletionSuggestion {
|
|||
/**
|
||||
* Constructor for {@link CompletionSuggestion}.
|
||||
*/
|
||||
public CompletionSuggestion(String kind, int relevance, String completion, String displayText, int selectionOffset, int selectionLength, boolean isDeprecated, boolean isPotential, String docSummary, String docComplete, String declaringType, String defaultArgumentListString, int[] defaultArgumentListTextRanges, Element element, String returnType, List<String> parameterNames, List<String> parameterTypes, Integer requiredParameterCount, Boolean hasNamedParameters, String parameterName, String parameterType, String importUri) {
|
||||
public CompletionSuggestion(String kind, int relevance, String completion, String displayText, String elementUri, int selectionOffset, int selectionLength, boolean isDeprecated, boolean isPotential, String docSummary, String docComplete, String declaringType, String defaultArgumentListString, int[] defaultArgumentListTextRanges, Element element, String returnType, List<String> parameterNames, List<String> parameterTypes, Integer requiredParameterCount, Boolean hasNamedParameters, String parameterName, String parameterType, String importUri) {
|
||||
this.kind = kind;
|
||||
this.relevance = relevance;
|
||||
this.completion = completion;
|
||||
this.displayText = displayText;
|
||||
this.elementUri = elementUri;
|
||||
this.selectionOffset = selectionOffset;
|
||||
this.selectionLength = selectionLength;
|
||||
this.isDeprecated = isDeprecated;
|
||||
|
@ -203,6 +210,7 @@ public class CompletionSuggestion {
|
|||
other.relevance == relevance &&
|
||||
ObjectUtilities.equals(other.completion, completion) &&
|
||||
ObjectUtilities.equals(other.displayText, displayText) &&
|
||||
ObjectUtilities.equals(other.elementUri, elementUri) &&
|
||||
other.selectionOffset == selectionOffset &&
|
||||
other.selectionLength == selectionLength &&
|
||||
other.isDeprecated == isDeprecated &&
|
||||
|
@ -230,6 +238,7 @@ public class CompletionSuggestion {
|
|||
int relevance = jsonObject.get("relevance").getAsInt();
|
||||
String completion = jsonObject.get("completion").getAsString();
|
||||
String displayText = jsonObject.get("displayText") == null ? null : jsonObject.get("displayText").getAsString();
|
||||
String elementUri = jsonObject.get("elementUri") == null ? null : jsonObject.get("elementUri").getAsString();
|
||||
int selectionOffset = jsonObject.get("selectionOffset").getAsInt();
|
||||
int selectionLength = jsonObject.get("selectionLength").getAsInt();
|
||||
boolean isDeprecated = jsonObject.get("isDeprecated").getAsBoolean();
|
||||
|
@ -248,7 +257,7 @@ public class CompletionSuggestion {
|
|||
String parameterName = jsonObject.get("parameterName") == null ? null : jsonObject.get("parameterName").getAsString();
|
||||
String parameterType = jsonObject.get("parameterType") == null ? null : jsonObject.get("parameterType").getAsString();
|
||||
String importUri = jsonObject.get("importUri") == null ? null : jsonObject.get("importUri").getAsString();
|
||||
return new CompletionSuggestion(kind, relevance, completion, displayText, selectionOffset, selectionLength, isDeprecated, isPotential, docSummary, docComplete, declaringType, defaultArgumentListString, defaultArgumentListTextRanges, element, returnType, parameterNames, parameterTypes, requiredParameterCount, hasNamedParameters, parameterName, parameterType, importUri);
|
||||
return new CompletionSuggestion(kind, relevance, completion, displayText, elementUri, selectionOffset, selectionLength, isDeprecated, isPotential, docSummary, docComplete, declaringType, defaultArgumentListString, defaultArgumentListTextRanges, element, returnType, parameterNames, parameterTypes, requiredParameterCount, hasNamedParameters, parameterName, parameterType, importUri);
|
||||
}
|
||||
|
||||
public static List<CompletionSuggestion> fromJsonArray(JsonArray jsonArray) {
|
||||
|
@ -329,6 +338,14 @@ public class CompletionSuggestion {
|
|||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URI of the element corresponding to this suggestion. It will be set whenever analysis server
|
||||
* is able to compute it.
|
||||
*/
|
||||
public String getElementUri() {
|
||||
return elementUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the function or method being suggested has at least one named parameter. This field is
|
||||
* omitted if the parameterNames field is omitted.
|
||||
|
@ -444,6 +461,7 @@ public class CompletionSuggestion {
|
|||
builder.append(relevance);
|
||||
builder.append(completion);
|
||||
builder.append(displayText);
|
||||
builder.append(elementUri);
|
||||
builder.append(selectionOffset);
|
||||
builder.append(selectionLength);
|
||||
builder.append(isDeprecated);
|
||||
|
@ -473,6 +491,9 @@ public class CompletionSuggestion {
|
|||
if (displayText != null) {
|
||||
jsonObject.addProperty("displayText", displayText);
|
||||
}
|
||||
if (elementUri != null) {
|
||||
jsonObject.addProperty("elementUri", elementUri);
|
||||
}
|
||||
jsonObject.addProperty("selectionOffset", selectionOffset);
|
||||
jsonObject.addProperty("selectionLength", selectionLength);
|
||||
jsonObject.addProperty("isDeprecated", isDeprecated);
|
||||
|
@ -546,6 +567,8 @@ public class CompletionSuggestion {
|
|||
builder.append(completion + ", ");
|
||||
builder.append("displayText=");
|
||||
builder.append(displayText + ", ");
|
||||
builder.append("elementUri=");
|
||||
builder.append(elementUri + ", ");
|
||||
builder.append("selectionOffset=");
|
||||
builder.append(selectionOffset + ", ");
|
||||
builder.append("selectionLength=");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<body>
|
||||
<h1>Analysis Server API Specification</h1>
|
||||
<h1 style="color:#999999">Version
|
||||
<version>1.21.1</version>
|
||||
<version>1.22.1</version>
|
||||
</h1>
|
||||
<p>
|
||||
This document contains a specification of the API provided by the
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// To regenerate the file, use the script
|
||||
// "pkg/analysis_server/tool/spec/generate_files".
|
||||
|
||||
const String PROTOCOL_VERSION = '1.21.1';
|
||||
const String PROTOCOL_VERSION = '1.22.1';
|
||||
|
||||
const String ANALYSIS_NOTIFICATION_ANALYZED_FILES = 'analysis.analyzedFiles';
|
||||
const String ANALYSIS_NOTIFICATION_ANALYZED_FILES_DIRECTORIES = 'directories';
|
||||
|
|
|
@ -1004,6 +1004,12 @@ a:focus, a:hover {
|
|||
is only defined if the displayed text should be different than the
|
||||
completion. Otherwise it is omitted.
|
||||
</p>
|
||||
</dd><dt class="field"><b>elementUri: String<span style="color:#999999"> (optional)</span></b></dt><dd>
|
||||
|
||||
<p>
|
||||
The URI of the element corresponding to this suggestion. It will be
|
||||
set whenever analysis server is able to compute it.
|
||||
</p>
|
||||
</dd><dt class="field"><b>selectionOffset: int</b></dt><dd>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -598,6 +598,7 @@ class ChangeContentOverlay implements HasToJson {
|
|||
* "relevance": int
|
||||
* "completion": String
|
||||
* "displayText": optional String
|
||||
* "elementUri": optional String
|
||||
* "selectionOffset": int
|
||||
* "selectionLength": int
|
||||
* "isDeprecated": bool
|
||||
|
@ -629,6 +630,8 @@ class CompletionSuggestion implements HasToJson {
|
|||
|
||||
String _displayText;
|
||||
|
||||
String _elementUri;
|
||||
|
||||
int _selectionOffset;
|
||||
|
||||
int _selectionLength;
|
||||
|
@ -728,6 +731,20 @@ class CompletionSuggestion implements HasToJson {
|
|||
this._displayText = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URI of the element corresponding to this suggestion. It will be set
|
||||
* whenever analysis server is able to compute it.
|
||||
*/
|
||||
String get elementUri => _elementUri;
|
||||
|
||||
/**
|
||||
* The URI of the element corresponding to this suggestion. It will be set
|
||||
* whenever analysis server is able to compute it.
|
||||
*/
|
||||
void set elementUri(String value) {
|
||||
this._elementUri = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The offset, relative to the beginning of the completion, of where the
|
||||
* selection should be placed after insertion.
|
||||
|
@ -1003,6 +1020,7 @@ class CompletionSuggestion implements HasToJson {
|
|||
bool isDeprecated,
|
||||
bool isPotential,
|
||||
{String displayText,
|
||||
String elementUri,
|
||||
String docSummary,
|
||||
String docComplete,
|
||||
String declaringType,
|
||||
|
@ -1021,6 +1039,7 @@ class CompletionSuggestion implements HasToJson {
|
|||
this.relevance = relevance;
|
||||
this.completion = completion;
|
||||
this.displayText = displayText;
|
||||
this.elementUri = elementUri;
|
||||
this.selectionOffset = selectionOffset;
|
||||
this.selectionLength = selectionLength;
|
||||
this.isDeprecated = isDeprecated;
|
||||
|
@ -1073,6 +1092,11 @@ class CompletionSuggestion implements HasToJson {
|
|||
displayText = jsonDecoder.decodeString(
|
||||
jsonPath + ".displayText", json["displayText"]);
|
||||
}
|
||||
String elementUri;
|
||||
if (json.containsKey("elementUri")) {
|
||||
elementUri = jsonDecoder.decodeString(
|
||||
jsonPath + ".elementUri", json["elementUri"]);
|
||||
}
|
||||
int selectionOffset;
|
||||
if (json.containsKey("selectionOffset")) {
|
||||
selectionOffset = jsonDecoder.decodeInt(
|
||||
|
@ -1178,6 +1202,7 @@ class CompletionSuggestion implements HasToJson {
|
|||
return new CompletionSuggestion(kind, relevance, completion,
|
||||
selectionOffset, selectionLength, isDeprecated, isPotential,
|
||||
displayText: displayText,
|
||||
elementUri: elementUri,
|
||||
docSummary: docSummary,
|
||||
docComplete: docComplete,
|
||||
declaringType: declaringType,
|
||||
|
@ -1206,6 +1231,9 @@ class CompletionSuggestion implements HasToJson {
|
|||
if (displayText != null) {
|
||||
result["displayText"] = displayText;
|
||||
}
|
||||
if (elementUri != null) {
|
||||
result["elementUri"] = elementUri;
|
||||
}
|
||||
result["selectionOffset"] = selectionOffset;
|
||||
result["selectionLength"] = selectionLength;
|
||||
result["isDeprecated"] = isDeprecated;
|
||||
|
@ -1265,6 +1293,7 @@ class CompletionSuggestion implements HasToJson {
|
|||
relevance == other.relevance &&
|
||||
completion == other.completion &&
|
||||
displayText == other.displayText &&
|
||||
elementUri == other.elementUri &&
|
||||
selectionOffset == other.selectionOffset &&
|
||||
selectionLength == other.selectionLength &&
|
||||
isDeprecated == other.isDeprecated &&
|
||||
|
@ -1297,6 +1326,7 @@ class CompletionSuggestion implements HasToJson {
|
|||
hash = JenkinsSmiHash.combine(hash, relevance.hashCode);
|
||||
hash = JenkinsSmiHash.combine(hash, completion.hashCode);
|
||||
hash = JenkinsSmiHash.combine(hash, displayText.hashCode);
|
||||
hash = JenkinsSmiHash.combine(hash, elementUri.hashCode);
|
||||
hash = JenkinsSmiHash.combine(hash, selectionOffset.hashCode);
|
||||
hash = JenkinsSmiHash.combine(hash, selectionLength.hashCode);
|
||||
hash = JenkinsSmiHash.combine(hash, isDeprecated.hashCode);
|
||||
|
|
|
@ -134,6 +134,7 @@ final Matcher isChangeContentOverlay = new LazyMatcher(() =>
|
|||
* "relevance": int
|
||||
* "completion": String
|
||||
* "displayText": optional String
|
||||
* "elementUri": optional String
|
||||
* "selectionOffset": int
|
||||
* "selectionLength": int
|
||||
* "isDeprecated": bool
|
||||
|
@ -165,6 +166,7 @@ final Matcher isCompletionSuggestion =
|
|||
"isPotential": isBool
|
||||
}, optionalFields: {
|
||||
"displayText": isString,
|
||||
"elementUri": isString,
|
||||
"docSummary": isString,
|
||||
"docComplete": isString,
|
||||
"declaringType": isString,
|
||||
|
|
|
@ -206,6 +206,13 @@
|
|||
completion. Otherwise it is omitted.
|
||||
</p>
|
||||
</field>
|
||||
<field name="elementUri" optional="true">
|
||||
<ref>String</ref>
|
||||
<p>
|
||||
The URI of the element corresponding to this suggestion. It will be
|
||||
set whenever analysis server is able to compute it.
|
||||
</p>
|
||||
</field>
|
||||
<field name="selectionOffset">
|
||||
<ref>int</ref>
|
||||
<p>
|
||||
|
|
Loading…
Reference in a new issue