diff options
Diffstat (limited to 'platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/BinaryPredicate.java')
-rw-r--r-- | platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/BinaryPredicate.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/BinaryPredicate.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/BinaryPredicate.java new file mode 100644 index 000000000000..b7d5432964d4 --- /dev/null +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/BinaryPredicate.java @@ -0,0 +1,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; + } +} |