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

Handle on-the-fly search path configuration changes, read search paths from config directly #1492

Merged
merged 13 commits into from
Aug 30, 2019

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Aug 28, 2019

Fixes #1388.
Fixes #915. (Null check added.)
Updates #469. (Less needed from initializationOptions, PYTHONPATH potential.)

User configured search paths are now pulled from the user configuration (and on the fly), rather than solely through the initialization options.

To do this, the LS initialization logic has been moved from initialize RPC call into the initialized notification handler. There, we can ask the editor for the python configuration, and then use the real configuration to set the initial search paths. If the configuration is changed later, then it will be re-processed, and a reload will be triggered if it changes (just like path watching).

The old python.autoComplete.extraPaths will still work. python.analysis.searchPaths and python.analysis.usePYTHONPATH have been added as a newer interface. Also in this change is a fix which makes watchSearchPaths accessible again, as python.analysis.watchSearchPaths; previously it was not accessible.

Config items:

  • searchPaths in the initialization options - Old, last resort.
  • python.autoComplete.extraPaths - Old, but still read.
  • python.analysis.searchPaths - New, replacement for extraPaths. If present, extraPaths is ignored entirely.
  • python.analysis.usePYTHONPATH - New, true (default) if PYTHONPATH should be added to the end of searchPaths/extraPaths (which the extension did)
  • python.analysis.watchSearchPaths - Fixed, true (default) if library search paths should be watched for file changes.

@jakebailey
Copy link
Member Author

I can see a way to handle the issues with the configuration coming in too late: The server can make a workspace/configuration call back to the editor and ask for the configuration. However, the server is not allowed to make any calls until initialize returns, which means that any initialization RPC calls back to the client need to happen later, which the spec says to do in the initialized handler. It's very likely that what we're doing in the initialize handler can be moved later.

That might be too invasive to do in this change, but, if it's done, the server can just ask the editor for the config, pre-populate the settings (before it ever gets workspace/didChangeConfiguration), and initialize based on that.

…PC call to get the user search paths instead of reloading, bring back searchPaths for full backwards compat
@jakebailey jakebailey changed the title [WIP] Handle on-the-fly search path configuration changes, don't read searchPaths from initialization options [WIP] Handle on-the-fly search path configuration changes Aug 29, 2019
@jakebailey jakebailey changed the title [WIP] Handle on-the-fly search path configuration changes Handle on-the-fly search path configuration changes Aug 29, 2019
@jakebailey jakebailey changed the title Handle on-the-fly search path configuration changes Handle on-the-fly search path configuration changes, read search paths from config directly Aug 29, 2019
@jakebailey jakebailey merged commit c214d9f into microsoft:master Aug 30, 2019
@jakebailey jakebailey deleted the issue-1388 branch August 30, 2019 22:21
jakebailey added a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 2019
…s from config directly (microsoft#1492)

* Remove SearchPaths and TypeshedPath from Interpreter, move search path logic into module resolution

* Move path processing into config change, with unfortunate extra reload

* Cleanup usings

* Eliminate nulls, since they aren't useful

* Move initialization logic from initialize to initialized, and do an RPC call to get the user search paths instead of reloading, bring back searchPaths for full backwards compat

* Cleanups

* Null checks

* Prevent errors on null settings or when the client doesn't implement workspace/configuration

* Formatting

* Replace IReadOnlyList with ImmutableArray where possible

* Eliminate IReadOnlyList

* Remove unused default/optional parameter
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants