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


Java IPackageFragmentRoot.K_BINARY屬性代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.IPackageFragmentRoot.K_BINARY屬性的典型用法代碼示例。如果您正苦於以下問題:Java IPackageFragmentRoot.K_BINARY屬性的具體用法?Java IPackageFragmentRoot.K_BINARY怎麽用?Java IPackageFragmentRoot.K_BINARY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.eclipse.jdt.core.IPackageFragmentRoot的用法示例。


在下文中一共展示了IPackageFragmentRoot.K_BINARY屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: attachSource

public static void attachSource(final IPackageFragmentRoot fragment, final IPath newSourcePath,
    IProgressMonitor monitor) {
  try {
    if (fragment == null || fragment.getKind() != IPackageFragmentRoot.K_BINARY) {
      return;
    }
    if (!Objects.equals(fragment.getSourceAttachmentPath(), newSourcePath)) {
      // would be so cool if it refreshed the UI automatically
      fragment.attachSource(newSourcePath, null, monitor);
      // close the root so that source attachment cache is flushed. Else UI
      // won't update
      fragment.close();
      // we have to manually fire a delta to notify the UI about the source
      // attachment.
      JavaModelManager manager = JavaModelManager.getJavaModelManager();
      JavaElementDelta attachedSourceDelta = new JavaElementDelta(fragment.getJavaModel());
      attachedSourceDelta.sourceAttached(fragment);
      manager.getDeltaProcessor().fire(attachedSourceDelta, ElementChangedEvent.POST_CHANGE);
    }
  } catch (CoreException e) {
    // ignore
  }
}
 
開發者ID:fbricon,項目名稱:pde.source.lookup,代碼行數:23,代碼來源:ClasspathUtils.java

示例2: getSimpleTextForJavaElement

private String getSimpleTextForJavaElement(Object element) {
  if (element instanceof IPackageFragmentRoot) {
    final IPackageFragmentRoot root = (IPackageFragmentRoot) element;
    // tweak label if the package fragment root is the project itself:
    if (root.getElementName().length() == 0) {
      element = root.getJavaProject();
    }
    // shorten JAR references
    try {
      if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
        return root.getPath().lastSegment();
      }
    } catch (JavaModelException e) {
      EclEmmaUIPlugin.log(e);
    }
  }
  return workbenchLabelProvider.getText(element);
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:18,代碼來源:CellTextConverter.java

示例3: internalGetContentReader

/**
 * Gets a reader for an package fragment's Javadoc comment content from the source attachment.
 * The content does contain only the text from the comment without the Javadoc leading star characters.
 * Returns <code>null</code> if the package fragment does not contain a Javadoc comment or if no source is available.
 * @param fragment The package fragment to get the Javadoc of.
 * @return Returns a reader for the Javadoc comment content or <code>null</code> if the member
 * does not contain a Javadoc comment or if no source is available
 * @throws JavaModelException is thrown when the package fragment's javadoc can not be accessed
 * @since 3.4
 */
private static Reader internalGetContentReader(IPackageFragment fragment) throws JavaModelException {
	IPackageFragmentRoot root= (IPackageFragmentRoot) fragment.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);

	//1==> Handle the case when the documentation is present in package-info.java or package-info.class file
	boolean isBinary= root.getKind() == IPackageFragmentRoot.K_BINARY;
	ITypeRoot packageInfo;
	if (isBinary) {
		packageInfo= fragment.getClassFile(PACKAGE_INFO_CLASS);
	} else {
		packageInfo= fragment.getCompilationUnit(PACKAGE_INFO_JAVA);
	}
	if (packageInfo != null && packageInfo.exists()) {
		String source = packageInfo.getSource();
		//the source can be null for some of the class files
		if (source != null) {
			Javadoc javadocNode = getPackageJavadocNode(fragment, source);
			if (javadocNode != null) {
				int start = javadocNode.getStartPosition();
				int length = javadocNode.getLength();
				return new JavaDocCommentReader(source, start, start + length - 1);
			}
		}
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:35,代碼來源:JavadocContentAccess.java

示例4: isBinaryFragment

public static boolean isBinaryFragment(IPackageFragmentRoot pfr) {
  try {
    return pfr != null && pfr.getKind() == IPackageFragmentRoot.K_BINARY;
  } catch (JavaModelException e) {
    return false;
  }
}
 
開發者ID:fbricon,項目名稱:pde.source.lookup,代碼行數:7,代碼來源:ClasspathUtils.java

示例5: isBinaryProject

private boolean isBinaryProject(IPackageFragmentRoot fragment) {
  try {
    return fragment.getKind() == IPackageFragmentRoot.K_BINARY;
  } catch (JavaModelException e) {
    return false;
  }
}
 
開發者ID:fbricon,項目名稱:pde.source.lookup,代碼行數:7,代碼來源:DownloadSourcesActionDelegate.java

示例6: getPathLabel

/**
 * Calculates a label for the class path of the given package fragment root.
 * For external entries this is the full path, otherwise it is the project
 * relative path.
 *
 * @param root
 *          package fragment root
 * @return label for the class path entry
 */
private static String getPathLabel(IPackageFragmentRoot root) {
  final IPath path = root.getPath();
  try {
    if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
      return path.lastSegment();
    }
  } catch (JavaModelException e) {
    EclEmmaUIPlugin.log(e);
  }
  return path.removeFirstSegments(1).toString();
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:20,代碼來源:ScopeViewer.java

示例7: processPackageFragment

private void processPackageFragment(ITypeVisitor visitor,
    IPackageFragment fragment, IProgressMonitor monitor)
    throws JavaModelException {
  switch (fragment.getKind()) {
  case IPackageFragmentRoot.K_SOURCE:
    final ICompilationUnit[] units = fragment.getCompilationUnits();
    monitor.beginTask("", units.length); //$NON-NLS-1$
    for (final ICompilationUnit unit : units) {
      if (monitor.isCanceled()) {
        break;
      }
      processCompilationUnit(visitor, unit, monitor);
      monitor.worked(1);
    }
    break;
  case IPackageFragmentRoot.K_BINARY:
    final IClassFile[] classfiles = fragment.getClassFiles();
    monitor.beginTask("", classfiles.length); //$NON-NLS-1$
    for (final IClassFile classfile : classfiles) {
      if (monitor.isCanceled()) {
        break;
      }
      processClassFile(visitor, classfile, monitor);
      monitor.worked(1);
    }
    break;
  }
  monitor.done();
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:29,代碼來源:TypeTraverser.java

示例8: getClassfilesLocation

private IResource getClassfilesLocation(IPackageFragmentRoot root)
    throws CoreException {

  // For binary roots the underlying resource directly points to class files:
  if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
    return root.getResource();
  }

  // For source roots we need to find the corresponding output folder:
  IPath path = root.getRawClasspathEntry().getOutputLocation();
  if (path == null) {
    path = root.getJavaProject().getOutputLocation();
  }
  return root.getResource().getWorkspace().getRoot().findMember(path);
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:15,代碼來源:PackageFragementRootAnalyzer.java


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