Enqueue running formatters, at least in most cases.

Partial mitigation of #3407; but really we need a more
general solution and hopefully one that can support caching,
as we run many of the same formatters over and over again during
startup.
This commit is contained in:
Matt Godbolt
2022-02-27 13:07:32 -06:00
parent e4a89ef03c
commit e113aa4817
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ export class BaseCompiler {
this.llvmIr = new LlvmIrParser(this.compilerProps);
this.llvmAst = new LlvmAstParser(this.compilerProps);
this.formatHandler = new FormattingHandler(this.env.ceProps);
this.formatHandler = new FormattingHandler(this.env.ceProps, async job => await this.env.enqueue(job));
this.toolchainPath = getToolchainPath(this.compiler.exe, this.compiler.options);
+3 -2
View File
@@ -29,7 +29,8 @@ import { getFormatterTypeByKey } from '../formatters';
import { logger } from '../logger';
export class FormattingHandler {
constructor(ceProps) {
constructor(ceProps, maybeEnqueue) {
this.enqueue = maybeEnqueue || (async job => await job());
this.formatters = {};
this.ceProps = ceProps;
const formatters = _.compact(ceProps('formatters', '').split(':'));
@@ -49,7 +50,7 @@ export class FormattingHandler {
const versionRe = this.ceProps(`formatter.${formatter}.versionRe`, '.*');
const hasExplicitVersion = this.ceProps(`formatter.${formatter}.explicitVersion`, '') !== '';
try {
const result = await exec.execute(exe, [versionArg], {});
const result = await this.enqueue(async () => exec.execute(exe, [versionArg], {}));
const match = result.stdout.match(versionRe);
const formatterClass = getFormatterTypeByKey(type);
const styleList = this.ceProps(`formatter.${formatter}.styles`);