mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: split off matching handler hierarchy from predicates
This commit is contained in:
+1
-2
@@ -18,12 +18,11 @@ package com.intellij.structuralsearch.impl.matcher;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.structuralsearch.MatchOptions;
|
||||
import com.intellij.structuralsearch.MatchVariableConstraint;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class JavaMatchPredicateProvider extends MatchPredicateProvider{
|
||||
public class JavaMatchPredicateProvider extends MatchPredicateProvider {
|
||||
@Override
|
||||
public void collectPredicates(MatchVariableConstraint constraint, String name, MatchOptions options, Set<MatchPredicate> predicates) {
|
||||
if (!StringUtil.isEmptyOrSpaces(constraint.getNameOfExprType())) {
|
||||
|
||||
+1
-1
@@ -25,11 +25,11 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.structuralsearch.MatchOptions;
|
||||
import com.intellij.structuralsearch.MatchResult;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler;
|
||||
import com.intellij.structuralsearch.impl.matcher.iterators.DocValuesIterator;
|
||||
import com.intellij.structuralsearch.impl.matcher.iterators.HierarchyNodeIterator;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.MatchPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.NotPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate;
|
||||
import com.intellij.util.SmartList;
|
||||
|
||||
+1
-2
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package com.intellij.structuralsearch.impl.matcher.predicates;
|
||||
|
||||
import com.intellij.dupLocator.iterators.NodeIterator;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.iterators.HierarchyNodeIterator;
|
||||
import com.intellij.dupLocator.iterators.NodeIterator;
|
||||
|
||||
/**
|
||||
* @author Maxim.Mossienko
|
||||
|
||||
+16
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.predicates;
|
||||
|
||||
import com.intellij.psi.PsiExpression;
|
||||
@@ -11,6 +26,7 @@ public class FormalArgTypePredicate extends ExprTypePredicate {
|
||||
super(type, baseName, withinHierarchy, caseSensitiveMatch, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiType evalType(PsiExpression match, MatchContext context) {
|
||||
return ExpectedTypeUtils.findExpectedType(match, true, true);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<extensionPoint qualifiedName="com.intellij.structuralsearch.profile"
|
||||
interface="com.intellij.structuralsearch.StructuralSearchProfile"/>
|
||||
<extensionPoint qualifiedName="com.intellij.structuralsearch.matchPredicateProvider"
|
||||
interface="com.intellij.structuralsearch.impl.matcher.MatchPredicateProvider"/>
|
||||
interface="com.intellij.structuralsearch.impl.matcher.predicates.MatchPredicateProvider"/>
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
||||
-2
@@ -35,11 +35,9 @@ import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.structuralsearch.*;
|
||||
import com.intellij.structuralsearch.impl.matcher.CompiledPattern;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchPredicateProvider;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil;
|
||||
import com.intellij.structuralsearch.impl.matcher.PatternTreeContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.*;
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.intellij.structuralsearch.impl.matcher.handlers;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
|
||||
/**
|
||||
* Root of handlers for pattern node matching. Handles simpliest type of the match.
|
||||
*/
|
||||
public abstract class MatchPredicate {
|
||||
/**
|
||||
* Matches given handler node against given value.
|
||||
* @param matchedNode for matching
|
||||
* @param context of the matching
|
||||
* @return true if matching was successfull and false otherwise
|
||||
*/
|
||||
public boolean match(PsiElement patternNode,PsiElement matchedNode, int start, int end, MatchContext context) {
|
||||
return match(patternNode,matchedNode,context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches given handler node against given value.
|
||||
* @param matchedNode for matching
|
||||
* @param context of the matching
|
||||
* @return true if matching was successfull and false otherwise
|
||||
*/
|
||||
public abstract boolean match(PsiElement patternNode,PsiElement matchedNode, MatchContext context);
|
||||
}
|
||||
+4
-4
@@ -17,13 +17,15 @@ package com.intellij.structuralsearch.impl.matcher.handlers;
|
||||
|
||||
import com.intellij.dupLocator.iterators.NodeIterator;
|
||||
import com.intellij.dupLocator.util.NodeFilter;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
|
||||
import com.intellij.structuralsearch.StructuralSearchUtil;
|
||||
import com.intellij.structuralsearch.impl.matcher.CompiledPattern;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchResultImpl;
|
||||
import com.intellij.structuralsearch.impl.matcher.filters.DefaultFilter;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.BinaryPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.MatchPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.NotPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.strategies.MatchingStrategy;
|
||||
@@ -34,7 +36,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Root of handlers for pattern node matching. Handles simplest type of the match.
|
||||
*/
|
||||
public abstract class MatchingHandler extends MatchPredicate {
|
||||
public abstract class MatchingHandler {
|
||||
protected NodeFilter filter;
|
||||
private PsiElement pinnedElement;
|
||||
|
||||
@@ -48,7 +50,6 @@ public abstract class MatchingHandler extends MatchPredicate {
|
||||
* @param context of the matching
|
||||
* @return true if matching was successful and false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean match(PsiElement patternNode, PsiElement matchedNode, int start, int end, MatchContext context) {
|
||||
return match(patternNode,matchedNode,context);
|
||||
}
|
||||
@@ -59,7 +60,6 @@ public abstract class MatchingHandler extends MatchPredicate {
|
||||
* @param context of the matching
|
||||
* @return true if matching was successful and false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
|
||||
if (patternNode == null) {
|
||||
return matchedNode == null;
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import com.intellij.structuralsearch.StructuralSearchUtil;
|
||||
import com.intellij.structuralsearch.impl.matcher.CompiledPattern;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchResultImpl;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.MatchPredicate;
|
||||
import com.intellij.structuralsearch.plugin.ui.Configuration;
|
||||
import com.intellij.structuralsearch.plugin.util.SmartPsiPointer;
|
||||
|
||||
|
||||
+16
-1
@@ -1,8 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.predicates;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
|
||||
/**
|
||||
* @author Maxim.Mossienko
|
||||
@@ -16,6 +30,7 @@ public class AbstractStringBasedPredicate extends MatchPredicate {
|
||||
myWithin = within;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
|
||||
return match(patternNode, matchedNode, 0, -1, context);
|
||||
}
|
||||
|
||||
-4
@@ -17,11 +17,7 @@ package com.intellij.structuralsearch.impl.matcher.predicates;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
|
||||
/**
|
||||
* Binary predicate
|
||||
*/
|
||||
public final class BinaryPredicate extends MatchPredicate {
|
||||
private final MatchPredicate first;
|
||||
private final MatchPredicate second;
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.predicates;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
|
||||
public abstract class MatchPredicate {
|
||||
/**
|
||||
* Matches given node against this predicate.
|
||||
* @param matchedNode for matching
|
||||
* @param context of the matching
|
||||
* @return true if matching was successful, false otherwise
|
||||
*/
|
||||
public boolean match(PsiElement patternNode,PsiElement matchedNode, int start, int end, MatchContext context) {
|
||||
return match(patternNode,matchedNode,context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches given handler node against given value.
|
||||
* @param matchedNode for matching
|
||||
* @param context of the matching
|
||||
* @return true if matching was successful, false otherwise
|
||||
*/
|
||||
public abstract boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context);
|
||||
}
|
||||
+16
-2
@@ -1,9 +1,23 @@
|
||||
package com.intellij.structuralsearch.impl.matcher;
|
||||
/*
|
||||
* Copyright 2000-2017 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.predicates;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.structuralsearch.MatchOptions;
|
||||
import com.intellij.structuralsearch.MatchVariableConstraint;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
-1
@@ -17,7 +17,6 @@ package com.intellij.structuralsearch.impl.matcher.predicates;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
|
||||
/**
|
||||
* Negates predicate
|
||||
|
||||
-1
@@ -21,7 +21,6 @@ import com.intellij.structuralsearch.StructuralSearchUtil;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchResultImpl;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchUtils;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
import com.intellij.structuralsearch.plugin.util.SmartPsiPointer;
|
||||
|
||||
public final class ReferencePredicate extends MatchPredicate {
|
||||
|
||||
-1
@@ -22,7 +22,6 @@ import com.intellij.structuralsearch.StructuralSearchProfile;
|
||||
import com.intellij.structuralsearch.StructuralSearchUtil;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchResultImpl;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
import com.intellij.structuralsearch.plugin.util.SmartPsiPointer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
|
||||
-1
@@ -25,7 +25,6 @@ import com.intellij.structuralsearch.MatchOptions;
|
||||
import com.intellij.structuralsearch.MatchResult;
|
||||
import com.intellij.structuralsearch.Matcher;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
|
||||
import com.intellij.structuralsearch.plugin.ui.Configuration;
|
||||
import com.intellij.structuralsearch.plugin.ui.ConfigurationManager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user