function Scanner::reconsumeCurrentTokenAsJSXText
Tries to reconsume the current token as a jsx text if possible
Return value
Token|null
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ JSX/ Scanner.php, line 26
Class
- Scanner
- JSX scanner trait
Namespace
Peast\Syntax\JSXCode
public function reconsumeCurrentTokenAsJSXText() {
//Current and next tokens must be reset and the open brackets count must be correct
//like they were never scanned
foreach (array(
$this->currentToken,
$this->nextToken,
) as $token) {
if ($token && isset($this->brackets[$token->value])) {
if ($refBracket = $this->brackets[$token->value]) {
$this->openBrackets[$refBracket]++;
}
else {
$this->openBrackets[$token->value]--;
}
}
}
$this->nextToken = null;
$this->currentToken = null;
$startPosition = $this->getPosition();
$this->setScanPosition($startPosition);
$result = $this->consumeUntil(array(
"{",
"<",
), false, false);
if ($result) {
$this->currentToken = new Token(Token::TYPE_JSX_TEXT, $result[0]);
$this->currentToken->location->start = $startPosition;
$this->currentToken->location->end = $this->getPosition(true);
}
return $this->currentToken;
}