( node *ast.Node, indenter *dynamicIndenter, nodeStartLine int, undecoratedNodeStartLine int, nodes *ast.NodeList, parent *ast.Node, parentStartLine int, parentDynamicIndentation *dynamicIndenter, )
| 430 | } |
| 431 | |
| 432 | func (w *formatSpanWorker) processChildNodes( |
| 433 | node *ast.Node, |
| 434 | indenter *dynamicIndenter, |
| 435 | nodeStartLine int, |
| 436 | undecoratedNodeStartLine int, |
| 437 | nodes *ast.NodeList, |
| 438 | parent *ast.Node, |
| 439 | parentStartLine int, |
| 440 | parentDynamicIndentation *dynamicIndenter, |
| 441 | ) { |
| 442 | debug.Assert(nodes != nil) |
| 443 | debug.Assert(!ast.PositionIsSynthesized(nodes.Pos())) |
| 444 | debug.Assert(!ast.PositionIsSynthesized(nodes.End())) |
| 445 | |
| 446 | listStartToken := getOpenTokenForList(parent, nodes) |
| 447 | |
| 448 | listDynamicIndentation := parentDynamicIndentation |
| 449 | startLine := parentStartLine |
| 450 | |
| 451 | // node range is outside the target range - do not dive inside |
| 452 | if !w.originalRange.Overlaps(nodes.Loc) { |
| 453 | if nodes.End() < w.originalRange.Pos() && (len(nodes.Nodes) == 0 || nodes.Nodes[0].Flags&ast.NodeFlagsReparsed == 0) { |
| 454 | w.formattingScanner.skipToEndOf(&nodes.Loc) |
| 455 | } |
| 456 | return |
| 457 | } |
| 458 | |
| 459 | if listStartToken != ast.KindUnknown { |
| 460 | // introduce a new indentation scope for lists (including list start and end tokens) |
| 461 | for w.formattingScanner.isOnToken() && w.formattingScanner.getTokenFullStart() < w.originalRange.End() { |
| 462 | tokenInfo := w.formattingScanner.readTokenInfo(parent) |
| 463 | if tokenInfo.token.Loc.End() > nodes.Pos() { |
| 464 | // stop when formatting scanner moves past the beginning of node list |
| 465 | break |
| 466 | } else if tokenInfo.token.Kind == listStartToken { |
| 467 | // consume list start token |
| 468 | startLine = scanner.GetECMALineOfPosition(w.sourceFile, tokenInfo.token.Loc.Pos()) |
| 469 | |
| 470 | w.consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent, false) |
| 471 | |
| 472 | indentationOnListStartToken := 0 |
| 473 | if w.indentationOnLastIndentedLine != -1 { |
| 474 | // scanner just processed list start token so consider last indentation as list indentation |
| 475 | // function foo(): { // last indentation was 0, list item will be indented based on this value |
| 476 | // foo: number; |
| 477 | // }: {}; |
| 478 | indentationOnListStartToken = w.indentationOnLastIndentedLine |
| 479 | } else { |
| 480 | startLinePosition := GetLineStartPositionForPosition(tokenInfo.token.Loc.Pos(), w.sourceFile) |
| 481 | indentationOnListStartToken = FindFirstNonWhitespaceColumn(startLinePosition, tokenInfo.token.Loc.Pos(), w.sourceFile, w.formattingContext.Options) |
| 482 | } |
| 483 | |
| 484 | listDynamicIndentation = w.getDynamicIndentation(parent, parentStartLine, indentationOnListStartToken, w.formattingContext.Options.IndentSize) |
| 485 | } else { |
| 486 | // consume any tokens that precede the list as child elements of 'node' using its indentation scope |
| 487 | w.consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent, false) |
| 488 | } |
| 489 | } |
no test coverage detected