You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/10/23 14:29:49 UTC

[GitHub] [netbeans] Ondrej-Douda commented on a change in pull request #2480: Search for JDK in typical location

Ondrej-Douda commented on a change in pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480#discussion_r510924266



##########
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')) {

Review comment:
       I would rather check on full property name: `java.home` and `netbeans.jdkhome`...




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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