Пример #1
0
  private boolean checkForSubType(
      TypeDeclaration curTypeDecl,
      Hashtable knownSubTypes,
      Hashtable finishedTypes,
      boolean descent) {
    if (curTypeDecl == null) {
      return false;
    }
    if (curTypeDecl == _localType) {
      return true;
    }
    if (knownSubTypes.containsKey(curTypeDecl)) {
      return true;
    }
    if (finishedTypes.containsKey(curTypeDecl)) {
      return false;
    }

    boolean result = false;

    if (curTypeDecl instanceof ClassDeclaration) {
      ClassDeclaration classDecl = (ClassDeclaration) curTypeDecl;

      if (classDecl.hasBaseClass()) {
        if (descent) {
          if (checkForSubType(
              classDecl.getBaseClass().getReferenceBaseTypeDecl(),
              knownSubTypes,
              finishedTypes,
              true)) {
            knownSubTypes.put(curTypeDecl, curTypeDecl);
            result = true;
          }
        } else {
          if (_localType == classDecl.getBaseClass().getReferenceBaseTypeDecl()) {
            knownSubTypes.put(curTypeDecl, curTypeDecl);
            result = true;
          }
        }
      }
    }
    if (!result) {
      for (TypeIterator it = curTypeDecl.getBaseInterfaces().getIterator(); it.hasNext(); ) {
        if (descent) {
          if (checkForSubType(
              it.getNext().getReferenceBaseTypeDecl(), knownSubTypes, finishedTypes, true)) {
            knownSubTypes.put(curTypeDecl, curTypeDecl);
            result = true;
          }
        } else {
          if (_localType == it.getNext().getReferenceBaseTypeDecl()) {
            knownSubTypes.put(curTypeDecl, curTypeDecl);
            result = true;
          }
        }
      }
    }
    finishedTypes.put(curTypeDecl, curTypeDecl);
    return result;
  }
Пример #2
0
  private void addPossibleBaseInterfaces(TypeDeclaration typeDecl) {
    if (typeDecl.hasBaseInterfaces()) {
      TypeDeclaration curAncestorDecl;

      for (TypeIterator iter = typeDecl.getBaseInterfaces().getIterator(); iter.hasNext(); ) {
        curAncestorDecl = iter.getNext().getReferenceBaseTypeDecl();
        if (curAncestorDecl != null) {
          _ancestors.add(curAncestorDecl);
          addAncestors((InterfaceDeclaration) curAncestorDecl);
        }
      }
    }
  }