MCPcopy Create free account
hub / github.com/microsoft/typescript-go / FormatSpan

Function FormatSpan

internal/format/api.go:58–79  ·  view source on GitHub ↗
(ctx context.Context, span core.TextRange, file *ast.SourceFile, kind FormatRequestKind)

Source from the content-addressed store, hash-verified

56}
57
58func FormatSpan(ctx context.Context, span core.TextRange, file *ast.SourceFile, kind FormatRequestKind) []core.TextChange {
59 // find the smallest node that fully wraps the range and compute the initial indentation for the node
60 enclosingNode := findEnclosingNode(span, file)
61 opts := GetFormatCodeSettingsFromContext(ctx)
62
63 return newFormattingScanner(
64 file.Text(),
65 file.LanguageVariant,
66 getScanStartPosition(enclosingNode, span, file),
67 span.End(),
68 newFormatSpanWorker(
69 ctx,
70 span,
71 enclosingNode,
72 GetIndentationForNode(enclosingNode, &span, file, opts),
73 getOwnOrInheritedDelta(enclosingNode, opts, file),
74 kind,
75 prepareRangeContainsErrorFunction(file.Diagnostics(), span),
76 file,
77 ),
78 )
79}
80
81func FormatNodeGivenIndentation(ctx context.Context, node *ast.Node, file *ast.SourceFile, languageVariant core.LanguageVariant, initialIndentation int, delta int) []core.TextChange {
82 textRange := core.NewTextRange(node.Pos(), node.End())

Callers 5

formatNodeLinesFunction · 0.85
FormatDocumentFunction · 0.85
FormatSelectionFunction · 0.85
FormatOnOpeningCurlyFunction · 0.85
FormatOnEnterFunction · 0.85

Calls 11

findEnclosingNodeFunction · 0.85
newFormattingScannerFunction · 0.85
getScanStartPositionFunction · 0.85
newFormatSpanWorkerFunction · 0.85
GetIndentationForNodeFunction · 0.85
getOwnOrInheritedDeltaFunction · 0.85
DiagnosticsMethod · 0.80
TextMethod · 0.65
EndMethod · 0.65

Tested by

no test coverage detected