Overriding token name in PsiErrorElement
Is there a way to override the name displayed in PsiErrorElements so they are more human readable? For example I have
PsiErrorElement:ElixirTokenType.AND_OPERATOR, ElixirTokenType.ARROW_OPERATOR, ElixirTokenType.ASSOCIATION_OPERATOR, ElixirTokenType.COMPARISON_OPERATOR, ElixirTokenType.EOL, ElixirTokenType.HAT_OPERATOR, ElixirTokenType.IN_MATCH_OPERATOR, ElixirTokenType.MATCH_OPERATOR, ElixirTokenType.MULTIPLICATION_OPERATOR, ElixirTokenType.OR_OPERATOR, ElixirTokenType.PIPE_OPERATOR, ElixirTokenType.RELATIONAL_OPERATOR, ElixirTokenType.STAB_OPERATOR, ElixirTokenType.TWO_OPERATOR, ElixirTokenType.TYPE_OPERATOR or ElixirTokenType.WHEN_OPERATOR expected, got '2'(127,128)
I'd like to override `ElixirTokenType.AND_OPERATOR` to just be "&&&, &&, or and" or something similar and do the same for all the ElixirTokenTypes, but the ElixirTokenTypes are autogenerated by "Generate Parser Code" action. Setting the tokens section in the top of bnf just changed the name of the token if I didn't use "regexp:" and even then I still get the "ElixirTokenType." prefix.
Somewhat related, should I be trying to avoid PsiErrorElements and DummyBlocks by adding move recoverWhiles or should I both override the ElixirTokenType names for when there is a PsiErrorElement AND add recoverWhiles?
请先登录再写评论。
Just tweak ElixirTokenType#toString() as you like:
@Override
public String toString() {
return "ElixirTokenType." + super.toString();
}