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

Method parseAccessorDeclaration

internal/parser/parser.go:3432–3450  ·  view source on GitHub ↗
(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList, kind ast.Kind, flags ParseFlags)

Source from the content-addressed store, hash-verified

3430}
3431
3432func (p *Parser) parseAccessorDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList, kind ast.Kind, flags ParseFlags) *ast.Node {
3433 name := p.parsePropertyName()
3434 typeParameters := p.parseTypeParameters()
3435 parameters := p.parseParameters(ParseFlagsNone)
3436 returnType := p.parseReturnType(ast.KindColonToken, false /*isType*/)
3437 body := p.parseFunctionBlockOrSemicolon(flags, nil /*diagnosticMessage*/)
3438 var result *ast.Node
3439 // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors
3440 if kind == ast.KindGetAccessor {
3441 result = p.factory.NewGetAccessorDeclaration(modifiers, name, typeParameters, parameters, returnType, nil /*fullSignature*/, body)
3442 } else {
3443 result = p.factory.NewSetAccessorDeclaration(modifiers, name, typeParameters, parameters, returnType, nil /*fullSignature*/, body)
3444 }
3445 p.withJSDoc(p.finishNode(result, pos), jsdoc)
3446 if flags&ParseFlagsType == 0 {
3447 p.checkJSSyntax(result)
3448 }
3449 return result
3450}
3451
3452func (p *Parser) parsePropertyName() *ast.Node {
3453 saveHasAwaitIdentifier := p.statementHasAwaitIdentifier

Callers 3

parseClassElementMethod · 0.95
parseTypeMemberMethod · 0.95

Calls 10

parsePropertyNameMethod · 0.95
parseTypeParametersMethod · 0.95
parseParametersMethod · 0.95
parseReturnTypeMethod · 0.95
withJSDocMethod · 0.95
finishNodeMethod · 0.95
checkJSSyntaxMethod · 0.95

Tested by

no test coverage detected