MCPcopy Create free account
hub / github.com/microsoft/typescript-go / tryParseConstructorDeclaration

Method tryParseConstructorDeclaration

internal/parser/parser.go:1921–1936  ·  view source on GitHub ↗
(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList)

Source from the content-addressed store, hash-verified

1919}
1920
1921func (p *Parser) tryParseConstructorDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Node {
1922 state := p.mark()
1923 if p.token == ast.KindConstructorKeyword || p.token == ast.KindStringLiteral && p.scanner.TokenValue() == "constructor" && p.lookAhead((*Parser).nextTokenIsOpenParen) {
1924 p.nextToken()
1925 typeParameters := p.parseTypeParameters()
1926 parameters := p.parseParameters(ParseFlagsNone)
1927 returnType := p.parseReturnType(ast.KindColonToken, false /*isType*/)
1928 body := p.parseFunctionBlockOrSemicolon(ParseFlagsNone, diagnostics.X_or_expected)
1929 result := p.finishNode(p.factory.NewConstructorDeclaration(modifiers, typeParameters, parameters, returnType, nil /*fullSignature*/, body), pos)
1930 p.withJSDoc(result, jsdoc)
1931 p.checkJSSyntax(result)
1932 return result
1933 }
1934 p.rewind(state)
1935 return nil
1936}
1937
1938func (p *Parser) nextTokenIsOpenParen() bool {
1939 return p.nextToken() == ast.KindOpenParenToken

Callers 1

parseClassElementMethod · 0.95

Calls 13

markMethod · 0.95
lookAheadMethod · 0.95
nextTokenMethod · 0.95
parseTypeParametersMethod · 0.95
parseParametersMethod · 0.95
parseReturnTypeMethod · 0.95
finishNodeMethod · 0.95
withJSDocMethod · 0.95
checkJSSyntaxMethod · 0.95
rewindMethod · 0.95
TokenValueMethod · 0.80

Tested by

no test coverage detected