List of usage examples for org.antlr.v4.runtime ParserRuleContext addErrorNode
@Deprecated
public ErrorNode addErrorNode(Token badToken)
From source file:illarion.easynpc.parser.Utils.java
License:Open Source License
@Nonnull private static <T extends Enum<T>> T getEnumValue(@Nullable ParserRuleContext node, @Nonnull Class<T> enumClass, @Nonnull T defaultValue) {/*from ww w . j a va2 s .c om*/ if (node == null) { LOGGER.warn("Expected node for enumerator {} not found.", enumClass.getSimpleName()); return defaultValue; } String string = removeQuotes(node.getText()); try { return Enum.valueOf(enumClass, string); } catch (IllegalArgumentException e) { node.addErrorNode(node.getStart()); LOGGER.warn("Failed to resolve {} to enumerator {}", string, enumClass.getSimpleName()); return defaultValue; } }