当前位置: 首页>>代码示例>>Java>>正文


Java IJavaProject.isOpen方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IJavaProject.isOpen方法的典型用法代码示例。如果您正苦于以下问题:Java IJavaProject.isOpen方法的具体用法?Java IJavaProject.isOpen怎么用?Java IJavaProject.isOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.IJavaProject的用法示例。


在下文中一共展示了IJavaProject.isOpen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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];
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:43,代码来源:JdtUtils.java


注:本文中的org.eclipse.jdt.core.IJavaProject.isOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。