String () { if (myPrevLeaf == null) return null; if (!myPrevLeaf.textMatches(PsiKeyword.PUBLIC) || !(myPrevLeaf.getParent() instanceof PsiModifierList)) return null; if (nextIsIdentifier(myPosition)) return null; PsiJavaFile file = getFileForDeclaration(myPrevLeaf); if (file == null) return null; String name = file.getName(); if (!StringUtil.endsWithIgnoreCase(name, JavaFileType.DOT_DEFAULT_EXTENSION)) return null; String candidate = name.substring(0, name.length() - JavaFileType.DOT_DEFAULT_EXTENSION.length()); if (StringUtil.isJavaIdentifier(candidate) && !ContainerUtil.exists(file.getClasses(), c -> candidate.equals(c.getName()))) { return candidate; } return null; }