Example usage for org.eclipse.jdt.internal.core ClasspathEntry validateClasspathEntry

List of usage examples for org.eclipse.jdt.internal.core ClasspathEntry validateClasspathEntry

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core ClasspathEntry validateClasspathEntry.

Prototype

public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry,
        boolean checkSourceAttachment, boolean referredByContainer) 

Source Link

Document

Returns a Java model status describing the problem related to this classpath entry if any, a status object with code IStatus.OK if the entry is fine (that is, if the given classpath entry denotes a valid element to be referenced onto a classpath).

Usage

From source file:org.eclipse.buckminster.jdt.internal.ClasspathEmitter.java

License:Open Source License

private static IClasspathEntry[] getResolvedClasspath(IJavaProject project, IClasspathEntry[] entries)
        throws CoreException {
    ArrayList<IClasspathEntry> resolvedEntries = new ArrayList<IClasspathEntry>();
    for (IClasspathEntry rawEntry : entries) {
        switch (rawEntry.getEntryKind()) {
        case IClasspathEntry.CPE_VARIABLE:

            IClasspathEntry resolvedEntry = null;
            try {
                resolvedEntry = JavaCore.getResolvedClasspathEntry(rawEntry);
            } catch (AssertionFailedException e) {
            }//w  w  w .  j a  v  a  2s.  c o m
            if (resolvedEntry == null)
                throw new JavaModelException(
                        ClasspathEntry.validateClasspathEntry(project, rawEntry, false, false));
            break;

        case IClasspathEntry.CPE_CONTAINER:
            IPath entryPath = rawEntry.getPath();
            IClasspathContainer container;
            if (BMClasspathContainer.PATH.isPrefixOf(entryPath))
                //
                // This one is probably not in the project classpath
                //
                container = new BMClasspathContainer(project.getProject(),
                        entryPath.segmentCount() > 1 ? entryPath.lastSegment() : null);
            else
                container = JavaCore.getClasspathContainer(entryPath, project);

            if (container == null)
                throw new JavaModelException(
                        ClasspathEntry.validateClasspathEntry(project, rawEntry, false, false));

            IClasspathEntry[] containerEntries = container.getClasspathEntries();
            if (containerEntries == null)
                continue;

            for (IClasspathEntry cEntry : containerEntries) {
                // if container is exported or restricted, then its
                // nested
                // entries must in turn be exported
                //
                cEntry = ((ClasspathEntry) cEntry).combineWith((ClasspathEntry) rawEntry);
                resolvedEntries.add(cEntry);
            }
            continue;
        }
        resolvedEntries.add(rawEntry);
    }
    return resolvedEntries.toArray(new IClasspathEntry[resolvedEntries.size()]);
}