def __init__(self, rx, tx) -> None: from robocorp_ls_core.pluginmanager import PluginManager from robotframework_ls.server_manager import ServerManager from robotframework_ls.ep_providers import DefaultConfigurationProvider from robotframework_ls.ep_providers import DefaultEndPointProvider from robotframework_ls.ep_providers import DefaultDirCacheProvider PythonLanguageServer.__init__(self, rx, tx) from robocorp_ls_core.cache import DirCache from robotframework_ls import robot_config home = robot_config.get_robotframework_ls_home() cache_dir = os.path.join(home, ".cache") log.debug(f"Cache dir: {cache_dir}") self._dir_cache = DirCache(cache_dir) self._pm = PluginManager() self._config_provider = DefaultConfigurationProvider(self.config) self._pm.set_instance(EPConfigurationProvider, self._config_provider) self._pm.set_instance(EPDirCacheProvider, DefaultDirCacheProvider(self._dir_cache)) self._pm.set_instance(EPEndPointProvider, DefaultEndPointProvider(self._endpoint)) self._server_manager = ServerManager(self._pm, language_server=self) self._lint_manager = _LintManager(self._server_manager, self._lsp_messages)
def get_internal_libspec_dir(cls): from robotframework_ls import robot_config home = robot_config.get_robotframework_ls_home() pyexe = sys.executable if not isinstance(pyexe, bytes): pyexe = pyexe.encode("utf-8") digest = hashlib.sha256(pyexe).hexdigest()[:8] v = cls.get_robot_version() # Note: _v1: information on the mtime of the libspec sources now available. return os.path.join(home, "specs", "%s_%s" % (digest, v))
def __init__(self, rx, tx) -> None: from robocorp_ls_core.pluginmanager import PluginManager from robotframework_ls.rf_interactive_integration import _RfInterpretersManager from robotframework_ls.server_manager import ServerManager from robotframework_ls.ep_providers import DefaultConfigurationProvider from robotframework_ls.ep_providers import DefaultEndPointProvider from robotframework_ls.ep_providers import DefaultDirCacheProvider from robocorp_ls_core import watchdog_wrapper from robocorp_ls_core.remote_fs_observer_impl import RemoteFSObserver from robocorp_ls_core.options import Setup PythonLanguageServer.__init__(self, rx, tx) from robocorp_ls_core.cache import DirCache from robotframework_ls import robot_config home = robot_config.get_robotframework_ls_home() cache_dir = os.path.join(home, ".cache") log.debug(f"Cache dir: {cache_dir}") self._dir_cache = DirCache(cache_dir) self._pm = PluginManager() self._config_provider = DefaultConfigurationProvider(self.config) self._pm.set_instance(EPConfigurationProvider, self._config_provider) self._pm.set_instance(EPDirCacheProvider, DefaultDirCacheProvider(self._dir_cache)) self._pm.set_instance(EPEndPointProvider, DefaultEndPointProvider(self._endpoint)) self._rf_interpreters_manager = _RfInterpretersManager( self._endpoint, self._pm) watch_impl = os.environ.get("ROBOTFRAMEWORK_LS_WATCH_IMPL", "auto") if watch_impl not in ("watchdog", "fsnotify", "auto"): log.info( f"ROBOTFRAMEWORK_LS_WATCH_IMPL should be 'auto', 'watchdog' or 'fsnotify'. Found: {watch_impl} (falling back to auto)" ) watch_impl = "auto" if watch_impl == "auto": # In auto mode we use watchdog for windows and fsnotify (polling) # for Linux and Mac. The reason for that is that on Linux and Mac # if big folders are watched the system may complain due to the # lack of resources, which may prevent the extension from working # properly. # # If users want to opt-in, they can change to watchdog (and # ideally install it to their env to get native extensions). if sys.platform == "win32": watch_impl = "watchdog" else: watch_impl = "fsnotify" self._fs_observer = watchdog_wrapper.create_remote_observer( watch_impl, (".py", ".libspec", "robot", ".resource")) remote_observer = typing.cast(RemoteFSObserver, self._fs_observer) log_file = Setup.options.log_file if not isinstance(log_file, str): log_file = None remote_observer.start_server(log_file=log_file) self._server_manager = ServerManager(self._pm, language_server=self) self._lint_manager = _LintManager(self._server_manager, self._lsp_messages)