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

Method ProvideFormatDocumentRange

internal/ls/format.go:45–63  ·  view source on GitHub ↗
(
	ctx context.Context,
	documentURI lsproto.DocumentUri,
	options *lsproto.FormattingOptions,
	r lsproto.Range,
)

Source from the content-addressed store, hash-verified

43}
44
45func (l *LanguageService) ProvideFormatDocumentRange(
46 ctx context.Context,
47 documentURI lsproto.DocumentUri,
48 options *lsproto.FormattingOptions,
49 r lsproto.Range,
50) (lsproto.DocumentRangeFormattingResponse, error) {
51 if l.UserPreferences().EnableFormatting.IsFalse() {
52 return lsproto.TextEditsOrNull{}, nil
53 }
54 _, file := l.getProgramAndFile(documentURI)
55 formatOpts := lsutil.FromLSFormatOptions(l.FormatOptions(), options)
56 edits := l.toLSProtoTextEdits(file, l.getFormattingEditsForRange(
57 ctx,
58 file,
59 formatOpts,
60 l.converters.FromLSPRange(file, r),
61 ))
62 return lsproto.TextEditsOrNull{TextEdits: &edits}, nil
63}
64
65func (l *LanguageService) ProvideFormatDocumentOnType(
66 ctx context.Context,

Callers 1

Calls 8

UserPreferencesMethod · 0.95
getProgramAndFileMethod · 0.95
FormatOptionsMethod · 0.95
toLSProtoTextEditsMethod · 0.95
FromLSFormatOptionsFunction · 0.92
IsFalseMethod · 0.80
FromLSPRangeMethod · 0.80

Tested by

no test coverage detected