List<LookupElement> (@NotNull CompletionParameters parameters, @NotNull PsiJavaCodeReferenceElement referenceElement, @NotNull PrefixMatcher prefixMatcher) { List<LookupElement> lookupElements = new SmartList<>(); PsiJavaFile psiJavaFile = ObjectUtils.tryCast(referenceElement.getContainingFile(), PsiJavaFile.class); if (psiJavaFile == null) return lookupElements; PsiJavaModule javaModule = JavaModuleGraphUtil.findDescriptorByElement(psiJavaFile.getOriginalElement()); if (javaModule == null) { String packageName = psiJavaFile.getPackageName(); PsiPackage psiPackage = JavaPsiFacade.getInstance(psiJavaFile.getProject()).findPackage(packageName); if (psiPackage == null) return lookupElements; for (PsiClass psiClass : psiPackage.getClasses(referenceElement.getResolveScope())) { CompletionElement completionElement = new CompletionElement(psiClass, PsiSubstitutor.EMPTY); JavaCompletionUtil.createLookupElements(completionElement, referenceElement).forEach(lookupElements::add); } } else { JavaClassNameCompletionContributor.addAllClasses(parameters, true, prefixMatcher, lookupElements::add); } return lookupElements; }