@Override public String getTextForElement(PsiElement element) { final JSBinaryExpression expression = (JSBinaryExpression) element; String operatorText = ""; String negatedOperatorText = ""; if (expression != null) { final IElementType sign = expression.getOperationSign(); operatorText = ComparisonUtils.getOperatorText(sign); negatedOperatorText = ComparisonUtils.getNegatedOperatorText(sign); } if (operatorText.equals(negatedOperatorText)) { return this.getSuffixedDisplayName("equals", operatorText); } else { return this.getSuffixedDisplayName("not-equals", operatorText, negatedOperatorText); } }
@Override public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { final JSBinaryExpression exp = (JSBinaryExpression) element; final JSExpression lhs = exp.getLOperand(); final JSExpression rhs = exp.getROperand(); final IElementType sign = exp.getOperationSign(); final String negatedOperator = ComparisonUtils.getNegatedOperatorText(sign); final String lhsText = lhs.getText(); assert (rhs != null); JSElementFactory.replaceExpressionWithNegatedExpressionString( exp, lhsText + negatedOperator + rhs.getText()); }