Skip to content

Commit 0175fd1

Browse files
committed
addressed regressions jdk downloader prompt not showing up and views not reloadingon extension restart
fixed no workspace present then extension crashing issue fixed jdk.verbose not working fixed runConfig settings not getting persisted regression and refactored configUpdate and get methods fixed dialog ox appearing when project compile and clean are executed
1 parent 38129b8 commit 0175fd1

File tree

11 files changed

+48
-48
lines changed

11 files changed

+48
-48
lines changed

vscode/src/commands/buildOperations.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ import { wrapCommandWithProgress, wrapProjectActionWithProgress } from "./utils"
2323
const compileWorkspaceHandler = () => {
2424
return wrapCommandWithProgress(nbCommands.buildWorkspace, l10n.value('jdk.extension.command.progress.compilingWorkSpace'), LOGGER.getOutputChannel());
2525
}
26+
2627
const cleanWorkspaceHandler = () => {
2728
return wrapCommandWithProgress(nbCommands.cleanWorkspace,l10n.value('jdk.extension.command.progress.cleaningWorkSpace'), LOGGER.getOutputChannel());
2829
}
2930

3031
const compileProjectHandler = (args: any) => {
31-
return wrapProjectActionWithProgress('build', undefined, l10n.value('jdk.extension.command.progress.compilingProject'), LOGGER.getOutputChannel(), args);
32+
wrapProjectActionWithProgress('build', undefined, l10n.value('jdk.extension.command.progress.compilingProject'), LOGGER.getOutputChannel(), args);
3233
}
3334

3435
const cleanProjectHandler = (args: any) => {
35-
return wrapProjectActionWithProgress('clean', undefined, l10n.value('jdk.extension.command.progress.cleaningProject'), LOGGER.getOutputChannel(), args);
36+
wrapProjectActionWithProgress('clean', undefined, l10n.value('jdk.extension.command.progress.cleaningProject'), LOGGER.getOutputChannel(), args);
3637
}
3738

3839

