Search in sources :

Example 11 with IClasspathContainer

use of org.eclipse.jdt.core.IClasspathContainer in project derby by apache.

the class DerbyClasspathContainerInitializer method initialize.

@Override
public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
    IClasspathContainer container = new DerbyClasspathContainer();
    JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null);
}
Also used : IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer)

Example 12 with IClasspathContainer

use of org.eclipse.jdt.core.IClasspathContainer in project azure-tools-for-java by Microsoft.

the class ContainerInitializer method initialize.

@Override
public void initialize(IPath path, IJavaProject project) throws CoreException {
    ClasspathContainer container = new ClasspathContainer(path);
    JavaCore.setClasspathContainer(path, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null);
}
Also used : IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer)

Example 13 with IClasspathContainer

use of org.eclipse.jdt.core.IClasspathContainer in project azure-tools-for-java by Microsoft.

the class ContainerInitializer method initialize.

@Override
public void initialize(IPath path, IJavaProject project) throws CoreException {
    ClasspathContainer container = new ClasspathContainer(path);
    JavaCore.setClasspathContainer(path, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null);
}
Also used : IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer)

Example 14 with IClasspathContainer

use of org.eclipse.jdt.core.IClasspathContainer in project che by eclipse.

the class JavaProject method resolveClasspath.

public ResolvedClasspath resolveClasspath(IClasspathEntry[] rawClasspath, IClasspathEntry[] referencedEntries, boolean usePreviousSession, boolean resolveChainedLibraries) throws JavaModelException {
    JavaModelManager manager = getJavaModelManager();
    //        ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager();
    ResolvedClasspath result = new ResolvedClasspath();
    Map knownDrives = new HashMap();
    Map referencedEntriesMap = new HashMap();
    List rawLibrariesPath = new ArrayList();
    LinkedHashSet resolvedEntries = new LinkedHashSet();
    if (resolveChainedLibraries) {
        for (int index = 0; index < rawClasspath.length; index++) {
            IClasspathEntry currentEntry = rawClasspath[index];
            if (currentEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                rawLibrariesPath.add(ClasspathEntry.resolveDotDot(getProject().getLocation(), currentEntry.getPath()));
            }
        }
        if (referencedEntries != null) {
            // The Set is required to keep the order intact while the referencedEntriesMap (Map)
            // is used to map the referenced entries with path
            LinkedHashSet referencedEntriesSet = new LinkedHashSet();
            for (int index = 0; index < referencedEntries.length; index++) {
                IPath path = referencedEntries[index].getPath();
                if (!rawLibrariesPath.contains(path) && referencedEntriesMap.get(path) == null) {
                    referencedEntriesMap.put(path, referencedEntries[index]);
                    referencedEntriesSet.add(referencedEntries[index]);
                }
            }
            if (referencedEntriesSet.size() > 0) {
                result.referencedEntries = new IClasspathEntry[referencedEntriesSet.size()];
                referencedEntriesSet.toArray(result.referencedEntries);
            }
        }
    }
    int length = rawClasspath.length;
    for (int i = 0; i < length; i++) {
        IClasspathEntry rawEntry = rawClasspath[i];
        IClasspathEntry resolvedEntry = rawEntry;
        switch(rawEntry.getEntryKind()) {
            case IClasspathEntry.CPE_VARIABLE:
                try {
                    resolvedEntry = manager.resolveVariableEntry(rawEntry, usePreviousSession);
                } catch (ClasspathEntry.AssertionFailedException e) {
                    // Catch the assertion failure and set status instead
                    // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
                    result.unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage());
                    break;
                }
                if (resolvedEntry == null) {
                    result.unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, this, rawEntry.getPath());
                } else {
                    // have already been processed. So, skip it.
                    if (resolveChainedLibraries && resolvedEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && result.rawReverseMap.get(resolvedEntry.getPath()) == null) {
                        // resolve Class-Path: in manifest
                        ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries();
                        for (int j = 0, length2 = extraEntries.length; j < length2; j++) {
                            if (!rawLibrariesPath.contains(extraEntries[j].getPath())) {
                                // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305037
                                // referenced entries for variable entries could also be persisted with extra attributes, so addAsChainedEntry = true
                                addToResult(rawEntry, extraEntries[j], result, resolvedEntries, /*externalFoldersManager*/
                                referencedEntriesMap, true, knownDrives);
                            }
                        }
                    }
                    addToResult(rawEntry, resolvedEntry, result, resolvedEntries, /*externalFoldersManager,*/
                    referencedEntriesMap, false, knownDrives);
                }
                break;
            case IClasspathEntry.CPE_CONTAINER:
                IClasspathContainer container = usePreviousSession ? manager.getPreviousSessionContainer(rawEntry.getPath(), this) : JavaCore.getClasspathContainer(rawEntry.getPath(), this);
                if (container == null) {
                    result.unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND, this, rawEntry.getPath());
                    break;
                }
                IClasspathEntry[] containerEntries = container.getClasspathEntries();
                if (containerEntries == null) {
                    if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) {
                    //                            JavaModelManager.getJavaModelManager().verbose_missbehaving_container_null_entries(this, rawEntry.getPath());
                    }
                    break;
                }
                // container was bound
                for (int j = 0, containerLength = containerEntries.length; j < containerLength; j++) {
                    ClasspathEntry cEntry = (ClasspathEntry) containerEntries[j];
                    if (cEntry == null) {
                        if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) {
                        //                                JavaModelManager.getJavaModelManager().verbose_missbehaving_container(this, rawEntry.getPath(), containerEntries);
                        }
                        break;
                    }
                    // if container is exported or restricted, then its nested entries must in turn be exported  (21749) and/or propagate restrictions
                    cEntry = cEntry.combineWith((ClasspathEntry) rawEntry);
                    if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                        // resolve ".." in library path
                        cEntry = cEntry.resolvedDotDot(getProject().getLocation());
                        // Do not resolve if the system attribute is set to false
                        if (resolveChainedLibraries && getJavaModelManager().resolveReferencedLibrariesForContainers && result.rawReverseMap.get(cEntry.getPath()) == null) {
                            // resolve Class-Path: in manifest
                            ClasspathEntry[] extraEntries = cEntry.resolvedChainedLibraries();
                            for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
                                if (!rawLibrariesPath.contains(extraEntries[k].getPath())) {
                                    addToResult(rawEntry, extraEntries[k], result, resolvedEntries, /*externalFoldersManager,*/
                                    referencedEntriesMap, false, knownDrives);
                                }
                            }
                        }
                    }
                    addToResult(rawEntry, cEntry, result, resolvedEntries, /*externalFoldersManager,*/
                    referencedEntriesMap, false, knownDrives);
                }
                break;
            case IClasspathEntry.CPE_LIBRARY:
                // resolve ".." in library path
                resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot(getProject().getLocation());
                if (resolveChainedLibraries && result.rawReverseMap.get(resolvedEntry.getPath()) == null) {
                    // resolve Class-Path: in manifest
                    ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries();
                    for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
                        if (!rawLibrariesPath.contains(extraEntries[k].getPath())) {
                            addToResult(rawEntry, extraEntries[k], result, resolvedEntries, /*externalFoldersManager,*/
                            referencedEntriesMap, true, knownDrives);
                        }
                    }
                }
                addToResult(rawEntry, resolvedEntry, result, resolvedEntries, /*externalFoldersManager,*/
                referencedEntriesMap, false, knownDrives);
                break;
            default:
                addToResult(rawEntry, resolvedEntry, result, resolvedEntries, /* externalFoldersManager,*/
                referencedEntriesMap, false, knownDrives);
                break;
        }
    }
    result.resolvedClasspath = new IClasspathEntry[resolvedEntries.size()];
    resolvedEntries.toArray(result.resolvedClasspath);
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ArrayList(java.util.ArrayList) IJavaModelStatus(org.eclipse.jdt.core.IJavaModelStatus) JavaModelManager.getJavaModelManager(org.eclipse.jdt.internal.core.JavaModelManager.getJavaModelManager) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer) Map(java.util.Map) HashMap(java.util.HashMap)

