Skip to content

Commit

Permalink
Merge pull request #47 from lf-lang/view-output
Browse files Browse the repository at this point in the history
Add button to view output from build
  • Loading branch information
petervdonovan authored May 17, 2022
2 parents b4f7c20 + f3bad0e commit f9c4f2d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
node_modules/*
out/*
.gradle/*

__pycache__/*
7 changes: 7 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
node_modules/
.git/
.github/
.gitmodules/
lingua-franca/
__pycache__/*
src/**

*.vsix
.gitignore
.vscodeignore
CHANGELOG.md
LICENSE.txt
jest.config.ts
tsconfig.json
tslint.json
uf.py
package-lock.json
developer-notes.md
2 changes: 1 addition & 1 deletion lingua-franca
Submodule lingua-franca updated 136 files
14 changes: 12 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,24 @@ export async function activate(context: ExtensionContext) {

client.start();

type messageShower = (message: string, ...items: string[]) => Thenable<string | undefined>
const withLogs = (showMessage: messageShower) => (message: string) => showMessage(
message, "Show output"
).then(choice => {
if (choice === "Show output") client.outputChannel.show()
})

context.subscriptions.push(commands.registerTextEditorCommand(
'linguafranca.build',
(textEditor: TextEditor, _) => {
const uri = getLfUri(textEditor.document)
if (!uri) return;
workspace.saveAll().then(function(successful) {
if (!successful) return;
client.sendRequest('generator/build', uri).then(window.showInformationMessage);
client.sendRequest('generator/build', uri).then((message: string) => {
if (message) withLogs(window.showInformationMessage)(message);
else withLogs(window.showErrorMessage)('Build failed.');
});
});
}
));
Expand All @@ -88,7 +98,7 @@ export async function activate(context: ExtensionContext) {
if (!successful) return;
client.sendRequest('generator/buildAndRun', uri).then((command: string[]) => {
if (!command || !command.length) {
window.showErrorMessage('Build failed.');
withLogs(window.showErrorMessage)('Build failed.');
return;
}
const runTerminalName = 'Lingua Franca: Run';
Expand Down

0 comments on commit f9c4f2d

Please sign in to comment.