MCPcopy Create free account
hub / github.com/nodejs/node / moveElementEntirelyPastChangeRange

Function moveElementEntirelyPastChangeRange

test/fixtures/snapshot/typescript.js:38455–38494  ·  view source on GitHub ↗
(element, isArray, delta, oldText, newText, aggressiveChecks)

Source from the content-addressed store, hash-verified

38453 }
38454 }
38455 function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) {
38456 if (isArray) {
38457 visitArray(element);
38458 }
38459 else {
38460 visitNode(element);
38461 }
38462 return;
38463 function visitNode(node) {
38464 var text = "";
38465 if (aggressiveChecks && shouldCheckNode(node)) {
38466 text = oldText.substring(node.pos, node.end);
38467 }
38468 // Ditch any existing LS children we may have created. This way we can avoid
38469 // moving them forward.
38470 if (node._children) {
38471 node._children = undefined;
38472 }
38473 ts.setTextRangePosEnd(node, node.pos + delta, node.end + delta);
38474 if (aggressiveChecks && shouldCheckNode(node)) {
38475 ts.Debug.assert(text === newText.substring(node.pos, node.end));
38476 }
38477 forEachChild(node, visitNode, visitArray);
38478 if (ts.hasJSDocNodes(node)) {
38479 for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
38480 var jsDocComment = _a[_i];
38481 visitNode(jsDocComment);
38482 }
38483 }
38484 checkNodePositions(node, aggressiveChecks);
38485 }
38486 function visitArray(array) {
38487 array._children = undefined;
38488 ts.setTextRangePosEnd(array, array.pos + delta, array.end + delta);
38489 for (var _i = 0, array_9 = array; _i < array_9.length; _i++) {
38490 var node = array_9[_i];
38491 visitNode(node);
38492 }
38493 }
38494 }
38495 function shouldCheckNode(node) {
38496 switch (node.kind) {
38497 case 10 /* SyntaxKind.StringLiteral */:

Callers 2

visitNodeFunction · 0.85
visitArrayFunction · 0.85

Calls 2

visitArrayFunction · 0.85
visitNodeFunction · 0.85

Tested by

no test coverage detected