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

Function shouldAddDelta

test/fixtures/snapshot/typescript.js:147396–147427  ·  view source on GitHub ↗
(line, kind, container)

Source from the content-addressed store, hash-verified

147394 }
147395 };
147396 function shouldAddDelta(line, kind, container) {
147397 switch (kind) {
147398 // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
147399 case 18 /* SyntaxKind.OpenBraceToken */:
147400 case 19 /* SyntaxKind.CloseBraceToken */:
147401 case 21 /* SyntaxKind.CloseParenToken */:
147402 case 91 /* SyntaxKind.ElseKeyword */:
147403 case 115 /* SyntaxKind.WhileKeyword */:
147404 case 59 /* SyntaxKind.AtToken */:
147405 return false;
147406 case 43 /* SyntaxKind.SlashToken */:
147407 case 31 /* SyntaxKind.GreaterThanToken */:
147408 switch (container.kind) {
147409 case 280 /* SyntaxKind.JsxOpeningElement */:
147410 case 281 /* SyntaxKind.JsxClosingElement */:
147411 case 279 /* SyntaxKind.JsxSelfClosingElement */:
147412 case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
147413 return false;
147414 }
147415 break;
147416 case 22 /* SyntaxKind.OpenBracketToken */:
147417 case 23 /* SyntaxKind.CloseBracketToken */:
147418 if (container.kind !== 195 /* SyntaxKind.MappedType */) {
147419 return false;
147420 }
147421 break;
147422 }
147423 // if token line equals to the line of containing node (this is a first token in the node) - use node indentation
147424 return nodeStartLine !== line
147425 // if this token is the first token following the list of decorators, we do not need to indent
147426 && !(node.decorators && kind === getFirstNonDecoratorTokenOfNode(node));
147427 }
147428 function getDelta(child) {
147429 // Delta value should be zero when the node explicitly prevents indentation of the child node
147430 return formatting.SmartIndenter.nodeWillIndentChild(options, node, child, sourceFile, /*indentByDefault*/ true) ? delta : 0;

Callers 1

getDynamicIndentationFunction · 0.85

Calls 1

Tested by

no test coverage detected