diff --git a/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java b/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java index 9e47a604..51a4566a 100644 --- a/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java +++ b/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java @@ -415,6 +415,9 @@ else if( Logger.isDebugEnabled() ) { } private static boolean isDeclaringTypeVisible(ClassNode declaringType) { + // plugin functions have no declaring type + if( ClassHelper.isDynamicTyped(declaringType) ) + return false; if( declaringType.implementsInterface(ClassHelper.makeCached(DslScope.class)) ) return false; if( declaringType.implementsInterface(ClassHelper.makeCached(Namespace.class)) ) diff --git a/src/main/java/nextflow/lsp/spec/ScriptSpecFactory.java b/src/main/java/nextflow/lsp/spec/ScriptSpecFactory.java index 1e8c792e..805ed934 100644 --- a/src/main/java/nextflow/lsp/spec/ScriptSpecFactory.java +++ b/src/main/java/nextflow/lsp/spec/ScriptSpecFactory.java @@ -113,7 +113,9 @@ private static ClassNode fromType(Object type) { } private static ClassNode rawType(String name) { - return STANDARD_TYPES.getOrDefault(name, ClassHelper.dynamicType()); + var type = STANDARD_TYPES.get(name); + // a raw type, not the generic declaration (e.g. List, not List) + return type != null ? type.getPlainNodeReference() : ClassHelper.dynamicType(); } } diff --git a/src/test/java/nextflow/lsp/services/script/ScriptHoverTest.java b/src/test/java/nextflow/lsp/services/script/ScriptHoverTest.java index 4c6ddc4f..31da152d 100644 --- a/src/test/java/nextflow/lsp/services/script/ScriptHoverTest.java +++ b/src/test/java/nextflow/lsp/services/script/ScriptHoverTest.java @@ -85,6 +85,28 @@ def make() { assertThat(value).isEqualTo("```nextflow\ndef make() -> Channel\n```"); } + @Test + void showSignatureWhenHoveringOverPluginFunctionCall() { + var server = TestServer.start(); + var uri = getUri("main.nf"); + + server.open("nextflow.config", "plugins { id 'nf-schema@2.7.3' }"); + server.settle(); + server.open("main.nf", """ + nextflow.enable.types = true + + include { samplesheetToList } from 'plugin/nf-schema' + + workflow { + samplesheetToList('s.csv', 'schema.json') + } + """); + server.settle(); + var value = getHoverHint(server, uri, new Position(5, 5)); + + assertThat(value).isEqualTo("```nextflow\nsamplesheetToList(arg0, arg1) -> List\n```"); + } + @Test void showLabelWhenHoveringOverWorkflowInvocation() { var server = TestServer.start();