本文整理汇总了Java中org.eclipse.jdt.core.IJavaProject.exists方法的典型用法代码示例。如果您正苦于以下问题:Java IJavaProject.exists方法的具体用法?Java IJavaProject.exists怎么用?Java IJavaProject.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IJavaProject
的用法示例。
在下文中一共展示了IJavaProject.exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSourceContainers
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
private static ISourceContainer[] getSourceContainers(IJavaProject project, Set<IRuntimeClasspathEntry> calculated) {
if (project == null || !project.exists()) {
return new ISourceContainer[0];
}
try {
IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
List<IRuntimeClasspathEntry> resolved = new ArrayList<>();
for (IRuntimeClasspathEntry entry : unresolved) {
for (IRuntimeClasspathEntry resolvedEntry : JavaRuntime.resolveRuntimeClasspathEntry(entry, project)) {
if (!calculated.contains(resolvedEntry)) {
calculated.add(resolvedEntry);
resolved.add(resolvedEntry);
}
}
}
Set<ISourceContainer> containers = new LinkedHashSet<>();
containers.addAll(Arrays.asList(
JavaRuntime.getSourceContainers(resolved.toArray(new IRuntimeClasspathEntry[0]))));
// Due to a known jdt java 9 support bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=525840,
// it would miss some JRE libraries source containers when the debugger is running on JDK9.
// As a workaround, recompute the possible source containers for JDK9 jrt-fs.jar libraries.
IRuntimeClasspathEntry jrtFs = resolved.stream().filter(entry -> {
return entry.getType() == IRuntimeClasspathEntry.ARCHIVE && entry.getPath().lastSegment().equals("jrt-fs.jar");
}).findFirst().orElse(null);
if (jrtFs != null && project.isOpen()) {
IPackageFragmentRoot[] allRoots = project.getPackageFragmentRoots();
for (IPackageFragmentRoot root : allRoots) {
if (root.getPath().equals(jrtFs.getPath()) && isSourceAttachmentEqual(root, jrtFs)) {
containers.add(new PackageFragmentRootSourceContainer(root));
}
}
}
return containers.toArray(new ISourceContainer[0]);
} catch (CoreException ex) {
// do nothing.
}
return new ISourceContainer[0];
}
示例2: packageChanged
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
protected IStatus packageChanged() {
StatusInfo status = new StatusInfo();
IPackageFragmentRoot root = getPackageFragmentRoot();
IJavaProject project = root != null ? root.getJavaProject() : null;
String packName = getPackageText().getText();
if (packName.length() > 0) {
IStatus val = validatePackageName(packName, project);
if (val.getSeverity() == IStatus.ERROR) {
status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
return status;
} else if (val.getSeverity() == IStatus.WARNING) {
status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
// continue
}
} else {
status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
}
if (project != null) {
if (project.exists() && packName.length() > 0) {
try {
IPath rootPath = root.getPath();
IPath outputPath = project.getOutputLocation();
if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
// if the bin folder is inside of our root, don't allow
// to name a package
// like the bin folder
IPath packagePath = rootPath.append(packName.replace('.', '/'));
if (outputPath.isPrefixOf(packagePath)) {
status.setError(NewWizardMessages.NewTypeWizardPage_error_ClashOutputLocation);
return status;
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
// let pass
}
}
fCurrPackage = root.getPackageFragment(packName);
IResource resource = fCurrPackage.getResource();
if (resource != null) {
if (resource.isVirtual()) {
status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageIsVirtual);
return status;
}
if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageNameFiltered);
return status;
}
}
} else {
status.setError("");
}
return status;
}
示例3: validatePackageName
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
private static IStatus validatePackageName(String text, IJavaProject project) {
if (project == null || !project.exists()) {
return JavaConventions.validatePackageName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
}
return JavaConventionsUtil.validatePackageName(text, project);
}