Skip to content

Commit

Permalink
Function3 footnote
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoqnc committed Jul 1, 2024
1 parent 011bc3d commit 95c88ee
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions docs/DETECTION_RULE_STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,10 @@ This creates a pattern over a single node, but the pattern can be a subtree, by
Using `includingChildren(List<IReorganizerRule> children)`, you can include other reorganizer specifications that have to be satisfied by some children of the current node. Note that you can recursively create children rules, meaning that you can specify a tree pattern of an arbitrary size.
Alternatively, you can use `withAnyNonNullChildren()` to simply guarantee that your node has at least one node child.

A last optional step specifying the pattern is to require any other condition, using `withDetectionCondition(Function3<INode, INode, List<INode>, Boolean> detectionConditionFunction)`, where `Function3` is defined as:
```java
@FunctionalInterface
public interface Function3<A1, A2, A3, R> {
R apply(A1 one, A2 two, A3 three);
}
```
A last optional step specifying the pattern is to require any other condition, using `withDetectionCondition(Function3<INode, INode, List<INode>, Boolean> detectionConditionFunction)`[^1].

[^1] : `Function3` is defined as: `@FunctionalInterface public interface Function3<A1, A2, A3, R> {R apply(A1 one, A2 two, A3 three);}`

The parameter of `withDetectionCondition` is a function `(node, parent, roots) -> {return ...}` taking the current node, its parent and the root nodes of the translation tree, and returning a boolean specifying whether the pattern is satisfied.
This step can be used to define more specific tree patterns than simply relying on a fixed pattern based on the nodes kinds, values and children.

Expand Down

0 comments on commit 95c88ee

Please sign in to comment.