private static String getTokenText(Lexer lexer) { final IElementType tokenType = lexer.getTokenType(); if (tokenType instanceof TokenWrapper) { return ((TokenWrapper)tokenType).getValue(); } String text = lexer.getBufferSequence().subSequence(lexer.getTokenStart(), lexer.getTokenEnd()).toString(); text = StringUtil.replace(text, "\n", "\\n"); return text; }
@NotNull private static IElementType dereferenceElementType(@NotNull IElementType type) { while ( type instanceof TokenWrapper) type = (( TokenWrapper ) type ).getDelegate(); return type; }
@Nullable @Override public IElementType getTokenType() { if (waitingTokens.isEmpty()) { return super.getTokenType(); } else if (waitingTokens.get(0) instanceof TokenWrapper) { return ((TokenWrapper) waitingTokens.get(0)).getDelegate(); } return waitingTokens.get(0); }
@Nullable @Override public String getTokenText() { if (waitingTokens.isEmpty()) { return super.getTokenText(); } else if (waitingTokens.get(0) instanceof TokenWrapper) { return ((TokenWrapper) waitingTokens.get(0)).getValue(); } return ""; }
private static IElementType dereferenceElementType(IElementType type) { while ( type instanceof TokenWrapper) type = (( TokenWrapper ) type ).getDelegate(); return type; }