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

Method parsePropertyAccessExpressionRest

internal/parser/parser.go:5402–5417  ·  view source on GitHub ↗
(pos int, expression *ast.Expression, questionDotToken *ast.Node)

Source from the content-addressed store, hash-verified

5400}
5401
5402func (p *Parser) parsePropertyAccessExpressionRest(pos int, expression *ast.Expression, questionDotToken *ast.Node) *ast.Node {
5403 name := p.parseRightSideOfDot(true /*allowIdentifierNames*/, true /*allowPrivateIdentifiers*/, true /*allowUnicodeEscapeSequenceInIdentifierName*/)
5404 isOptionalChain := questionDotToken != nil || p.tryReparseOptionalChain(expression)
5405 propertyAccess := p.factory.NewPropertyAccessExpression(expression, questionDotToken, name, core.IfElse(isOptionalChain, ast.NodeFlagsOptionalChain, ast.NodeFlagsNone))
5406 if isOptionalChain && ast.IsPrivateIdentifier(name) {
5407 p.parseErrorAtRange(p.skipRangeTrivia(name.Loc), diagnostics.An_optional_chain_cannot_contain_private_identifiers)
5408 }
5409 if ast.IsExpressionWithTypeArguments(expression) {
5410 typeArguments := expression.TypeArgumentList()
5411 if typeArguments != nil {
5412 loc := core.NewTextRange(typeArguments.Pos()-1, scanner.SkipTrivia(p.sourceText, typeArguments.End())+1)
5413 p.parseErrorAtRange(loc, diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access)
5414 }
5415 }
5416 return p.finishNode(propertyAccess, pos)
5417}
5418
5419func (p *Parser) tryReparseOptionalChain(node *ast.Expression) bool {
5420 if node.Flags&ast.NodeFlagsOptionalChain != 0 {

Callers 1

Calls 14

parseRightSideOfDotMethod · 0.95
parseErrorAtRangeMethod · 0.95
skipRangeTriviaMethod · 0.95
finishNodeMethod · 0.95
IfElseFunction · 0.92
IsPrivateIdentifierFunction · 0.92
NewTextRangeFunction · 0.92
SkipTriviaFunction · 0.92
TypeArgumentListMethod · 0.80

Tested by

no test coverage detected