Пример #1
0
  /** Checks if the given <code>type</code> implements/extends <code>className</code>. */
  public static boolean doesImplement(IResource resource, IType type, String className) {
    if (resource == null || type == null || className == null) {
      return false;
    }
    if (className.startsWith("java.") || className.startsWith("javax.")) {
      try {
        ClassLoader cls = getClassLoader(resource.getProject(), null);
        Class<?> typeClass = cls.loadClass(type.getFullyQualifiedName('$'));
        Class<?> interfaceClass = cls.loadClass(className);
        return typeClass.equals(interfaceClass) || interfaceClass.isAssignableFrom(typeClass);
      } catch (Throwable e) {
        // ignore this and fall back to JDT does implement checks
      }
    }

    if (System.getProperty(TypeHierarchyEngine.ENABLE_PROPERTY, "true").equals("true")) {
      return SpringCore.getTypeHierarchyEngine().doesImplement(type, className, true)
          || SpringCore.getTypeHierarchyEngine().doesExtend(type, className, true);
    } else {
      return doesImplementWithJdt(resource, type, className);
    }
  }