PsiElement (@NotNull PsiElement refElement) { for (ContainerProvider provider : ContainerProvider.EP_NAME.getExtensionList()) { PsiElement container = provider.getContainer(refElement); if (container != null) { return container; } } // it's assumed that in the general case of unknown language the .getParent() will lead to reparse, // (all these Javascript stubbed methods under non-stubbed block statements under stubbed classes - meh) // so return null instead of refElement.getParent() here to avoid making things worse. return null; }