MCPcopy Index your code
hub / github.com/microsoft/typescript-go / parseThrowStatement

Method parseThrowStatement

internal/parser/parser.go:1450–1473  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1448}
1449
1450func (p *Parser) parseThrowStatement() *ast.Node {
1451 // ThrowStatement[Yield] :
1452 // throw [no LineTerminator here]Expression[In, ?Yield];
1453 pos := p.nodePos()
1454 jsdoc := p.jsdocScannerInfo()
1455 p.parseExpected(ast.KindThrowKeyword)
1456 // Because of automatic semicolon insertion, we need to report error if this
1457 // throw could be terminated with a semicolon. Note: we can't call 'parseExpression'
1458 // directly as that might consume an expression on the following line.
1459 // Instead, we create a "missing" identifier, but don't report an error. The actual error
1460 // will be reported in the grammar walker.
1461 var expression *ast.Expression
1462 if !p.hasPrecedingLineBreak() {
1463 expression = p.parseExpressionAllowIn()
1464 } else {
1465 expression = p.createMissingIdentifier()
1466 }
1467 if !p.tryParseSemicolon() {
1468 p.parseErrorForMissingSemicolonAfter(expression)
1469 }
1470 result := p.finishNode(p.factory.NewThrowStatement(expression), pos)
1471 p.withJSDoc(result, jsdoc)
1472 return result
1473}
1474
1475// TODO: Review for error recovery
1476func (p *Parser) parseTryStatement() *ast.Node {

Callers 1

parseStatementMethod · 0.95

Calls 11

nodePosMethod · 0.95
jsdocScannerInfoMethod · 0.95
parseExpectedMethod · 0.95
hasPrecedingLineBreakMethod · 0.95
tryParseSemicolonMethod · 0.95
finishNodeMethod · 0.95
withJSDocMethod · 0.95
NewThrowStatementMethod · 0.80

Tested by

no test coverage detected