Skip to content

Commit ce3664c

Browse files
committed
Fix: Hover over type
Fixes issue where imported type did not appear on hover unless the path textually matched the $import path.
1 parent 4c8e630 commit ce3664c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

benten/cwl/enumtype.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ def parse(self,
8686
if node[-2:] == "[]":
8787
node = node[:-2]
8888

89-
if node not in self.symbols: # Not a native type
90-
if node not in code_intel.type_defs: # Path doesn't match denormalized
89+
if node not in self.symbols: # Not a native type
90+
self._hover_value = code_intel.type_defs.get(node)
91+
if self._hover_value is None: # Path doesn't match denormalized
9192
_norm_path = normalized_path(doc_uri, node)
92-
for _type in code_intel.type_defs.keys():
93+
for _type, _type_def in code_intel.type_defs.items():
9394
if _norm_path == normalized_path(doc_uri, _type):
95+
self._hover_value = _type_def
9496
break
9597
else:
9698
problems += [
@@ -100,9 +102,6 @@ def parse(self,
100102
severity=DiagnosticSeverity.Error)
101103
]
102104

103-
else:
104-
self._hover_value = code_intel.type_defs[node]
105-
106105
ln = LookupNode(loc=value_range)
107106
ln.intelligence_node = self
108107
code_intel.add_lookup_node(ln)

tests/test_code_intelligence.py

+4
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ def test_schemadef_import():
141141
assert "./paired_end_record.yml#paired_end_options" in [c.label for c in cmpl]
142142
# The completer should offer user defined types as completions too
143143

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

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

0 commit comments

Comments
 (0)