Skip to content

Commit 6ea48bc

Browse files
committed
Extension restart fix
Moved the reload window pop up from jdk downloader to configuration change listener(restartExtension) triggered whenever any configuration is changed and extension is in bad state.
1 parent 78f4858 commit 6ea48bc

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

vscode/l10n/bundle.l10n.en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,7 @@
9696
"jdk.workspace.new.prompt": "Input the directory path where the new file will be generated",
9797
"jdk.extension.utils.error_message.failedHttpsRequest": "Failed to get {url} ({statusCode})",
9898
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME} not enabled",
99-
"jdk.telemetry.consent": "Allow anonymous telemetry data to be reported to Oracle? You may opt-out or in at any time from the Settings for jdk.telemetry.enabled."
99+
"jdk.telemetry.consent": "Allow anonymous telemetry data to be reported to Oracle? You may opt-out or in at any time from the Settings for jdk.telemetry.enabled.",
100+
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
101+
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
100102
}

vscode/l10n/bundle.l10n.ja.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,7 @@
9696
"jdk.workspace.new.prompt": "新しいファイルを生成するディレクトリのパスを入力してください",
9797
"jdk.extension.utils.error_message.failedHttpsRequest": "{url}の取得に失敗しました({statusCode})",
9898
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME}が有効化されていません",
99-
"jdk.telemetry.consent": "匿名テレメトリ・データをOracleにレポートすることを許可しますか。jdk.telemetry.enabledの設定からいつでもオプトアウトまたはオプトインできます。"
99+
"jdk.telemetry.consent": "匿名テレメトリ・データをOracleにレポートすることを許可しますか。jdk.telemetry.enabledの設定からいつでもオプトアウトまたはオプトインできます。",
100+
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
101+
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
100102
}

vscode/l10n/bundle.l10n.zh-cn.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,7 @@
9696
"jdk.workspace.new.prompt": "输入生成新文件的目录路径",
9797
"jdk.extension.utils.error_message.failedHttpsRequest": "无法获取 {url} ({statusCode})",
9898
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME} 未启用",
99-
"jdk.telemetry.consent": "是否允许向 Oracle 报告匿名遥测数据?您随时可以通过 jdk.telemetry.enabled 对应的设置选择退出或加入。"
99+
"jdk.telemetry.consent": "是否允许向 Oracle 报告匿名遥测数据?您随时可以通过 jdk.telemetry.enabled 对应的设置选择退出或加入。",
100+
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
101+
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
100102
}

vscode/src/lsp/clientPromise.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
import { commands } from "vscode";
16+
import { commands,window } from "vscode";
1717
import { LOGGER } from "../logger";
1818
import { NbProcessManager } from "./nbProcessManager";
1919
import { clientInit } from "./initializer";
2020
import { NbLanguageClient } from "./nbLanguageClient";
2121
import { globalState } from "../globalState";
22+
import { l10n } from "../localiser";
2223

2324
export class ClientPromise {
2425
setClient!: [(c: NbLanguageClient) => void, (err: any) => void];
@@ -60,25 +61,35 @@ export class ClientPromise {
6061
}
6162

6263
public restartExtension = async (nbProcessManager: NbProcessManager | null, notifyKill: boolean) => {
63-
if (this.activationPending) {
64-
LOGGER.warn("Server activation requested repeatedly, ignoring...");
65-
return;
66-
}
67-
if (!nbProcessManager) {
64+
if (nbProcessManager) {
65+
try {
66+
globalState.setDeactivated(true);
67+
await this.stopClient();
68+
await nbProcessManager.killProcess(notifyKill);
69+
this.initialize();
70+
clientInit();
71+
} catch (error) {
72+
LOGGER.error(`Error during activation: ${error}`);
73+
const reloadNow: string = l10n.value("jdk.downloader.message.reload");
74+
const dialogBoxMessage = l10n.value("jdk.configChangedFailed");
75+
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
76+
if (selected === reloadNow) {
77+
await commands.executeCommand('workbench.action.reloadWindow');
78+
}
79+
return;
80+
} finally {
81+
this.activationPending = false;
82+
}
83+
}else{
6884
LOGGER.error("Nbcode Process is null");
85+
const reloadNow: string = l10n.value("jdk.downloader.message.reload");
86+
const dialogBoxMessage = l10n.value("jdk.configChanged");
87+
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
88+
if (selected === reloadNow) {
89+
await commands.executeCommand('workbench.action.reloadWindow');
90+
}
6991
return;
7092
}
71-
try {
72-
await this.stopClient();
73-
await nbProcessManager.killProcess(notifyKill);
74-
this.initialize();
75-
clientInit();
76-
} catch (error) {
77-
LOGGER.error(`Error during activation: ${error}`);
78-
throw error;
79-
} finally {
80-
this.activationPending = false;
81-
}
8293
}
8394

8495
}

vscode/src/webviews/jdkDownloader/action.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,7 @@ export class JdkDownloaderAction {
121121
dialogBoxMessage = l10n.value("jdk.downloader.message.completedInstallingJdk");
122122
}
123123
LOGGER.log(`JDK installation completed successfully`);
124-
125-
const reloadNow: string = l10n.value("jdk.downloader.message.reload");
126-
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
127-
if (selected === reloadNow) {
128-
await this.downloaderView.disposeView();
129-
await commands.executeCommand('workbench.action.reloadWindow');
130-
}
124+
await window.showInformationMessage(dialogBoxMessage);
131125
}
132126

133127
private jdkInstallationManager = async () => {

0 commit comments

Comments
 (0)