本文整理汇总了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
}
}
示例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);
}
示例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;
}
示例4: isBinaryFragment
public static boolean isBinaryFragment(IPackageFragmentRoot pfr) {
try {
return pfr != null && pfr.getKind() == IPackageFragmentRoot.K_BINARY;
} catch (JavaModelException e) {
return false;
}
}
示例5: isBinaryProject
private boolean isBinaryProject(IPackageFragmentRoot fragment) {
try {
return fragment.getKind() == IPackageFragmentRoot.K_BINARY;
} catch (JavaModelException e) {
return false;
}
}
示例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();
}
示例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();
}
示例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);
}