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

Function getNodeToInsertConstantBefore

test/fixtures/snapshot/typescript.js:161234–161262  ·  view source on GitHub ↗
(node, scope)

Source from the content-addressed store, hash-verified

161232 return prevMember;
161233 }
161234 function getNodeToInsertConstantBefore(node, scope) {
161235 ts.Debug.assert(!ts.isClassLike(scope));
161236 var prevScope;
161237 for (var curr = node; curr !== scope; curr = curr.parent) {
161238 if (isScope(curr)) {
161239 prevScope = curr;
161240 }
161241 }
161242 for (var curr = (prevScope || node).parent;; curr = curr.parent) {
161243 if (isBlockLike(curr)) {
161244 var prevStatement = void 0;
161245 for (var _i = 0, _a = curr.statements; _i < _a.length; _i++) {
161246 var statement = _a[_i];
161247 if (statement.pos > node.pos) {
161248 break;
161249 }
161250 prevStatement = statement;
161251 }
161252 if (!prevStatement && ts.isCaseClause(curr)) {
161253 // We must have been in the expression of the case clause.
161254 ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement");
161255 return curr.parent.parent;
161256 }
161257 // There must be at least one statement since we started in one.
161258 return ts.Debug.checkDefined(prevStatement, "prevStatement failed to get set");
161259 }
161260 ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope");
161261 }
161262 }
161263 function getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes) {
161264 var variableAssignments = ts.map(exposedVariableDeclarations, function (v) { return ts.factory.createShorthandPropertyAssignment(v.symbol.name); });
161265 var writeAssignments = ts.map(writes, function (w) { return ts.factory.createShorthandPropertyAssignment(w.symbol.name); });

Callers 1

extractConstantInScopeFunction · 0.85

Calls 3

isScopeFunction · 0.85
isBlockLikeFunction · 0.85
assertMethod · 0.80

Tested by

no test coverage detected