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

Method parseDeclaration

internal/parser/parser.go:1125–1150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1123}
1124
1125func (p *Parser) parseDeclaration() *ast.Statement {
1126 // `parseListElement` attempted to get the reused node at this position,
1127 // but the ambient context flag was not yet set, so the node appeared
1128 // not reusable in that context.
1129 pos := p.nodePos()
1130 jsdoc := p.jsdocScannerInfo()
1131 modifiers := p.parseModifiersEx( /*allowDecorators*/ true, false /*permitConstAsModifier*/, false /*stopOnStartOfClassStaticBlock*/)
1132 isAmbient := modifiers != nil && core.Some(modifiers.Nodes, isDeclareModifier)
1133 if isAmbient {
1134 // !!! incremental parsing
1135 // node := p.tryReuseAmbientDeclaration(pos)
1136 // if node {
1137 // return node
1138 // }
1139 for _, m := range modifiers.Nodes {
1140 m.Flags |= ast.NodeFlagsAmbient
1141 }
1142 saveContextFlags := p.contextFlags
1143 p.setContextFlags(ast.NodeFlagsAmbient, true)
1144 result := p.parseDeclarationWorker(pos, jsdoc, modifiers)
1145 p.contextFlags = saveContextFlags
1146 return result
1147 } else {
1148 return p.parseDeclarationWorker(pos, jsdoc, modifiers)
1149 }
1150}
1151
1152func (p *Parser) parseDeclarationWorker(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Statement {
1153 switch p.token {

Callers 1

parseStatementMethod · 0.95

Calls 6

nodePosMethod · 0.95
jsdocScannerInfoMethod · 0.95
parseModifiersExMethod · 0.95
setContextFlagsMethod · 0.95
SomeFunction · 0.92

Tested by

no test coverage detected