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

Method parseJsxElementName

internal/parser/parser.go:4968–4984  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4966}
4967
4968func (p *Parser) parseJsxElementName() *ast.Expression {
4969 pos := p.nodePos()
4970 // JsxElement can have name in the form of
4971 // propertyAccessExpression
4972 // primaryExpression in the form of an identifier and "this" keyword
4973 // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword
4974 // We only want to consider "this" as a primaryExpression
4975 initialExpression := p.parseJsxTagName()
4976 if ast.IsJsxNamespacedName(initialExpression) {
4977 return initialExpression // `a:b.c` is invalid syntax, don't even look for the `.` if we parse `a:b`, and let `parseAttribute` report "unexpected :" instead.
4978 }
4979 expression := initialExpression
4980 for p.parseOptional(ast.KindDotToken) {
4981 expression = p.finishNode(p.factory.NewPropertyAccessExpression(expression, nil, p.parseRightSideOfDot(true /*allowIdentifierNames*/, false /*allowPrivateIdentifiers*/, false /*allowUnicodeEscapeSequenceInIdentifierName*/), ast.NodeFlagsNone), pos)
4982 }
4983 return expression
4984}
4985
4986func (p *Parser) parseJsxTagName() *ast.Expression {
4987 pos := p.nodePos()

Calls 7

nodePosMethod · 0.95
parseJsxTagNameMethod · 0.95
parseOptionalMethod · 0.95
finishNodeMethod · 0.95
parseRightSideOfDotMethod · 0.95
IsJsxNamespacedNameFunction · 0.92

Tested by

no test coverage detected