GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add basic Goto Implementation Request support by smheidrich · Pull Request #644 · python-lsp/python-lsp-server Conversation
|
| rope_project = workspace._rope_project_builder(rope_config) | ||
| rope_resource = document._rope_resource(rope_config) | ||
|
|
||
| impls = find_implementations(rope_project, rope_resource, offset) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should it be wrapped in try-except to handle exceptions, as in:
python-lsp-server/pylsp/plugins/rope_completion.py
Lines 59 to 65 in 04fa3e5
| try: | |
| definitions = code_assist( | |
| rope_project, document.source, offset, document_rope, maxfixes=3 | |
| ) | |
| except Exception as e: | |
| log.debug("Failed to run Rope code assist: %s", e) | |
| return [] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| from rope.base.project import Project | ||
| from rope.base.resources import Resource | ||
| from rope.contrib.findit import Location, find_implementations |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I guess it would also make sense to add find_definition?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If you mean using rope.contrib.findit.find_definition to implement the LSP textDocument/definition request, that one is already implemented in python-lsp-server using Jedi, so I don't think adding an additional Rope-powered implementation makes sense. But maybe I misunderstand it?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I meant. My reasoning is twofold:
Of note, rope is disabled by default in general because it is hard to guarantee it works well and does not conflict with jedi (e.g. by de-duplciating responses).
For the best UX for an average user I think it would be best to add textDocument/implementation using jedi, but I would not object to adding one with rope as in this PR.
I was just curious as to your reasoning for adding only textDocument/implementation and not also textDocument/definition which would be my choice if I was adding a rope version for it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
(Comment deleted because it doesn't make sense, give me a minute while I write a new one)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I originally wrote a response disagreeing but there was a glaring mistake in it because I overlooked that the current Rope find_implementations implementation is much buggier than I thought: E.g. for a file like
class A: def f(self): ... class B(A): def f(self): ... a: A = A() a.f()
using Rope's find_implementations on the a.f() call will go to B.f for some reason 😕
It works well for moving between overridden methods within a class hierarchy, where it nicely complements the Jedi textDocument/definition, which always moves "up", by moving "down" instead.
But my guess is that it would take quite a lot of effort to fix Rope's find_implementations so it works correctly when used on method calls as well 😔
I'll open an issue but this PR should be on hold until it's fixed, no point merging something that's fundamentally buggy from day 1.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It looks like a few of the tests are failing: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| { | ||
| "uri": uris.uri_with( | ||
| document.uri, | ||
| path=os.path.join(workspace.root_path, impl.resource.path), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Under certain circumstances I seem to get URIs like ///example.py here for a file that is actually in another directory - will have to investigate & fix.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Custom pylsp is based on [python-lsp-server](https://github.com/python-lsp/python-lsp-server), and plus the following pull requests: 1. semanticTokens/full: python-lsp/python-lsp-server#645 2. typeDefinition: python-lsp/python-lsp-server#533 Maybe also 3. implementation: python-lsp/python-lsp-server#644
…n-lsp/python-lsp-server), and plus the following pull requests: 1. semanticTokens/full: python-lsp/python-lsp-server#645 2. typeDefinition: python-lsp/python-lsp-server#533 Maybe also 3. implementation: python-lsp/python-lsp-server#644
…n-lsp/python-lsp-server), and plus the following pull requests: 1. semanticTokens/full: python-lsp/python-lsp-server#645 2. typeDefinition: python-lsp/python-lsp-server#533 Maybe also 3. implementation: python-lsp/python-lsp-server#644
…n-lsp/python-lsp-server), and plus the following pull requests: 1. semanticTokens/full: python-lsp/python-lsp-server#645 2. typeDefinition: python-lsp/python-lsp-server#533 Maybe also 3. implementation: python-lsp/python-lsp-server#644
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.