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

Method ifStatement

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

Source from the content-addressed store, hash-verified

1578 }
1579
1580 private IfStatement ifStatement() throws IOException {
1581 if (currentToken != Token.IF) codeBug();
1582 consumeToken();
1583 int pos = ts.tokenBeg, lineno = lineNumber(), elsePos = -1, column = columnNumber();
1584 IfStatement pn = new IfStatement(pos);
1585 ConditionData data = condition();
1586 AstNode ifTrue = getNextStatementAfterInlineComments(pn), ifFalse = null;
1587 if (matchToken(Token.ELSE, true)) {
1588 int tt = peekToken();
1589 if (tt == Token.COMMENT) {
1590 pn.setElseKeyWordInlineComment(scannedComments.get(scannedComments.size() - 1));
1591 consumeToken();
1592 }
1593 elsePos = ts.tokenBeg - pos;
1594 ifFalse = statement();
1595 }
1596 int end = getNodeEnd(ifFalse != null ? ifFalse : ifTrue);
1597 pn.setLength(end - pos);
1598 pn.setCondition(data.condition);
1599 pn.setParens(data.lp - pos, data.rp - pos);
1600 pn.setThenPart(ifTrue);
1601 pn.setElsePart(ifFalse);
1602 pn.setElsePosition(elsePos);
1603 pn.setLineColumnNumber(lineno, column);
1604 return pn;
1605 }
1606
1607 private SwitchStatement switchStatement() throws IOException {
1608 if (currentToken != Token.SWITCH) codeBug();

Callers 1

statementHelperMethod · 0.95

Calls 15

codeBugMethod · 0.95
consumeTokenMethod · 0.95
lineNumberMethod · 0.95
columnNumberMethod · 0.95
conditionMethod · 0.95
matchTokenMethod · 0.95
peekTokenMethod · 0.95
statementMethod · 0.95
getNodeEndMethod · 0.95
setConditionMethod · 0.95

Tested by

no test coverage detected