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

Function formatNodeLines

internal/format/api.go:101–109  ·  view source on GitHub ↗
(ctx context.Context, sourceFile *ast.SourceFile, node *ast.Node, requestKind FormatRequestKind)

Source from the content-addressed store, hash-verified

99}
100
101func formatNodeLines(ctx context.Context, sourceFile *ast.SourceFile, node *ast.Node, requestKind FormatRequestKind) []core.TextChange {
102 if node == nil {
103 return nil
104 }
105 tokenStart := scanner.GetTokenPosOfNode(node, sourceFile, false)
106 lineStart := GetLineStartPositionForPosition(tokenStart, sourceFile)
107 span := core.NewTextRange(lineStart, node.End())
108 return FormatSpan(ctx, span, sourceFile, requestKind)
109}
110
111func FormatDocument(ctx context.Context, sourceFile *ast.SourceFile) []core.TextChange {
112 return FormatSpan(ctx, core.NewTextRange(0, sourceFile.End()), sourceFile, FormatRequestKindFormatDocument)

Callers 2

FormatOnClosingCurlyFunction · 0.85
FormatOnSemicolonFunction · 0.85

Calls 5

GetTokenPosOfNodeFunction · 0.92
NewTextRangeFunction · 0.92
FormatSpanFunction · 0.85
EndMethod · 0.65

Tested by

no test coverage detected