lahodaj commented on code in PR #8514: URL: https://github.com/apache/netbeans/pull/8514#discussion_r2149121008
########## java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java: ########## @@ -346,7 +346,7 @@ void cancelDiagnostics(AtomicBoolean cancel) { } } - class LspClient implements LanguageClient { +class LspClient implements LanguageClient { Review Comment: Nit: this change seems unnecessary? ########## java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/ClientConfigurationManager.java: ########## @@ -0,0 +1,204 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.java.lsp.server.protocol; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.List; +import java.util.WeakHashMap; +import java.util.concurrent.CompletableFuture; +import java.util.function.BiConsumer; +import org.eclipse.lsp4j.ConfigurationItem; +import org.eclipse.lsp4j.ConfigurationParams; +import org.eclipse.lsp4j.services.LanguageClient; +import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; +import org.netbeans.modules.java.lsp.server.Utils; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Lookup; + +/** + * Manages configuration settings for LSP clients + * + * @author atalati + */ +public class ClientConfigurationManager { + + final WeakHashMap<LanguageClient, ConfigValueCache> clientCaches = new WeakHashMap<>(); + + private ClientConfigurationManager() { + } + + public static ClientConfigurationManager getInstance() { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder { + + private static final ClientConfigurationManager INSTANCE = new ClientConfigurationManager(); + } + + public void registerClient(LanguageClient client) { + clientCaches.put(client, new ConfigValueCache()); + } + + public void registerConfigChangeListener(NbCodeLanguageClient client, String section, BiConsumer<String, JsonElement> consumer) { + ConfigValueCache cache = clientCaches.get(client); + if (cache != null) { + cache.registerListener(section, consumer); + } + } + + public void registerConfigCache(NbCodeLanguageClient client, String section) { Review Comment: I guess my concern is this: given the registration and the actual config read are on completely different places, it is very easy to imagine that when adding a configuration, only the config read will be added, and not the registration. And given it will all work(?), no one will notice, except it will be slower. And after a little while, no one will be sure anymore if the non-caching was intentional or an oversight. I wonder if we have a particular setting now or in a foreseeable future that we don't want to cache. And if yes, is there a reason why the read cannot go directly through the API without the cache? (With a clear comment saying something along the lines of "not using the cache, as this setting is too big, and should be fetched anew every time, instead of being cache".) -- 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. To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists