示例#1
0
 private static boolean derivesFrom(ICPPClassType derived, ICPPClassType target, int maxdepth) {
   if (derived == target || derived.isSameType(target)) {
     return true;
   }
   if (maxdepth > 0) {
     for (ICPPBase cppBase : derived.getBases()) {
       IBinding base = cppBase.getBaseClass();
       if (base instanceof ICPPClassType) {
         ICPPClassType tbase = (ICPPClassType) base;
         if (tbase.isSameType(target)) {
           return true;
         }
         if (derivesFrom(tbase, target, maxdepth - 1)) return true;
       }
     }
   }
   return false;
 }
示例#2
0
  private boolean isAccessible(
      IBinding binding,
      int bindingVisibility,
      ICPPClassType owner,
      ICPPClassType derivedClass,
      int accessLevel,
      int depth) {
    if (depth > CPPSemantics.MAX_INHERITANCE_DEPTH) return false;

    accessLevel = getMemberAccessLevel(derivedClass, accessLevel);
    if (owner.isSameType(derivedClass)) {
      return isAccessible(bindingVisibility, accessLevel);
    }

    ICPPBase[] bases = derivedClass.getBases();
    if (bases != null) {
      for (ICPPBase base : bases) {
        IBinding baseBinding = base.getBaseClass();
        if (baseBinding instanceof ICPPDeferredClassInstance) {
          // Support content assist for members of deferred instances.
          baseBinding = ((ICPPDeferredClassInstance) baseBinding).getTemplateDefinition();
        }
        if (!(baseBinding instanceof ICPPClassType)) {
          continue;
        }
        if (!isAccessible(base.getVisibility(), accessLevel)) {
          continue;
        }
        if (isAccessible(
            binding,
            bindingVisibility,
            owner,
            (ICPPClassType) baseBinding,
            accessLevel == v_private ? v_protected : accessLevel,
            depth + 1)) {
          return true;
        }
      }
    }
    return false;
  }
示例#3
0
  private boolean isAccessibleBaseClass(ICPPClassType classType, ICPPClassType defived, int depth) {
    if (depth > CPPSemantics.MAX_INHERITANCE_DEPTH) return false;

    if (defived.isSameType(classType)) return true;

    ICPPBase[] bases = defived.getBases();
    if (bases != null) {
      for (ICPPBase base : bases) {
        IBinding baseClass = base.getBaseClass();
        if (!(baseClass instanceof ICPPClassType)) {
          continue;
        }
        if (depth > 0 && !isAccessible(base.getVisibility(), v_protected)) {
          continue;
        }
        if (isAccessibleBaseClass(classType, (ICPPClassType) baseClass, depth + 1)) {
          return true;
        }
      }
    }
    return false;
  }