.getState(newTokenOffset);
final LexerState endState = tokensContainer.getState(tokenEnd
.getEnd() + 1);
final TwigTokenContainer newContainer = new TwigTokenContainer();
final TwigLexer twigLexer = getTwigLexer(new DocumentReader(
flatnode, changes, requestStart, lengthToReplace,
newTokenOffset), startState);
Object state = startState;
try {
String yylex = twigLexer.getNextToken();
if (shouldDeprecatedKeyword
&& TwigTokenContainer.isKeyword(yylex)) {
yylex = TwigRegionTypes.PHP_STRING;
}
int yylength;
final int toOffset = offset + length;
while (yylex != null
&& newTokenOffset <= toOffset
&& (yylex != TwigRegionTypes.TWIG_COMMENT_CLOSE
&& yylex != TwigRegionTypes.TWIG_CLOSETAG && yylex != TwigRegionTypes.TWIG_STMT_CLOSE)) {
yylength = twigLexer.getLength();
newContainer.addLast(yylex, newTokenOffset, yylength,
yylength, state);
newTokenOffset += yylength;
state = twigLexer.createLexicalStateMemento();
yylex = twigLexer.getNextToken();
}
if (yylex == TwigRegionTypes.WHITESPACE) {
yylength = twigLexer.getLength();
newContainer.adjustWhitespace(yylex, newTokenOffset,
yylength, yylength, state);
}
} catch (IOException e) {
Logger.logException(e);