+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.structuralsearch.impl.matcher;
import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator;
return false;
}
final MatchingHandler matchingHandler = pattern.getHandler(patternNode);
- if (matchingHandler == null || !matchingHandler.canMatch(patternNode, matchedNode)) {
+ if (matchingHandler == null || !matchingHandler.canMatch(patternNode, matchedNode, context)) {
return false;
}
matchedNodes.advance();
MatchingHandler handler = null;
while (element.getClass() == targetNode.getClass() ||
- compiledPattern.isTypedVar(targetNode) && compiledPattern.getHandler(targetNode).canMatch(targetNode, element)) {
+ compiledPattern.isTypedVar(targetNode) && compiledPattern.getHandler(targetNode).canMatch(targetNode, element, matchContext)) {
handler = compiledPattern.getHandler(targetNode);
handler.setPinnedElement(element);
elementToStartMatching = element;
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.structuralsearch.impl.matcher.handlers;
import com.intellij.psi.PsiElement;
myDelegate = delegate;
}
+ @Override
public boolean match(final PsiElement patternNode, final PsiElement matchedNode, final MatchContext matchContext) {
return myDelegate.match(patternNode, matchedNode, matchContext);
}
@Override
- public boolean canMatch(PsiElement patternNode, PsiElement matchedNode) {
- return myDelegate.canMatch(patternNode, matchedNode);
+ public boolean canMatch(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
+ return myDelegate.canMatch(patternNode, matchedNode, context);
}
@Override
return myDelegate.matchSequentially(nodes, nodes2, context);
}
+ @Override
public boolean match(final PsiElement patternNode,
final PsiElement matchedNode, final int start, final int end, final MatchContext context) {
return myDelegate.match(patternNode, matchedNode, start, end, context);
}
+ @Override
public boolean isMatchSequentiallySucceeded(final NodeIterator nodes2) {
return true;
}
return myDelegate.shouldAdvanceTheMatchFor(patternElement, matchedElement);
}
+ @Override
public MatchingHandler getDelegate() {
return myDelegate;
}
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.structuralsearch.impl.matcher.handlers;
import com.intellij.dupLocator.iterators.NodeIterator;
* @param context of the matching
* @return true if matching was successful and false otherwise
*/
- public boolean match(PsiElement patternNode,PsiElement matchedNode, int start, int end, MatchContext context) {
+ @Override
+ public boolean match(PsiElement patternNode, PsiElement matchedNode, int start, int end, MatchContext context) {
return match(patternNode,matchedNode,context);
}
* @param context of the matching
* @return true if matching was successful and false otherwise
*/
- public boolean match(PsiElement patternNode,PsiElement matchedNode, MatchContext context) {
+ @Override
+ public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
if (patternNode == null) {
return matchedNode == null;
}
- return canMatch(patternNode, matchedNode);
+ return canMatch(patternNode, matchedNode, context);
}
- public boolean canMatch(final PsiElement patternNode, final PsiElement matchedNode) {
+ public boolean canMatch(final PsiElement patternNode, final PsiElement matchedNode, MatchContext context) {
if (filter!=null) {
return filter.accepts(matchedNode);
} else {
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.structuralsearch.impl.matcher.handlers;
import com.intellij.dupLocator.equivalence.EquivalenceDescriptor;
myDelegate = delegate;
}
+ @Override
public boolean match(PsiElement patternNode, PsiElement matchedNode, final MatchContext matchContext) {
if (patternNode == null || matchedNode == null || matchedNode.getClass() == patternNode.getClass()) {
return myDelegate.match(patternNode, matchedNode, matchContext);
}
@Override
- public boolean canMatch(PsiElement patternNode, PsiElement matchedNode) {
- return myDelegate.canMatch(patternNode, matchedNode);
+ public boolean canMatch(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
+ final PsiElement newPatternNode = skipNodeIfNeccessary(patternNode);
+ if (newPatternNode != patternNode) {
+ return context.getPattern().getHandler(newPatternNode).canMatch(newPatternNode, matchedNode, context);
+ }
+ return myDelegate.canMatch(patternNode, matchedNode, context);
}
@Override
return myDelegate.matchSequentially(nodes, nodes2, context);
}
+ @Override
public boolean match(PsiElement patternNode,
PsiElement matchedNode,
final int start,
return myDelegate.match(patternNode, matchedNode, start, end, context);
}
+ @Override
protected boolean isMatchSequentiallySucceeded(final NodeIterator nodes2) {
return myDelegate.isMatchSequentiallySucceeded(nodes2);
}
return true;
}
+ @Override
public MatchingHandler getDelegate() {
return myDelegate;
}
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.structuralsearch.impl.matcher.handlers;
import com.intellij.psi.PsiElement;
@Override
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
- return handler.canMatch(patternNode, matchedNode) && handler.handle(matchedNode, context);
+ return handler.canMatch(patternNode, matchedNode, context) && handler.handle(matchedNode, context);
}
}
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.structuralsearch.impl.matcher.handlers;
import com.intellij.dupLocator.iterators.NodeIterator;
setFilter(_delegate.getFilter());
}
+ @Override
public boolean match(final PsiElement patternNode, final PsiElement matchedNode, final MatchContext matchContext) {
final boolean matched = delegate.match(patternNode, matchedNode, matchContext);
}
@Override
- public boolean canMatch(PsiElement patternNode, PsiElement matchedNode) {
- return delegate.canMatch(patternNode, matchedNode);
+ public boolean canMatch(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
+ return delegate.canMatch(patternNode, matchedNode, context);
}
@Override
return delegate.matchSequentially(nodes, nodes2, context);
}
+ @Override
public boolean match(final PsiElement patternNode,
final PsiElement matchedNode, final int start, final int end, final MatchContext context) {
return match(patternNode, matchedNode, context);
}
+ @Override
public boolean isMatchSequentiallySucceeded(final NodeIterator nodes2) {
return true;
}
return delegate.shouldAdvanceTheMatchFor(patternElement, matchedElement);
}
+ @Override
public MatchingHandler getDelegate() {
return delegate;
}