本文整理汇总了Java中org.eclipse.jdt.core.IPackageFragmentRoot.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java IPackageFragmentRoot.getResource方法的具体用法?Java IPackageFragmentRoot.getResource怎么用?Java IPackageFragmentRoot.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IPackageFragmentRoot
的用法示例。
在下文中一共展示了IPackageFragmentRoot.getResource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findOldGraphFile
import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
private void findOldGraphFile(IProgressMonitor monitor) throws JavaModelException, FileNotFoundException {
AnnotationParsing ap = JDTManager.findAnnotationParsingInModelAnnotation(testInterface, "file");
this.model = ap.getValue("file");
IPackageFragmentRoot[] roots = testInterface.getJavaProject().getPackageFragmentRoots();
for (int j = 0; j < roots.length; j++) {
IPackageFragmentRoot root = roots[j];
IFolder resource = (IFolder) root.getResource();
if (resource==null) throw new FileNotFoundException (model);
IFile graphFile = resource.getFile(model);
if (graphFile.exists()) {
oldGraphFile = graphFile;
break;
}
}
}
示例2: getClassfilesLocation
import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
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);
}
示例3: appendInternalArchiveLabel
import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
private void appendInternalArchiveLabel(IPackageFragmentRoot root, long flags) {
IResource resource= root.getResource();
boolean rootQualified= getFlag(flags, JavaElementLabels.ROOT_QUALIFIED);
if (rootQualified) {
fBuilder.append(root.getPath().makeRelative().toString());
} else {
fBuilder.append(root.getElementName());
boolean referencedPostQualified= getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED);
if (referencedPostQualified && isReferenced(root)) {
fBuilder.append(JavaElementLabels.CONCAT_STRING);
fBuilder.append(resource.getParent().getFullPath().makeRelative().toString());
} else if (getFlag(flags, JavaElementLabels.ROOT_POST_QUALIFIED)) {
fBuilder.append(JavaElementLabels.CONCAT_STRING);
fBuilder.append(root.getParent().getPath().makeRelative().toString());
}
if (referencedPostQualified) {
try {
IClasspathEntry referencingEntry= JavaModelUtil.getClasspathEntry(root).getReferencingEntry();
if (referencingEntry != null) {
fBuilder.append(NLS.bind(" (from {0} of {1})", new Object[] { Name.CLASS_PATH.toString(), referencingEntry.getPath().lastSegment() }));
}
} catch (JavaModelException e) {
// ignore
}
}
}
}
示例4: appendFolderLabel
import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
private void appendFolderLabel(IPackageFragmentRoot root, long flags) {
IResource resource= root.getResource();
if (resource == null) {
appendExternalArchiveLabel(root, flags);
return;
}
boolean rootQualified= getFlag(flags, JavaElementLabels.ROOT_QUALIFIED);
boolean referencedQualified= getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED) && isReferenced(root);
if (rootQualified) {
fBuilder.append(root.getPath().makeRelative().toString());
} else {
IPath projectRelativePath= resource.getProjectRelativePath();
if (projectRelativePath.segmentCount() == 0) {
fBuilder.append(resource.getName());
referencedQualified= false;
} else {
fBuilder.append(projectRelativePath.toString());
}
if (referencedQualified) {
fBuilder.append(JavaElementLabels.CONCAT_STRING);
fBuilder.append(resource.getProject().getName());
} else if (getFlag(flags, JavaElementLabels.ROOT_POST_QUALIFIED)) {
fBuilder.append(JavaElementLabels.CONCAT_STRING);
fBuilder.append(root.getParent().getElementName());
} else {
return;
}
}
}
示例5: isReferenced
import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
/**
* Returns <code>true</code> if the given package fragment root is
* referenced. This means it is a descendant of a different project but is referenced
* by the root's parent. Returns <code>false</code> if the given root
* doesn't have an underlying resource.
*
* @param root the package fragment root
* @return returns <code>true</code> if the given package fragment root is referenced
*/
private boolean isReferenced(IPackageFragmentRoot root) {
IResource resource= root.getResource();
if (resource != null) {
IProject jarProject= resource.getProject();
IProject container= root.getJavaProject().getProject();
return !container.equals(jarProject);
}
return false;
}