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

Method parseJsxChild

internal/parser/parser.go:4844–4870  ·  view source on GitHub ↗
(openingTag *ast.Node, token ast.Kind)

Source from the content-addressed store, hash-verified

4842}
4843
4844func (p *Parser) parseJsxChild(openingTag *ast.Node, token ast.Kind) *ast.Expression {
4845 switch token {
4846 case ast.KindEndOfFile:
4847 // If we hit EOF, issue the error at the tag that lacks the closing element
4848 // rather than at the end of the file (which is useless)
4849 if ast.IsJsxOpeningFragment(openingTag) {
4850 p.parseErrorAtRange(openingTag.Loc, diagnostics.JSX_fragment_has_no_corresponding_closing_tag)
4851 } else {
4852 // We want the error span to cover only 'Foo.Bar' in < Foo.Bar >
4853 // or to cover only 'Foo' in < Foo >
4854 tag := openingTag.TagName()
4855 start := min(scanner.SkipTrivia(p.sourceText, tag.Pos()), tag.End())
4856 p.parseErrorAt(start, tag.End(), diagnostics.JSX_element_0_has_no_corresponding_closing_tag,
4857 scanner.GetTextOfNodeFromSourceText(p.sourceText, openingTag.TagName(), false /*includeTrivia*/))
4858 }
4859 return nil
4860 case ast.KindLessThanSlashToken, ast.KindConflictMarkerTrivia:
4861 return nil
4862 case ast.KindJsxText, ast.KindJsxTextAllWhiteSpaces:
4863 return p.parseJsxText()
4864 case ast.KindOpenBraceToken:
4865 return p.parseJsxExpression(false /*inExpressionContext*/)
4866 case ast.KindLessThanToken:
4867 return p.parseJsxElementOrSelfClosingElementOrFragment(false /*inExpressionContext*/, -1 /*topInvalidNodePosition*/, openingTag, false)
4868 }
4869 panic("Unhandled case in parseJsxChild")
4870}
4871
4872func (p *Parser) parseJsxText() *ast.Node {
4873 pos := p.nodePos()

Callers 1

parseJsxChildrenMethod · 0.95

Calls 13

parseErrorAtRangeMethod · 0.95
parseErrorAtMethod · 0.95
parseJsxTextMethod · 0.95
parseJsxExpressionMethod · 0.95
IsJsxOpeningFragmentFunction · 0.92
SkipTriviaFunction · 0.92
minFunction · 0.85
panicFunction · 0.85
TagNameMethod · 0.80
PosMethod · 0.65

Tested by

no test coverage detected