use of com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler in project intellij-community by JetBrains.
the class XmlMatchingVisitor method visitXmlTag.
@Override
public void visitXmlTag(XmlTag tag) {
final XmlTag another = (XmlTag) myMatchingVisitor.getElement();
final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(tag.getName());
myMatchingVisitor.setResult((matches(tag.getName(), another.getName()) || isTypedVar) && myMatchingVisitor.matchInAnyOrder(tag.getAttributes(), another.getAttributes()));
if (myMatchingVisitor.getResult()) {
final XmlTagChild[] contentChildren = tag.getValue().getChildren();
if (contentChildren.length > 0) {
PsiElement[] patternNodes = contentChildren;
PsiElement[] matchedNodes = another.getValue().getChildren();
if (contentChildren.length != 1) {
patternNodes = filterOutWhitespace(patternNodes);
matchedNodes = filterOutWhitespace(matchedNodes);
}
final boolean result = myMatchingVisitor.matchSequentially(new ArrayBackedNodeIterator(patternNodes), new ArrayBackedNodeIterator(matchedNodes));
myMatchingVisitor.setResult(result);
}
}
if (myMatchingVisitor.getResult() && isTypedVar) {
final PsiElement[] children = another.getChildren();
if (children.length > 1) {
MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(tag.getName());
myMatchingVisitor.setResult(((SubstitutionHandler) handler).handle(children[1], myMatchingVisitor.getMatchContext()));
}
}
}
use of com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler in project intellij-community by JetBrains.
the class CompiledPattern method getHandler.
public MatchingHandler getHandler(PsiElement node) {
if (node == last) {
return lastHandler;
}
MatchingHandler handler = handlers.get(node);
if (handler == null) {
handler = new SimpleHandler();
setHandler(node, handler);
}
last = node;
lastHandler = handler;
return handler;
}
use of com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler in project intellij-community by JetBrains.
the class GlobalMatchingVisitor method handleTypedElement.
public final boolean handleTypedElement(final PsiElement typedElement, final PsiElement match) {
MatchingHandler handler = matchContext.getPattern().getHandler(typedElement);
final MatchingHandler initialHandler = handler;
if (handler instanceof DelegatingHandler) {
handler = ((DelegatingHandler) handler).getDelegate();
}
assert handler instanceof SubstitutionHandler : handler != null ? handler.getClass() : "null" + ' ' + (initialHandler != null ? initialHandler.getClass() : "null");
return ((SubstitutionHandler) handler).handle(match, matchContext);
}
Aggregations