Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public void visitMethodCallExpression(MethodCallExpression node) {
visit(receiver);
if( inWrappedMethodChain ) {
incIndent();
if( !(receiver instanceof ClassExpression) ) {
if( !nextflow.script.types.Types.isNamespace(receiver.getType()) ) {
appendNewLine();
appendIndent();
}
Expand Down
22 changes: 20 additions & 2 deletions modules/nf-lang/src/main/java/nextflow/script/types/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import groovy.lang.GString;
import groovy.lang.Tuple2;
import nextflow.script.ast.ASTNodeMarker;
import nextflow.script.dsl.DslScope;
import nextflow.script.dsl.Namespace;
import nextflow.script.types.shim.ShimType;
import org.codehaus.groovy.GroovyBugError;
Expand Down Expand Up @@ -91,15 +92,32 @@ public static boolean isAssignableFrom(Class target, Class source) {
return target.equals(source);
}

/**
* Determine whether a class is a DSL scope.
*
* @param cn
*/
public static boolean isDslScope(ClassNode cn) {
return cn.implementsInterface(ClassHelper.makeCached(DslScope.class));
}

/**
* Determine whether a class is a namespace.
*
* @param cn
*/
public static boolean isNamespace(ClassNode cn) {
return cn.implementsInterface(ClassHelper.makeCached(Namespace.class));
}

/**
* Given a method node corresponding to a built-in constant, determine
* whether the constant is a namespace.
*
* @param mn
*/
public static boolean isNamespace(MethodNode mn) {
var cn = mn.getReturnType();
return hasTypeClass(cn) && Namespace.class.isAssignableFrom(cn.getTypeClass());
return isNamespace(mn.getReturnType());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ class ScriptFormatterTest extends Specification {
expect:
checkFormat(
'''\
Channel.of( 1, 2, 3 )
channel.of( 1, 2, 3 )
.multiMap{v->foo:bar:v}.set{result}
''',
'''\
Channel.of(1, 2, 3)
channel.of(1, 2, 3)
.multiMap { v -> foo: bar: v }
.set { result }
'''
Expand Down