Skip to content

Commit b8322a0

Browse files
committed
Polish bean completion items optics
1 parent 1630eb1 commit b8322a0

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2016, 2019 Pivotal, Inc.
2+
* Copyright (c) 2016, 2025 Pivotal, Inc.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@
1616

1717
import org.eclipse.lsp4j.Command;
1818
import org.eclipse.lsp4j.CompletionItemKind;
19+
import org.eclipse.lsp4j.CompletionItemLabelDetails;
1920
import org.springframework.ide.vscode.commons.util.Renderable;
2021

2122
/**
@@ -63,4 +64,8 @@ default Optional<Command> getCommand() {
6364
return Optional.empty();
6465
}
6566

67+
default CompletionItemLabelDetails getLabelDetails() {
68+
return null;
69+
}
70+
6671
}

headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ private CompletionItem adaptItem(TextDocument doc, ICompletionProposal completio
281281
item.setSortText(sortkeys.next());
282282
item.setFilterText(completion.getFilterText());
283283
item.setInsertTextMode(InsertTextMode.AsIs);
284+
item.setLabelDetails(completion.getLabelDetails());
284285
if (completion.isDeprecated()) {
285286
item.setTags(List.of(CompletionItemTag.Deprecated));
286287
}

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/beans/BeanCompletionProposal.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import org.eclipse.lsp4j.Command;
1818
import org.eclipse.lsp4j.CompletionItemKind;
19+
import org.eclipse.lsp4j.CompletionItemLabelDetails;
20+
import org.openrewrite.java.tree.JavaType;
1921
import org.springframework.ide.vscode.boot.java.rewrite.RewriteRefactorings;
2022
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
2123
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposalWithScore;
@@ -32,6 +34,8 @@
3234
*/
3335
public class BeanCompletionProposal implements ICompletionProposalWithScore {
3436

37+
private static final String DETAIL = " - autowire bean";
38+
3539
private DocumentEdits edits;
3640
private IDocument doc;
3741
private String beanId;
@@ -54,12 +58,12 @@ public BeanCompletionProposal(DocumentEdits edits, IDocument doc, String beanId,
5458

5559
@Override
5660
public String getLabel() {
57-
return this.beanId;
61+
return beanId;
5862
}
5963

6064
@Override
6165
public CompletionItemKind getKind() {
62-
return CompletionItemKind.Constructor;
66+
return CompletionItemKind.Field;
6367
}
6468

6569
@Override
@@ -71,6 +75,14 @@ public DocumentEdits getTextEdit() {
7175
public String getDetail() {
7276
return "Autowire a bean";
7377
}
78+
79+
@Override
80+
public CompletionItemLabelDetails getLabelDetails() {
81+
CompletionItemLabelDetails labelDetails = new CompletionItemLabelDetails();
82+
labelDetails.setDetail(DETAIL);
83+
labelDetails.setDescription(JavaType.ShallowClass.build(beanType).getClassName());
84+
return labelDetails;
85+
}
7486

7587
@Override
7688
public Renderable getDocumentation() {

0 commit comments

Comments
 (0)