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

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

Introduction

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

Prototype

@Override
public synchronized void refresh(IProgressMonitor monitor) throws JavaModelException 

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  av a2s .c  om
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 ww  . j av a  2  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 w  w w  .  j  ava2s  .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);//from w w w  .ja  v a 2  s  .com

    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.internal.core.ext.AbstractMarkable.java

License:Open Source License

/**
 * Get all direct and indirect subtypes of all types in 'types'.
 * @param types//from w w  w.j ava  2 s.  co m
 * @param monitor
 * @return
 * @throws JavaModelException
 */
Set<IType> getSubTypes(Set<IType> types, IProgressMonitor monitor) throws JavaModelException {
    monitor.beginTask(OTCoreExtMessages.AbstractMarkable_baseClassHierarchy_progress, types.size());

    IJavaSearchScope workspaceScope = SearchEngine.createWorkspaceScope();
    Set<IType> subTypes = new HashSet<IType>(13);
    for (IType type : types) {
        TypeHierarchy hier = new TypeHierarchy(type, null, workspaceScope, true);
        hier.refresh(monitor);
        for (IType subType : hier.getAllSubtypes(type))
            subTypes.add(subType);
        monitor.worked(1);
    }
    monitor.done();
    return subTypes;
}

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

License:Open Source License

public void testGetAllSubtypes_T20T10T00R1() throws JavaModelException {
    _focusType = _T20T10T00R1;//from w w w.  j a  va  2s. c  o m
    TypeHierarchy hierarchy = new TypeHierarchy(_focusType, null, _focusType.getJavaProject(), true);
    hierarchy.refresh(new NullProgressMonitor());

    IType[] expected = { _T21T10T00R1, _T21T10T00R2, _T21T11T00R1, _T21T11T00R2 };
    IType[] actual = hierarchy.getAllSubtypes(_focusType);

    assertTrue(compareTypes(expected, actual));
}

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

License:Open Source License

public void testGetTSuperTypes_T21T11T00R0() throws JavaModelException {
    _focusType = _T21T11T00R0;/*w  w w . ja  v  a2 s . c o m*/
    TypeHierarchy hierarchy = new TypeHierarchy(_focusType, null, _focusType.getJavaProject(), false);
    hierarchy.refresh(new NullProgressMonitor());

    IType[] expected = { _T20T10T00R0 };
    IType[] actual = OTTypeHierarchies.getInstance().getTSuperTypes(hierarchy, _focusType);

    assertTrue(compareTypes(expected, actual));
}

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

License:Open Source License

public void testGetTSuperTypes_T21T11T00R1() throws JavaModelException {
    _focusType = _T21T11T00R1;//ww  w.j  a  v  a2  s  . c o  m
    TypeHierarchy hierarchy = new TypeHierarchy(_focusType, null, _focusType.getJavaProject(), false);
    hierarchy.refresh(new NullProgressMonitor());

    IType[] expected = { _T21T10T00R1 };
    IType[] actual = OTTypeHierarchies.getInstance().getTSuperTypes(hierarchy, _focusType);

    assertTrue(compareTypes(expected, actual));
}

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

License:Open Source License

public void testGetSubtypes_T1R1() throws JavaModelException {
    _focusType = _T1R1;//  w  w w .  j  a  v  a 2 s  . com

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

    IType[] actual = hierarchy.getSubtypes(_focusType);
    IType[] expected = new IType[] { _T2R1 };

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

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

License:Open Source License

public void testGetSubtypes_T2R1() throws JavaModelException {
    _focusType = _T2R1;/*from   www. j  a v  a  2  s  . c o  m*/

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

    IType[] actual = hierarchy.getSubtypes(_focusType);
    IType[] expected = new IType[] { _T3R1 };

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