Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Support goto definition in library files #840

Closed
MikhailArkhipov opened this issue Mar 28, 2019 · 11 comments · Fixed by #1861
Closed

Support goto definition in library files #840

MikhailArkhipov opened this issue Mar 28, 2019 · 11 comments · Fixed by #1861
Assignees
Labels
bug Something isn't working feature: references

Comments

@MikhailArkhipov
Copy link

Currently we navigate to library, but then Goto Def is no longer available.

@MikhailArkhipov
Copy link
Author

microsoft/vscode#71418

@jakebailey
Copy link
Member

This appears to be coming from the extension, rather than VS Code itself. See microsoft/vscode-python#5132.

@MikhailArkhipov
Copy link
Author

Modules outside of the workspace are considered libraries and in order to conserve memory file content, parse tree and navigation information is not preserved. This might be made into an option if memory consumption increase is not a concern.

@MikhailArkhipov
Copy link
Author

AnalysisOptions could have an setting at the expense of memory consumption.

@rvanlaar
Copy link

As I created issue: #1848 that was closed a duplicate of this one.

I do have three things that irk me about how it works now.

Why:

  • doesn't the Language server tell me it won't do libraries when it opens the code?
  • doesn't the Language server start introspection when I open a library file?
  • when I open a workspace with a library file open does the Language server do introspection on said library file?

I couldn't find documentation about this.
For now it seems Jedi should be recommended instead of the Language server.

@MikhailArkhipov
Copy link
Author

Libraries are analyzed but information is not completely kept in order to conserve memory. They are analyzed when imported, library doesn't have to be opened. If you open library file it is not re-analyzed. As mentioned above, a setting may be added to keep all information at the expense of memory.

@rvanlaar
Copy link

rvanlaar commented Dec 23, 2019 via email

@jakebailey
Copy link
Member

For those watching this, you may be able to restore this functionality through a pair of settings that will tell the LS to not drop info for libraries from memory:

"python.analysis.memory.keepLibraryAst": true,
"python.analysis.memory.keepLibraryLocalVariables": true,

But the memory cost of storing this info will likely be significant, as it will be stored for all referenced libraries in the dependency graph for the opened files.

@MisLink
Copy link

MisLink commented Feb 27, 2020

I tried these two settings but language server still can't jump between library files. I have to say the lack of this feature is a little frustrating.

@jakebailey
Copy link
Member

This will be available in 0.5.37 and above as an optional feature that can be enabled (#1861) by setting:

"python.analysis.memory.keepLibraryAst": true

Note that storing this information about libraries is likely to be very memory heavy, hence why we threw this information away in the first place. Your experience may vary.

@usuyama
Copy link

usuyama commented Jun 10, 2020

I just tried @jakebailey 's suggestion and it's working perfectly on my environment (Windows 10 + SSH to Linux Azure VM). It's great that I can just Go To Definition (F12) for library code/functions. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working feature: references
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants