()
| 1123 | } |
| 1124 | |
| 1125 | func (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 | |
| 1152 | func (p *Parser) parseDeclarationWorker(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Statement { |
| 1153 | switch p.token { |
no test coverage detected