-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
Thanks for your contribution! Could you please fix the test failures? |
I am already working on it. |
Please follow the contribution guide here #31 (comment) |
I have only updated the tests as of now, I am working on improving the coverage and fix a minor logging issue during running testing. |
README.md
Outdated
@@ -13,7 +13,7 @@ A visual studio code plugin working via [Language Server Protocol (LSP)](https:/ | |||
|
|||
You'll need python version 3.5 or greater, run `pip3 install -r requirements.txt` to install the requirements, and run `python3 langserver-python.py --mode=tcp --addr=2087` to start a local languager server listening at port 2087. | |||
|
|||
Then you should update the `./vscode-client/src/extension.ts` to make client in TCP mode. | |||
Then you should update the `./vscode-client/src/extension.ts` to make client in TCP mode. |
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.
discard this change. create a newcomer bug about adding style linting rules for this file.
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.
Noted.
README.md
Outdated
@@ -24,7 +24,7 @@ export function activate(context: ExtensionContext) { | |||
} | |||
``` | |||
|
|||
To try it in [Visual Studio Code](https://code.visualstudio.com), open ./vscode-client in VS Code and turn to debug view, launch the extension. | |||
To try it in [Visual Studio Code](https://code.visualstudio.com), open ./vscode-client in VS Code and turn to debug view, launch the extension. If the langserver fails try disabling the GitCommitBear. |
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.
Create a newcomer issue about this, and remove it from your PR. it has nothing to do with jsonrpc.
Also a change like this should be done by adding a new line, so the origin of existing line doesnt change unnecessarily.
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.
Noted.
coala_langserver/diagnostic.py
Outdated
|
||
log = logging.getLogger(__name__) |
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.
call this logger
coala_langserver/langserver.py
Outdated
def start(self): | ||
self._jsonrpc_stream_reader.listen(self._endpoint.consume) | ||
|
||
# def handle(self, _id, request): |
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.
we dont want commented out code.
If there is extra stuff to be done, create an issue after this is merged
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.
A clean up issue, I just wanted to have a reference to the previous code to cross verify.
coala_langserver/langserver.py
Outdated
params = { | ||
'uri': 'file://{0}'.format(path), | ||
'diagnostics': _diagnostics, | ||
'diagnostics': [] if diagnostics is None else diagnostics, |
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.
this seems to be a pointless change
@@ -0,0 +1,35 @@ | |||
# Copyright 2018 Palantir Technologies, Inc. |
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.
I would prefer that we did not copy other code into the repository. For example, I can not easily check to see if you modified a line from the origin.
While there are some additional dependencies at https://github.com/palantir/python-language-server/blob/develop/setup.py#L34 , could we not require that it is installed, and then use the jsonrpc they provide? If that is not possible, maybe we can coordinate with @palantir to split that out into a sharable library.
This tool is still a prototype, so it can have additional install steps , and keeping the origin of source code clear.
It also means that additional tests for the jsonrpc would be contributed to https://github.com/palantir/python-language-server , so everyone benefits.
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.
I will follow your recommendations, python-lang-server will be added as a dependency.
|
||
@given('the LangServer instance') | ||
def step_impl(context): | ||
context.f = tempfile.TemporaryFile() | ||
context.langServer = LangServer(conn=TCPReadWriter(context.f, context.f)) | ||
context.file = tempfile.TemporaryFile() |
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.
why does it need renaming from f
to file
? It causes all sorts of other unnecessary changes to appear in this PR, slowing down the review.
is that related to the issue that this PR is intending to solve.
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.
'f' didn't seem to be a semantic name. My intention was to improve readability, retaining such occurrences could indicate tolerance for those practices and could even mean encouragement.
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.
I think the re-naming is justified, do you still recommend this particular change?
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.
Of course I do. it is not related to using jsonrpc. Create a new PR for other changes you wish to make.
coala_langserver/langserver.py
Outdated
""" | ||
PY3K = sys.version_info >= (3, 0) | ||
|
||
if PY3K: |
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.
See #35
coala_langserver/langserver.py
Outdated
server = socketserver.TCPServer((bind_addr, port), wrapper_class) | ||
except Exception as e: | ||
log.fatal("Exception: %s", str(e)) | ||
exit(1) |
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.
sys.exit
?
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.
Noted.
coala_langserver/langserver.py
Outdated
|
||
from .jsonrpc import JSONRPC2Connection, ReadWriter, TCPReadWriter | ||
from .log import log |
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.
removing this (and other logging enhancements) should be done as a separate PR. I've assigned #36 to you, as you've already done a lot of this.
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.
Noted.
coala_langserver/langserver.py
Outdated
@@ -108,7 +108,11 @@ def start_tcp_lang_server(bind_addr, port, handler_class): | |||
{'DELEGATE_CLASS': handler_class} | |||
) | |||
|
|||
server = socketserver.TCPServer((bind_addr, port), wrapper_class) | |||
try: |
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.
This change should be a new PR.
Ideally create a new issue showing why this change is needed.
coala_langserver/langserver.py
Outdated
# s = LangServer(conn=ReadWriter(sys.stdin, sys.stdout)) | ||
# s.listen() | ||
pass | ||
stdin, stdout = _binary_stdio() |
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.
move this code out to a PR for #48
As far as I can see, after removing all the unrelated features, there should only be one commit in this PR. fwiw, updating tests should be part of the atomic change of modifying the code. |
@ksdme Thanks for your contribution! I think we could try to add some tests. |
coala_langserver/langserver.py
Outdated
class ThreadingTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): | ||
pass | ||
class _StreamHandlerWrapper(socketserver.StreamRequestHandler, object): | ||
"""A wrapper class that is used to construct a custom handler class.""" |
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.
You do not use the preferred quotation marks.
Origin: QuotesBear, Section: python
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmp_evza00r/coala_langserver/langserver.py
+++ b/tmp/tmp_evza00r/coala_langserver/langserver.py
@@ -14,7 +14,7 @@
class _StreamHandlerWrapper(socketserver.StreamRequestHandler, object):
- """A wrapper class that is used to construct a custom handler class."""
+ '""A wrapper class that is used to construct a custom handler class.""'
delegate = None
coala_langserver/langserver.py
Outdated
self.write_response(request['id'], resp) | ||
|
||
def serve_initialize(self, request): | ||
#TODO: didChange |
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.
E265 block comment should start with '# '
Origin: PycodestyleBear (E265), Section: autopep8
.
from pyls.jsonrpc.endpoint import Endpoint | ||
from pyls.jsonrpc.dispatchers import MethodDispatcher | ||
from pyls.jsonrpc.streams import JsonRpcStreamReader | ||
from pyls.jsonrpc.streams import JsonRpcStreamWriter |
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.
You do not use the preferred quotation marks.
Origin: QuotesBear, Section: python
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmp7wx9j6yx/coala_langserver/langserver.py
+++ b/tmp/tmp7wx9j6yx/coala_langserver/langserver.py
@@ -111,7 +111,7 @@
try:
server = socketserver.TCPServer((bind_addr, port), wrapper_class)
except Exception as e:
- log("Fatal Exception: {}".format(e))
+ log('Fatal Exception: {}'.format(e))
sys.exit(1)
try:
log('Serving %s on (%s, %s)', handler_class.__name__, bind_addr, port)
Comment on f253090. Shortlog of the HEAD commit contains 60 character(s). This is 10 character(s) longer than the limit (60 > 50). Origin: GitCommitBear, Section: |
Comment on 45df0f8, file coala_langserver/langserver.py, line 126. Line is longer than allowed. (85 > 79) Origin: LineLengthBear, Section: |
Comment on de0098b, file tests/server.features/steps/jsonrpc_steps.py, line 63. Line is longer than allowed. (83 > 79) Origin: LineLengthBear, Section: |
'capabilities': {}, | ||
}, | ||
'id': 1, | ||
'jsonrpc': '2.0' |
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.
trailing comma
'capabilities': {}, | ||
}, | ||
'id': 1, | ||
'jsonrpc': '2.0' |
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.
trailing comma
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.
still not done?
coala_langserver/langserver.py
Outdated
wrapper_class = type( | ||
handler_class.__name__ + 'Handler', | ||
(_StreamHandlerWrapper,), | ||
{'DELEGATE_CLASS': handler_class} |
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.
trailing comma ; not likely to be needed any time soon, but likely doesnt hurt
coala_langserver/langserver.py
Outdated
log('Fatal Exception: {}'.format(e)) | ||
sys.exit(1) | ||
try: | ||
log('Serving {} on ({}, {})'.format( |
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.
log
isnt useful inside the try.
but, it is a new log
call, and redundant due to existing Accepting TCP connections ..
log
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.
I have to retain this log compared to the other one because the tests watch this log call to trigger sending requests.
|
||
@enforce_signature | ||
def start_io_lang_server(handler_class: LangServer, rstream, wstream): | ||
log('Starting {} IO language server'.format(handler_class.__name__)) |
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.
new log
call, also redundant.
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.
For the reasons mentioned in the previous change request and maintaining uniformity I think I'll have to retain this log and remove the other redundant log call.
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.
ok.
Comment on de0098b, file tests/server.features/steps/jsonrpc_steps.py, line 63. The code does not comply to PEP8. Origin: PEP8Bear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpc942a8vq/tests/server.features/steps/jsonrpc_steps.py
+++ b/tmp/tmpc942a8vq/tests/server.features/steps/jsonrpc_steps.py
@@ -60,7 +60,8 @@
@given('the JSONRPC2Connection instance')
def step_impl(context):
context.f = tempfile.TemporaryFile()
- context.jsonConn = JSONRPC2Connection(conn=TCPReadWriter(context.f, context.f))
+ context.jsonConn = JSONRPC2Connection(
+ conn=TCPReadWriter(context.f, context.f))
@when('I write a request to the JSONRPC2Connection with id') |
Comment on de0098b, file tests/server.features/steps/jsonrpc_steps.py, line 10. E501 line too long (82 > 79 characters) Origin: PycodestyleBear (E501), Section: |
Comment on de0098b, file tests/server.features/steps/jsonrpc_steps.py, line 63. E501 line too long (83 > 79 characters) Origin: PycodestyleBear (E501), Section: |
Comment on de0098b, file tests/server.features/steps/jsonrpc_steps.py, line 10. Line is longer than allowed. (82 > 79) Origin: LineLengthBear, Section: |
Comment on de0098b, file tests/server.features/steps/jsonrpc_steps.py, line 63. Line is longer than allowed. (83 > 79) Origin: LineLengthBear, Section: |
coala_langserver/langserver.py
Outdated
wrapper_class = type( | ||
handler_class.__name__ + 'Handler', | ||
(_StreamHandlerWrapper,), | ||
{'DELEGATE_CLASS': handler_class, } |
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.
no, a trailing comma is for allowing new additions without modifications to exiting lines. hence this ,
is not a trailing comma.
{'DELEGATE_CLASS': handler_class},
|
||
@enforce_signature | ||
def start_io_lang_server(handler_class: LangServer, rstream, wstream): | ||
log('Starting {} IO language server'.format(handler_class.__name__)) |
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.
ok.
'capabilities': {}, | ||
}, | ||
'id': 1, | ||
'jsonrpc': '2.0' |
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.
still not done?
coala_langserver/langserver.py
Outdated
def start(self): | ||
self._jsonrpc_stream_reader.listen(self._endpoint.consume) | ||
|
||
def m_initialize(self, rootUri=None, rootPath=None, **kargs): |
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.
def m_initialize(self, **params)
then nothing below needs to be modified, except removal of params = request['params']
sorry I didnt notice this earlier.
this helps show the similarities of the two jsonrpc's , making differences more clear
coala_langserver/langserver.py
Outdated
return { | ||
'capabilities': { | ||
'textDocumentSync': 1 | ||
} | ||
} | ||
|
||
def serve_did_save(self, request): | ||
def m_text_document__did_save(self, textDocument=None, **kargs): |
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.
likewise use **params
to avoid changes below
This updates the project to use jsonrpc module from python-language-server. Closes coala#27
ack bd12657 |
ack de0098b |
@gitmate-bot ff |
Hey! I'm GitMate.io! This pull request is being fastforwarded automatically. Please DO NOT push while fastforward is in progress or your changes would be lost permanently |
Automated fastforward with GitMate.io was successful! 🎉 |
🎉 |
Updates coala-vs-code to use jsonrpc module from python-language-server (palantir/python-language-server#32).
Closes #27