PsiElement (PsiElement toReplace, CommentTracker ct) { String replacement; if (this.myLeft.getType() instanceof PsiClassType) { replacement = ct.text(this.myLeft, ParenthesesUtils.METHOD_CALL_PRECEDENCE) + ".compareTo(" + ct.text(this.myRight) + ")"; } else { replacement = this.myClass.getCanonicalText() + ".compare(" + ct.text(this.myLeft) + "," + ct.text(this.myRight) + ")"; } if(toReplace == myTemplate) { return ct.replaceAndRestoreComments(myToReplace, replacement); } else { ct.replace(myToReplace, replacement); return ct.replaceAndRestoreComments(toReplace, myTemplate); } }