(node *Node)
| 1927 | } |
| 1928 | |
| 1929 | func IsExpressionNode(node *Node) bool { |
| 1930 | switch node.Kind { |
| 1931 | case KindSuperKeyword, KindNullKeyword, KindTrueKeyword, KindFalseKeyword, KindRegularExpressionLiteral, |
| 1932 | KindArrayLiteralExpression, KindObjectLiteralExpression, KindPropertyAccessExpression, KindElementAccessExpression, |
| 1933 | KindCallExpression, KindNewExpression, KindTaggedTemplateExpression, KindAsExpression, KindTypeAssertionExpression, |
| 1934 | KindSatisfiesExpression, KindNonNullExpression, KindParenthesizedExpression, KindFunctionExpression, |
| 1935 | KindClassExpression, KindArrowFunction, KindVoidExpression, KindDeleteExpression, KindTypeOfExpression, |
| 1936 | KindPrefixUnaryExpression, KindPostfixUnaryExpression, KindBinaryExpression, KindConditionalExpression, |
| 1937 | KindSpreadElement, KindTemplateExpression, KindOmittedExpression, KindJsxElement, KindJsxSelfClosingElement, |
| 1938 | KindJsxFragment, KindYieldExpression, KindAwaitExpression: |
| 1939 | return true |
| 1940 | case KindMetaProperty: |
| 1941 | // `import.defer` in `import.defer(...)` is not an expression |
| 1942 | return !IsImportCall(node.Parent) || node.Parent.Expression() != node |
| 1943 | case KindExpressionWithTypeArguments: |
| 1944 | return !IsHeritageClause(node.Parent) |
| 1945 | case KindQualifiedName: |
| 1946 | for node.Parent.Kind == KindQualifiedName { |
| 1947 | node = node.Parent |
| 1948 | } |
| 1949 | return IsTypeQueryNode(node.Parent) || IsJSDocLinkLike(node.Parent) || IsJSDocNameReference(node.Parent) || IsJsxTagName(node) |
| 1950 | case KindPrivateIdentifier: |
| 1951 | return IsBinaryExpression(node.Parent) && node.Parent.AsBinaryExpression().Left == node && node.Parent.AsBinaryExpression().OperatorToken.Kind == KindInKeyword |
| 1952 | case KindIdentifier: |
| 1953 | if IsTypeQueryNode(node.Parent) || IsJSDocLinkLike(node.Parent) || IsJSDocNameReference(node.Parent) || IsJsxTagName(node) { |
| 1954 | return true |
| 1955 | } |
| 1956 | fallthrough |
| 1957 | case KindNumericLiteral, KindBigIntLiteral, KindStringLiteral, KindNoSubstitutionTemplateLiteral, KindThisKeyword: |
| 1958 | return IsInExpressionContext(node) |
| 1959 | default: |
| 1960 | return false |
| 1961 | } |
| 1962 | } |
| 1963 | |
| 1964 | func IsInExpressionContext(node *Node) bool { |
| 1965 | parent := node.Parent |
no test coverage detected