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

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

Introduction

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

Prototype

@Override
public IType[] getAllClasses() 

Source Link

Usage

From source file:org.eclipse.ajdt.ui.tests.hierarchy.ITDAwareHierarchyTests.java

License:Open Source License

/**
 * Tests that ITD super types and super interfaces are included in the type hierarchy
 * when they are declared on the focus type
 *///from w w  w.jav a 2s. com
public void testSuperTypeHierarchyOfFocusType() throws Exception {
    TypeHierarchy hierarchy = new TypeHierarchy(ship.findPrimaryType(), new ICompilationUnit[] { ship, yacht },
            shipProj, false);
    hierarchy.refresh(null);
    IType[] allClasses = hierarchy.getAllClasses();
    assertEquals(3, allClasses.length);
    arrayContains("Object", allClasses);
    arrayContains("FloatingThing", allClasses);
    arrayContains("Ship", allClasses);

    IType[] allInterfaces = hierarchy.getAllInterfaces();
    assertEquals(1, allInterfaces.length);
    arrayContains("Log", allInterfaces);
}

From source file:org.eclipse.ajdt.ui.tests.hierarchy.ITDAwareHierarchyTests.java

License:Open Source License

/**
 * Tests that ITD super types and super interfaces are included in the type hierarchy
 * when they are declared on the non-focus type
 *///from  w  w w .jav a2 s. c  om
public void testSuperTypeHierarchyOfNonFocusType() throws Exception {
    TypeHierarchy hierarchy = new TypeHierarchy(yacht.findPrimaryType(), new ICompilationUnit[] { ship, yacht },
            shipProj, false);
    hierarchy.refresh(null);
    IType[] allClasses = hierarchy.getAllClasses();
    assertEquals(4, allClasses.length);
    arrayContains("Object", allClasses);
    arrayContains("FloatingThing", allClasses);
    arrayContains("Ship", allClasses);
    arrayContains("Yacht", allClasses);

    IType[] allInterfaces = hierarchy.getAllInterfaces();
    assertEquals(1, allInterfaces.length);
    arrayContains("Log", allInterfaces);
}

From source file:org.eclipse.ajdt.ui.tests.hierarchy.ITDAwareHierarchyTests2.java

License:Open Source License

public void testAbstractAspectWithDeclare() throws Exception {
    ICompilationUnit[] units = createUnits(new String[] { "p" }, new String[] { "AbstractAspect.aj" },
            new String[] { "package p;\n" + "public abstract aspect AbstractAspect {\n"
                    + "declare parents : Class extends X;\n" + "declare parents : Class extends Y;\n" + "}\n"
                    + "aspect Aspect extends AbstractAspect {\n" + "    void something(X x) {\n"
                    + "       something(new Class());\n" + "    }\n" + "    void something2(Y y) {\n"
                    + "        something2(new Class());\n" + "    }\n" + "}\n" + "interface X { }\n"
                    + "interface Y { }\n" + "class Class { }" },
            proj);/*from  www . j  a  va  2  s  .  c  o  m*/

    IType clazz = units[0].getType("Class");

    TypeHierarchy hierarchy = new TypeHierarchy(clazz, units, proj, false);
    hierarchy.refresh(null);
    IType[] allClasses = hierarchy.getAllClasses();
    assertEquals(2, allClasses.length);
    arrayContains("Object", allClasses);
    arrayContains("Class", allClasses);

    IType[] allInterfaces = hierarchy.getAllInterfaces();
    assertEquals(2, allInterfaces.length);
    arrayContains("X", allInterfaces);
    arrayContains("Y", allInterfaces);
}

From source file:org.eclipse.ajdt.ui.tests.hierarchy.ITDAwareHierarchyTests2.java

License:Open Source License

public void testAbstractGenericAspectWithDeclare() throws Exception {
    ICompilationUnit[] units = createUnits(new String[] { "p" }, new String[] { "AbstractAspect.aj" },
            new String[] { "package p;\n" + "public abstract aspect AbstractAspect<S, T> {\n"
                    + "declare parents : Class extends S;\n" + "declare parents : Class extends T;\n" + "}\n"
                    + "aspect Aspect extends AbstractAspect<X, Y> {\n" + "    void something(X x) {\n"
                    + "       something(new Class());\n" + "    }\n" + "    void something2(Y y) {\n"
                    + "        something2(new Class());\n" + "    }\n" + "}\n" + "interface X { }\n"
                    + "interface Y { }\n" + "class Class { }" },
            proj);// www .j av  a 2 s. c o  m

    IType clazz = units[0].getType("Class");

    TypeHierarchy hierarchy = new TypeHierarchy(clazz, units, proj, false);
    hierarchy.refresh(null);
    IType[] allClasses = hierarchy.getAllClasses();
    assertEquals(2, allClasses.length);
    arrayContains("Object", allClasses);
    arrayContains("Class", allClasses);

    IType[] allInterfaces = hierarchy.getAllInterfaces();
    assertEquals(2, allInterfaces.length);
    arrayContains("X", allInterfaces);
    arrayContains("Y", allInterfaces);
}

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

License:Open Source License

public void testGetAllClasses_T1R1() throws JavaModelException {
    _focusType = _T1R1;//from  w w  w .  j ava  2 s  .c  o m

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

    IType[] actual = hierarchy.getAllClasses();
    IType[] expected = new IType[] { _T1R1, _T2R1, _T3R1, _objectType };

    assertEquals(expected.length, actual.length);
    assertTrue(compareTypes(expected, actual));
}

From source file:org.eclipse.objectteams.otdt.tests.superhierarchy.OTSuperTypeHierarchyTest013.java

License:Open Source License

public void testGetAllClasses_TA2TB2TC2R1() throws JavaModelException {
    _focusType = _TA2TB2TC2R1;/*from   w ww.  j  a v  a  2s.  co  m*/

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

    IType[] actual = hierarchy.getAllClasses();
    IType[] expected = new IType[] { _TA1TB2TC2R1, _TA1TB2TC1R1, _TA1TB1TC2R1, _TA1TB1TC1R1, _TA2TB2TC2R1,
            _TA2TB2TC1R1, _TA2TB1TC2R1, _TA2TB1TC1R1, _C0, _C1, _C2, // illegal inheritance, causes incompatible supers
            _C3, // illegal inheritance, causes incompatible supers
            _objectType };

    assertEquals(expected.length, actual.length);
    assertTrue(compareTypes(expected, actual));
}