vscode/src/commands/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const wrapCommandWithProgress = (lsCommand: string, title: string, log?:
9898
resolve(res);
9999
} else {
100100
if (log) {
101-
LOGGER.error(`Command ${lsCommand} takes too long to start`);
101+
LOGGER.error(`Result not obtained while executing ${lsCommand}`);
102102
}
103103
reject(res);
104104
}
@@ -107,6 +107,7 @@ export const wrapCommandWithProgress = (lsCommand: string, title: string, log?:
107107
if (log) {
108108
LOGGER.error(`command ${lsCommand} executed with error: ${JSON.stringify(err)}`);
109109
}
110+
reject(err);
110111
}
111112
} else {
112113
reject(l10n.value("jdk.extension.progressBar.error_msg.cannotRun", { lsCommand: lsCommand, client: c }));

vscode/src/configurations/configuration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ export const configKeys = {
2424
formatPrefs: 'format',
2525
hintPrefs: 'hints',
2626
importPrefs: 'java.imports',
27-
runConfig: 'runCofig',
2827
runConfigVmOptions: 'runConfig.vmOptions',
28+
runConfigArguments: 'runConfig.arguments',
2929
runConfigCwd: 'runConfig.cwd',
30+
runConfigEnv: 'runConfig.env',
3031
verbose: 'verbose',
3132
userdir: 'userdir',
3233
revealInActivteProj: "revealActiveInProjects"

vscode/src/configurations/handlers.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
import { extensions, workspace, WorkspaceConfiguration } from "vscode";
17+
import { ConfigurationTarget, extensions, workspace, WorkspaceConfiguration } from "vscode";
1818
import { builtInConfigKeys, configKeys } from "./configuration";
1919
import { extConstants, NODE_WINDOWS_LABEL } from "../constants";
2020
import * as os from 'os';
@@ -28,12 +28,12 @@ export const getConfiguration = (key: string = extConstants.COMMAND_PREFIX): Wor
2828
}
2929

3030
export const getConfigurationValue = <T>(key: string, defaultValue: T | undefined = undefined): T => {
31-
const conf = workspace.getConfiguration(extConstants.COMMAND_PREFIX);
32-
return defaultValue != undefined ? conf.get(key, defaultValue) : conf.get(key) as T;
31+
const conf = getConfiguration();
32+
return defaultValue != undefined ? conf.get(key, defaultValue) : conf.get(key) as T;
3333
}
3434

35-
export const updateConfigurationValue = <T>(key: string, newValue: T): void => {
36-
workspace.getConfiguration(extConstants.COMMAND_PREFIX).update(key, newValue);
35+
export const updateConfigurationValue = <T>(key: string, newValue: T, configurationTarget: ConfigurationTarget | boolean | null = null): void => {
36+
getConfiguration().update(key, newValue, configurationTarget);
3737
}
3838

3939
export const getBuiltinConfigurationValue = <T>(key: string, defaultValue: T | undefined = undefined): T => {
@@ -115,8 +115,9 @@ export const isDarkColorThemeHandler = (): boolean => {
115115

116116
export const userdirHandler = (): string => {
117117
const userdirScope = process.env['nbcode_userdir'] || getConfigurationValue(configKeys.userdir, "local");
118-
const userdirParentDir = userdirScope === "local"
119-
? globalVars.extensionInfo.getWorkspaceStorage()?.fsPath
118+
const workspaceStoragePath = globalVars.extensionInfo.getWorkspaceStorage()?.fsPath;
119+
const userdirParentDir = userdirScope === "local" && workspaceStoragePath
120+
? workspaceStoragePath
120121
: globalVars.extensionInfo.getGlobalStorage().fsPath;
121122

122123
if (!userdirParentDir) {
@@ -142,4 +143,8 @@ export const userdirHandler = (): string => {
142143

143144
export const isNbJavacDisabledHandler = (): boolean => {
144145
return getConfigurationValue(configKeys.disableNbJavac, false);
146+
}
147+
148+
export const isNetbeansVerboseEnabled = (): boolean => {
149+
return getConfigurationValue(configKeys.verbose, false);
145150
}

vscode/src/extension.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323

2424
'use strict';
2525

26-
import { ExtensionContext, TextEditorDecorationType } from 'vscode';
27-
28-
29-
import * as vscode from 'vscode';
26+
import { ExtensionContext, TextEditorDecorationType, Uri } from 'vscode';
3027
import { NbTestAdapter } from './views/TestViewController';
3128
import { SetTextEditorDecorationParams } from './lsp/protocol';
3229
import * as launchConfigurations from './launchConfigurations';
@@ -40,7 +37,6 @@ import { VSNetBeansAPI } from './lsp/types';
4037
import { registerDebugger } from './debugger/debugger';
4138
import { registerConfigChangeListeners } from './configurations/listener';
4239
import { registerFileProviders } from './lsp/listeners/textDocumentContentProvider';
43-
import { createViews } from './views/initializer';
4440

4541
export namespace globalVars {
4642
export const listeners = new Map<string, string[]>();
@@ -52,7 +48,7 @@ export namespace globalVars {
5248
export let nbProcessManager: NbProcessManager | null;
5349
export let testAdapter: NbTestAdapter | undefined;
5450
export let decorations = new Map<string, TextEditorDecorationType>();
55-
export let decorationParamsByUri = new Map<vscode.Uri, SetTextEditorDecorationParams>();
51+
export let decorationParamsByUri = new Map<Uri, SetTextEditorDecorationParams>();
5652
}
5753

5854

@@ -66,7 +62,6 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
6662

6763
registerDebugger(context);
6864
subscribeCommands(context);
69-
createViews(context);
7065
registerFileProviders(context);
7166

7267
launchConfigurations.updateLaunchConfig();

vscode/src/lsp/initializer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { NbLanguageClient } from "./nbLanguageClient";
2727
import { registerListenersAfterClientInit } from "../views/listener";
2828
import { registerNotificationListeners } from "./listeners/notifications/register";
2929
import { registerRequestListeners } from "./listeners/requests/register";
30+
import { createViews } from "../views/initializer";
3031

3132
const establishConnection = () => new Promise<StreamInfo>((resolve, reject) => {
3233
const nbProcess = globalVars.nbProcessManager?.getProcess();
@@ -112,7 +113,7 @@ export const clientInit = () => {
112113
registerListenersAfterClientInit();
113114
registerNotificationListeners(client);
114115
registerRequestListeners(client);
115-
116+
createViews();
116117
LOGGER.log('Language Client: Ready');
117118
globalVars.clientPromise.initializedSuccessfully(client);
118119

vscode/src/lsp/launchOptions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616
import { builtInConfigKeys, configKeys } from "../configurations/configuration"
17-
import { isDarkColorThemeHandler, isNbJavacDisabledHandler, jdkHomeValueHandler, lspServerVmOptionsHandler, projectSearchRootsValueHandler, userdirHandler } from "../configurations/handlers";
17+
import { isDarkColorThemeHandler, isNetbeansVerboseEnabled, jdkHomeValueHandler, lspServerVmOptionsHandler, projectSearchRootsValueHandler, userdirHandler } from "../configurations/handlers";
1818
import { l10n } from "../localiser";
1919
import { isString } from "../utils";
2020
import { userDefinedLaunchOptionsType } from "./types"
@@ -31,9 +31,10 @@ export const getUserConfigLaunchOptionsDefaults = (): userDefinedLaunchOptionsTy
3131
},
3232
[configKeys.disableProjSearchLimit]: {
3333
value: projectSearchRootsValueHandler(),
34-
optionToPass: '-J-Dproject.limitScanRoot=',
35-
},[configKeys.verbose]: {
36-
value: isNbJavacDisabledHandler(),
34+
optionToPass: '-J-Dproject.limitScanRoot='
35+
},
36+
[configKeys.verbose]: {
37+
value: isNetbeansVerboseEnabled(),
3738
optionToPass: '-J-Dnetbeans.logger.console='
3839
},
3940
[builtInConfigKeys.vscodeTheme]: {

vscode/src/lsp/nbcode.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ const processOnDataHandler = (nbProcessManager: NbProcessManager, text: string,
6767
if (nbProcessManager) {
6868
globalVars.clientPromise.activationPending = false;
6969
}
70+
if(!text.match(/with hash/)){
71+
LOGGER.logNoNL(text);
72+
}
7073
if (nbProcessManager.getStdOut() == null) {
7174
return;
7275
}
73-
LOGGER.logNoNL(text);
7476
isOut ? nbProcessManager.appendStdOut(text) : nbProcessManager.appendStdErr(text);
7577

7678
if (nbProcessManager.getStdOut()?.match(/org.netbeans.modules.java.lsp.server/)) {
@@ -87,7 +89,7 @@ const processOnCloseHandler = (nbProcessManager: NbProcessManager, code: number)
8789
window.showWarningMessage(l10n.value("jdk.extension.lspServer.warning_message.serverExited", { SERVER_NAME: extConstants.SERVER_NAME, code }));
8890
}
8991
}
90-
if (nbProcessManager.getStdOut()?.match(/Cannot find java/) || (os.type() === NODE_WINDOWS_LABEL && !globalVars.deactivated)) {
92+
if (nbProcessManager.getStdErr()?.match(/Cannot find java/) || (os.type() === NODE_WINDOWS_LABEL && !globalVars.deactivated)) {
9193
jdkDownloaderPrompt();
9294
}
9395
if (nbProcessManager.getStdOut() != null) {

vscode/src/views/initializer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ import { configKeys } from "../configurations/configuration";
2525
import { initializeRunConfiguration } from "../utils";
2626
import { NbTestAdapter } from "./TestViewController";
2727

28-
export async function createViews(context: ExtensionContext) {
28+
export async function createViews() {
29+
const context = globalVars.extensionInfo.getExtensionContext();
2930
createRunConfigurationView(context);
3031
const client = await globalVars.clientPromise.client;
3132
createProjectView(client);
3233
globalVars.testAdapter = new NbTestAdapter();
3334
}
35+
3436
function createRunConfigurationView(context: ExtensionContext) {
3537
initializeRunConfiguration().then(initialized => {
3638
if (initialized) {
@@ -59,9 +61,8 @@ async function createProjectView(client: NbLanguageClient) {
5961
}
6062
tv.reveal(vis, { select: true, focus: false, expand: false });
6163
}
62-
const netbeansConfig = workspace.getConfiguration(extConstants.COMMAND_PREFIX);
6364
globalVars.extensionInfo.pushSubscription(window.onDidChangeActiveTextEditor(ed => {
64-
if (netbeansConfig.get("revealActiveInProjects")) {
65+
if (getConfigurationValue(configKeys.revealInActivteProj)) {
6566
revealActiveEditor(ed);
6667
}
6768
}));

vscode/src/views/runConfiguration.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@
2222
import * as vscode from 'vscode';
2323
import { homedir } from 'os';
2424
import { l10n } from '../localiser';
25-
import { getConfiguration } from '../configurations/handlers';
25+
import { getConfigurationValue, updateConfigurationValue } from '../configurations/handlers';
2626
import { configKeys } from '../configurations/configuration';
2727

28-
29-
30-
31-
3228
class RunConfigurationNodeProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
3329

3430
private _onDidChangeTreeData: vscode.EventEmitter<vscode.TreeItem | undefined | null> = new vscode.EventEmitter<vscode.TreeItem | undefined | null>();
@@ -70,7 +66,7 @@ class RunConfigurationNode extends vscode.TreeItem {
7066

7167
this.settingsKey = settingsKey;
7268

73-
this.value = this.getConfig().get(this.settingsKey);
69+
this.value = getConfigurationValue(this.settingsKey);
7470
this.updateNode();
7571
}
7672

@@ -96,29 +92,24 @@ class RunConfigurationNode extends vscode.TreeItem {
9692

9793
setValue(value: string | undefined) {
9894
this.value = value;
99-
this.getConfig().update(this.settingsKey, this.value, vscode.workspace.name || vscode.workspace.workspaceFile ? null : true);
95+
updateConfigurationValue(this.settingsKey, this.value, vscode.workspace.name || vscode.workspace.workspaceFile ? null : true);
10096
this.updateNode();
10197
}
10298

10399
updateNode(reload?: boolean) {
104100
if (reload) {
105-
this.value = this.getConfig().get(this.settingsKey) as string;
101+
this.value = getConfigurationValue(this.settingsKey) as string;
106102
}
107103
this.description = this.value ? this.value : l10n.value("jdk.extension.runConfig.default.label");
108104
this.tooltip = `${this.label} ${this.description}`;
109105
runConfigurationNodeProvider.refresh();
110106
}
111-
112-
getConfig(): vscode.WorkspaceConfiguration {
113-
return getConfiguration(configKeys.runConfig);
114-
}
115-
116107
}
117108

118109
class ArgumentsNode extends RunConfigurationNode {
119110

120111
constructor() {
121-
super(l10n.value("jdk.extension.runConfig.arguments.label"), l10n.value("jdk.extension.runConfig.arguments.prompt"), l10n.value("jdk.extension.runConfig.example.label", { data: "foo bar" }), 'arguments');
112+
super(l10n.value("jdk.extension.runConfig.arguments.label"), l10n.value("jdk.extension.runConfig.arguments.prompt"), l10n.value("jdk.extension.runConfig.example.label", { data: "foo bar" }), configKeys.runConfigArguments);
122113
}
123114

124115
}
@@ -127,7 +118,7 @@ export const argumentsNode = new ArgumentsNode();
127118
class VMOptionsNode extends RunConfigurationNode {
128119

129120
constructor() {
130-
super(l10n.value("jdk.extension.runConfig.vmoptions.label"), l10n.value("jdk.extension.runConfig.vmoptions.prompt"), l10n.value("jdk.extension.runConfig.example.label", { data: "-Xmx512m -Xms256m" }), 'vmOptions');
121+
super(l10n.value("jdk.extension.runConfig.vmoptions.label"), l10n.value("jdk.extension.runConfig.vmoptions.prompt"), l10n.value("jdk.extension.runConfig.example.label", { data: "-Xmx512m -Xms256m" }), configKeys.runConfigVmOptions);
131122
}
132123

133124
}
@@ -136,7 +127,7 @@ export const vmOptionsNode = new VMOptionsNode();
136127
class EnvironmentVariablesNode extends RunConfigurationNode {
137128

138129
constructor() {
139-
super(l10n.value("jdk.extension.runConfig.env.label"), l10n.value("jdk.extension.runConfig.env.prompt"), l10n.value("jdk.extension.runConfig.example.label", { data: "var1=one, varTwo=2" }), 'env');
130+
super(l10n.value("jdk.extension.runConfig.env.label"), l10n.value("jdk.extension.runConfig.env.prompt"), l10n.value("jdk.extension.runConfig.example.label", { data: "var1=one, varTwo=2" }), configKeys.runConfigEnv);
140131
}
141132

142133
}
@@ -145,7 +136,7 @@ export const environmentVariablesNode = new EnvironmentVariablesNode();
145136
class WorkingDirectoryNode extends RunConfigurationNode {
146137

147138
constructor() {
148-
super(l10n.value("jdk.extension.runConfig.wrkdir.label"), l10n.value("jdk.extension.runConfig.wrkdir.prompt"), WorkingDirectoryNode.getExample(), 'cwd');
139+
super(l10n.value("jdk.extension.runConfig.wrkdir.label"), l10n.value("jdk.extension.runConfig.wrkdir.prompt"), WorkingDirectoryNode.getExample(), configKeys.runConfigCwd);
149140
}
150141

151142
static getExample(): string {

0 commit comments

Comments
 (0)