void (PsiExpression expr, int newValue, boolean hex, boolean hasAlpha) { PsiElementFactory factory = JavaPsiFacade.getElementFactory(expr.getProject()); if (getInt(expr) != newValue) { String text; if (hex) { text = "0x"; Color c = new Color(newValue, hasAlpha); if (hasAlpha) { text += StringUtil.toUpperCase(Integer.toHexString(c.getAlpha())); } text += StringUtil.toUpperCase(ColorUtil.toHex(c)); } else { text = Integer.toString(newValue); } expr.replace(factory.createExpressionFromText(text, null)); } }