def get_documentation(self, document: Document, position: Position) -> Optional[Hover]: """Gets the documentation about the element at the given position.""" context = self.xml_context_service.get_xml_context(document, position) if context.token and (context.is_tag or context.is_attribute_key): documentation = self.xsd_service.get_documentation_for(context) context_range = self.xml_context_service.get_range_for_context( document, context) return Hover(documentation, context_range) return None
def hover(server: JediLanguageServer, params: TextDocumentPositionParams) -> Optional[Hover]: """Support Hover.""" document = server.workspace.get_document(params.textDocument.uri) jedi_script = jedi_utils.script(server.project, document) jedi_lines = jedi_utils.line_column(jedi_script, params.position) for name in jedi_script.help(**jedi_lines): docstring = name.docstring() if not docstring: continue markup_kind = choose_markup(server) contents = MarkupContent(kind=markup_kind, value=docstring) document = server.workspace.get_document(params.textDocument.uri) _range = pygls_utils.current_word_range(document, params.position) return Hover(contents=contents, range=_range) return None
def hover(params: TextDocumentPositionParams): word = self._cursor_word(params.textDocument.uri, params.position, True) if not word: return None candidates = [ lambda x: self._api.get_command_doc(x.lower()), lambda x: self._api.get_variable_doc(x), lambda x: self._api.get_module_doc(x, False), lambda x: self._api.get_module_doc(x, True), ] for c in candidates: doc = c(word[0]) if doc is None: continue return Hover(MarkupContent(MarkupKind.Markdown, doc), word[1]) return None
def hover(params: TextDocumentPositionParams): text_doc = server.workspace.get_document(params.textDocument.uri) antfile = get_antfile(text_doc) symbols, range_ = antfile.symbols_at(sb_position(params.position)) if not symbols: return None assert range_ is not None # TODO fix the interface sym = symbols[0] text = sym.help_str() contents = MarkupContent(MarkupKind.Markdown, text) return Hover( contents=contents, range=pygls_range(range_), )
def hover(server: LanguageServer, params: TextDocumentPositionParams) -> Optional[Hover]: """Support Hover""" jedi_script = jedi_utils.script(server.workspace, params.textDocument.uri) jedi_lines = jedi_utils.line_column(params.position) jedi_docstrings = (n.docstring() for n in jedi_script.help(**jedi_lines)) docstrings = [x for x in jedi_docstrings if x] if not docstrings: return None # Only the first one should matter, right? docstring = docstrings[0] content = docstring_to_markup_content(docstring) document = server.workspace.get_document(params.textDocument.uri) _range = pygls_utils.current_word_range(document, params.position) return Hover(contents=content, range=_range)
def hover(server: JediLanguageServer, params: TextDocumentPositionParams) -> Optional[Hover]: """Support Hover.""" jedi_script = jedi_utils.script(server.workspace, params.textDocument.uri) jedi_lines = jedi_utils.line_column(jedi_script, params.position) for name in jedi_script.help(**jedi_lines): docstring = name.docstring() if not docstring: continue markup_preferred = ( server.initialize_params.initializationOptions_markupKindPreferred) markup_supported = (server.initialize_params. capabilities_textDocument_hover_contentFormat) markup_kind = (markup_preferred if markup_preferred in markup_supported else markup_supported[0]) contents = MarkupContent(kind=markup_kind, value=docstring) document = server.workspace.get_document(params.textDocument.uri) _range = pygls_utils.current_word_range(document, params.position) return Hover(contents=contents, range=_range) return None
async def handle_hover(ls, params): text_doc = ls.workspace.get_document(params.textDocument.uri) pos = params.position return Hover(contents=repr(checker.help(pos)[0][1]))