8080import org .codehaus .groovy .ast .stmt .Statement ;
8181import org .codehaus .groovy .control .SourceUnit ;
8282import org .codehaus .groovy .control .messages .SyntaxErrorMessage ;
83+ import org .codehaus .groovy .control .messages .WarningMessage ;
8384import org .codehaus .groovy .syntax .SyntaxException ;
85+ import org .codehaus .groovy .syntax .Token ;
8486import org .codehaus .groovy .syntax .Types ;
8587
8688import static nextflow .script .ast .ASTUtils .*;
@@ -226,7 +228,7 @@ private static ClassNode asDataflowType(ClassNode type, ClassNode sourceType) {
226228
227229 @ Override
228230 public void visitProcessV2 (ProcessNodeV2 node ) {
229- visit (node .directives );
231+ visitProcessDirectives (node .directives );
230232 visit (node .stagers );
231233 visit (node .when );
232234 visit (node .exec );
@@ -235,6 +237,17 @@ public void visitProcessV2(ProcessNodeV2 node) {
235237 visitProcessTopics (node .topics );
236238 }
237239
240+ private void visitProcessDirectives (Statement block ) {
241+ asDirectives (block ).forEach ((call ) -> {
242+ var arguments = asMethodCallArguments (call );
243+ if ( arguments .size () == 1 && arguments .get (0 ) instanceof ClosureExpression ) {
244+ addWarning ("Closure is no longer required for dynamic process directives" , call .getMethodAsString (), call );
245+ return ;
246+ }
247+ visit (call );
248+ });
249+ }
250+
238251 private void visitProcessTopics (Statement block ) {
239252 for ( var stmt : asBlockStatements (block ) ) {
240253 var es = (ExpressionStatement )stmt ;
@@ -252,7 +265,7 @@ private void visitProcessTopics(Statement block) {
252265 @ Override
253266 public void visitProcessV1 (ProcessNodeV1 node ) {
254267 // don't try to type-check input/output directives
255- visit (node .directives );
268+ visitProcessDirectives (node .directives );
256269 visit (node .when );
257270 visit (node .exec );
258271 visit (node .stub );
@@ -1219,6 +1232,11 @@ private static MethodNode asMethodNamedOutput(PropertyExpression node) {
12191232 return null ;
12201233 }
12211234
1235+ public void addWarning (String message , String tokenText , ASTNode node ) {
1236+ var token = new Token (0 , tokenText , node .getLineNumber (), node .getColumnNumber ()); // ASTNode to CSTNode
1237+ sourceUnit .getErrorCollector ().addWarning (WarningMessage .POSSIBLE_ERRORS , message , token , sourceUnit );
1238+ }
1239+
12221240 @ Override
12231241 public void addError (String message , ASTNode node ) {
12241242 var cause = new TypeError (message , node );
0 commit comments