diff --git a/extension/src/cli.ts b/extension/src/cli.ts index 26d818c..365f18e 100644 --- a/extension/src/cli.ts +++ b/extension/src/cli.ts @@ -35,6 +35,7 @@ export interface CliOutput { export type CliResult = | { hasRun: true } & CliOutput | { hasRun: false, success: false } & CliNotOk +//| { healthy: false, hasRun: false, success: false } & CliNotHealthy export type CliNamespace = string; diff --git a/extension/src/diagnostics.ts b/extension/src/diagnostics.ts index 5ed822e..8ad27a8 100644 --- a/extension/src/diagnostics.ts +++ b/extension/src/diagnostics.ts @@ -47,6 +47,14 @@ export class Diagnostics { cause: ("cause" in event.error) ? event.error.cause : event.error, }); } + /* + * Pseudo-code for interface segregation: + * const ifmMessages: ifm.Message[] = ifm.parseCliStderr(event.stderr); + * const diagnostics: Diagnostic[] = ifmMessages.map((message) => + * toDiagnostic(message, event.document), + * ); + * this.#diagnosticCollection.set(event.document.uri, diagnostics); + */ const matchResult = grammar.match(event.stderr); if (matchResult.failed()) { throw new Error(matchResult.message); diff --git a/extension/src/parser.ts b/extension/src/parser.ts index 7bf4d95..2434c55 100644 --- a/extension/src/parser.ts +++ b/extension/src/parser.ts @@ -17,6 +17,22 @@ export class Parser { } async parseDocument(document: TextDocument) { + /* + * Pseudo-code for interface segregation: + * const config: ExecutableConfig = await this.#configFor(document); + * try { + * const cliResult: ifm.CliResult = ifm.runSync(document.getText(), config); + * if (!cliResult.success) { + * log.error("exit status:", cliResult.status); + * log.error("error:", cliResult.error); + * } + * } catch (error) { + * // … + * } + * this.#didParseDocumentEventEmitter.fire( + * { document, ...cliResult }); + */ + const cli: IfmCli = await this.#cliProvider.cliFor(document); if (!cli.ok) { this.#didParseDocumentEventEmitter.fire(