blob: ce25b998ba9b7b60d793899ef1789d89e1a340ca (
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
|
package com.intellij.structuralsearch.impl.matcher.predicates;
import com.intellij.psi.*;
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
import com.intellij.structuralsearch.impl.matcher.MatchContext;
import com.intellij.structuralsearch.impl.matcher.MatchUtils;
/**
* Handler for value read
*/
public final class ReadPredicate extends MatchPredicate {
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
if (matchedNode instanceof PsiIdentifier) {
matchedNode = matchedNode.getParent();
}
if (matchedNode instanceof PsiReferenceExpression &&
( !(matchedNode.getParent() instanceof PsiMethodCallExpression) &&
( !(matchedNode.getParent() instanceof PsiAssignmentExpression) ||
((PsiAssignmentExpression)matchedNode.getParent()).getLExpression() != matchedNode
)
) &&
MatchUtils.getReferencedElement(matchedNode) instanceof PsiVariable
) {
return true;
}
return false;
}
}
|