void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { final PsiReferenceExpression nanExpression = (PsiReferenceExpression)startElement; final PsiElement target = nanExpression.resolve(); if (!(target instanceof PsiField field)) { return; } final PsiClass containingClass = field.getContainingClass(); if (containingClass == null) { return; } final String typeText = containingClass.getQualifiedName(); final PsiBinaryExpression comparison = (PsiBinaryExpression)nanExpression.getParent(); final PsiExpression lhs = comparison.getLOperand(); final PsiExpression rhs = comparison.getROperand(); final PsiExpression operand; if (nanExpression.equals(lhs)) { operand = rhs; } else { operand = lhs; } assert operand != null; CommentTracker commentTracker = new CommentTracker(); final String operandText = commentTracker.text(operand); final IElementType tokenType = comparison.getOperationTokenType(); final String negationText; if (tokenType.equals(JavaTokenType.EQEQ)) { negationText = ""; } else { negationText = "!"; } @NonNls final String newExpressionText = negationText + typeText + ".isNaN(" + operandText + ')'; PsiReplacementUtil.replaceExpression(comparison, newExpressionText, commentTracker); }