refactor to more generic proposal implementation for annotation attribute proposals
This commit is contained in:
@@ -26,7 +26,6 @@ import org.eclipse.jdt.core.dom.ITypeBinding;
|
||||
import org.eclipse.jdt.core.dom.MemberValuePair;
|
||||
import org.eclipse.jdt.core.dom.SimpleName;
|
||||
import org.eclipse.jdt.core.dom.StringLiteral;
|
||||
import org.springframework.ide.vscode.boot.java.beans.QualifierCompletionProposal;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.CompletionProvider;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
@@ -124,7 +123,7 @@ public class AnnotationAttributeCompletionProcessor implements CompletionProvide
|
||||
DocumentEdits edits = new DocumentEdits(doc, false);
|
||||
edits.replace(startOffset, endOffset, createReplacementText.apply(candidate));
|
||||
|
||||
QualifierCompletionProposal proposal = new QualifierCompletionProposal(edits, candidate, candidate, null, score--);
|
||||
AnnotationAttributeCompletionProposal proposal = new AnnotationAttributeCompletionProposal(edits, candidate, candidate, null, score--);
|
||||
completions.add(proposal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Contributors:
|
||||
* Broadcom - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.beans;
|
||||
package org.springframework.ide.vscode.boot.java.annotations;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
@@ -18,7 +18,7 @@ import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class QualifierCompletionProposal extends ScoreableProposal {
|
||||
public class AnnotationAttributeCompletionProposal extends ScoreableProposal {
|
||||
|
||||
private static final String EMPTY_DETAIL = "";
|
||||
|
||||
@@ -28,7 +28,7 @@ public class QualifierCompletionProposal extends ScoreableProposal {
|
||||
private final Renderable documentation;
|
||||
private final double score;
|
||||
|
||||
public QualifierCompletionProposal(DocumentEdits edits, String label, String detail, Renderable documentation, double score) {
|
||||
public AnnotationAttributeCompletionProposal(DocumentEdits edits, String label, String detail, Renderable documentation, double score) {
|
||||
this.edits = edits;
|
||||
this.label = label;
|
||||
this.detail = detail == null ? EMPTY_DETAIL : detail;
|
||||
@@ -1,62 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2024 Broadcom
|
||||
* 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Broadcom - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.beans;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class DependsOnCompletionProposal implements ICompletionProposal {
|
||||
|
||||
private static final String EMPTY_DETAIL = "";
|
||||
|
||||
private DocumentEdits edits;
|
||||
private String label;
|
||||
private String detail;
|
||||
private Renderable documentation;
|
||||
|
||||
public DependsOnCompletionProposal(DocumentEdits edits, String label, String detail, Renderable documentation) {
|
||||
this.edits = edits;
|
||||
this.label = label;
|
||||
this.detail = detail == null ? EMPTY_DETAIL : detail;
|
||||
this.documentation = documentation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionItemKind getKind() {
|
||||
return CompletionItemKind.Value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentEdits getTextEdit() {
|
||||
return this.edits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetail() {
|
||||
return this.detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Renderable getDocumentation() {
|
||||
return this.documentation;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import org.eclipse.jdt.core.dom.StringLiteral;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.beans.QualifierCompletionProposal;
|
||||
import org.springframework.ide.vscode.boot.java.annotations.AnnotationAttributeCompletionProposal;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.CompletionProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
@@ -148,7 +148,7 @@ public class ValueCompletionProcessor implements CompletionProvider {
|
||||
|
||||
String label = "classpath:" + resource;
|
||||
|
||||
ICompletionProposal proposal = new QualifierCompletionProposal(edits, label, label, null, score--);
|
||||
ICompletionProposal proposal = new AnnotationAttributeCompletionProposal(edits, label, label, null, score--);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user