From fdc261d0423fcb6d7182c2c965ec7d09c279fa7e Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Mon, 26 Mar 2018 14:34:09 +0200 Subject: [PATCH] Populate Workspace.PRELOADED_MODULES lazily Otherwise we spend time populating PRELOADED_MODULES regardless if we use Rope or not. --- pyls/workspace.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyls/workspace.py b/pyls/workspace.py index 6dd7969c..c060412a 100644 --- a/pyls/workspace.py +++ b/pyls/workspace.py @@ -70,7 +70,7 @@ class Workspace(object): M_PUBLISH_DIAGNOSTICS = 'textDocument/publishDiagnostics' M_APPLY_EDIT = 'workspace/applyEdit' M_SHOW_MESSAGE = 'window/showMessage' - PRELOADED_MODULES = get_preferred_submodules() + PRELOADED_MODULES = None def __init__(self, root_uri, endpoint): self._root_uri = root_uri @@ -86,6 +86,9 @@ def __init__(self, root_uri, endpoint): def _rope_project_builder(self, rope_config): from rope.base.project import Project + if self.PRELOADED_MODULES is None: + self.__class__.PRELOADED_MODULES = get_preferred_submodules() + # TODO: we could keep track of dirty files and validate only those if self.__rope is None or self.__rope_config != rope_config: rope_folder = rope_config.get('ropeFolder')