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

Function getStatementOrExpressionRange

test/fixtures/snapshot/typescript.js:160510–160525  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

160508 return { start: start, length: end - start };
160509 }
160510 function getStatementOrExpressionRange(node) {
160511 if (ts.isStatement(node)) {
160512 return [node];
160513 }
160514 if (ts.isExpressionNode(node)) {
160515 // If our selection is the expression in an ExpressionStatement, expand
160516 // the selection to include the enclosing Statement (this stops us
160517 // from trying to care about the return value of the extracted function
160518 // and eliminates double semicolon insertion in certain scenarios)
160519 return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
160520 }
160521 if (isStringLiteralJsxAttribute(node)) {
160522 return node;
160523 }
160524 return undefined;
160525 }
160526 function isScope(node) {
160527 return ts.isArrowFunction(node) ? ts.isFunctionBody(node.body) :
160528 ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);

Callers 1

getRangeToExtractFunction · 0.85

Calls 1

Tested by

no test coverage detected