Examples of ITypeHierarchy


Examples of org.eclipse.jdt.core.ITypeHierarchy

      if (elem instanceof ICompilationUnit) {
        ICompilationUnit unit = (ICompilationUnit) elem;
        try {
          IType primaryType = unit.findPrimaryType();
          if (primaryType != null) {
            ITypeHierarchy supertypeHierarchy = primaryType.newSupertypeHierarchy(new NullProgressMonitor());
            if (supertypeHierarchy.contains(getDefaultWOComponentType())) {
              setSuperClass(primaryType.getFullyQualifiedName(), true);
            }
          }
        } catch (JavaModelException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
     
      // auto-populate implementing interface (if selected)
      initSuperInterfaces(elem);
     
      // if the package fragment isn't set default to Main.class's package
      if (getPackageFragment() == null || getPackageFragment().isDefaultPackage()) {
        IPackageFragmentRoot froot = getPackageFragmentRoot();
        if (froot != null) {
          IJavaElement compilationUnit = findMainClass(froot);
          if (compilationUnit instanceof ICompilationUnit) {
            IType type = ((ICompilationUnit) compilationUnit).findPrimaryType();
            if (type != null) {
              setPackageFragment(type.getPackageFragment(), true);
            }
          }
        }
      }
    }
    // if the superclass isn't initialised set the default
    boolean requiresSuperclass = getSuperClass() == null || getSuperClass().matches("\\s*");
    if (!requiresSuperclass) {
      requiresSuperclass = true;
      try {
        IType supertype = getJavaProject().findType(getSuperClass());
        ITypeHierarchy supertypeHierarchy = supertype.newSupertypeHierarchy(new NullProgressMonitor());
        if (supertypeHierarchy.contains(getDefaultWOComponentType())) {
          requiresSuperclass = false;
        }
      } catch (JavaModelException e) {
        // nothing to do, invalid type
      } catch (NullPointerException e) {
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

        superclassStatus.setError(DEFAULT_SUPERCLASS_NAME + " is not on the classpath");
      }
      else {
        try {
          IType type = getJavaProject().findType(getSuperClass());
          ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
          if (!JavaModelUtil.isSuperType(typeHierarchy, getDefaultWOComponentType(), type)) {
            superclassStatus.setError("The super type must be assignable to " + DEFAULT_SUPERCLASS_NAME);
          }
        } catch (JavaModelException e) {
          System.err.println(getClass().getName() + ".superClassChanged() Failed to determine superclass hierarchy.");
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

      //}
      return type;
    }

    public List<IType> getSupertypes() throws JavaModelException {
      ITypeHierarchy typeHierarchy = SuperTypeHierarchyCache.getTypeHierarchy(_type);
      List<IType> types = new LinkedList<IType>();
      types.add(_type);
      for (IType type : typeHierarchy.getAllSupertypes(_type)) {
        types.add(type);
      }
      return types;
    }
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

      return types;
    }

    public List<IType> getSubtypesInProject(IJavaProject project) throws JavaModelException {
      //System.out.println("TypeCache.getSubtypesOf: " + type.getFullyQualifiedName() + " (hits=" + SubTypeHierarchyCache.getCacheHits() + ",misses=" + SubTypeHierarchyCache.getCacheMisses() + ")");
      ITypeHierarchy typeHierarchy = SubTypeHierarchyCache.getTypeHierarchyInProject(_type, project);
      List<IType> types = new LinkedList<IType>();
      IType[] subtypes = typeHierarchy.getAllSubtypes(_type);
      for (int subtypeNum = subtypes.length - 1; subtypeNum >= 0; subtypeNum--) {
        types.add(subtypes[subtypeNum]);
      }
      types.add(_type);
      return types;
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

    if (superclasses == null || superclasses.length == 0) {
      return true;
    }
    ICompilationUnit compilationUnit = (ICompilationUnit) javaElement;
    IType typeToCeck = compilationUnit.findPrimaryType();
    ITypeHierarchy typeHierarchy = typeToCeck.newSupertypeHierarchy(new NullProgressMonitor());
    IType[] types = typeHierarchy.getAllClasses();
    for (int i = 0; i < types.length; i++) {
      IType type = types[i];
      for (int j = 0; j < superclasses.length; j++) {
        String superclass = superclasses[j];
        if (type.getFullyQualifiedName().equals(superclass)) {
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

    MethodOverrideTester test = null;
    synchronized (fgMethodOverrideTesterCache) {
      test = fgMethodOverrideTesterCache.get(type);
    }
    if (test == null) {
      ITypeHierarchy hierarchy = getTypeHierarchy(type); // don't nest the locks
      synchronized (fgMethodOverrideTesterCache) {
        test = fgMethodOverrideTesterCache.get(type); // test again after waiting a long time for 'getTypeHierarchy'
        if (test == null) {
          test = new MethodOverrideTester(type, hierarchy);
          fgMethodOverrideTesterCache.put(type, test);
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

  /**
   * Get a hierarchy for the given type
   */
  public static ITypeHierarchy getTypeHierarchy(IType type, IProgressMonitor progressMonitor) throws JavaModelException {
    ITypeHierarchy hierarchy = findTypeHierarchyInCache(type);
    if (hierarchy == null) {
      fgCacheMisses++;
      hierarchy = type.newSupertypeHierarchy(progressMonitor);
      addTypeHierarchyToCache(hierarchy);
    } else {
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

        // find obsolete entries or remove entry that was least recently accessed
        HierarchyCacheEntry oldest = null;
        ArrayList<HierarchyCacheEntry> obsoleteHierarchies = new ArrayList<HierarchyCacheEntry>(CACHE_SIZE);
        for (int i = 0; i < nEntries; i++) {
          HierarchyCacheEntry entry = fgHierarchyCache.get(i);
          ITypeHierarchy curr = entry.getTypeHierarchy();
          if (!curr.exists() || hierarchy.contains(curr.getType())) {
            obsoleteHierarchies.add(entry);
          } else {
            if (oldest == null || entry.getLastAccess() < oldest.getLastAccess()) {
              oldest = entry;
            }
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

  protected static ITypeHierarchy findTypeHierarchyInCache(IType type) {
    synchronized (fgHierarchyCache) {
      for (int i = fgHierarchyCache.size() - 1; i >= 0; i--) {
        HierarchyCacheEntry curr = fgHierarchyCache.get(i);
        ITypeHierarchy hierarchy = curr.getTypeHierarchy();
        if (!hierarchy.exists()) {
          removeHierarchyEntryFromCache(curr);
        } else {
          if (hierarchy.contains(type)) {
            curr.markAsAccessed();
            return hierarchy;
          }
        }
      }
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

          if (compilationUnit != null) {
            IType type = compilationUnit.findPrimaryType();
            if (type != null) {
              IType woElementType = type.getJavaProject().findType("com.webobjects.appserver.WOElement", progressMonitor);
              if (woElementType != null) {
                ITypeHierarchy typeHierarchy = SuperTypeHierarchyCache.getTypeHierarchy(type, progressMonitor);
                if (typeHierarchy != null && typeHierarchy.contains(woElementType)) {
                  LocalizedComponentsLocateResult results = LocatePlugin.getDefault().getLocalizedComponentsLocateResult(resource);
                  IFile wodFile = results.getFirstWodFile();
                  if (wodFile != null && wodFile.exists()) {
                    wodFile.touch(progressMonitor);
                    validateWodFile(wodFile, progressMonitor);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.