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



##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -156,6 +157,13 @@ export function activate(context: ExtensionContext): 
VSNetBeansAPI {
 
     // find acceptable JDK and launch the Java part
     findJDK((specifiedJDK) => {
+        context.subscriptions.push(vscode.extensions.onDidChange(() => {
+            const currentClustersSorted = currentClusters.slice().sort();

Review comment:
       keep the global state somewhere here, if possible.

##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -66,7 +67,7 @@ export function enableConsoleLog() {
 }
 
 export function findClusters(myPath : string): string[] {

Review comment:
       This is an exported function, I'd prefer to keep it pure (e.g. without 
side effects).

##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -156,6 +157,13 @@ export function activate(context: ExtensionContext): 
VSNetBeansAPI {
 
     // find acceptable JDK and launch the Java part
     findJDK((specifiedJDK) => {
+        context.subscriptions.push(vscode.extensions.onDidChange(() => {
+            const currentClustersSorted = currentClusters.slice().sort();
+            const newClusters = findClusters(context.extensionPath);
+            if (newClusters.length !== currentClustersSorted.length || 
newClusters.sort().find((value, index) => value !== 
currentClustersSorted[index])) {

Review comment:
       Wow. That's a functional programming!




----------------------------------------------------------------
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