blob: b7d5432964d4e0830057ec95bcd2eb8004d504e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package com.intellij.structuralsearch.impl.matcher.predicates;
import com.intellij.psi.PsiElement;
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
import com.intellij.structuralsearch.impl.matcher.MatchContext;
/**
* Binary predicate
*/
public final class BinaryPredicate extends MatchPredicate {
private final MatchPredicate first;
private final MatchPredicate second;
private final boolean or;
public BinaryPredicate(MatchPredicate first, MatchPredicate second, boolean or) {
this.first = first;
this.second = second;
this.or = or;
}
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
if (or) {
return first.match(patternNode,matchedNode,context) ||
second.match(patternNode,matchedNode,context);
} else {
return first.match(patternNode,matchedNode,context) &&
second.match(patternNode,matchedNode,context);
}
}
public MatchPredicate getFirst() {
return first;
}
public MatchPredicate getSecond() {
return second;
}
}
|