boolean (@NotNull PsiElement @NotNull [] elements) { if (elements.length == 0) return false; if (elements[0].getContainingFile() instanceof PsiCodeFragment) { return false; } Language language = elements[0].getLanguage(); if (!myProvider.isSupported(language)) return false; for (FoldingBuilder each : LanguageFolding.INSTANCE.allForLanguage(language)) { if (myProvider.isSupportedBy(each)) return true; } return false; }