-
Notifications
You must be signed in to change notification settings - Fork 184
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
Generalize implementation of the transport #1847
Conversation
Extracted the JSON RPC-specific handling into a separate processor and used composition concept to pass and use it within the transport. That should allow re-using the transport implementation in the file watcher to implement a transport that uses plain lines of text rather than JSON RPC. Not using abstract classes anymore as that is not compatible with generic types.
I probably want to rewrite this part of the code once we can use py38. How would that work when other packages use this code? |
The LSP-file-watcher-chokidar is tightly tied to LSP so I imagine those would have to be updated at the same time. |
headers = http.client.parse_headers(reader) # type: ignore | ||
try: | ||
body = reader.read(int(headers.get("Content-Length"))) | ||
except TypeError: | ||
# Expected error on process stopping. Stop the read loop. | ||
raise StopLoopError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed so that explicit action is used to stop the read loop instead of relying on TypeError
doing it.
We could maybe just raise StopLoopError()
earlier by checking if headers.get("Content-Length")
is None
.
Extracted the JSON RPC-specific handling into a separate processor
and used composition concept to pass and use it within the transport.
That should allow re-using the transport implementation in the file
watcher to implement a transport that uses plain lines of text rather
than JSON RPC.
Not using abstract classes anymore as that is not compatible with
generic types.