Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a protected method for easy configuration of retrieval of ConfigurationItem #1054

Closed
wants to merge 1 commit into from

Conversation

rubenporras
Copy link
Contributor

Configuration Items

@rubenporras rubenporras changed the title Add a protected method for easy configuration of retrieval of Add a protected method for easy configuration of retrieval of ConfigurationItem Aug 14, 2024
@rubenporras rubenporras requested a review from sebthom August 14, 2024 15:14
@rubenporras
Copy link
Contributor Author

Hi @sebthom ,

I could not find a way to override the method CompletableFuture<List<@Nullable Object>> configuration(ConfigurationParams configurationParams) after the new annotations, as the definition in LanguageClientImpl and LanguageClient do not have the same annotations.

To me this is a bug in the JDT, but the new protected method is in any case a better API for subclasses than the previous one.

What do you think of this PR?

@sebthom
Copy link
Contributor

sebthom commented Aug 14, 2024

Hi @rubenporras I don't understand why you can't find a way to override it. It seems to work fine for me:

package org.haxe4e.langserver;

import java.util.List;
import java.util.concurrent.CompletableFuture;

import org.eclipse.jdt.annotation.*;
import org.eclipse.lsp4e.LanguageClientImpl;
import org.eclipse.lsp4j.*;
import org.haxe4e.util.TreeBuilder;

@SuppressWarnings("restriction") // https://bugs.eclipse.org/bugs/show_bug.cgi?id=536215
public final class HaxeLangServerClientImpl extends LanguageClientImpl implements HaxeLangServerClient {

   private volatile boolean isInitTriggered = false;

   @Override
   public CompletableFuture<List<@Nullable Object>> configuration(final ConfigurationParams configurationParams) {
      return super.configuration(configurationParams);
   }

   @Override
   public @NonNullByDefault({}) CompletableFuture<Void> registerCapability(final RegistrationParams params) {
      if (!isInitTriggered) {
         // workaround for https://github.com/vshaxe/vshaxe/issues/501
         final var event = new DidChangeConfigurationParams(new TreeBuilder<String>() //
            .put("haxe", new TreeBuilder<String>() //
               .getMap() //
            ).getMap());

         getLanguageServer().getWorkspaceService().didChangeConfiguration(event);
         isInitTriggered = true;
      }

      return super.registerCapability(params);
   }
}

What is the error or warning you are seeing?

@rubenporras
Copy link
Contributor Author

Hi @sebthom,

I do not know why, but changing the configuration item org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations from disabled to enabled and restarting eclipse seems to solve the problem. I have tried changing the configuration yesterday already but it looks like the build that is triggered afterwards is not enough, and a restart is needed.

Does it makes sense to you?

@sebthom
Copy link
Contributor

sebthom commented Aug 15, 2024

do you still have the issue now that you merged the no-npe 1.0.4 version?
I made a change to the EEA of LanguageClientImpl at vegardit/no-npe@ec54909 which might solve the issue.

@rubenporras
Copy link
Contributor Author

The problem is solved for me now. Thanks.

@rubenporras rubenporras deleted the configItems branch August 15, 2024 12:43
@sebthom
Copy link
Contributor

sebthom commented Aug 15, 2024

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants