PsiTryStatement (@NotNull PsiElement element) { if (!(element instanceof PsiJavaToken)) { return null; } final IElementType tokenType = ((PsiJavaToken)element).getTokenType(); if (!JavaTokenType.TRY_KEYWORD.equals(tokenType) && !JavaTokenType.CATCH_KEYWORD.equals(tokenType)) { return null; } PsiElement parent = element.getParent(); if (parent instanceof PsiCatchSection) { parent = parent.getParent(); } if (!(parent instanceof PsiTryStatement)) { return null; } return (PsiTryStatement)parent; }