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

Method ProvideFormatDocument

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

Source from the content-addressed store, hash-verified

25}
26
27func (l *LanguageService) ProvideFormatDocument(
28 ctx context.Context,
29 documentURI lsproto.DocumentUri,
30 options *lsproto.FormattingOptions,
31) (lsproto.DocumentFormattingResponse, error) {
32 if l.UserPreferences().EnableFormatting.IsFalse() {
33 return lsproto.TextEditsOrNull{}, nil
34 }
35 _, file := l.getProgramAndFile(documentURI)
36 formatOpts := lsutil.FromLSFormatOptions(l.FormatOptions(), options)
37 edits := l.toLSProtoTextEdits(file, l.getFormattingEditsForDocument(
38 ctx,
39 file,
40 formatOpts,
41 ))
42 return lsproto.TextEditsOrNull{TextEdits: &edits}, nil
43}
44
45func (l *LanguageService) ProvideFormatDocumentRange(
46 ctx context.Context,

Callers 1

handleDocumentFormatMethod · 0.80

Calls 7

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

Tested by

no test coverage detected