MCPcopy Create free account
hub / github.com/mozilla/rhino / peekToken

Method peekToken

rhino/src/main/java/org/mozilla/javascript/Parser.java:436–464  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

434 // Note that this function always returned the un-flagged token!
435 // The flags, if any, are saved in currentFlaggedToken.
436 private int peekToken() throws IOException {
437 // By far the most common case: last token hasn't been consumed,
438 // so return already-peeked token.
439 if (currentFlaggedToken != Token.EOF) {
440 return currentToken;
441 }
442
443 int tt = ts.getToken();
444 boolean sawEOL = false;
445
446 // process comments and whitespace
447 while (tt == Token.EOL || tt == Token.COMMENT) {
448 if (tt == Token.EOL) {
449 sawEOL = true;
450 tt = ts.getToken();
451 } else {
452 if (compilerEnv.isRecordingComments()) {
453 String comment = ts.getAndResetCurrentComment();
454 recordComment(ts.getTokenStartLineno(), ts.getTokenColumn(), comment);
455 break;
456 }
457 tt = ts.getToken();
458 }
459 }
460
461 currentToken = tt;
462 currentFlaggedToken = tt | (sawEOL ? TI_AFTER_EOL : 0);
463 return currentToken; // return unflagged token
464 }
465
466 private int lineNumber() {
467 return lastTokenLineno;

Callers 15

peekFlaggedTokenMethod · 0.95
nextTokenMethod · 0.95
matchTokenMethod · 0.95
peekTokenOrEOLMethod · 0.95
parseMethod · 0.95
parseFunctionBodyMethod · 0.95
parseFunctionParamsMethod · 0.95
statementsMethod · 0.95
statementMethod · 0.95
statementHelperMethod · 0.95
ifStatementMethod · 0.95
switchStatementMethod · 0.95

Calls 6

recordCommentMethod · 0.95
getTokenMethod · 0.80
isRecordingCommentsMethod · 0.80
getTokenStartLinenoMethod · 0.80
getTokenColumnMethod · 0.80

Tested by

no test coverage detected