Search in sources :

Example 1 with IOrdinaryClassFile

use of org.eclipse.jdt.core.IOrdinaryClassFile in project eclipse.jdt.ls by eclipse.

the class TypeHierarchyCommand method getTypeHierarchy.

private TypeHierarchyItem getTypeHierarchy(String uri, Position position, TypeHierarchyDirection direction, int resolve, TypeHierarchyItem itemInput, IProgressMonitor monitor) {
    if (uri == null || position == null || direction == null) {
        return null;
    }
    try {
        IType type = null;
        if (itemInput == null) {
            type = getType(uri, position, monitor);
        } else {
            String handleIdentifier = JSONUtility.toModel(itemInput.getData(), String.class);
            IJavaElement element = JavaCore.create(handleIdentifier);
            if (element instanceof IType) {
                type = ((IType) element);
            } else if (element instanceof IOrdinaryClassFile) {
                type = ((IOrdinaryClassFile) element).getType();
            } else {
                return null;
            }
        }
        TypeHierarchyItem item = TypeHierarchyCommand.toTypeHierarchyItem(type);
        if (item == null) {
            return null;
        }
        resolve(item, type, direction, resolve, monitor);
        return item;
    } catch (JavaModelException e) {
        return null;
    }
}
Also used : IOrdinaryClassFile(org.eclipse.jdt.core.IOrdinaryClassFile) IJavaElement(org.eclipse.jdt.core.IJavaElement) JavaModelException(org.eclipse.jdt.core.JavaModelException) TypeHierarchyItem(org.eclipse.lsp4j.TypeHierarchyItem) IType(org.eclipse.jdt.core.IType)

Aggregations

IJavaElement (org.eclipse.jdt.core.IJavaElement)1 IOrdinaryClassFile (org.eclipse.jdt.core.IOrdinaryClassFile)1 IType (org.eclipse.jdt.core.IType)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 TypeHierarchyItem (org.eclipse.lsp4j.TypeHierarchyItem)1