MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / format

Method format

lib/formatting-service.ts:46–57  ·  view source on GitHub ↗
(formatterid: string, source: string, options: FormatOptions)

Source from the content-addressed store, hash-verified

44 }
45
46 public async format(formatterid: string, source: string, options: FormatOptions): Promise<UnprocessedExecResult> {
47 const formatter = this.getFormatterById(formatterid);
48 // Ensure the formatter exists
49 if (formatter === null) {
50 throw new Error(`Formatter ${formatterid} not found`);
51 }
52 // Ensure the formatting style is valid
53 if (!formatter.isValidStyle(options.baseStyle)) {
54 throw new Error(`Formatter ${formatterid} does not support style ${options.baseStyle}`);
55 }
56 return await formatter.format(source, options);
57 }
58
59 public async initialize(ceProps: PropertyGetter): Promise<void> {
60 const formatters = _.compact(ceProps('formatters', '').split(':'));

Callers

nothing calls this directly

Calls 2

getFormatterByIdMethod · 0.95
isValidStyleMethod · 0.45

Tested by

no test coverage detected