Skip to content

Commit

Permalink
get diagnostics from pyls_lint
Browse files Browse the repository at this point in the history
  • Loading branch information
youben11 committed Nov 12, 2019
1 parent 2d12e54 commit 71b8385
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
8 changes: 3 additions & 5 deletions pyls/plugins/importmagic_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def pyls_lint(document):


@hookimpl
def pyls_code_actions(config, document, context):
def pyls_code_actions(config, document):
"""Build a list of actions to be suggested to the user. Each action follow this format:
{
'title': 'importmagic',
Expand All @@ -150,11 +150,9 @@ def pyls_code_actions(config, document, context):
# TODO (youben): add project path for indexing
index = _get_index(sys.path)
actions = []
diagnostics = context.get('diagnostics', [])
for diagnostic in diagnostics:
if diagnostic.get('source') != SOURCE:
continue

diagnostics = pyls_lint(document)
for diagnostic in diagnostics:
message = diagnostic.get('message', '')
unref_match = UNREF_RE.match(message)
unres_match = UNRES_RE.match(message)
Expand Down
17 changes: 1 addition & 16 deletions test/plugins/test_importmagic_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,9 @@ def test_importmagic_lint():


def test_importmagic_actions(config):
context = {
'diagnostics': [
{
'range':
{
'start': {'line': 1, 'character': 0},
'end': {'line': 1, 'character': 10}
},
'message': "Unresolved import 'time.sleep'",
'severity': lsp.DiagnosticSeverity.Hint,
'source': importmagic_lint.SOURCE
}
]
}

try:
name, doc = temp_document(DOC)
actions = importmagic_lint.pyls_code_actions(config, doc, context)
actions = importmagic_lint.pyls_code_actions(config, doc)
action = [a for a in actions if a['title'] == 'Import "time"'][0]
arguments = action['arguments'][0]

Expand Down

0 comments on commit 71b8385

Please sign in to comment.