當前位置: 首頁>>代碼示例>>Java>>正文


Java ExternalPackageFragmentRoot類代碼示例

本文整理匯總了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());
	}
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:26,代碼來源:JarEntryLocator.java

示例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;
}
 
開發者ID:AndreasWBartels,項目名稱:libraries,代碼行數:28,代碼來源:WorkspaceUtilities.java


注:本文中的org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。