List of usage examples for org.eclipse.jdt.internal.core JavaProject resolveClasspath
public IClasspathEntry[] resolveClasspath(IClasspathEntry[] rawClasspath) throws JavaModelException
From source file:com.google.gdt.eclipse.core.ClasspathUtilities.java
License:Open Source License
/** * Return the raw classpath entry on the project's classpath that contributes * the given type to the project.//from w ww.ja v a 2 s . c om * * @param javaProject The java project * @param fullyQualifiedName The fully-qualified type name * @return The raw classpath entry that contributes the type to the project, * or <code>null</code> if no such classpath entry can be found. * @throws JavaModelException */ public static IClasspathEntry findRawClasspathEntryFor(IJavaProject javaProject, String fullyQualifiedName) throws JavaModelException { IType type = javaProject.findType(fullyQualifiedName); if (type != null) { IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) type .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); JavaProject jProject = (JavaProject) javaProject; IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); for (IClasspathEntry rawClasspathEntry : rawClasspath) { IClasspathEntry[] resolvedClasspath = jProject .resolveClasspath(new IClasspathEntry[] { rawClasspathEntry }); IPackageFragmentRoot[] computePackageFragmentRoots = jProject .computePackageFragmentRoots(resolvedClasspath, true, null); if (Arrays.asList(computePackageFragmentRoots).contains(packageFragmentRoot)) { return rawClasspathEntry; } } return packageFragmentRoot.getRawClasspathEntry(); } return null; }