How to set the presentation of a reference?
Answered
I implemented "go to declaration" by extends PsiReferenceBase and implements PsiPolyVariantReference, according to this: https://plugins.jetbrains.com/docs/intellij/references-and-resolve.html
When I press Ctrl+click it can jump to the declaration, but the presentation of the hint looks very original. **How Can I override that hint message with my custom presentation?** Any help/pointers are very gratefully received.
P.S. Here's my source code about psiElement.getReference() :
public class KCLIdentifierReference extends PsiReferenceBase<KCLIdentifier> implements PsiPolyVariantReference {
public KCLIdentifierReference(@NotNull KCLIdentifier element) {
super(element);
}
@Override
public @NotNull ResolveResult[] multiResolve(boolean incompleteCode) {
KCLFile mainFile = (KCLFile) myElement.getContainingFile();
SymbolTable symbolTable = KCLUtil.buildSymbolTable(mainFile);
return wrapResult(symbolTable.searchSymbol(myElement));
}
@Override
public @Nullable PsiElement resolve() {
ResolveResult[] resolveResults = multiResolve(false);
return resolveResults.length == 1 ? resolveResults[0].getElement() : null;
}
@Override
public @NotNull TextRange getRangeInElement() {
return TextRange.create(0, myElement.getTextRange().getLength());
}
private ResolveResult[] wrapResult(List<Symbol> symbols) {
if (symbols == null) {
return new ResolveResult[] {};
}
return symbols.stream().map(symbol -> new PsiElementResolveResult(symbol.getNode())).collect(Collectors.toList()).toArray(
new ResolveResult[symbols.size()]);
}
}
Please sign in to leave a comment.
This is provided by com.intellij.lang.documentation.DocumentationProvider#getQuickNavigateInfo
See https://plugins.jetbrains.com/intellij-platform-explorer?extensions=com.intellij.lang.documentationProvider for samples