void (@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result, PsiElement position) { PrefixMatcher matcher = result.getPrefixMatcher(); int prefixStart = parameters.getOffset() - matcher.getPrefix().length() - position.getTextRange().getStartOffset(); String text = position.getText(); if (prefixStart > 0 && text.charAt(prefixStart - 1) == '#') { int classNameStart = findClassNameStart(text, prefixStart - 1); String mockCommentPrefix = "/** {@link "; String mockText = mockCommentPrefix + text.substring(classNameStart) + "}*/"; PsiDocComment mockComment = JavaPsiFacade.getElementFactory(position.getProject()).createDocCommentFromText(mockText, position); PsiJavaReference ref = (PsiJavaReference)mockComment.findReferenceAt(mockCommentPrefix.length() + prefixStart - classNameStart); assert ref != null : mockText; for (LookupElement element : completeJavadocReference(ref.getElement(), ref)) { result.addElement(LookupElementDecorator.withInsertHandler(element, wrapIntoLinkTag((context, item) -> element.handleInsert(context)))); } } else if (!matcher.getPrefix().isEmpty()) { InsertHandler<JavaPsiClassReferenceElement> handler = wrapIntoLinkTag(JavaClassNameInsertHandler.JAVA_CLASS_INSERT_HANDLER); AllClassesGetter.processJavaClasses(parameters, matcher, parameters.getInvocationCount() == 1, psiClass -> result.addElement(AllClassesGetter.createLookupItem(psiClass, handler))); } }