Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use method references in lambda #28

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -59,16 +59,16 @@ private static void recurseGetAllControlFlowNodes(ControlFlowNode current, Set<C
public Set<ControlFlowNode.BasicBlock> getBasicBlocks() {
return getAllNodes()
.stream()
.filter(node -> node instanceof ControlFlowNode.BasicBlock)
.map(node -> (ControlFlowNode.BasicBlock) node)
.filter(org.openrewrite.analysis.controlflow.ControlFlowNode.BasicBlock.class::isInstance)
timtebeek marked this conversation as resolved.
Show resolved Hide resolved
.map(org.openrewrite.analysis.controlflow.ControlFlowNode.BasicBlock.class::cast)
.collect(Collectors.toSet());
}

public Set<ControlFlowNode.ConditionNode> getConditionNodes() {
return getAllNodes()
.stream()
.filter(node -> node instanceof ControlFlowNode.ConditionNode)
.map(node -> (ControlFlowNode.ConditionNode) node)
.filter(org.openrewrite.analysis.controlflow.ControlFlowNode.ConditionNode.class::isInstance)
.map(org.openrewrite.analysis.controlflow.ControlFlowNode.ConditionNode.class::cast)
.collect(Collectors.toSet());
}

Expand All @@ -92,8 +92,8 @@ public Set<ControlFlowNode.BasicBlock> computeReachableBasicBlock(BarrierGuardPr
recurseComputeReachableBasicBlock(start, predicate, reachable);
return reachable
.stream()
.filter(cfn -> cfn instanceof ControlFlowNode.BasicBlock)
.map(cfn -> (ControlFlowNode.BasicBlock) cfn)
.filter(org.openrewrite.analysis.controlflow.ControlFlowNode.BasicBlock.class::isInstance)
.map(org.openrewrite.analysis.controlflow.ControlFlowNode.BasicBlock.class::cast)
.collect(Collectors.toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public GlobalDataFlow.Summary summary(Cursor cursor) {
}
return DataFlowNode
.of(cursor)
.map(n -> (GlobalDataFlow.Summary) new ResultSummary(n, prunedParticipatingNodes))
.map(org.openrewrite.analysis.dataflow.global.GlobalDataFlow.Summary.class::cast)
timtebeek marked this conversation as resolved.
Show resolved Hide resolved
.orSome(AlwaysFalseSummary.INSTANCE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public static Set<J> find(J j, String methodPattern, boolean matchOverrides) {
)
.stream()
.filter(t -> t instanceof J.MethodInvocation || t instanceof J.MemberReference || t instanceof J.NewClass)
.map(t -> (J) t)
.map(J.class::cast)
.collect(Collectors.toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public boolean hasQualifier() {

@Override
public Option<Expr> getQualifier() {
return InstanceAccess.viewOf(cursor.getParentTreeCursor()).map(e -> (Expr) e).toOption();
return InstanceAccess.viewOf(cursor.getParentTreeCursor()).map(Expr.class::cast).toOption();
}

@Override
Expand Down