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

Method tryParseModifier

internal/parser/parser.go:3925–3946  ·  view source on GitHub ↗
(hasSeenStaticModifier bool, permitConstAsModifier bool, stopOnStartOfClassStaticBlock bool)

Source from the content-addressed store, hash-verified

3923}
3924
3925func (p *Parser) tryParseModifier(hasSeenStaticModifier bool, permitConstAsModifier bool, stopOnStartOfClassStaticBlock bool) *ast.Node {
3926 pos := p.nodePos()
3927 kind := p.token
3928 if p.token == ast.KindConstKeyword && permitConstAsModifier {
3929 // We need to ensure that any subsequent modifiers appear on the same line
3930 // so that when 'const' is a standalone declaration, we don't issue an error.
3931 if !p.lookAhead((*Parser).nextTokenIsOnSameLineAndCanFollowModifier) {
3932 return nil
3933 } else {
3934 p.nextToken()
3935 }
3936 } else if stopOnStartOfClassStaticBlock && p.token == ast.KindStaticKeyword && p.lookAhead((*Parser).nextTokenIsOpenBrace) {
3937 return nil
3938 } else if hasSeenStaticModifier && p.token == ast.KindStaticKeyword {
3939 return nil
3940 } else {
3941 if !p.parseAnyContextualModifier() {
3942 return nil
3943 }
3944 }
3945 return p.finishNode(p.factory.NewModifier(kind), pos)
3946}
3947
3948func (p *Parser) parseContextualModifier(t ast.Kind) bool {
3949 state := p.mark()

Callers 1

parseModifiersExMethod · 0.95

Calls 6

nodePosMethod · 0.95
lookAheadMethod · 0.95
nextTokenMethod · 0.95
finishNodeMethod · 0.95
NewModifierMethod · 0.80

Tested by

no test coverage detected