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

Fix dynamic registration and diagnostic streams #2564

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jwortmann
Copy link
Member

Fix #2561

@captain0xff
Copy link

There are no diagnostics and the console is logging these errors.

Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 546, in _apply_document_diagnostic_async
    self.session.diagnostics_result_ids[self._last_known_uri] = response.get('resultId')
AttributeError: 'NoneType' object has no attribute 'get'

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 546, in _apply_document_diagnostic_async
    self.session.diagnostics_result_ids[self._last_known_uri] = response.get('resultId')
AttributeError: 'NoneType' object has no attribute 'get'

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 546, in _apply_document_diagnostic_async
    self.session.diagnostics_result_ids[self._last_known_uri] = response.get('resultId')
AttributeError: 'NoneType' object has no attribute 'get'

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier enc must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier XamlDiagnostics must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier HotReloadDiagnostics must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier WorkspaceDocumentsAndProject must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier syntax must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier DocumentCompilerSemantic must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier DocumentAnalyzerSyntax must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier DocumentAnalyzerSemantic must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier NonLocal must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier WorkspaceDocumentsAndProject must be registered first

Error handling None
Traceback (most recent call last):
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/sessions.py", line 2430, in on_payload
    handler(result)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 538, in _on_document_diagnostic_async
    self._apply_document_diagnostic_async(identifier, version, response)
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/session_buffer.py", line 548, in _apply_document_diagnostic_async
    self.session.diagnostics[(self._last_known_uri, identifier)] = response['items']
  File "/home/captain/.config/sublime-text/Packages/LSP/plugin/core/diagnostics_storage.py", line 35, in __setitem__
    raise ValueError(f'identifier {identifier} must be registered first')
ValueError: identifier XamlDiagnostics must be registered first```

@captain0xff
Copy link

I was also able to add support for Samsung's netcoredbg in the debugger package. So, I will keep using C# from sublime with this branch and would try to fix/report any issues I can find.
I can create a lsp plugin with my custom wrapper once this or a better implementation gets merged. If someday this client supports named pipes then the wrapper part can also be omitted.
Finally, thanks a lot for diagnosing and fixing this issue.

@jwortmann
Copy link
Member Author

The latest commit may fix the errors from the console. I noticed that I forgot some parts in the implementation earlier. Note that workspace diagnostics (usually used for diagnostics that result in different files from the one currently edited) will still not work correctly with this. And there are a few other TODOs left in the code. As mentioned before, the implementation in this PR is more of a workaround and ideally things like get_capability_2 should not be introduced. But to do it in a proper way, we first need to figure out a proper design how to store server capability options from static and dynamic registration.

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.

LSP doesn't handle diagnostic dynamic registration correctly
2 participants