def __call__(self) -> None: from robocorp_ls_core.jsonrpc.exceptions import JsonRpcRequestCancelled from robocorp_ls_core.client_base import wait_for_message_matcher from robotframework_ls.server_api.client import SubprocessDiedError try: doc_uri = self.doc_uri self._monitor.check_cancelled() found = [] message_matcher = self._rf_lint_api_client.request_lint(doc_uri) if message_matcher is not None: if wait_for_message_matcher( message_matcher, monitor=self._monitor, request_cancel=self._rf_lint_api_client.request_cancel, timeout=60 * 3, ): diagnostics_msg = message_matcher.msg if diagnostics_msg: found = diagnostics_msg.get("result", []) self.lsp_messages.publish_diagnostics(doc_uri, found) except JsonRpcRequestCancelled: log.info(f"Cancelled linting: {self.doc_uri}.") except SubprocessDiedError: log.info(f"Subprocess exited while linting: {self.doc_uri}.") except Exception: log.exception("Error linting.")
def _async_api_request_no_doc( self, rf_api_client: IRobotFrameworkApiClient, request_method_name: str, monitor: Optional[IMonitor], **kwargs, ): from robocorp_ls_core.client_base import wait_for_message_matcher func = getattr(rf_api_client, request_method_name) # Asynchronous completion. message_matcher: Optional[IIdMessageMatcher] = func(**kwargs) if message_matcher is None: log.debug("Message matcher for %s returned None.", request_method_name) return None if wait_for_message_matcher( message_matcher, rf_api_client.request_cancel, DEFAULT_COMPLETIONS_TIMEOUT, monitor, ): msg = message_matcher.msg if msg is not None: result = msg.get("result") if result: return result return None
def _threaded_workspace_symbol( self, api_client: IRobotFrameworkApiClient, query: Optional[str], monitor: IMonitor, ): from robocorp_ls_core.client_base import wait_for_message_matcher # Asynchronous completion. message_matcher: Optional[ IIdMessageMatcher] = api_client.request_workspace_symbols(query) if message_matcher is None: log.debug("Message matcher for workspace symbols returned None.") return None if wait_for_message_matcher( message_matcher, api_client.request_cancel, DEFAULT_COMPLETIONS_TIMEOUT, monitor, ): msg = message_matcher.msg if msg is not None: result = msg.get("result") if result: return result return None
def _async_api_request( self, rf_api_client: IRobotFrameworkApiClient, request_method_name: str, doc_uri: str, monitor: IMonitor, **kwargs, ): from robocorp_ls_core.client_base import wait_for_message_matcher func = getattr(rf_api_client, request_method_name) ws = self.workspace if not ws: log.critical("Workspace must be set before calling %s.", request_method_name) return None document = ws.get_document(doc_uri, accept_from_file=True) if document is None: log.critical("Unable to find document (%s) for %s." % (doc_uri, request_method_name)) return None # Asynchronous completion. message_matcher: Optional[IIdMessageMatcher] = func(doc_uri, **kwargs) if message_matcher is None: log.debug("Message matcher for %s returned None.", request_method_name) return None if wait_for_message_matcher( message_matcher, rf_api_client.request_cancel, DEFAULT_COMPLETIONS_TIMEOUT, monitor, ): msg = message_matcher.msg if msg is not None: result = msg.get("result") if result: return result return None
def _signature_help( self, rf_api_client: IRobotFrameworkApiClient, doc_uri: str, line: int, col: int, monitor: Monitor, ) -> Optional[dict]: from robocorp_ls_core.client_base import wait_for_message_matcher ws = self.workspace if not ws: log.critical( "Workspace must be set before getting signature help.") return None document = ws.get_document(doc_uri, accept_from_file=True) if document is None: log.critical("Unable to find document (%s) for completions." % (doc_uri, )) return None # Asynchronous completion. message_matcher: Optional[ IIdMessageMatcher] = rf_api_client.request_signature_help( doc_uri, line, col) if message_matcher is None: log.debug("Message matcher for signature returned None.") return None if wait_for_message_matcher( message_matcher, rf_api_client.request_cancel, DEFAULT_COMPLETIONS_TIMEOUT, monitor, ): msg = message_matcher.msg if msg is not None: result = msg.get("result") if result: return result return None