Skip to content

Commit

Permalink
Add Magik session wrapper (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenLooman authored Jan 7, 2025
1 parent 7fec9dd commit f75f22d
Show file tree
Hide file tree
Showing 28 changed files with 1,264 additions and 288 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@
"sw_type_dumper"
]
},
{
"type": "java",
"name": "Debug (Launch)-MagikSessionWrapper<magik-session-wrapper>",
"request": "launch",
"mainClass": "nl.ramsolutions.sw.magik.sessionwrapper.Main",
"projectName": "magik-session-wrapper",
"args": [
"--debug",
"--do-not-wait-for-prompt",
"--",
"${env:SMALLWORLD_GIS}/bin/share/runalias",
"-j", "-Djava.awt.headless=true",
"base"
]
},
{
"type": "java",
"name": "Debug (Launch)-MagikToolkit<sslr-magik-toolkit>",
Expand Down
3 changes: 2 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"cd magik-language-server/client-vscode/server && ",
"rm -f ./* ; ",
"ln -s ../../../magik-language-server/target/magik-language-server-*.jar && ",
"ln -s ../../../magik-debug-adapter/target/magik-debug-adapter-*.jar",
"ln -s ../../../magik-debug-adapter/target/magik-debug-adapter-*.jar && ",
"ln -s ../../../magik-session-wrapper/target/magik-session-wrapper-*.jar",
],
"group": "build",
"presentation": {
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- Fix auto formatting bug where `_pragma` caused lines to be removed.
- FormattingCheck now uses formatting code to detect issues.
- Formatter now supports ranged formatting.
- Add `magik-session-wrapper` to wrap a Magik running image/session, providing a better CLI experience.
- Several fixes.

### Breaking changes (reiterated from above)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';

import { getJavaExec } from './common';
import { MAGIK_TOOLS_VERSION } from './const';

export class MagikAliasTaskProvider implements vscode.TaskProvider, vscode.Disposable {

public static readonly AliasType: string = 'run_alias';
Expand Down Expand Up @@ -49,7 +52,7 @@ export class MagikAliasTaskProvider implements vscode.TaskProvider, vscode.Dispo
const runAliasPath = getRunAliasPath();
const aliasesPath = getAliasesPath(definition.aliasesPath);
const environmentFile = getEnvironmentPath(definition.environmentPath);
const commandLine = getStartAliasCommand(runAliasPath, aliasesPath, definition.entry, environmentFile, definition.args);
const commandLine = getCommandLine(runAliasPath, aliasesPath, definition.entry, environmentFile, definition.args);
const shellExecutionOptions: vscode.ShellExecutionOptions = {
env: definition.env,
};
Expand Down Expand Up @@ -126,15 +129,32 @@ function getAliasesPath(aliasesPath?: fs.PathLike): fs.PathLike {
return vscode.workspace.getConfiguration().get('magik.aliases');
}

function getStartAliasCommand(runAliasPath: fs.PathLike, aliasesPath: fs.PathLike, entryName: string, environmentFile?: fs.PathLike, additionalArgs?: string[]): string {
let commandLine = `${runAliasPath} -a ${aliasesPath}`;
function getCommandLine(runAliasPath: fs.PathLike, aliasesPath: fs.PathLike, entryName: string, environmentFile?: fs.PathLike, additionalArgs?: string[]): string {
let commandLine = `${runAliasPath}`;
if (aliasesPath != null) {
commandLine = `${commandLine} -a ${aliasesPath}`;
}
if (environmentFile != null) {
commandLine = `${commandLine} -e ${environmentFile}`;
}
if (additionalArgs != null) {
commandLine = `${commandLine} ${additionalArgs.join(' ')}`;
}
commandLine = `${commandLine} ${entryName}`;

const useWrapper = vscode.workspace.getConfiguration().get('magik.useSessionWrapper', true);
if (useWrapper) {
const javaExec = getJavaExec();
if (javaExec == null) {
const errorMessage = 'Could locate java executable, either set Java Home setting ("magik.javaHome") or JAVA_HOME environment variable.'
vscode.window.showWarningMessage(errorMessage);
throw new Error(errorMessage);
}

const jar = path.join(__dirname, '..', '..', 'server', 'magik-session-wrapper-' + MAGIK_TOOLS_VERSION + '.jar');
commandLine = `${javaExec} -jar ${jar} --debug -- ${commandLine}`;
}

return commandLine;
}

Expand Down Expand Up @@ -171,7 +191,7 @@ async function getAliasesTasks(aliasesPath: fs.PathLike): Promise<vscode.Task[]>
additionalArguments: [],
env: {},
};
const commandLine = getStartAliasCommand(runAliasPath, aliasesPath, definition.entry, environmentFile, definition.additionalArguments);
const commandLine = getCommandLine(runAliasPath, aliasesPath, definition.entry, environmentFile, definition.additionalArguments);
const shellExecutionOptions: vscode.ShellExecutionOptions = {
env: definition.env,
};
Expand Down
5 changes: 5 additions & 0 deletions magik-language-server/client-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@
"description": "Path to environment file -- only used by the VS Code extension.",
"type": "string"
},
"magik.useSessionWrapper": {
"description": "Use Smallworld session wrapper.",
"type": "boolean",
"default": true
},
"magik.formatting.indentChar": {
"description": "Indent character, 'tab' or 'space' -- only used by the VS Code extension.",
"type": "string"
Expand Down
1 change: 1 addition & 0 deletions magik-language-server/client-vscode/server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
magik-debug-adapter-*.jar
magik-language-server-*.jar
magik-session-wrapper-*.jar

This file was deleted.

Loading

0 comments on commit f75f22d

Please sign in to comment.