Skip to content

Commit

Permalink
fix: file uri handling
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman committed Jan 28, 2023
1 parent 9a9ecc2 commit e19dac2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/src/commands/compileToTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function compileToTarget(client:LanguageClient, file: vscode.Uri) {
try {
const targetNames:string[] = await client.sendRequest("concertoCompileTargets");
const target = await vscode.window.showQuickPick(targetNames, { canPickMany: false });
const response = await client.sendRequest("concertoCompile", {uri:file, target});
const response = await client.sendRequest("concertoCompile", {uri:file.toString(), target});
vscode.window.showInformationMessage(`${response}.`);
} catch (e) {
vscode.window.showErrorMessage(`Compilation error: ${e}`);
Expand Down
12 changes: 9 additions & 3 deletions server/src/commands/concertoCompile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import { CodeGen } from '@accordproject/concerto-tools';
import { InMemoryWriter } from '@accordproject/concerto-util';
import { Utils, URI } from 'vscode-uri';

import { log } from '../state';
import { LanguageServerState } from '../types';
Expand All @@ -30,15 +31,20 @@ export async function concertoCompileToTarget(state: LanguageServerState, event:
fileWriter: imw
} as any;
state.modelManager.accept(visitor, parameters);
const output = `${event.uri.scheme}://${event.uri.authority}/output/${event.target}`;
saveInMemoryWriter(state, output, imw);
const uri = URI.parse(event.uri);
log(`Compiling CTO file ${uri.toString()}`);
const dir = Utils.dirname(uri);
const output = Utils.joinPath(dir, `/output/${event.target}`);
await saveInMemoryWriter(state, output.toString(), imw);
return `Saved ${event.target} model to ${output}`;
}
else {
log(`Invalid compilation target ${event.target} to compile model`);
}
} catch (e) {
log(`Failed to compile models to ${event.target} with error ${e}`);
const ee = (e as Error);
const stack = ee.stack ? ee.stack : 'missing';
log(`Failed to compile models to ${event.target} with error ${e} at ${stack}`);
}
}

Expand Down

0 comments on commit e19dac2

Please sign in to comment.