void (@NotNull String text, TokenSet tokenTypes) { Lexer lexer = createLexer(); lexer.start(text); while (true) { IElementType type = lexer.getTokenType(); if (type == null) { break; } if (tokenTypes.contains(type) && lexer.getState() != 0) { fail("Non-zero lexer state on token \"" + lexer.getTokenText() + "\" (" + type + ") at " + lexer.getTokenStart()); } lexer.advance(); } }