From ce3664c8218e1ad34a95cb1c1efef36608ec7a86 Mon Sep 17 00:00:00 2001 From: C02CR2E3ML85 Date: Mon, 28 Sep 2020 22:02:12 -0400 Subject: [PATCH] Fix: Hover over type Fixes issue where imported type did not appear on hover unless the path textually matched the $import path. --- benten/cwl/enumtype.py | 11 +++++------ tests/test_code_intelligence.py | 4 ++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/benten/cwl/enumtype.py b/benten/cwl/enumtype.py index 16ffc85..872a33a 100644 --- a/benten/cwl/enumtype.py +++ b/benten/cwl/enumtype.py @@ -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 += [ @@ -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) diff --git a/tests/test_code_intelligence.py b/tests/test_code_intelligence.py index 9f327a7..e669895 100644 --- a/tests/test_code_intelligence.py +++ b/tests/test_code_intelligence.py @@ -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"