1 12 package org.eclipse.jdt.internal.corext.callhierarchy; 13 14 import java.util.Arrays ; 15 import java.util.Collection ; 16 import java.util.HashSet ; 17 18 import org.eclipse.core.runtime.IProgressMonitor; 19 20 import org.eclipse.jdt.core.IType; 21 import org.eclipse.jdt.core.ITypeHierarchy; 22 import org.eclipse.jdt.core.JavaModelException; 23 import org.eclipse.jdt.internal.ui.JavaPlugin; 24 25 public class JavaImplementorFinder implements IImplementorFinder { 26 29 public Collection findImplementingTypes(IType type, IProgressMonitor progressMonitor) { 30 ITypeHierarchy typeHierarchy; 31 32 try { 33 typeHierarchy = type.newTypeHierarchy(progressMonitor); 34 35 IType[] implementingTypes = typeHierarchy.getAllClasses(); 36 HashSet result = new HashSet (Arrays.asList(implementingTypes)); 37 38 return result; 39 } catch (JavaModelException e) { 40 JavaPlugin.log(e); 41 } 42 43 return null; 44 } 45 46 49 public Collection findInterfaces(IType type, IProgressMonitor progressMonitor) { 50 ITypeHierarchy typeHierarchy; 51 52 try { 53 typeHierarchy = type.newSupertypeHierarchy(progressMonitor); 54 55 IType[] interfaces = typeHierarchy.getAllSuperInterfaces(type); 56 HashSet result = new HashSet (Arrays.asList(interfaces)); 57 58 return result; 59 } catch (JavaModelException e) { 60 JavaPlugin.log(e); 61 } 62 63 return null; 64 } 65 } 66 | Popular Tags |