MCPcopy Index your code
hub / github.com/nodejs/node / isExtractableExpression

Function isExtractableExpression

test/fixtures/snapshot/typescript.js:161644–161664  ·  view source on GitHub ↗

* Computes whether or not a node represents an expression in a position where it could * be extracted. * The isExpression() in utilities.ts returns some false positives we need to handle, * such as `import x from 'y'` -- the 'y' is a StringLiteral but is *not*

(node)

Source from the content-addressed store, hash-verified

161642 * in the sense of something that you could extract on
161643 */
161644 function isExtractableExpression(node) {
161645 var parent = node.parent;
161646 switch (parent.kind) {
161647 case 299 /* SyntaxKind.EnumMember */:
161648 return false;
161649 }
161650 switch (node.kind) {
161651 case 10 /* SyntaxKind.StringLiteral */:
161652 return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ &&
161653 parent.kind !== 270 /* SyntaxKind.ImportSpecifier */;
161654 case 225 /* SyntaxKind.SpreadElement */:
161655 case 201 /* SyntaxKind.ObjectBindingPattern */:
161656 case 203 /* SyntaxKind.BindingElement */:
161657 return false;
161658 case 79 /* SyntaxKind.Identifier */:
161659 return parent.kind !== 203 /* SyntaxKind.BindingElement */ &&
161660 parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ &&
161661 parent.kind !== 275 /* SyntaxKind.ExportSpecifier */;
161662 }
161663 return true;
161664 }
161665 function isBlockLike(node) {
161666 switch (node.kind) {
161667 case 235 /* SyntaxKind.Block */:

Callers 2

checkNodeFunction · 0.85
getExtractableParentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected