本文整理汇总了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;
}