private void checkForJavaDependencies(IPluginModelBase[] models, IProgressMonitor monitor) { try { if (!fProject.hasNature(JavaCore.NATURE_ID)) return; IJavaProject jProject = JavaCore.create(fProject); IPackageFragment[] packageFragments = PluginJavaSearchUtil.collectPackageFragments(models, jProject, true); monitor.beginTask("", packageFragments.length); // $NON-NLS-1$ SearchEngine engine = new SearchEngine(); for (int i = 0; i < packageFragments.length; i++) { if (monitor.isCanceled()) break; IPackageFragment pkgFragment = packageFragments[i]; monitor.subTask( PDEUIMessages.DependencyExtentOperation_inspecting + " " + pkgFragment.getElementName()); // $NON-NLS-1$ if (pkgFragment.hasChildren()) { IJavaElement[] children = pkgFragment.getChildren(); for (int j = 0; j < children.length; j++) { if (monitor.isCanceled()) break; IJavaElement child = children[j]; IType[] types = new IType[0]; if (child instanceof IClassFile) { types = new IType[] {((IClassFile) child).getType()}; } else if (child instanceof ICompilationUnit) { types = ((ICompilationUnit) child).getTypes(); } if (types.length > 0) searchForTypesUsed( engine, child, types, PluginJavaSearchUtil.createSeachScope(jProject)); } } monitor.worked(1); } } catch (CoreException e) { } finally { monitor.done(); } }
/* * Ensures that getPrimaryElement() on an package fragment returns the same handle. */ public void testGetPrimaryElement3() { IPackageFragment pkg = getPackage("P"); assertEquals("Unexpected element", pkg, pkg.getPrimaryElement()); }