void (boolean showAll) { final PsiElement parent = myElement.getParent(); if (parent instanceof PsiReferenceExpression && ((PsiReferenceExpression)parent).getQualifierExpression() != null) return; PsiJavaFile file = ObjectUtils.tryCast(parent.getContainingFile(), PsiJavaFile.class); if (file == null) return; final PsiClass collectionsClass = JavaPsiFacade.getInstance(file.getProject()).findClass(JAVA_UTIL_COLLECTIONS, file.getResolveScope()); if (collectionsClass == null) return; PsiImportList importList = file.getImportList(); if (importList != null) { for (PsiImportStaticStatement statement : importList.getImportStaticStatements()) { PsiClass aClass = statement.resolveTargetClass(); if (aClass != null && file.getManager().areElementsEquivalent(aClass, collectionsClass)) { // The Collections class is already statically imported; // should be suggested anyway in JavaStaticMemberProcessor return; } } } final PsiElement pparent = parent.getParent(); if (showAll || pparent instanceof PsiReturnStatement || pparent instanceof PsiConditionalExpression && pparent.getParent() instanceof PsiReturnStatement) { addCollectionMethod(JAVA_UTIL_LIST, "emptyList", collectionsClass); addCollectionMethod(JAVA_UTIL_SET, "emptySet", collectionsClass); addCollectionMethod(JAVA_UTIL_MAP, "emptyMap", collectionsClass); } if (showAll) { addCollectionMethod(JAVA_UTIL_LIST, "singletonList", collectionsClass); addCollectionMethod(JAVA_UTIL_SET, "singleton", collectionsClass); addCollectionMethod(JAVA_UTIL_MAP, "singletonMap", collectionsClass); addCollectionMethod(JAVA_UTIL_COLLECTION, "unmodifiableCollection", collectionsClass); addCollectionMethod(JAVA_UTIL_LIST, "unmodifiableList", collectionsClass); addCollectionMethod(JAVA_UTIL_SET, "unmodifiableSet", collectionsClass); addCollectionMethod(JAVA_UTIL_MAP, "unmodifiableMap", collectionsClass); addCollectionMethod(JAVA_UTIL_SORTED_SET, "unmodifiableSortedSet", collectionsClass); addCollectionMethod("java.util.SortedMap", "unmodifiableSortedMap", collectionsClass); } }