Skip to content

Commit

Permalink
applied review
Browse files Browse the repository at this point in the history
  • Loading branch information
iusildra authored and adpi2 committed Feb 7, 2024
1 parent db4e1d3 commit 10feada
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 115 deletions.
22 changes: 1 addition & 21 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,5 @@
"typescript.tsdk": "node_modules/typescript/lib",
"files.watcherExclude": {
"**/target": true
},
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#0083dc",
"activityBar.background": "#0083dc",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#9f005f",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#0083dc",
"statusBar.background": "#0065a9",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#0083dc",
"statusBarItem.remoteBackground": "#0065a9",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#0065a9",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#0065a999",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#0065A9"
}
}
7 changes: 3 additions & 4 deletions packages/metals-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@
"configuration": {
"title": "Metals",
"properties": {
"metals.debug.settings.hotCodeReplace": {
"metals.hotCodeReplace": {
"type": "boolean",
"default": false,
"markdownDescription": "Allow Hot Code Replace (HCR) while debugging. Only available since Metals 1.0.X"
"markdownDescription": "Allow Hot Code Replace (HCR) while debugging"
},
"metals.serverVersion": {
"type": "string",
Expand Down Expand Up @@ -1108,8 +1108,7 @@
"metals-languageclient": "file:../metals-languageclient",
"promisify-child-process": "4.1.1",
"semver": "^7.5.2",
"vscode-languageclient": "8.1.0",
"vscode-extension-telemetry-wrapper": "^0.13.3"
"vscode-languageclient": "8.1.0"
},
"extensionPack": [
"scala-lang.scala"
Expand Down
12 changes: 3 additions & 9 deletions packages/metals-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ import {
} from "./consts";
import { ScalaCodeLensesParams } from "./debugger/types";
import { applyHCR, initializeHotCodeReplace } from "./hotCodeReplace";
import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";

const outputChannel = window.createOutputChannel("Metals");
const downloadJava = "Download Java";
Expand Down Expand Up @@ -1190,14 +1189,9 @@ function launchMetals(
}
);
context.subscriptions.push(decorationsRangesDidChangeDispoasable);
context.subscriptions.push(
instrumentOperationAsVsCodeCommand(
"metals.debug.hotCodeReplace",
async () => {
await applyHCR();
}
)
);
registerCommand("metals.debug.hotCodeReplace", () => {
applyHCR();
});
initializeHotCodeReplace();
},
(reason) => {
Expand Down
35 changes: 11 additions & 24 deletions packages/metals-vscode/src/hotCodeReplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,28 @@ import * as vscode from "vscode";

import { DebugSession, commands } from "vscode";

const HCR_CONFIG = "metals.hotCodeReplace";
const HCR_ACTIVE = "scalaHotReloadOn";

export function initializeHotCodeReplace() {
vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration("metals.debug.settings.hotCodeReplace")) {
if (event.affectsConfiguration(HCR_CONFIG)) {
vscode.commands.executeCommand(
"setContext",
"scalaHotReloadOn",
HCR_ACTIVE,
hotReplaceIsOn()
);
}
});
vscode.debug.onDidStartDebugSession((session) => {
if (session?.configuration.noDebug && !vscode.debug.activeDebugSession) {
vscode.commands.executeCommand("setContext", "scalaHotReloadOn", false);
vscode.commands.executeCommand("setContext", HCR_ACTIVE, false);
}
});
vscode.debug.onDidChangeActiveDebugSession((session) => {
vscode.commands.executeCommand(
"setContext",
"scalaHotReloadOn",
HCR_ACTIVE,
session && !session.configuration.noDebug && hotReplaceIsOn()
);
});
Expand Down Expand Up @@ -66,21 +69,10 @@ export async function applyHCR() {
return;
}

const NO_HCR = "Disable HCR";

if (!response?.changedClasses?.length) {
const res = await vscode.window.showWarningMessage(
"No classes were reloaded",
"Ok",
NO_HCR
vscode.window.showWarningMessage(
"No classes were reloaded, please check the logs"
);

if (res === NO_HCR) {
vscode.workspace
.getConfiguration("metals.debug.settings")
.update("hotCodeReplace", false, vscode.ConfigurationTarget.Workspace);
vscode.commands.executeCommand("setContext", "scalaHotReloadOn", false);
}
return;
}

Expand All @@ -91,10 +83,5 @@ export async function applyHCR() {
);
}

function hotReplaceIsOn(): boolean {
return (
vscode.workspace
.getConfiguration("metals.debug.settings")
.get("hotCodeReplace") ?? false
);
}
const hotReplaceIsOn = () =>
vscode.workspace.getConfiguration("metals").get("hotCodeReplace") ?? false;
57 changes: 0 additions & 57 deletions packages/metals-vscode/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,6 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==

"@microsoft/1ds-core-js@3.2.13", "@microsoft/1ds-core-js@^3.2.3":
version "3.2.13"
resolved "https://registry.yarnpkg.com/@microsoft/1ds-core-js/-/1ds-core-js-3.2.13.tgz#0c105ed75091bae3f1555c0334704fa9911c58fb"
integrity sha512-CluYTRWcEk0ObG5EWFNWhs87e2qchJUn0p2D21ZUa3PWojPZfPSBs4//WIE0MYV8Qg1Hdif2ZTwlM7TbYUjfAg==
dependencies:
"@microsoft/applicationinsights-core-js" "2.8.15"
"@microsoft/applicationinsights-shims" "^2.0.2"
"@microsoft/dynamicproto-js" "^1.1.7"

"@microsoft/1ds-post-js@^3.2.3":
version "3.2.13"
resolved "https://registry.yarnpkg.com/@microsoft/1ds-post-js/-/1ds-post-js-3.2.13.tgz#560aacac8a92fdbb79e8c2ebcb293d56e19f51aa"
integrity sha512-HgS574fdD19Bo2vPguyznL4eDw7Pcm1cVNpvbvBLWiW3x4e1FCQ3VMXChWnAxCae8Hb0XqlA2sz332ZobBavTA==
dependencies:
"@microsoft/1ds-core-js" "3.2.13"
"@microsoft/applicationinsights-shims" "^2.0.2"
"@microsoft/dynamicproto-js" "^1.1.7"

"@microsoft/applicationinsights-core-js@2.8.15":
version "2.8.15"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-2.8.15.tgz#8fa466474260e01967fe649f14dd9e5ff91dcdc8"
integrity sha512-yYAs9MyjGr2YijQdUSN9mVgT1ijI1FPMgcffpaPmYbHAVbQmF7bXudrBWHxmLzJlwl5rfep+Zgjli2e67lwUqQ==
dependencies:
"@microsoft/applicationinsights-shims" "2.0.2"
"@microsoft/dynamicproto-js" "^1.1.9"

"@microsoft/applicationinsights-shims@2.0.2", "@microsoft/applicationinsights-shims@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-shims/-/applicationinsights-shims-2.0.2.tgz#92b36a09375e2d9cb2b4203383b05772be837085"
integrity sha512-PoHEgsnmcqruLNHZ/amACqdJ6YYQpED0KSRe6J7gIJTtpZC1FfFU9b1fmDKDKtFoUSrPzEh1qzO3kmRZP0betg==

"@microsoft/dynamicproto-js@^1.1.7", "@microsoft/dynamicproto-js@^1.1.9":
version "1.1.9"
resolved "https://registry.yarnpkg.com/@microsoft/dynamicproto-js/-/dynamicproto-js-1.1.9.tgz#7437db7aa061162ee94e4131b69a62b8dad5dea6"
integrity sha512-n1VPsljTSkthsAFYdiWfC+DKzK2WwcRp83Y1YAqdX552BstvsDjft9YXppjUzp11BPsapDoO1LDgrDB0XVsfNQ==

"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -318,14 +282,6 @@
async "^3.2.2"
semver "^7.3.5"

"@vscode/extension-telemetry@^0.6.2":
version "0.6.2"
resolved "https://registry.yarnpkg.com/@vscode/extension-telemetry/-/extension-telemetry-0.6.2.tgz#b86814ee680615730da94220c2b03ea9c3c14a8e"
integrity sha512-yb/wxLuaaCRcBAZtDCjNYSisAXz3FWsSqAha5nhHcYxx2ZPdQdWuZqVXGKq0ZpHVndBWWtK6XqtpCN2/HB4S1w==
dependencies:
"@microsoft/1ds-core-js" "^3.2.3"
"@microsoft/1ds-post-js" "^3.2.3"

"@vscode/test-electron@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@vscode/test-electron/-/test-electron-2.3.0.tgz#de0ba2f5d36546a83cd481b458cbdbb7cc0f7049"
Expand Down Expand Up @@ -2489,19 +2445,6 @@ util-deprecate@^1.0.1, util-deprecate@~1.0.1:
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=

uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

vscode-extension-telemetry-wrapper@^0.13.3:
version "0.13.3"
resolved "https://registry.yarnpkg.com/vscode-extension-telemetry-wrapper/-/vscode-extension-telemetry-wrapper-0.13.3.tgz#685fe92843b07fe785e416926721e26f867c3a69"
integrity sha512-k/PbUbH9/xqiMXI2g2RXpDg+4/v08t3NzdPc7HuDPF3A1XcYkgYwsPnS/bqsKZNymSQdbLvVuie6STMxbDX9KQ==
dependencies:
"@vscode/extension-telemetry" "^0.6.2"
uuid "^8.3.2"

vscode-jsonrpc@8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz#cb9989c65e219e18533cc38e767611272d274c94"
Expand Down

0 comments on commit 10feada

Please sign in to comment.