List of usage examples for org.eclipse.jdt.core IJavaProject newTypeHierarchy
ITypeHierarchy newTypeHierarchy(IType type, IRegion region, IProgressMonitor monitor) throws JavaModelException;
From source file:edu.brown.cs.bubbles.bedrock.BedrockJava.java
License:Open Source License
/********************************************************************************/ void handleFindHierarchy(String proj, String pkg, String cls, boolean all, IvyXmlWriter xw) throws BedrockException { IJavaProject ijp = getJavaProject(proj); IRegion rgn = JavaCore.newRegion();/*from w ww .ja va 2s . c o m*/ IType fortype = null; boolean havejp = (ijp != null); if (ijp == null && (pkg != null || cls != null)) { IJavaElement[] aps = getAllProjects(); if (aps.length == 0) return; if (cls != null) { for (IJavaElement ije : aps) { IJavaProject xjp = ije.getJavaProject(); try { if (xjp.findType(cls) != null) { ijp = xjp; break; } } catch (JavaModelException e) { } } } if (ijp == null) ijp = aps[0].getJavaProject(); } int addct = 0; if (cls != null && ijp != null) { try { IType typ = ijp.findType(cls); fortype = typ; // rgn.add(typ); // ++addct; } catch (JavaModelException e) { BedrockPlugin.logE("Problem getting type by name: " + e); } } if (pkg != null && ijp != null) { String ppth = "/" + pkg.replace(".", "/"); try { for (IPackageFragmentRoot ipr : ijp.getPackageFragmentRoots()) { IPath rpath = ipr.getPath(); Path npath = new Path(rpath.toString() + ppth); IPackageFragment ipf = ijp.findPackageFragment(npath); if (ipf != null) { rgn.add(ipf); ++addct; } } } catch (Exception e) { BedrockPlugin.logE("Problem getting package fragments for " + ppth + ": " + e); } } else if (havejp && ijp != null) { if (all) { rgn.add(ijp); ++addct; } else { try { for (IPackageFragment ipf : ijp.getPackageFragments()) { for (ICompilationUnit icu : ipf.getCompilationUnits()) { IType ity = ((ITypeRoot) icu).findPrimaryType(); if (ity != null) { rgn.add(ity); ++addct; } } } } catch (Throwable e) { BedrockPlugin.logE("Problem getting package fragments: " + e); } } } else { for (IJavaElement pi : getAllProjects()) { IJavaProject xjp = pi.getJavaProject(); if (xjp != null && !rgn.contains(xjp)) { rgn.add(xjp); ++addct; } // String pnm = pi.getJavaProject().getProject().getName(); // handleFindHierarchy(pnm,null,null,all,xw); } } if (addct > 0 && ijp != null) { try { BedrockPlugin.logD("FIND TYPE HIERARCHY FOR " + fortype + " " + addct + " " + rgn); ITypeHierarchy ith; if (fortype != null) ith = ijp.newTypeHierarchy(fortype, rgn, null); else ith = ijp.newTypeHierarchy(rgn, null); BedrockUtil.outputTypeHierarchy(ith, xw); } catch (JavaModelException e) { BedrockPlugin.logE("Problem outputing type hierarchy: " + e); } catch (NullPointerException e) { // this is a bug in Eclipse that should be fixed } } }
From source file:org.bonitasoft.studio.businessobject.core.repository.BusinessObjectModelRepositoryStore.java
License:Open Source License
protected ITypeHierarchy typeHierarchy(final IJavaProject javaProject, final IType daoType) { IRegion newRegion = null;//ww w . j a va 2s . c o m try { newRegion = regionWithBDM(javaProject); } catch (final JavaModelException e) { BonitaStudioLog.error("Failed to compute region for BDM", e); } ITypeHierarchy newTypeHierarchy = null; try { newTypeHierarchy = javaProject.newTypeHierarchy(daoType, newRegion, Repository.NULL_PROGRESS_MONITOR); } catch (final JavaModelException e) { BonitaStudioLog.error(String.format("Failed to compute %s hierarchy", daoType.getElementName()), e); } return newTypeHierarchy; }
From source file:org.eclipse.birt.report.designer.internal.ui.ide.util.ClassFinder.java
License:Open Source License
private List findCLasses(IJavaElement element, IProgressMonitor pm) throws JavaModelException { List found = new ArrayList(); IJavaProject javaProject = element.getJavaProject(); IType testCaseType = classType(javaProject); if (testCaseType == null) return found; IType[] subtypes = javaProject.newTypeHierarchy(testCaseType, getRegion(element), pm) .getAllSubtypes(testCaseType); if (subtypes == null) throw new JavaModelException(new CoreException(new Status(IStatus.ERROR, ID, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE, ERROR_MESSAGE, null))); for (int i = 0; i < subtypes.length; i++) { try {/*from ww w. jav a 2 s.co m*/ if (hasValidModifiers(subtypes[i])) found.add(subtypes[i]); } catch (JavaModelException e) { logger.log(Level.SEVERE, e.getMessage(), e); } } return found; }