本文整理匯總了Java中org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot類的典型用法代碼示例。如果您正苦於以下問題:Java ExternalPackageFragmentRoot類的具體用法?Java ExternalPackageFragmentRoot怎麽用?Java ExternalPackageFragmentRoot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ExternalPackageFragmentRoot類屬於org.eclipse.jdt.internal.core包,在下文中一共展示了ExternalPackageFragmentRoot類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getURI
import org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot; //導入依賴的package包/類
/**
* @return a URI for the given jarEntry, can be <code>null</code>.
*/
public URI getURI(IPackageFragmentRoot root, IJarEntryResource jarEntry, TraversalState state) {
if (root.isArchive()) {
URI jarURI = JarEntryURIHelper.getUriForPackageFragmentRoot(root);
URI storageURI = URI.createURI(jarEntry.getFullPath().toString());
return createJarURI(root.isArchive(), jarURI, storageURI);
} else if (root instanceof ExternalPackageFragmentRoot) {
IResource resource = ((ExternalPackageFragmentRoot) root).resource();
IPath result = resource.getFullPath();
for(int i = 1; i < state.getParents().size(); i++) {
Object obj = state.getParents().get(i);
if (obj instanceof IPackageFragment) {
result = result.append(new Path(((IPackageFragment) obj).getElementName().replace('.', '/')));
} else if (obj instanceof IJarEntryResource) {
result = result.append(((IJarEntryResource) obj).getName());
}
}
result = result.append(jarEntry.getName());
return URI.createPlatformResourceURI(result.toString(), true);
} else {
throw new IllegalStateException("Unexpeced root type: " + root.getClass().getName());
}
}
示例2: getPackages
import org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot; //導入依賴的package包/類
public static List<Object> getPackages(final IPackage paccage) {
final ILibrary library = paccage.getLibrary();
final List<Object> eclipseTypes = new ArrayList<>();
if (library instanceof IProject) {
final List<IJavaProject> eclipseProjects = getProjects((IProject) library);
try {
for (final IJavaProject javaProject : eclipseProjects) {
final IPackageFragmentRoot[] allPackageFragmentRoots = javaProject.getAllPackageFragmentRoots();
for (final IPackageFragmentRoot packageFragmentRoot : allPackageFragmentRoots) {
if (packageFragmentRoot instanceof JarPackageFragmentRoot) {
continue;
}
if (packageFragmentRoot instanceof ExternalPackageFragmentRoot) {
continue;
}
final IPackageFragment packageFragment = packageFragmentRoot.getPackageFragment(paccage.getName());
if (packageFragment.exists()) {
eclipseTypes.add(packageFragment);
}
}
}
} catch (final JavaModelException e) {
// nothing to do
}
}
return eclipseTypes;
}