本文整理汇总了Java中com.intellij.psi.util.MethodSignature.equals方法的典型用法代码示例。如果您正苦于以下问题:Java MethodSignature.equals方法的具体用法?Java MethodSignature.equals怎么用?Java MethodSignature.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.MethodSignature
的用法示例。
在下文中一共展示了MethodSignature.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canImplementOverride
import com.intellij.psi.util.MethodSignature; //导入方法依赖的package包/类
private static boolean canImplementOverride(final MethodHierarchyNodeDescriptor descriptor, final MethodHierarchyBrowser methodHierarchyBrowser, final boolean toImplement) {
final PsiElement psiElement = descriptor.getPsiClass();
if (!(psiElement instanceof PsiClass)) return false;
final PsiClass psiClass = (PsiClass)psiElement;
if (psiClass instanceof PsiSyntheticClass) return false;
final PsiMethod baseMethod = methodHierarchyBrowser.getBaseMethod();
if (baseMethod == null) return false;
final MethodSignature signature = baseMethod.getSignature(PsiSubstitutor.EMPTY);
Collection<MethodSignature> allOriginalSignatures = toImplement
? OverrideImplementUtil.getMethodSignaturesToImplement(psiClass)
: OverrideImplementUtil.getMethodSignaturesToOverride(psiClass);
for (final MethodSignature originalSignature : allOriginalSignatures) {
if (originalSignature.equals(signature)) {
return true;
}
}
return false;
}
示例2: findSubmemberHidesMemberCollisions
import com.intellij.psi.util.MethodSignature; //导入方法依赖的package包/类
private static void findSubmemberHidesMemberCollisions(final PsiMethod method, final String newName, final List<UsageInfo> result) {
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null) return;
if (method.hasModifierProperty(PsiModifier.PRIVATE)) return;
Collection<PsiClass> inheritors = ClassInheritorsSearch.search(containingClass, true).findAll();
MethodSignature oldSignature = method.getSignature(PsiSubstitutor.EMPTY);
MethodSignature newSignature = MethodSignatureUtil.createMethodSignature(newName, oldSignature.getParameterTypes(),
oldSignature.getTypeParameters(),
oldSignature.getSubstitutor(),
method.isConstructor());
for (PsiClass inheritor : inheritors) {
PsiSubstitutor superSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(containingClass, inheritor, PsiSubstitutor.EMPTY);
final PsiMethod[] methodsByName = inheritor.findMethodsByName(newName, false);
for (PsiMethod conflictingMethod : methodsByName) {
if (newSignature.equals(conflictingMethod.getSignature(superSubstitutor))) {
result.add(new SubmemberHidesMemberUsageInfo(conflictingMethod, method));
break;
}
}
}
}
示例3: canImplementOverride
import com.intellij.psi.util.MethodSignature; //导入方法依赖的package包/类
private static boolean canImplementOverride(final MethodHierarchyNodeDescriptor descriptor, final MethodHierarchyBrowser methodHierarchyBrowser, final boolean toImplement) {
final PsiClass psiClass = descriptor.getPsiClass();
if (psiClass == null || psiClass instanceof JspClass) return false;
final PsiMethod baseMethod = methodHierarchyBrowser.getBaseMethod();
if (baseMethod == null) return false;
final MethodSignature signature = baseMethod.getSignature(PsiSubstitutor.EMPTY);
Collection<MethodSignature> allOriginalSignatures = toImplement
? OverrideImplementUtil.getMethodSignaturesToImplement(psiClass)
: OverrideImplementUtil.getMethodSignaturesToOverride(psiClass);
for (final MethodSignature originalSignature : allOriginalSignatures) {
if (originalSignature.equals(signature)) {
return true;
}
}
return false;
}
示例4: visitMethod
import com.intellij.psi.util.MethodSignature; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return;
}
if (method.getNameIdentifier() == null) {
return;
}
final String methodName = method.getName();
final MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
PsiClass ancestorClass = aClass.getSuperClass();
final Set<PsiClass> visitedClasses = new HashSet<PsiClass>();
while (ancestorClass != null) {
if (!visitedClasses.add(ancestorClass)) {
return;
}
final PsiMethod[] methods =
ancestorClass.findMethodsByName(methodName, false);
for (final PsiMethod testMethod : methods) {
final MethodSignature testSignature = testMethod.getSignature(PsiSubstitutor.EMPTY);
if (!signature.equals(testSignature)) {
continue;
}
if (testMethod.hasModifierProperty(PsiModifier.STATIC) &&
!testMethod.hasModifierProperty(PsiModifier.PRIVATE)) {
registerMethodError(method);
return;
}
}
ancestorClass = ancestorClass.getSuperClass();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:MethodOverridesStaticMethodInspectionBase.java
示例5: findMethodsBySignature
import com.intellij.psi.util.MethodSignature; //导入方法依赖的package包/类
@NotNull
private static List<PsiMethod> findMethodsBySignature(@NotNull PsiClass aClass, @NotNull PsiMethod patternMethod, boolean checkBases, boolean stopOnFirst)
{
final PsiMethod[] methodsByName = aClass.findMethodsByName(patternMethod.getName(), checkBases);
if(methodsByName.length == 0)
{
return Collections.emptyList();
}
final List<PsiMethod> methods = new SmartList<PsiMethod>();
final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY);
for(final PsiMethod method : methodsByName)
{
final PsiClass superClass = method.getContainingClass();
final PsiSubstitutor substitutor = checkBases && !aClass.equals(superClass) && superClass != null ? TypeConversionUtil.getSuperClassSubstitutor(superClass, aClass, PsiSubstitutor.EMPTY)
: PsiSubstitutor.EMPTY;
final MethodSignature signature = method.getSignature(substitutor);
if(signature.equals(patternSignature))
{
methods.add(method);
if(stopOnFirst)
{
break;
}
}
}
return methods;
}
示例6: canImplementOverride
import com.intellij.psi.util.MethodSignature; //导入方法依赖的package包/类
private static boolean canImplementOverride(final MethodHierarchyNodeDescriptor descriptor, final MethodHierarchyBrowser methodHierarchyBrowser, final boolean toImplement)
{
final PsiElement psiElement = descriptor.getPsiClass();
if(!(psiElement instanceof PsiClass))
{
return false;
}
final PsiClass psiClass = (PsiClass) psiElement;
if(psiClass instanceof PsiSyntheticClass)
{
return false;
}
final PsiMethod baseMethod = methodHierarchyBrowser.getBaseMethod();
if(baseMethod == null)
{
return false;
}
final MethodSignature signature = baseMethod.getSignature(PsiSubstitutor.EMPTY);
Collection<MethodSignature> allOriginalSignatures = toImplement ? OverrideImplementUtil.getMethodSignaturesToImplement(psiClass) : OverrideImplementUtil.getMethodSignaturesToOverride
(psiClass);
for(final MethodSignature originalSignature : allOriginalSignatures)
{
if(originalSignature.equals(signature))
{
return true;
}
}
return false;
}
示例7: isInNonNlsEquals
import com.intellij.psi.util.MethodSignature; //导入方法依赖的package包/类
private static boolean isInNonNlsEquals(PsiExpression expression, final Set<PsiModifierListOwner> nonNlsTargets) {
if (!(expression.getParent().getParent() instanceof PsiMethodCallExpression)) {
return false;
}
final PsiMethodCallExpression call = (PsiMethodCallExpression)expression.getParent().getParent();
final PsiReferenceExpression methodExpression = call.getMethodExpression();
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (qualifier != expression) {
return false;
}
if (!"equals".equals(methodExpression.getReferenceName())) {
return false;
}
final PsiElement resolved = methodExpression.resolve();
if (!(resolved instanceof PsiMethod)) {
return false;
}
PsiType objectType = PsiType.getJavaLangObject(resolved.getManager(), resolved.getResolveScope());
MethodSignature equalsSignature = MethodSignatureUtil.createMethodSignature("equals",
new PsiType[]{objectType},
PsiTypeParameter.EMPTY_ARRAY,
PsiSubstitutor.EMPTY);
if (!equalsSignature.equals(((PsiMethod)resolved).getSignature(PsiSubstitutor.EMPTY))) {
return false;
}
final PsiExpression[] expressions = call.getArgumentList().getExpressions();
if (expressions.length != 1) {
return false;
}
final PsiExpression arg = expressions[0];
PsiReferenceExpression ref = null;
if (arg instanceof PsiReferenceExpression) {
ref = (PsiReferenceExpression)arg;
}
else if (arg instanceof PsiMethodCallExpression) ref = ((PsiMethodCallExpression)arg).getMethodExpression();
if (ref != null) {
final PsiElement resolvedEntity = ref.resolve();
if (resolvedEntity instanceof PsiModifierListOwner) {
PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)resolvedEntity;
if (annotatedAsNonNls(modifierListOwner)) {
return true;
}
nonNlsTargets.add(modifierListOwner);
}
}
return false;
}