Polish bean completion items optics
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 2025 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -16,6 +16,7 @@ import java.util.function.Supplier;
|
||||
|
||||
import org.eclipse.lsp4j.Command;
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
import org.eclipse.lsp4j.CompletionItemLabelDetails;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
/**
|
||||
@@ -63,4 +64,8 @@ public interface ICompletionProposal {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default CompletionItemLabelDetails getLabelDetails() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -281,6 +281,7 @@ public class VscodeCompletionEngineAdapter implements VscodeCompletionEngine {
|
||||
item.setSortText(sortkeys.next());
|
||||
item.setFilterText(completion.getFilterText());
|
||||
item.setInsertTextMode(InsertTextMode.AsIs);
|
||||
item.setLabelDetails(completion.getLabelDetails());
|
||||
if (completion.isDeprecated()) {
|
||||
item.setTags(List.of(CompletionItemTag.Deprecated));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.Optional;
|
||||
|
||||
import org.eclipse.lsp4j.Command;
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
import org.eclipse.lsp4j.CompletionItemLabelDetails;
|
||||
import org.openrewrite.java.tree.JavaType;
|
||||
import org.springframework.ide.vscode.boot.java.rewrite.RewriteRefactorings;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposalWithScore;
|
||||
@@ -32,6 +34,8 @@ import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
*/
|
||||
public class BeanCompletionProposal implements ICompletionProposalWithScore {
|
||||
|
||||
private static final String DETAIL = " - autowire bean";
|
||||
|
||||
private DocumentEdits edits;
|
||||
private IDocument doc;
|
||||
private String beanId;
|
||||
@@ -54,12 +58,12 @@ public class BeanCompletionProposal implements ICompletionProposalWithScore {
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return this.beanId;
|
||||
return beanId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionItemKind getKind() {
|
||||
return CompletionItemKind.Constructor;
|
||||
return CompletionItemKind.Field;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,6 +75,14 @@ public class BeanCompletionProposal implements ICompletionProposalWithScore {
|
||||
public String getDetail() {
|
||||
return "Autowire a bean";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionItemLabelDetails getLabelDetails() {
|
||||
CompletionItemLabelDetails labelDetails = new CompletionItemLabelDetails();
|
||||
labelDetails.setDetail(DETAIL);
|
||||
labelDetails.setDescription(JavaType.ShallowClass.build(beanType).getClassName());
|
||||
return labelDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Renderable getDocumentation() {
|
||||
|
||||
Reference in New Issue
Block a user