use of com.intellij.structuralsearch.impl.matcher.predicates.NotPredicate in project intellij-community by JetBrains.
the class JavaMatchingVisitor method checkMatchWithinHierarchy.
private boolean checkMatchWithinHierarchy(PsiElement el2, SubstitutionHandler handler, PsiElement context) {
boolean includeInterfaces = true;
boolean includeClasses = true;
final PsiElement contextParent = context.getParent();
if (contextParent instanceof PsiReferenceList) {
final PsiElement grandParentContext = contextParent.getParent();
if (grandParentContext instanceof PsiClass) {
final PsiClass psiClass = (PsiClass) grandParentContext;
if (contextParent == psiClass.getExtendsList()) {
includeInterfaces = psiClass.isInterface();
} else if (contextParent == psiClass.getImplementsList()) {
includeClasses = false;
}
}
}
// is type2 is (strict) subtype of type
final NodeIterator node = new HierarchyNodeIterator(el2, includeClasses, includeInterfaces);
if (handler.isStrictSubtype()) {
node.advance();
}
final boolean notPredicate = handler.getPredicate() instanceof NotPredicate;
while (node.hasNext() && !handler.validate(node.current(), 0, -1, myMatchingVisitor.getMatchContext())) {
if (notPredicate)
return false;
node.advance();
}
if (node.hasNext()) {
handler.addResult(el2, 0, -1, myMatchingVisitor.getMatchContext());
return true;
} else {
return false;
}
}
use of com.intellij.structuralsearch.impl.matcher.predicates.NotPredicate in project intellij-community by JetBrains.
the class MatchingHandler method findRegExpPredicate.
private static MatchPredicate findRegExpPredicate(MatchPredicate start) {
if (start == null)
return null;
if (start instanceof RegExpPredicate)
return start;
if (start instanceof BinaryPredicate) {
BinaryPredicate binary = (BinaryPredicate) start;
final MatchPredicate result = findRegExpPredicate(binary.getFirst());
if (result != null)
return result;
return findRegExpPredicate(binary.getSecond());
} else if (start instanceof NotPredicate) {
return null;
}
return null;
}
Aggregations