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

NPE in TextDocumentHandler #240

Closed
aBothe opened this issue May 16, 2020 · 3 comments
Closed

NPE in TextDocumentHandler #240

aBothe opened this issue May 16, 2020 · 3 comments

Comments

@aBothe
Copy link

aBothe commented May 16, 2020

Hey there,

I'm trying to set up a LanguageServer having a custom DefinitionHandler.
This handler currently features a DefinitionRegistrationOptions config object with a DocumentSelector set to null (it's just still the default - I'll define it soon).

When trying to start the LanguageServer in one of my tests, it just didn't want to fully initialize.
I manually stepped through LanguageServer code to find out what's throwing an exception there.

Turns out, it's an NullPointerException in TextDocumentHandler.GetHandler:

if (registrationOptions?.DocumentSelector == null || registrationOptions.DocumentSelector.IsMatch(attributes))

There might be a ? missing in the second clause, as it's evaluating said second expression as soon as registrationOptions is not null - but DocumentSelector might be.

My code was:

public DDefinitionHandler(ProgressManager progressManager)
            : base(new DefinitionRegistrationOptions(), progressManager)
        {
        }

Thanks for your project!

@david-driscoll
Copy link
Member

Thanks @aBothe

I think you might be right, it's very possible the registrations options is null in that scenario. After this next big change I'll look at adding that in.

@david-driscoll
Copy link
Member

I will get a fix in for this, I think it is still there looking at the code I just need to create a test case.

@david-driscoll
Copy link
Member

I have added a test to my latest commit, to confirm this appears to be working as expected. Let me know if you have any more problems!

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

No branches or pull requests

2 participants