mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test that freemarker lexer is restartable at every directive
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -52,6 +53,22 @@ public abstract class LexerTestCase extends UsefulTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkZeroState(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();
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkCorrectRestart(String text) {
|
||||
Lexer mainLexer = createLexer();
|
||||
String allTokens = printTokens(text, 0, mainLexer);
|
||||
|
||||
Reference in New Issue
Block a user