Example usage for org.eclipse.jdt.internal.core.hierarchy TypeHierarchy getType

List of usage examples for org.eclipse.jdt.internal.core.hierarchy TypeHierarchy getType

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.hierarchy TypeHierarchy getType.

Prototype

@Override
public IType getType() 

Source Link

Usage

From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.java

License:Open Source License

public HierarchyBuilder(TypeHierarchy hierarchy) throws JavaModelException {

    this.hierarchy = hierarchy;
    JavaProject project = (JavaProject) hierarchy.javaProject();

    IType focusType = hierarchy.getType();
    org.eclipse.jdt.core.ICompilationUnit unitToLookInside = focusType == null ? null
            : focusType.getCompilationUnit();
    org.eclipse.jdt.core.ICompilationUnit[] workingCopies = this.hierarchy.workingCopies;
    org.eclipse.jdt.core.ICompilationUnit[] unitsToLookInside;
    if (unitToLookInside != null) {
        int wcLength = workingCopies == null ? 0 : workingCopies.length;
        if (wcLength == 0) {
            unitsToLookInside = new org.eclipse.jdt.core.ICompilationUnit[] { unitToLookInside };
        } else {/*from  ww  w  . j av  a2  s. c  o  m*/
            unitsToLookInside = new org.eclipse.jdt.core.ICompilationUnit[wcLength + 1];
            unitsToLookInside[0] = unitToLookInside;
            System.arraycopy(workingCopies, 0, unitsToLookInside, 1, wcLength);
        }
    } else {
        unitsToLookInside = workingCopies;
    }
    if (project != null) {
        // GROOVY start - pulled out of the call
        Map optionMap = project.getOptions(true);
        CompilerUtils.configureOptionsBasedOnNature(optionMap, project);
        // GROOVY end
        SearchableEnvironment searchableEnvironment = project.newSearchableNameEnvironment(unitsToLookInside);
        this.nameLookup = searchableEnvironment.nameLookup;
        this.hierarchyResolver = new HierarchyResolver(searchableEnvironment,
                // GROOVY start
                /* old {
                project.getOptions(true),
                } new */
                optionMap,
                // GROOVY end
                this, new DefaultProblemFactory());
    }
    this.infoToHandle = new HashMap(5);
    this.focusQualifiedName = focusType == null ? null : focusType.getFullyQualifiedName();
}

From source file:org.eclipse.objectteams.otdt.tests.subhierarchy.OTSubTypeHierarchyTest010.java

License:Open Source License

public void testGetType_T1R1() throws JavaModelException {
    _focusType = _T1R1;/*from w  w w.j a v  a2  s .c  om*/

    TypeHierarchy hierarchy = new TypeHierarchy(_focusType, null, _focusType.getJavaProject(), true);
    hierarchy.refresh(new NullProgressMonitor());

    IType actual = hierarchy.getType();
    IType expected = _focusType;

    assertTrue(compareTypes(expected, actual));
}