@Override @NotNull public PsiReference[] getReferences() { if (getLabelIdentifier() == null) return PsiReference.EMPTY_ARRAY; return new PsiReference[]{new PsiLabelReference(this, getLabelIdentifier())}; }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiReference ref = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset()); if (ref instanceof PsiLabelReference) { processLabelReference(result, (PsiLabelReference)ref); } }
@RequiredReadAction @Override public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiReference ref = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset()); if(ref instanceof PsiLabelReference) { result.addAllElements(processLabelReference((PsiLabelReference) ref)); } }
static void processLabelReference(CompletionResultSet result, PsiLabelReference ref) { for (String s : ref.getVariants()) { result.addElement(TailTypeDecorator.withTail(LookupElementBuilder.create(s), TailType.SEMICOLON)); } }
static List<LookupElement> processLabelReference(PsiLabelReference ref) { return ContainerUtil.map(ref.getVariants(), s -> TailTypeDecorator.withTail(LookupElementBuilder.create(s), TailType.SEMICOLON)); }