StaticMemberProcessor (CompletionParameters parameters) { final PsiElement position = parameters.getPosition(); final PsiElement originalPosition = parameters.getOriginalPosition(); final StaticMemberProcessor processor = new StaticMemberProcessor(position) { @NotNull @Override protected LookupElement createLookupElement(@NotNull PsiMember member, @NotNull PsiClass containingClass, boolean shouldImport) { shouldImport |= originalPosition != null && PsiTreeUtil.isAncestor(containingClass, originalPosition, false); return createGlobalMemberElement(member, containingClass, shouldImport); } @Override protected LookupElement createLookupElement(@NotNull List<? extends PsiMethod> overloads, @NotNull PsiClass containingClass, boolean shouldImport) { shouldImport |= originalPosition != null && PsiTreeUtil.isAncestor(containingClass, originalPosition, false); return new JavaGlobalMemberLookupElement(overloads, containingClass, QualifiedMethodInsertHandler.INSTANCE, StaticImportInsertHandler.INSTANCE, shouldImport); } @Override protected boolean isAccessible(@NotNull PsiMember member) { boolean result = super.isAccessible(member); if (!result && member instanceof GrField) { GrAccessorMethod[] getters = ((GrField)member).getGetters(); return getters.length > 0 && super.isAccessible(getters[0]); } return result; } }; final PsiFile file = position.getContainingFile(); if (file instanceof GroovyFile) { for (GrImportStatement statement : ((GroovyFile)file).getImportStatements()) { if (statement.isStatic()) { GrCodeReferenceElement importReference = statement.getImportReference(); if (importReference != null) { if (!statement.isOnDemand()) { importReference = importReference.getQualifier(); } if (importReference != null) { final PsiElement target = importReference.resolve(); if (target instanceof PsiClass) { processor.importMembersOf((PsiClass)target); } } } } } } return processor; }