Skip to content

Commit

Permalink
Change displayBuildTarget to listBuildTargets
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthurm1 committed Feb 24, 2022
1 parent 4fb88f8 commit d53c4d2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@
},
"dependencies": {
"ansicolor": "^1.1.100",
"metals-languageclient": "0.5.8",
"metals-languageclient": "0.5.9",
"promisify-child-process": "4.1.1",
"vscode-languageclient": "7.0.0"
},
Expand Down
44 changes: 34 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,40 @@ function launchMetals(
);
});

function displayBuildTarget(target: string): void {
const workspaceRoots = workspace.workspaceFolders;
if (workspaceRoots && workspaceRoots.length > 0) {
const uriStr = `metalsDecode:file:///${workspaceRoots[0].name}/${target}.metals-buildtarget`;
const uri = Uri.parse(uriStr);
workspace
.openTextDocument(uri)
.then((textDocument) => window.showTextDocument(textDocument));
}
}

registerCommand(`metals.target-info-display`, async (...args: any[]) => {
if (args.length > 0) {
// get build target name from treeview uri of the form "projects:file:/root/metals/.mtags/?id=mtags3!/_root_/"
const treeViewUri = args[0] as string;
const query = treeViewUri.split("/?id=");
if (query.length > 1) {
const buildTarget = query[1].split("!");
if (buildTarget.length > 0) {
displayBuildTarget(buildTarget[0]);
}
}
} else {
// pick from list of targets
const targets = await client.sendRequest(ExecuteCommandRequest.type, {
command: ServerCommands.ListBuildTargets,
});
const picked = await window.showQuickPick(targets);
if (picked) {
displayBuildTarget(picked);
}
}
});

let channelOpen = false;

registerCommand(ClientCommands.FocusDiagnostics, () =>
Expand All @@ -577,16 +611,6 @@ function launchMetals(
commands.executeCommand(ClientCommands.RunDoctor)
);

registerCommand(
`metals.${ServerCommands.DisplayTargetInfo}`,
(...args) => {
client.sendRequest(ExecuteCommandRequest.type, {
command: ServerCommands.DisplayTargetInfo,
arguments: args,
});
}
);

registerCommand(ClientCommands.ToggleLogs, () => {
if (channelOpen) {
client.outputChannel.hide();
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1407,10 +1407,10 @@ merge2@^1.3.0, merge2@^1.4.1:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==

metals-languageclient@0.5.8:
version "0.5.8"
resolved "https://registry.yarnpkg.com/metals-languageclient/-/metals-languageclient-0.5.8.tgz#7d6975c7f77b9d798b200c28646ed28e83911f1e"
integrity sha512-Ah7/IniDC4SEKZw1tq6Xb2h9keyfi/rbzw0OmRxaH9vN18/9siwxsXnKUTd6gFb6w0LaymvotHqsd5yneuoXBA==
metals-languageclient@0.5.9:
version "0.5.9"
resolved "https://registry.yarnpkg.com/metals-languageclient/-/metals-languageclient-0.5.9.tgz#bd923367fdb6bf8fe0258e28a2f10ea4dd5349c4"
integrity sha512-dD7O4zXcQIjVk7TtRuGgGACavX5zT+W6fa2ANgS3rhmiibNezdBzhzlbpjms4EQXeVKUsqSzQvqlK+IGdKfcjA==
dependencies:
"@viperproject/locate-java-home" "^1.1.5"
fp-ts "^2.4.1"
Expand Down

0 comments on commit d53c4d2

Please sign in to comment.