void (Color currentColor, boolean withAlpha, Color newColor) { if (newColor == null || newColor.equals(currentColor)) return; String newColorHex = "#" + ColorUtil.toHex(newColor, withAlpha); Project project = myLiteral.getProject(); JsonStringLiteral newLiteral = new JsonElementGenerator(project).createStringLiteral(newColorHex); WriteCommandAction.writeCommandAction(project, myLiteral.getContainingFile()).run( () -> myLiteral = (JsonStringLiteral)myLiteral.replace(newLiteral) ); }