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

Function GetAssignmentDeclarationKind

internal/ast/utilities.go:1522–1554  ·  view source on GitHub ↗
(node *Node)

Source from the content-addressed store, hash-verified

1520)
1521
1522func GetAssignmentDeclarationKind(node *Node) JSDeclarationKind {
1523 switch node.Kind {
1524 case KindBinaryExpression:
1525 bin := node.AsBinaryExpression()
1526 if bin.OperatorToken.Kind == KindEqualsToken && IsAccessExpression(bin.Left) {
1527 if IsInJSFile(bin.Left) {
1528 if IsModuleExportsAccessExpression(bin.Left) && !IsExportsIdentifier(bin.Right) {
1529 return JSDeclarationKindModuleExports
1530 }
1531 if (IsModuleExportsAccessExpression(bin.Left.Expression()) || IsExportsIdentifier(bin.Left.Expression())) &&
1532 GetElementOrPropertyAccessName(bin.Left) != nil {
1533 return JSDeclarationKindExportsProperty
1534 }
1535 if bin.Left.Expression().Kind == KindThisKeyword {
1536 return JSDeclarationKindThisProperty
1537 }
1538 }
1539 if bin.Left.Kind == KindPropertyAccessExpression && IsEntityNameExpressionEx(bin.Left.Expression(), IsInJSFile(bin.Left)) && IsIdentifier(bin.Left.Name()) ||
1540 bin.Left.Kind == KindElementAccessExpression && IsEntityNameExpressionEx(bin.Left.Expression(), IsInJSFile(bin.Left)) {
1541 return JSDeclarationKindProperty
1542 }
1543 }
1544 case KindCallExpression:
1545 if IsInJSFile(node) && IsBindableObjectDefinePropertyCall(node) {
1546 entityName := node.Arguments()[0]
1547 if IsExportsIdentifier(entityName) || IsModuleExportsAccessExpression(entityName) {
1548 return JSDeclarationKindObjectDefinePropertyExports
1549 }
1550 return JSDeclarationKindObjectDefinePropertyValue
1551 }
1552 }
1553 return JSDeclarationKindNone
1554}
1555
1556func IsBindableObjectDefinePropertyCall(node *Node) bool {
1557 if args := node.Arguments(); len(args) == 3 {

Calls 12

IsAccessExpressionFunction · 0.85
IsInJSFileFunction · 0.85
IsExportsIdentifierFunction · 0.85
IsEntityNameExpressionExFunction · 0.85
IsIdentifierFunction · 0.85
AsBinaryExpressionMethod · 0.80
ExpressionMethod · 0.80
ArgumentsMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected