Skip to content

Commit

Permalink
WIP: temporary suggestions for splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
claui committed Dec 17, 2023
1 parent 72e1784 commit ee9b2e8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions extension/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 38 in extension/src/cli.ts

View workflow job for this annotation

GitHub Actions / build

Expected space or tab after '//' in comment

export type CliNamespace = string;

Expand Down
8 changes: 8 additions & 0 deletions extension/src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions extension/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ export class Parser {
}

async parseDocument(document: TextDocument) {

Check warning on line 19 in extension/src/parser.ts

View workflow job for this annotation

GitHub Actions / build

Async method 'parseDocument' has too many lines (57). Maximum allowed is 50
/*
* Pseudo-code for interface segregation:
* const config: ExecutableConfig = await this.#configFor(document);
* try {
* const cliResult: ifm.CliResult = ifm.runSync(document.getText(), config);

Check warning on line 24 in extension/src/parser.ts

View workflow job for this annotation

GitHub Actions / build

This line has a length of 82. Maximum allowed is 80
* 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(
Expand Down

0 comments on commit ee9b2e8

Please sign in to comment.