boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof PyFile)) { return false; } PsiElement elementAtOffset = file.findElementAt(editor.getCaretModel().getOffset()); if (elementAtOffset == null || elementAtOffset.getNode() == null) { return false; } // PY-745 final IElementType elementType = elementAtOffset.getNode().getElementType(); if (elementType == PyTokenTypes.COLON) { elementAtOffset = elementAtOffset.getPrevSibling(); elementAtOffset = PyPsiUtils.getPrevNonCommentSibling(elementAtOffset, false); } else if (elementType == PyTokenTypes.IF_KEYWORD) { elementAtOffset = elementAtOffset.getNextSibling(); elementAtOffset = PyPsiUtils.getNextNonCommentSibling(elementAtOffset, false); } PsiElement element = PsiTreeUtil.getParentOfType(elementAtOffset, PyBinaryExpression.class, false); if (element == null) { return false; } while (element.getParent() instanceof PyBinaryExpression) { element = element.getParent(); } if (((PyBinaryExpression)element).getOperator() != PyTokenTypes.AND_KEYWORD || ((PyBinaryExpression) element).getRightExpression() == null) { return false; } final PsiElement parent = element.getParent(); if (!(parent instanceof PyIfPart)) { return false; } setText(PyPsiBundle.message("INTN.split.if")); return true; }