Skip to content

Commit caa0079

Browse files
committed
Use toList() for streams
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 908a5c9 commit caa0079

File tree

5 files changed

+34
-39
lines changed

5 files changed

+34
-39
lines changed

modules/compiler/src/main/java/config/parser/ConfigAstBuilder.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Collections;
2323
import java.util.List;
2424
import java.util.concurrent.atomic.AtomicInteger;
25-
import java.util.stream.Collectors;
2625

2726
import groovy.lang.Tuple2;
2827
import nextflow.config.ast.ConfigAppendNode;
@@ -233,7 +232,7 @@ private ConfigStatement configInclude(ConfigIncludeContext ctx) {
233232
private ConfigStatement configAssignment(ConfigAssignmentContext ctx) {
234233
var names = ctx.configAssignmentPath().configPrimary().stream()
235234
.map(this::configPrimary)
236-
.collect(Collectors.toList());
235+
.toList();
237236
var value = expression(ctx.expression());
238237
return ast( new ConfigAssignNode(names, value), ctx );
239238
}
@@ -256,7 +255,7 @@ private ConfigStatement configBlock(ConfigBlockContext ctx) {
256255
var statements = ctx.configBlockStatement().stream()
257256
.map(this::configBlockStatement)
258257
.filter(stmt -> stmt != null)
259-
.collect(Collectors.toList());
258+
.toList();
260259
return new ConfigBlockNode(name, statements);
261260
}
262261

@@ -298,15 +297,15 @@ private ConfigStatement configSelector(ConfigSelectorContext ctx) {
298297
var target = configPrimary(ctx.target);
299298
var statements = ctx.configAssignment().stream()
300299
.map(this::configAssignment)
301-
.collect(Collectors.toList());
300+
.toList();
302301
return new ConfigBlockNode(kind, target, statements);
303302
}
304303

305304
private ConfigStatement configAppendBlock(ConfigAppendBlockContext ctx) {
306305
var name = configPrimary(ctx.configPrimary());
307306
var statements = ctx.configAppendBlockStatement().stream()
308307
.map(this::configAppendBlockStatement)
309-
.collect(Collectors.toList());
308+
.toList();
310309
var result = ast( new ConfigBlockNode(name, statements), ctx );
311310
if( !"plugins".equals(name) )
312311
collectSyntaxError(new SyntaxException("Only the `plugins` scope can use the append syntax (i.e. no equals sign)", result));
@@ -401,15 +400,15 @@ private BlockStatement blockStatements(BlockStatementsContext ctx) {
401400
return block(new VariableScope(), Collections.emptyList());
402401
var statements = ctx.statement().stream()
403402
.map(this::statement)
404-
.collect(Collectors.toList());
403+
.toList();
405404
return ast( block(new VariableScope(), statements), ctx );
406405
}
407406

408407
private Statement tryCatchStatement(TryCatchStatementContext ctx) {
409408
var tryStatement = statementOrBlock(ctx.statementOrBlock());
410409
var catchClauses = ctx.catchClause().stream()
411410
.map(this::catchClause)
412-
.collect(Collectors.toList());
411+
.toList();
413412
var result = tryCatchS(tryStatement);
414413
for( var clause : catchClauses )
415414
for( var stmt : clause )
@@ -427,7 +426,7 @@ private List<CatchStatement> catchClause(CatchClauseContext ctx) {
427426
var code = statementOrBlock(ctx.statementOrBlock());
428427
return ast( new CatchStatement(variable, code), ctx );
429428
})
430-
.collect(Collectors.toList());
429+
.toList();
431430
}
432431

433432
private List<ClassNode> catchTypes(CatchTypesContext ctx) {
@@ -436,7 +435,7 @@ private List<ClassNode> catchTypes(CatchTypesContext ctx) {
436435

437436
return ctx.qualifiedClassName().stream()
438437
.map(this::qualifiedClassName)
439-
.collect(Collectors.toList());
438+
.toList();
440439
}
441440

442441
private Statement returnStatement(ExpressionContext ctx) {
@@ -465,7 +464,7 @@ private Statement variableDeclaration(VariableDeclarationContext ctx) {
465464
// multiple assignment
466465
var variables = ctx.variableNames().identifier().stream()
467466
.map(ident -> (Expression) variableName(ident))
468-
.collect(Collectors.toList());
467+
.toList();
469468
var target = new ArgumentListExpression(variables);
470469
var initializer = expression(ctx.initializer);
471470
return stmt(ast( declX(target, initializer), ctx ));
@@ -483,7 +482,7 @@ private Statement variableDeclaration(VariableDeclarationContext ctx) {
483482
private Expression variableNames(VariableNamesContext ctx) {
484483
var vars = ctx.identifier().stream()
485484
.map(this::variableName)
486-
.collect(Collectors.toList());
485+
.toList();
487486
return ast( new TupleExpression(vars), ctx );
488487
}
489488

@@ -1032,7 +1031,7 @@ private List<Expression> expressionList(ExpressionListContext ctx) {
10321031

10331032
return ctx.expression().stream()
10341033
.map(this::expression)
1035-
.collect(Collectors.toList());
1034+
.toList();
10361035
}
10371036

10381037
private Expression map(MapContext ctx) {
@@ -1041,7 +1040,7 @@ private Expression map(MapContext ctx) {
10411040

10421041
var entries = ctx.mapEntryList().mapEntry().stream()
10431042
.map(this::mapEntry)
1044-
.collect(Collectors.toList());
1043+
.toList();
10451044
var result = mapX(entries);
10461045
if( ctx.COMMA() != null )
10471046
result.putNodeMetaData(TRAILING_COMMA, Boolean.TRUE);
@@ -1172,7 +1171,7 @@ private Parameter[] formalParameterList(FormalParameterListContext ctx) {
11721171

11731172
var params = ctx.formalParameter().stream()
11741173
.map(this::formalParameter)
1175-
.collect(Collectors.toList());
1174+
.toList();
11761175
for( int n = params.size(), i = n - 1; i >= 0; i -= 1 ) {
11771176
var param = params.get(i);
11781177
for( var other : params ) {

modules/compiler/src/main/java/script/parser/ScriptAstBuilder.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.List;
2525
import java.util.Optional;
2626
import java.util.concurrent.atomic.AtomicInteger;
27-
import java.util.stream.Collectors;
2827

2928
import groovy.lang.Tuple2;
3029
import nextflow.script.ast.AssignmentExpression;
@@ -348,7 +347,7 @@ private IncludeNode includeDeclaration(IncludeDeclarationContext ctx) {
348347
result.putNodeMetaData("_START_ALIAS", tokenPosition(it.alias));
349348
return ast( result, it );
350349
})
351-
.collect(Collectors.toList());
350+
.toList();
352351

353352
return ast( new IncludeNode(source, modules), ctx );
354353
}
@@ -401,7 +400,7 @@ private Statement processDirectives(ProcessDirectivesContext ctx) {
401400
var statements = ctx.statement().stream()
402401
.map(this::statement)
403402
.map(stmt -> checkDirective(stmt, "Invalid process directive"))
404-
.collect(Collectors.toList());
403+
.toList();
405404
return ast( block(null, statements), ctx );
406405
}
407406

@@ -411,7 +410,7 @@ private Statement processInputs(ProcessInputsContext ctx) {
411410
var statements = ctx.statement().stream()
412411
.map(this::statement)
413412
.map(stmt -> checkDirective(stmt, "Invalid process input"))
414-
.collect(Collectors.toList());
413+
.toList();
415414
return ast( block(null, statements), ctx );
416415
}
417416

@@ -421,7 +420,7 @@ private Statement processOutputs(ProcessOutputsContext ctx) {
421420
var statements = ctx.statement().stream()
422421
.map(this::statement)
423422
.map(stmt -> checkDirective(stmt, "Invalid process output"))
424-
.collect(Collectors.toList());
423+
.toList();
425424
return ast( block(null, statements), ctx );
426425
}
427426

@@ -543,7 +542,7 @@ private Statement workflowTakes(WorkflowTakesContext ctx) {
543542

544543
var statements = ctx.identifier().stream()
545544
.map(this::workflowTake)
546-
.collect(Collectors.toList());
545+
.toList();
547546
return ast( block(null, statements), ctx );
548547
}
549548

@@ -560,7 +559,7 @@ private Statement workflowEmits(WorkflowEmitsContext ctx) {
560559
var statements = ctx.statement().stream()
561560
.map(this::workflowEmit)
562561
.filter(stmt -> stmt != null)
563-
.collect(Collectors.toList());
562+
.toList();
564563
var result = ast( block(null, statements), ctx );
565564
var hasEmitExpression = statements.stream().anyMatch(this::isEmitExpression);
566565
if( hasEmitExpression && statements.size() > 1 )
@@ -594,7 +593,7 @@ private Statement workflowPublishers(WorkflowPublishersContext ctx) {
594593
.map(this::statement)
595594
.map(this::checkWorkflowPublisher)
596595
.filter(stmt -> stmt != null)
597-
.collect(Collectors.toList());
596+
.toList();
598597
return ast( block(null, statements), ctx );
599598
}
600599

@@ -619,7 +618,7 @@ private Statement outputBody(OutputBodyContext ctx) {
619618
return EmptyStatement.INSTANCE;
620619
var statements = ctx.outputTargetBody().stream()
621620
.map(this::outputTargetBody)
622-
.collect(Collectors.toList());
621+
.toList();
623622
return ast( block(null, statements), ctx );
624623
}
625624

@@ -716,15 +715,15 @@ private BlockStatement blockStatements(BlockStatementsContext ctx) {
716715
return block(new VariableScope(), Collections.emptyList());
717716
var statements = ctx.statement().stream()
718717
.map(this::statement)
719-
.collect(Collectors.toList());
718+
.toList();
720719
return ast( block(new VariableScope(), statements), ctx );
721720
}
722721

723722
private Statement tryCatchStatement(TryCatchStatementContext ctx) {
724723
var tryStatement = statementOrBlock(ctx.statementOrBlock());
725724
var catchClauses = ctx.catchClause().stream()
726725
.map(this::catchClause)
727-
.collect(Collectors.toList());
726+
.toList();
728727
var result = tryCatchS(tryStatement);
729728
for( var clause : catchClauses )
730729
for( var stmt : clause )
@@ -742,7 +741,7 @@ private List<CatchStatement> catchClause(CatchClauseContext ctx) {
742741
var code = statementOrBlock(ctx.statementOrBlock());
743742
return ast( new CatchStatement(variable, code), ctx );
744743
})
745-
.collect(Collectors.toList());
744+
.toList();
746745
}
747746

748747
private List<ClassNode> catchTypes(CatchTypesContext ctx) {
@@ -751,7 +750,7 @@ private List<ClassNode> catchTypes(CatchTypesContext ctx) {
751750

752751
return ctx.qualifiedClassName().stream()
753752
.map(this::qualifiedClassName)
754-
.collect(Collectors.toList());
753+
.toList();
755754
}
756755

757756
private Statement returnStatement(ExpressionContext ctx) {
@@ -780,7 +779,7 @@ private Statement variableDeclaration(VariableDeclarationContext ctx) {
780779
// multiple assignment
781780
var variables = ctx.variableNames().identifier().stream()
782781
.map(ident -> (Expression) variableName(ident))
783-
.collect(Collectors.toList());
782+
.toList();
784783
var target = new ArgumentListExpression(variables);
785784
var initializer = expression(ctx.initializer);
786785
return stmt(ast( declX(target, initializer), ctx ));
@@ -799,7 +798,7 @@ private Statement variableDeclaration(VariableDeclarationContext ctx) {
799798
private Expression variableNames(VariableNamesContext ctx) {
800799
var vars = ctx.identifier().stream()
801800
.map(this::variableName)
802-
.collect(Collectors.toList());
801+
.toList();
803802
return ast( new TupleExpression(vars), ctx );
804803
}
805804

@@ -1365,7 +1364,7 @@ private Expression closureWithLabels(ClosureWithLabelsContext ctx) {
13651364
private BlockStatement blockStatementsWithLabels(BlockStatementsWithLabelsContext ctx) {
13661365
var statements = ctx.statementOrLabeled().stream()
13671366
.map(this::statementOrLabeled)
1368-
.collect(Collectors.toList());
1367+
.toList();
13691368
return ast( block(new VariableScope(), statements), ctx );
13701369
}
13711370

@@ -1397,7 +1396,7 @@ private List<Expression> expressionList(ExpressionListContext ctx) {
13971396

13981397
return ctx.expression().stream()
13991398
.map(this::expression)
1400-
.collect(Collectors.toList());
1399+
.toList();
14011400
}
14021401

14031402
private Expression map(MapContext ctx) {
@@ -1406,7 +1405,7 @@ private Expression map(MapContext ctx) {
14061405

14071406
var entries = ctx.mapEntryList().mapEntry().stream()
14081407
.map(this::mapEntry)
1409-
.collect(Collectors.toList());
1408+
.toList();
14101409
var result = mapX(entries);
14111410
if( ctx.COMMA() != null )
14121411
result.putNodeMetaData(TRAILING_COMMA, Boolean.TRUE);
@@ -1537,7 +1536,7 @@ private Parameter[] formalParameterList(FormalParameterListContext ctx) {
15371536

15381537
var params = ctx.formalParameter().stream()
15391538
.map(this::formalParameter)
1540-
.collect(Collectors.toList());
1539+
.toList();
15411540
for( int n = params.size(), i = n - 1; i >= 0; i -= 1 ) {
15421541
var param = params.get(i);
15431542
for( var other : params ) {

modules/language-server/src/main/java/nextflow/lsp/ast/ASTUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Iterator;
2121
import java.util.List;
2222
import java.util.Optional;
23-
import java.util.stream.Collectors;
2423

2524
import nextflow.script.ast.AssignmentExpression;
2625
import nextflow.script.ast.FeatureFlagNode;
@@ -325,7 +324,7 @@ public static List<MethodNode> getMethodOverloadsFromCallExpression(MethodCall n
325324
if( constructorType != null ) {
326325
return constructorType.getDeclaredConstructors().stream()
327326
.map(ctor -> (MethodNode) ctor)
328-
.collect(Collectors.toList());
327+
.toList();
329328
}
330329
}
331330

modules/language-server/src/main/java/nextflow/lsp/services/SemanticTokensVisitor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.util.ArrayList;
1919
import java.util.List;
20-
import java.util.stream.Collectors;
2120
import java.util.stream.Stream;
2221

2322
import nextflow.lsp.util.Positions;
@@ -107,7 +106,7 @@ public SemanticTokens getTokens() {
107106
TOKEN_TYPES.indexOf(token.type()),
108107
0
109108
))
110-
.collect(Collectors.toList());
109+
.toList();
111110

112111
return new SemanticTokens(data);
113112
}

modules/language-server/src/main/java/nextflow/lsp/services/script/ParameterSchemaVisitor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.List;
2424
import java.util.Map;
2525
import java.util.Optional;
26-
import java.util.stream.Collectors;
2726
import java.util.stream.Stream;
2827

2928
import groovy.json.JsonSlurper;
@@ -122,7 +121,7 @@ private void declareParameters() {
122121
? map.entrySet().stream()
123122
: Stream.empty()
124123
)
125-
.collect(Collectors.toList());
124+
.toList();
126125

127126
if( entries.isEmpty() )
128127
return;

0 commit comments

Comments
 (0)