Example 15 with IClasspathContainer

use of org.eclipse.jdt.core.IClasspathContainer in project che by eclipse.

the class JavaModelManager method containerBeingInitializedGet.

public IClasspathContainer containerBeingInitializedGet(IJavaProject project, IPath containerPath) {
    Map perProjectContainers = (Map) this.containersBeingInitialized.get();
    if (perProjectContainers == null)
        return null;
    HashMap perPathContainers = (HashMap) perProjectContainers.get(project);
    if (perPathContainers == null)
        return null;
    return (IClasspathContainer) perPathContainers.get(containerPath);
}
Also used : HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer) Map(java.util.Map) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap)

Aggregations

IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)34 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)16 IJavaProject (org.eclipse.jdt.core.IJavaProject)16 IPath (org.eclipse.core.runtime.IPath)13 CoreException (org.eclipse.core.runtime.CoreException)10 ClasspathContainerInitializer (org.eclipse.jdt.core.ClasspathContainerInitializer)8 ArrayList (java.util.ArrayList)6 JavaModelException (org.eclipse.jdt.core.JavaModelException)6 Map (java.util.Map)5 IProject (org.eclipse.core.resources.IProject)5 HashMap (java.util.HashMap)4 WeakHashMap (java.util.WeakHashMap)3 IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)3 ILiferayRuntime (com.liferay.ide.server.core.ILiferayRuntime)2 PortalBundle (com.liferay.ide.server.core.portal.PortalBundle)2 IResource (org.eclipse.core.resources.IResource)2 IStatus (org.eclipse.core.runtime.IStatus)2 Path (org.eclipse.core.runtime.Path)2 IJavaModelStatus (org.eclipse.jdt.core.IJavaModelStatus)2 ClasspathDecorations (org.eclipse.jst.common.jdt.internal.classpath.ClasspathDecorations)2