( node *ast.Node, indenter *dynamicIndenter, nodeStartLine int, undecoratedNodeStartLine int, child *ast.Node, inheritedIndentation int, parent *ast.Node, parentDynamicIndentation *dynamicIndenter, parentStartLine int, undecoratedParentStartLine int, isListItem bool, isFirstListItem bool, )
| 331 | } |
| 332 | |
| 333 | func (w *formatSpanWorker) processChildNode( |
| 334 | node *ast.Node, |
| 335 | indenter *dynamicIndenter, |
| 336 | nodeStartLine int, |
| 337 | undecoratedNodeStartLine int, |
| 338 | child *ast.Node, |
| 339 | inheritedIndentation int, |
| 340 | parent *ast.Node, |
| 341 | parentDynamicIndentation *dynamicIndenter, |
| 342 | parentStartLine int, |
| 343 | undecoratedParentStartLine int, |
| 344 | isListItem bool, |
| 345 | isFirstListItem bool, |
| 346 | ) int { |
| 347 | debug.Assert(!ast.NodeIsSynthesized(child)) |
| 348 | |
| 349 | if ast.NodeIsMissing(child) || isGrammarError(parent, child) || child.Flags&ast.NodeFlagsReparsed != 0 { |
| 350 | return inheritedIndentation |
| 351 | } |
| 352 | |
| 353 | childStartPos := scanner.GetTokenPosOfNode(child, w.sourceFile, false) |
| 354 | childStartLine := scanner.GetECMALineOfPosition(w.sourceFile, childStartPos) |
| 355 | |
| 356 | undecoratedChildStartLine := childStartLine |
| 357 | if ast.HasDecorators(child) { |
| 358 | undecoratedChildStartLine = scanner.GetECMALineOfPosition(w.sourceFile, getNonDecoratorTokenPosOfNode(child, w.sourceFile)) |
| 359 | } |
| 360 | |
| 361 | // if child is a list item - try to get its indentation, only if parent is within the original range. |
| 362 | childIndentationAmount := -1 |
| 363 | |
| 364 | if isListItem && parent.Loc.ContainedBy(w.originalRange) { |
| 365 | childIndentationAmount = w.tryComputeIndentationForListItem(childStartPos, child.End(), parentStartLine, w.originalRange, inheritedIndentation) |
| 366 | if childIndentationAmount != -1 { |
| 367 | inheritedIndentation = childIndentationAmount |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | // child node is outside the target range - do not dive inside |
| 372 | if !w.originalRange.Overlaps(child.Loc) { |
| 373 | if child.End() < w.originalRange.Pos() { |
| 374 | w.formattingScanner.skipToEndOf(&child.Loc) |
| 375 | } |
| 376 | return inheritedIndentation |
| 377 | } |
| 378 | |
| 379 | if child.Loc.Len() == 0 { |
| 380 | return inheritedIndentation |
| 381 | } |
| 382 | |
| 383 | for w.formattingScanner.isOnToken() && w.formattingScanner.getTokenFullStart() < w.originalRange.End() { |
| 384 | // proceed any parent tokens that are located prior to child.getStart() |
| 385 | tokenInfo := w.formattingScanner.readTokenInfo(node) |
| 386 | if tokenInfo.token.Loc.End() > w.originalRange.End() { |
| 387 | return inheritedIndentation |
| 388 | } |
| 389 | if tokenInfo.token.Loc.End() > childStartPos { |
| 390 | if tokenInfo.token.Loc.Pos() > childStartPos { |
no test coverage detected