JaroslavTulach commented on a change in pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480#discussion_r511015000



##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -65,33 +65,112 @@ function findClusters(myPath : string): string[] {
     return clusters;
 }
 
-export function activate(context: ExtensionContext) {
-    //verify acceptable JDK is available/set:
-    let specifiedJDK = workspace.getConfiguration('netbeans').get('jdkhome');
-    const beVerbose : boolean = 
workspace.getConfiguration('netbeans').get('verbose', false);
-    let info = {
-        clusters : findClusters(context.extensionPath),
-        extensionPath: context.extensionPath,
-        storagePath : context.globalStoragePath,
-        jdkHome : specifiedJDK,
-        verbose: beVerbose
-    };
-    
-    let log = vscode.window.createOutputChannel("Java Language Server");
+function findJDK(onChange: (path : string | null) => void): void {
+    function find(): string | null {
+        let nbJdk = workspace.getConfiguration('netbeans').get('jdkhome');
+        if (nbJdk) {
+            return nbJdk as string;
+        }
+        let javahome = workspace.getConfiguration('java').get('home');
+        if (javahome) {
+            return javahome as string;
+        }
 
-    vscode.extensions.all.forEach((e, index) => {
+        let jdkHome: any = process.env.JDK_HOME;
+        if (jdkHome) {
+            return jdkHome as string;
+        }
+        let jHome: any = process.env.JAVA_HOME;
+        if (jHome) {
+            return jHome as string;
+        }
+        return null;
+    }
+
+    let currentJdk = find();
+    workspace.onDidChangeConfiguration(params => {
+        if (!params.affectsConfiguration('java') && 
!params.affectsConfiguration('netbeans')) {
+            return;
+        }
+        let newJdk = find();
+        if (newJdk !== currentJdk) {
+            onChange(newJdk);
+        }
+    });
+    onChange(currentJdk);
+}
+
+export function activate(context: ExtensionContext) {
+    vscode.extensions.all.forEach((e) => {

Review comment:
       OK, thanks: Done in e38771f 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to