boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof PyFile)) { return false; } PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); PyBinaryExpression binaryExpression = PsiTreeUtil.getParentOfType(element, PyBinaryExpression.class, false); while (binaryExpression != null) { PyElementType operator = binaryExpression.getOperator(); if (operator != null && Holder.FLIPPED_OPERATORS.containsKey(operator)) { String operatorText = binaryExpression.getPsiOperator().getText(); String flippedOperatorText = Holder.FLIPPED_OPERATORS.get(operator); if (flippedOperatorText.equals(operatorText)) { setText(PyPsiBundle.message("INTN.flip.comparison", operatorText)); } else { setText(PyPsiBundle.message("INTN.flip.comparison.to.operator", operatorText, flippedOperatorText)); } return true; } binaryExpression = PsiTreeUtil.getParentOfType(binaryExpression, PyBinaryExpression.class); } return false; }