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

Method parseJsxChildren

internal/parser/parser.go:4821–4842  ·  view source on GitHub ↗
(openingTag *ast.Expression)

Source from the content-addressed store, hash-verified

4819}
4820
4821func (p *Parser) parseJsxChildren(openingTag *ast.Expression) *ast.NodeList {
4822 pos := p.nodePos()
4823 saveParsingContexts := p.parsingContexts
4824 p.parsingContexts |= 1 << PCJsxChildren
4825 var list []*ast.Node
4826 for {
4827 currentToken := p.scanner.ReScanJsxToken(true /*allowMultilineJsxText*/)
4828 child := p.parseJsxChild(openingTag, currentToken)
4829 if child == nil {
4830 break
4831 }
4832 list = append(list, child)
4833 if ast.IsJsxOpeningElement(openingTag) && child.Kind == ast.KindJsxElement &&
4834 !ast.TagNamesAreEquivalent(child.AsJsxElement().OpeningElement.TagName(), child.AsJsxElement().ClosingElement.TagName()) &&
4835 ast.TagNamesAreEquivalent(openingTag.TagName(), child.AsJsxElement().ClosingElement.TagName()) {
4836 // stop after parsing a mismatched child like <div>...(<span></div>) in order to reattach the </div> higher
4837 break
4838 }
4839 }
4840 p.parsingContexts = saveParsingContexts
4841 return p.newNodeList(core.NewTextRange(pos, p.nodePos()), list)
4842}
4843
4844func (p *Parser) parseJsxChild(openingTag *ast.Node, token ast.Kind) *ast.Expression {
4845 switch token {

Calls 10

nodePosMethod · 0.95
parseJsxChildMethod · 0.95
newNodeListMethod · 0.95
IsJsxOpeningElementFunction · 0.92
TagNamesAreEquivalentFunction · 0.92
NewTextRangeFunction · 0.92
ReScanJsxTokenMethod · 0.80
TagNameMethod · 0.80
AsJsxElementMethod · 0.80
appendFunction · 0.50

Tested by

no test coverage detected