diff options
Diffstat (limited to 'platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptPredicate.java')
-rw-r--r-- | platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptPredicate.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptPredicate.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptPredicate.java new file mode 100644 index 000000000000..9310eb9e70a0 --- /dev/null +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptPredicate.java @@ -0,0 +1,28 @@ +package com.intellij.structuralsearch.impl.matcher.predicates; + +import com.intellij.psi.PsiElement; +import com.intellij.structuralsearch.impl.matcher.MatchContext; + +/** + * @author Maxim.Mossienko + */ +public class ScriptPredicate extends AbstractStringBasedPredicate { + private final ScriptSupport scriptSupport; + + public ScriptPredicate(String name, String within) { + super(name, within); + scriptSupport = new ScriptSupport(within, name); + } + + public boolean match(PsiElement node, PsiElement match, int start, int end, MatchContext context) { + if (match == null) return false; + + return Boolean.TRUE.equals( + Boolean.valueOf(scriptSupport.evaluate( + context.hasResult() ? context.getResult() : null, + match + )) + ); + } + +}
\ No newline at end of file |