10000 add comments to POIs by fwetdb · Pull Request #1 · fwetdb/python-lsp-server · GitHub
[go: up one dir, main page]

Skip to content

add comments to POIs #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pylsp/hookspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def pylsp_document_did_open(config, workspace, document):
pass


# the method can be hooked into by plugins which will receive the args
@hookspec
def pylsp_document_did_save(config, workspace, document):
pass
Expand Down
1 change: 1 addition & 0 deletions pylsp/plugins/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@hookimpl
def pylsp_hover(config, document, position):
code_position = _utils.position_to_jedi_linecolumn(document, position)
# uses jedi to determine code positions
definitions = document.jedi_script(use_document_path=True).infer(**code_position)
word = document.word_at_position(position)

Expand Down
9 changes: 9 additions & 0 deletions pylsp/python_lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ async def run_server():
asyncio.run(run_server())


# calls methods for a given message type e.g. m_text_document__did_change for textDocument/didChange
# the logic lives within pylsp_jsonrpc.MethodDispatcher

# in general, a lot of the calling logic is contained within pylsp_jsonrpc e.g. Endpoint, JsonRpcStreamReader, JsonRpcStreamWriter
class PythonLSPServer(MethodDispatcher):
""" Implementation of the Microsoft VSCode Language Server Protocol
https://github.com/Microsoft/language-server-protocol/blob/master/versions/protocol-1-x.md
Expand Down Expand Up @@ -232,6 +236,7 @@ def _hook(self, hook_name, doc_uri=None, **kwargs):
workspace = self._match_uri_to_workspace(doc_uri)
doc = workspace.get_document(doc_uri) if doc_uri else None
hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugins)
# point where config, workspace, document are passed to hook handlers
return hook_handlers(config=self.config, workspace=workspace, document=doc, **kwargs)

def capabilities(self):
Expand Down Expand Up @@ -369,6 +374,7 @@ def highlight(self, doc_uri, position):
return flatten(self._hook('pylsp_document_highlight', doc_uri, position=position)) or None

def hover(self, doc_uri, position):
# might be involved in go to definition
return self._hook('pylsp_hover', doc_uri, position=position) or {'contents': ''}

@_utils.debounce(LINT_DEBOUNCE_S, keyed_by='doc_uri')
Expand All @@ -382,6 +388,7 @@ def lint(self, doc_uri, is_saved):
)

def references(self, doc_uri, position, exclude_declaration):
# might derive references for go to definition
return flatten(self._hook(
'pylsp_references', doc_uri, position=position,
exclude_declaration=exclude_declaration
Expand Down Expand Up @@ -411,13 +418,15 @@ def m_text_document__did_open(self, textDocument=None, **_kwargs):
self.lint(textDocument['uri'], is_saved=True)

def m_text_document__did_change(self, contentChanges=None, textDocument=None, **_kwargs):
# called for textDocument/didChange
workspace = self._match_uri_to_workspace(textDocument['uri'])
for change in contentChanges:
workspace.update_document(
textDocument['uri'],
change,
version=textDocument.get('version')
)
# lint triggers a diagnostics message in a debounced fashion
self.lint(textDocument['uri'], is_saved=False)

def m_text_document__did_save(self, textDocument=None, **_kwargs):
Expand Down
3 changes: 3 additions & 0 deletions pylsp/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def wrapper(self, *args, **kwargs):
return wrapper


# object that is available for plugins
class Workspace:

M_PUBLISH_DIAGNOSTICS = 'textDocument/publishDiagnostics'
Expand Down Expand Up @@ -263,6 +264,7 @@ def close(self):
self.__rope_autoimport.close()


# object that is available for plugins
class Document:

def __init__(self, uri, workspace, source=None, version=None, local=True, extra_sys_path=None,
Expand Down Expand Up @@ -380,6 +382,7 @@ def jedi_names(self, all_scopes=False, definitions=True, references=False):

@lock
def jedi_script(self, position=None, use_document_path=False):
# get jedi.Script for Document which might be involved for go to definition
extra_paths = []
environment_path = None
env_vars = None
Expand Down
0