Example usage for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT

List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT.

Prototype

int CPE_PROJECT

To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT.

Click Source Link

Document

Entry kind constant describing a classpath entry identifying a required project.

Usage

From source file:x10dt.ui.parser.CompilerDelegate.java

License:Open Source License

/**
 * Build a class path string for a project
 * @param project The root project to start with
 * @param buff Accumulates the classpath into this buffer
 * @throws JavaModelException//from   w  w  w.j a  va2  s.c  o m
 */
private static void buildClassPathSpec(final IWorkspaceRoot root, IJavaProject rootProject,
        IJavaProject project, Set<IPath> container) throws JavaModelException {
    if (project == null) {
        return;
    }

    IClasspathEntry[] classPath = project.getResolvedClasspath(true);
    for (IClasspathEntry cpEntry : classPath) {
        switch (cpEntry.getEntryKind()) {
        case IClasspathEntry.CPE_SOURCE:
            if (isX10Project(project)) {
                IPath outputPath = getOutputLocation(cpEntry, project);
                if (outputPath.lastSegment().equals("bin-java")) {
                    container.add(makeAbsolutePath(root, outputPath));
                } else {
                    container.add(makeAbsolutePath(root, cpEntry.getPath()));
                }
            } else {
                container.add(makeAbsolutePath(root, getOutputLocation(cpEntry, project)));
            }
            break;

        case IClasspathEntry.CPE_LIBRARY:
            IPath path = makeAbsolutePath(root, cpEntry.getPath());
            container.add(path);
            break;

        case IClasspathEntry.CPE_PROJECT:
            final IResource resource = root.findMember(cpEntry.getPath());
            if (resource == null) {
                X10DTCorePlugin.getInstance().writeErrorMsg("Error resolving class path: " + cpEntry.getPath());
            } else {
                final IJavaProject refProject = JavaCore.create((IProject) resource);
                for (final IClasspathEntry newCPEntry : refProject.getResolvedClasspath(true)) {
                    buildClassPathSpec(root, rootProject, refProject, container);
                }
            }
            break;

        default:
            X10DTCorePlugin.getInstance()
                    .writeErrorMsg("Error resolving class path kind: " + cpEntry.getEntryKind());
        }
    }
}