Converts an operator node's meaning to a prefix operator variant. For example, converts PLUS to PREFIX_PLUS. @param node the node whose meaning is to be modified @param throwIfInvalid if true, throws GroovyBugError if the type cannot be converted
(CSTNode node, boolean throwIfInvalid)
| 1071 | * @param throwIfInvalid if {@code true}, throws {@link GroovyBugError} if the type cannot be converted |
| 1072 | */ |
| 1073 | public static void makePrefix(CSTNode node, boolean throwIfInvalid) { |
| 1074 | |
| 1075 | switch (node.getMeaning()) { |
| 1076 | case PLUS: |
| 1077 | node.setMeaning(PREFIX_PLUS); |
| 1078 | break; |
| 1079 | |
| 1080 | case MINUS: |
| 1081 | node.setMeaning(PREFIX_MINUS); |
| 1082 | break; |
| 1083 | |
| 1084 | case PLUS_PLUS: |
| 1085 | node.setMeaning(PREFIX_PLUS_PLUS); |
| 1086 | break; |
| 1087 | |
| 1088 | case MINUS_MINUS: |
| 1089 | node.setMeaning(PREFIX_MINUS_MINUS); |
| 1090 | break; |
| 1091 | |
| 1092 | default: |
| 1093 | if (throwIfInvalid) { |
| 1094 | throw new GroovyBugError("cannot convert to prefix for type [" + node.getMeaning() + "]"); |
| 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | } |
| 1099 | |
| 1100 | /** |
| 1101 | * Converts an operator node's meaning to a postfix operator variant. |
nothing calls this directly
no test coverage detected