improved XML bean class content assist for improved matching, sorting, and performance

This commit is contained in:
Martin Lippert
2019-04-10 13:42:51 +02:00
parent 4e2d29de47
commit 350560b850
3 changed files with 16 additions and 8 deletions

View File

@@ -66,10 +66,11 @@ public class SpringXMLCompletionEngine implements ICompletionEngine {
DOMAttr attributeAt = dom.findAttrAt(offset);
if (attributeAt != null) {
XMLCompletionProviderKey key = new XMLCompletionProviderKey(namespace, node.getNodeName(), attributeAt.getNodeName());
XMLCompletionProviderKey key = new XMLCompletionProviderKey(namespace, node.getLocalName(), attributeAt.getNodeName());
XMLCompletionProvider completionProvider = this.completionProviders.get(key);
if (completionProvider != null) {
return completionProvider.getCompletions(doc, namespace, node, attributeAt, scanner, offset);
Collection<ICompletionProposal> completions = completionProvider.getCompletions(doc, namespace, node, attributeAt, scanner, offset);
return completions;
}
}
}

View File

@@ -12,27 +12,29 @@ package org.springframework.ide.vscode.boot.xml;
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.languageserver.completion.ScoreableProposal;
import org.springframework.ide.vscode.commons.util.Renderable;
/**
* @author Martin Lippert
*/
public class TypeCompletionProposal implements ICompletionProposal {
public class TypeCompletionProposal extends ScoreableProposal {
private final String label;
private final CompletionItemKind kind;
private final DocumentEdits edits;
private final String detail;
private final Renderable documentation;
private final double score;
public TypeCompletionProposal(String label, CompletionItemKind kind, DocumentEdits edits, String detail, Renderable documentation) {
public TypeCompletionProposal(String label, CompletionItemKind kind, DocumentEdits edits, String detail, Renderable documentation, double score) {
super();
this.label = label;
this.kind = kind;
this.edits = edits;
this.detail = detail;
this.documentation = documentation;
this.score = score;
}
@Override
@@ -60,4 +62,9 @@ public class TypeCompletionProposal implements ICompletionProposal {
return this.documentation;
}
@Override
public double getBaseScore() {
return this.score;
}
}

View File

@@ -56,8 +56,8 @@ public class TypeCompletionProposalProvider implements XMLCompletionProvider {
prefix = prefix.substring(1);
}
Flux<Tuple2<IType, Double>> types = project.getIndex().fuzzySearchTypes(prefix, true, true);
// Flux<Tuple2<IType, Double>> types = project.getIndex().camelcaseSearchTypes(prefix, true, true);
// Flux<Tuple2<IType, Double>> types = project.getIndex().fuzzySearchTypes(prefix, true, true);
Flux<Tuple2<IType, Double>> types = project.getIndex().camelcaseSearchTypes(prefix, true, true);
return types
.filter(result -> result.getT1() != null && result.getT1().getElementName() != null && result.getT1().getElementName().length() > 0)
@@ -94,7 +94,7 @@ public class TypeCompletionProposalProvider implements XMLCompletionProvider {
Renderable renderable = null;
return new TypeCompletionProposal(label, kind, edits, type.getFullyQualifiedName(), renderable);
return new TypeCompletionProposal(label, kind, edits, type.getFullyQualifiedName(), renderable, t.getT2());
}
}