Skip to content

Commit

Permalink
Fix: Hover over type
Browse files Browse the repository at this point in the history
Fixes issue where imported type did
not appear on hover unless the path
textually matched the $import path.
  • Loading branch information
kghose committed Sep 29, 2020
1 parent 4c8e630 commit ce3664c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 5 additions & 6 deletions benten/cwl/enumtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ def parse(self,
if node[-2:] == "[]":
node = node[:-2]

if node not in self.symbols: # Not a native type
if node not in code_intel.type_defs: # Path doesn't match denormalized
if node not in self.symbols: # Not a native type
self._hover_value = code_intel.type_defs.get(node)
if self._hover_value is None: # Path doesn't match denormalized
_norm_path = normalized_path(doc_uri, node)
for _type in code_intel.type_defs.keys():
for _type, _type_def in code_intel.type_defs.items():
if _norm_path == normalized_path(doc_uri, _type):
self._hover_value = _type_def
break
else:
problems += [
Expand All @@ -100,9 +102,6 @@ def parse(self,
severity=DiagnosticSeverity.Error)
]

else:
self._hover_value = code_intel.type_defs[node]

ln = LookupNode(loc=value_range)
ln.intelligence_node = self
code_intel.add_lookup_node(ln)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_code_intelligence.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ def test_schemadef_import():
assert "./paired_end_record.yml#paired_end_options" in [c.label for c in cmpl]
# The completer should offer user defined types as completions too

hov = doc.hover(Position(4, 12))
assert "type: record" in hov.contents.value
# Hover should show contents of included file


def test_schemadef_include():
this_path = current_path / "cwl" / "misc" / "cl-schemadef-include.cwl"
Expand Down

0 comments on commit ce3664c

Please sign in to comment.