Examples of ITypeHierarchy


Examples of org.eclipse.jdt.core.ITypeHierarchy

  /**
   * Get a hierarchy for the given type
   */
  public static ITypeHierarchy getTypeHierarchyInProject(IType type, IJavaProject project, IProgressMonitor progressMonitor) throws JavaModelException {
    ITypeHierarchy hierarchy = findTypeHierarchyInProjectInCache(type, project);
    if (hierarchy == null) {
      fgCacheMisses++;
      if (project != null) {
        hierarchy = type.newTypeHierarchy(project, progressMonitor);
      }
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;
        List<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

  private static ITypeHierarchy findTypeHierarchyInProjectInCache(IType type, IJavaProject project) {
    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 (((project == null && curr.getProject() == null) || (project != null && project.equals(curr.getProject()))) && hierarchy.contains(type)) {
            curr.markAsAccessed();
            return hierarchy;
          }
        }
      }
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

    return this;
  }
 
  public ITypeMockBuilder junit3_class() {
    setPublic();
    ITypeHierarchy typeHierarchy = mock(ITypeHierarchy.class);
    IType test = mock(IType.class);
    when(test.getFullyQualifiedName()).thenReturn(JavaTypes.TEST_INTERFACE_NAME);
    when(test.getFullyQualifiedName(anyChar())).thenReturn(JavaTypes.TEST_INTERFACE_NAME);
    when(typeHierarchy.getAllInterfaces()).thenReturn(new IType[]{test });
    try {
      when(result.newSupertypeHierarchy((IProgressMonitor)any())).thenReturn(typeHierarchy);
    } catch (JavaModelException e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

 
  @Test
  public void junit3_class_should_extends_junit_framework_Test() throws Exception {
   
    IType result = builder.junit3_class().build();
    ITypeHierarchy hierarchy = result.newSupertypeHierarchy(new NullProgressMonitor());
    IType[] interfaces = hierarchy.getAllInterfaces();
    for (IType type : interfaces) {
      if(type.getFullyQualifiedName().equals(JavaTypes.TEST_INTERFACE_NAME)){
        return;
      }
    }
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

  public static final String TEST_INTERFACE_NAME= "junit.framework.Test"; //$NON-NLS-1$
  private static final String TEST_ANNOTATION_NAME = "Test"; //$NON-NLS-1$
  static final String TEST_ANNOTATION_FULL_NAME = "org.junit.Test"; //$NON-NLS-1$

    public static boolean isTest(IType type) throws JavaModelException {
    ITypeHierarchy typeHier= type.newSupertypeHierarchy(null);
    IType[] superInterfaces= typeHier.getAllInterfaces();
    for (int i= 0; i < superInterfaces.length; i++) {
      if (superInterfaces[i].getFullyQualifiedName(ENCLOSING_TYPE_SEPARATOR).equals(TEST_INTERFACE_NAME))
        return true;
    }
    IMethod[] methods = type.getMethods();
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

        }
        return cu != null ? cu.findPrimaryType() : null;
    }
   
    public static boolean isTestClass(IType type) throws JavaModelException {
        ITypeHierarchy superTypeHierarchy = type.newSupertypeHierarchy(null);
        IType superTypes[] = superTypeHierarchy.getAllInterfaces();
        for (int i = 0; i < superTypes.length; ++i) {
            IType superType = superTypes[i];
            if (superType.getFullyQualifiedName().equals(JavaTypes.TEST_INTERFACE_NAME))
                return true;
        }
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

        }
   
        if (toStringMethod(type).exists()) {
            return;
        }
        ITypeHierarchy supertypes = type.newSupertypeHierarchy(null);
        IType[] allSuperclasses = supertypes.getAllSuperclasses(type);
        for(IType superclass: allSuperclasses) {
            if ("Ljava/lang/Object;".equals(superclass.getKey())) {
                continue;
            }
            if (toStringMethod(superclass).exists()) {
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

        else
        {
            this.kind = JavaTypeKind.CLASS;
        }
       
        final ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy( null );
       
        final IType base = typeHierarchy.getSuperclass( type );
       
        if( base != null )
        {
            this.base = new JdtJavaType( base );
        }
        else
        {
            this.base = null;
        }
       
        final Set<JavaType> interfaces = new HashSet<JavaType>();
       
        for( IType i : typeHierarchy.getSuperInterfaces( type ) )
        {
            interfaces.add( new JdtJavaType( i ) );
        }
       
        this.interfaces = Collections.unmodifiableSet( interfaces );
View Full Code Here

Examples of org.eclipse.jdt.core.ITypeHierarchy

    fLink.setLayoutData(gd);
    updateBuildPathMessage();
  }

  private void createConstructor(IType type, ImportsManager imports) throws CoreException {
    ITypeHierarchy typeHierarchy = null;
    IType[] superTypes = null;
    String content;
    IMethod methodTemplate = null;
    if (type.exists()) {
      typeHierarchy = type.newSupertypeHierarchy(null);
      superTypes = typeHierarchy.getAllSuperclasses(type);
      for (IType superType : superTypes) {
        if (superType.exists()) {
          IMethod constrMethod = superType.getMethod(superType.getElementName(),
              new String[] { "Ljava.lang.String;" }); //$NON-NLS-1$
          if (constrMethod.exists() && constrMethod.isConstructor()) {
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.