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

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

Introduction

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

Prototype

@Override
public IType[] getAllInterfaces() 

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. j  a  v  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.j a va2  s .co  m
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   ww  w.  java  2s .  co 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);// w  w  w .j  a  v  a 2s. 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 testGetAllInterfaces_interfaceA() throws JavaModelException {
    _focusType = _interfaceA;/*  w ww . j a  v  a  2s .co  m*/

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

    IType[] actual = hierarchy.getAllInterfaces();
    IType[] expected = new IType[] { _interfaceA };

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