Java 类com.intellij.psi.HierarchicalMethodSignature 实例源码

项目:intellij-ce-playground    文件:ClashingTraitMethodsInspectionBase.java   
@NotNull
protected static List<ClashingMethod> collectClassingMethods(@NotNull GrTypeDefinition typeDefinition) {
  Collection<HierarchicalMethodSignature> visibleSignatures = typeDefinition.getVisibleSignatures();

  List<ClashingMethod> clashingMethods = ContainerUtil.newArrayList();
  for (HierarchicalMethodSignature signature : visibleSignatures) {
    PsiMethod method = signature.getMethod();
    if (method instanceof GrTraitMethod && method.getContainingClass() == typeDefinition) {
      List<HierarchicalMethodSignature> superSignatures = signature.getSuperSignatures();
      if (superSignatures.size() > 1) {
        List<GrTypeDefinition> traits = ContainerUtil.newArrayList();
        for (HierarchicalMethodSignature superSignature : superSignatures) {
          PsiMethod superMethod = superSignature.getMethod();
          PsiClass superClass = superMethod.getContainingClass();
          if (GrTraitUtil.isTrait(superClass) &&
              !superMethod.getModifierList().hasExplicitModifier(PsiModifier.ABSTRACT)) {
            traits.add((GrTypeDefinition)superClass);
          }
        }

        if (traits.size() > 1) {
          clashingMethods.add(new ClashingMethod(signature, traits));
        }
      }
    }
  }

  return clashingMethods;
}
项目:consulo-java    文件:MethodSuperSearcher.java   
@Override
public boolean execute(@NotNull final SuperMethodsSearch.SearchParameters queryParameters, @NotNull final Processor<MethodSignatureBackedByPsiMethod> consumer)
{
    final PsiClass parentClass = queryParameters.getPsiClass();
    final PsiMethod method = queryParameters.getMethod();
    return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>()
    {
        @Override
        public Boolean compute()
        {
            HierarchicalMethodSignature signature = method.getHierarchicalMethodSignature();

            final boolean checkBases = queryParameters.isCheckBases();
            final boolean allowStaticMethod = queryParameters.isAllowStaticMethod();
            final List<HierarchicalMethodSignature> supers = signature.getSuperSignatures();
            for(HierarchicalMethodSignature superSignature : supers)
            {
                if(MethodSignatureUtil.isSubsignature(superSignature, signature))
                {
                    if(!addSuperMethods(superSignature, method, parentClass, allowStaticMethod, checkBases, consumer))
                    {
                        return false;
                    }
                }
            }

            return true;
        }
    });
}
项目:consulo-java    文件:MethodSuperSearcher.java   
private static boolean addSuperMethods(final HierarchicalMethodSignature signature,
        final PsiMethod method,
        final PsiClass parentClass,
        final boolean allowStaticMethod,
        final boolean checkBases,
        final Processor<MethodSignatureBackedByPsiMethod> consumer)
{
    PsiMethod signatureMethod = signature.getMethod();
    PsiClass hisClass = signatureMethod.getContainingClass();
    if(parentClass == null || InheritanceUtil.isInheritorOrSelf(parentClass, hisClass, true))
    {
        if(isAcceptable(signatureMethod, method, allowStaticMethod))
        {
            if(parentClass != null && !parentClass.equals(hisClass) && !checkBases)
            {
                return true;
            }
            LOG.assertTrue(signatureMethod != method, method); // method != method.getsuper()
            return consumer.process(signature); //no need to check super classes
        }
    }
    for(HierarchicalMethodSignature superSignature : signature.getSuperSignatures())
    {
        if(MethodSignatureUtil.isSubsignature(superSignature, signature))
        {
            addSuperMethods(superSignature, method, parentClass, allowStaticMethod, checkBases, consumer);
        }
    }

    return true;
}
项目:consulo-java    文件:ClassUtil.java   
@Nullable
private static PsiMethod checkPackageLocalInSuperClass(@NotNull PsiClass aClass) {
  // super class can have package local abstract methods not accessible for overriding
  PsiClass superClass = aClass.getSuperClass();
  if (superClass == null) return null;
  if (CommonClassNames.JAVA_LANG_OBJECT.equals(aClass.getQualifiedName())) return null;
  if (JavaPsiFacade.getInstance(aClass.getProject()).arePackagesTheSame(aClass, superClass)) return null;

  for (HierarchicalMethodSignature methodSignature : superClass.getVisibleSignatures()) {
    PsiMethod method = methodSignature.getMethod();
    if (method.hasModifierProperty(PsiModifier.ABSTRACT) && method.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) return method;
  }
  return null;
}
项目:intellij-ce-playground    文件:HierarchicalMethodSignatureImpl.java   
public void addSuperSignature(@NotNull HierarchicalMethodSignature superSignatureHierarchical) {
  if (mySupers == null) mySupers = new SmartList<HierarchicalMethodSignature>();
  mySupers.add(superSignatureHierarchical);
}
项目:intellij-ce-playground    文件:HierarchicalMethodSignatureImpl.java   
@Override
@NotNull
public List<HierarchicalMethodSignature> getSuperSignatures() {
  return mySupers == null ? Collections.<HierarchicalMethodSignature>emptyList() : mySupers;
}
项目:intellij-ce-playground    文件:ClashingTraitMethodsInspectionBase.java   
public ClashingMethod(@NotNull HierarchicalMethodSignature signature, @NotNull List<GrTypeDefinition> superTraits) {
  mySignature = signature;
  mySuperTraits = superTraits;
}
项目:intellij-ce-playground    文件:ClashingTraitMethodsInspectionBase.java   
@NotNull
public HierarchicalMethodSignature getSignature() {
  return mySignature;
}
项目:tools-idea    文件:HierarchicalMethodSignatureImpl.java   
public void addSuperSignature(@NotNull HierarchicalMethodSignature superSignatureHierarchical) {
  if (mySupers == null) mySupers = new SmartList<HierarchicalMethodSignature>();
  mySupers.add(superSignatureHierarchical);
}
项目:tools-idea    文件:HierarchicalMethodSignatureImpl.java   
@Override
@NotNull
public List<HierarchicalMethodSignature> getSuperSignatures() {
  return mySupers == null ? Collections.<HierarchicalMethodSignature>emptyList() : mySupers;
}
项目:consulo-java    文件:HierarchicalMethodSignatureImpl.java   
public void addSuperSignature(@NotNull HierarchicalMethodSignature superSignatureHierarchical) {
  if (mySupers == null) mySupers = new SmartList<HierarchicalMethodSignature>();
  mySupers.add(superSignatureHierarchical);
}
项目:consulo-java    文件:HierarchicalMethodSignatureImpl.java   
@Override
@NotNull
public List<HierarchicalMethodSignature> getSuperSignatures() {
  return mySupers == null ? Collections.<HierarchicalMethodSignature>emptyList() : mySupers;
}