Skip to content

Commit 8ef4039

Browse files
authored
Label Details support (#1240)
Support `CompletionItem` `LabelDetails` object Separated from #1238
1 parent 366d962 commit 8ef4039

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/completion/LSCompletionProposal.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.eclipse.lsp4j.Command;
7272
import org.eclipse.lsp4j.CompletionItem;
7373
import org.eclipse.lsp4j.CompletionItemDefaults;
74+
import org.eclipse.lsp4j.CompletionItemLabelDetails;
7475
import org.eclipse.lsp4j.CompletionOptions;
7576
import org.eclipse.lsp4j.ExecuteCommandOptions;
7677
import org.eclipse.lsp4j.ExecuteCommandParams;
@@ -283,9 +284,7 @@ private boolean isDeprecated() {
283284
@Override
284285
public StyledString getStyledDisplayString(IDocument document, int offset, BoldStylerProvider boldStylerProvider) {
285286
String rawString = getDisplayString();
286-
StyledString res = isDeprecated()
287-
? new StyledString(rawString, StyleUtil.DEPRECATE)
288-
: new StyledString(rawString);
287+
StyledString res = getStyledDisplayString();
289288
if (offset > bestOffset) {
290289
try {
291290
String subString = getDocumentFilter(offset).toLowerCase();
@@ -324,10 +323,19 @@ public String getDisplayString() {
324323

325324
@Override
326325
public StyledString getStyledDisplayString() {
327-
if (Boolean.TRUE.equals(item.getDeprecated())) {
328-
return new StyledString(getDisplayString(), StyleUtil.DEPRECATE);
326+
StyledString ss = isDeprecated()
327+
? new StyledString(getDisplayString(), StyleUtil.DEPRECATE)
328+
: new StyledString(getDisplayString());
329+
CompletionItemLabelDetails labelDetails = item.getLabelDetails();
330+
if (labelDetails != null) {
331+
if (labelDetails.getDetail() != null) {
332+
ss.append(new StyledString(labelDetails.getDetail(), StyledString.QUALIFIER_STYLER));
333+
}
334+
if (labelDetails.getDescription() != null) {
335+
ss.append(' ' + labelDetails.getDescription(), StyledString.DECORATIONS_STYLER);
336+
}
329337
}
330-
return new StyledString(getDisplayString());
338+
return ss;
331339
}
332340

333341
@Override

0 commit comments

Comments
 (0)