(node *ast.Node, emitFlags EmitFlags, commentRange core.TextRange)
| 5384 | } |
| 5385 | |
| 5386 | func (p *Printer) emitLeadingCommentsOfNode(node *ast.Node, emitFlags EmitFlags, commentRange core.TextRange) { |
| 5387 | pos := commentRange.Pos() |
| 5388 | end := commentRange.End() |
| 5389 | |
| 5390 | // Save current container state on the stack. |
| 5391 | if (!ast.PositionIsSynthesized(pos) || !ast.PositionIsSynthesized(end)) && pos != end { |
| 5392 | // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. |
| 5393 | // It is expensive to walk entire tree just to set one kind of node to have no comments. |
| 5394 | skipLeadingComments := ast.PositionIsSynthesized(pos) || emitFlags&EFNoLeadingComments != 0 || node.Kind == ast.KindJsxText |
| 5395 | skipTrailingComments := ast.PositionIsSynthesized(end) || emitFlags&EFNoTrailingComments != 0 || node.Kind == ast.KindJsxText |
| 5396 | |
| 5397 | // Emit leading comments if the position is not synthesized and the node |
| 5398 | // has not opted out from emitting leading comments. |
| 5399 | if !skipLeadingComments { |
| 5400 | p.emitLeadingComments(pos, node.Kind == ast.KindNotEmittedStatement /*elided*/) |
| 5401 | } |
| 5402 | |
| 5403 | if !skipLeadingComments || (pos >= 0 && (emitFlags&EFNoLeadingComments) != 0) { |
| 5404 | // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. |
| 5405 | p.containerPos = pos |
| 5406 | } |
| 5407 | |
| 5408 | if !skipTrailingComments || (end >= 0 && (emitFlags&EFNoTrailingComments) != 0) { |
| 5409 | // Advance the container end if comments get emitted or if they've been disabled explicitly using NoTrailingComments. |
| 5410 | p.containerEnd = end |
| 5411 | |
| 5412 | // To avoid invalid comment emit in a down-level binding pattern, we |
| 5413 | // keep track of the last declaration list container's end |
| 5414 | if node.Kind == ast.KindVariableDeclarationList { |
| 5415 | p.declarationListContainerEnd = end |
| 5416 | } |
| 5417 | } |
| 5418 | } |
| 5419 | } |
| 5420 | |
| 5421 | func (p *Printer) emitTrailingCommentsOfNode(node *ast.Node, emitFlags EmitFlags, commentRange core.TextRange, containerPos int, containerEnd int, declarationListContainerEnd int) { |
| 5422 | pos := commentRange.Pos() |
no test coverage detected