LookupElement (PsiMethod prototype, PsiSubstitutor substitutor, Icon icon, String typeText, InsertHandler<LookupElement> insertHandler, boolean generateByWizard, boolean generateDefaultMethod, PsiClass targetClass) { String methodName = prototype.getName(); String visibility = VisibilityUtil.getVisibilityModifier(prototype.getModifierList()); String modifiers = (visibility.equals(PsiModifier.PACKAGE_LOCAL) || visibility.equals(PsiModifier.PUBLIC) && targetClass.isInterface() ? "" : visibility + " "); if (generateDefaultMethod) { modifiers = "default " + modifiers; } PsiType type = substitutor.substitute(prototype.getReturnType()); String signature = modifiers + (type == null ? "" : type.getPresentableText() + " ") + methodName; String parameters = "(" + StringUtil.join(prototype.getParameterList().getParameters(), p -> getShortParameterName(substitutor, p) + " " + p.getName(), ", ") + ")"; String overrideSignature = " @Override " + signature; // leading space to make it a middle match, under all annotation suggestions String tailText = " " + (generateByWizard ? JavaBundle.message("completion.generate.via.wizard") : "{...}"); LookupElementBuilder element = LookupElementBuilder.create(prototype, signature).withLookupString(methodName). withLookupString(signature).withLookupString(overrideSignature).withInsertHandler(insertHandler). appendTailText(parameters, false).appendTailText(tailText, true).withTypeText(typeText).withIcon(icon); if (generateByWizard) { JavaMethodMergingContributor.disallowMerge(element); } if (prototype.isDeprecated()) { element = element.withStrikeoutness(true); } element.putUserData(GENERATE_ELEMENT, true); return PrioritizedLookupElement.withPriority(element, -1); }