Example usage for org.eclipse.jdt.internal.core JavaElementInfo NO_NON_JAVA_RESOURCES

List of usage examples for org.eclipse.jdt.internal.core JavaElementInfo NO_NON_JAVA_RESOURCES

Introduction

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

Prototype

Object[] NO_NON_JAVA_RESOURCES

To view the source code for org.eclipse.jdt.internal.core JavaElementInfo NO_NON_JAVA_RESOURCES.

Click Source Link

Document

Shared empty collection used for efficiency.

Usage

From source file:org.eclipse.jdt.internal.core.JarPackageFragment.java

License:Open Source License

/**
 * Compute all the non-java resources according to the given entry names.
 *//*from w  w  w .  j av  a  2  s  .co  m*/
private Object[] computeNonJavaResources(ArrayList entryNames) {
    int length = entryNames.size();
    if (length == 0)
        return JavaElementInfo.NO_NON_JAVA_RESOURCES;
    HashMap jarEntries = new HashMap(); // map from IPath to IJarEntryResource
    HashMap childrenMap = new HashMap(); // map from IPath to ArrayList<IJarEntryResource>

    // GROOVY start
    boolean isInteresting = LanguageSupportFactory.isInterestingProject(this.getJavaProject().getProject());
    // GROOVY end

    ArrayList topJarEntries = new ArrayList();
    for (int i = 0; i < length; i++) {
        String resName = (String) entryNames.get(i);
        // consider that a .java file is not a non-java resource (see bug 12246 Packages view shows .class and .java files when JAR has source)
        // GROOVY start 
        // we want to show uncompiled groovy scripts that are coming in from a jar file
        /* old {
        if (!Util.isJavaLikeFileName(resName)) {
        } new */
        if ((!Util.isJavaLikeFileName(resName)
                || (isInteresting && LanguageSupportFactory.isInterestingSourceFile(resName)))) {
            // GROOVY end
            IPath filePath = new Path(resName);
            IPath childPath = filePath.removeFirstSegments(this.names.length);
            if (jarEntries.containsKey(childPath)) {
                // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=222665
                continue;
            }
            JarEntryFile file = new JarEntryFile(filePath.lastSegment());
            jarEntries.put(childPath, file);
            if (childPath.segmentCount() == 1) {
                file.setParent(this);
                topJarEntries.add(file);
            } else {
                IPath parentPath = childPath.removeLastSegments(1);
                while (parentPath.segmentCount() > 0) {
                    ArrayList parentChildren = (ArrayList) childrenMap.get(parentPath);
                    if (parentChildren == null) {
                        Object dir = new JarEntryDirectory(parentPath.lastSegment());
                        jarEntries.put(parentPath, dir);
                        childrenMap.put(parentPath, parentChildren = new ArrayList());
                        parentChildren.add(childPath);
                        if (parentPath.segmentCount() == 1) {
                            topJarEntries.add(dir);
                            break;
                        }
                        childPath = parentPath;
                        parentPath = childPath.removeLastSegments(1);
                    } else {
                        parentChildren.add(childPath);
                        break; // all parents are already registered
                    }
                }
            }
        }
    }
    Iterator entries = childrenMap.entrySet().iterator();
    while (entries.hasNext()) {
        Map.Entry entry = (Map.Entry) entries.next();
        IPath entryPath = (IPath) entry.getKey();
        ArrayList entryValue = (ArrayList) entry.getValue();
        JarEntryDirectory jarEntryDirectory = (JarEntryDirectory) jarEntries.get(entryPath);
        int size = entryValue.size();
        IJarEntryResource[] children = new IJarEntryResource[size];
        for (int i = 0; i < size; i++) {
            JarEntryResource child = (JarEntryResource) jarEntries.get(entryValue.get(i));
            child.setParent(jarEntryDirectory);
            children[i] = child;
        }
        jarEntryDirectory.setChildren(children);
        if (entryPath.segmentCount() == 1) {
            jarEntryDirectory.setParent(this);
        }
    }
    return topJarEntries.toArray(new Object[topJarEntries.size()]);
}

From source file:org.eclipse.jdt.internal.core.JarPackageFragment.java

License:Open Source License

/**
 * Returns an array of non-java resources contained in the receiver.
 *///from  www.  j a  va  2 s. c om
public Object[] getNonJavaResources() throws JavaModelException {
    if (isDefaultPackage()) {
        // We don't want to show non java resources of the default package (see PR #1G58NB8)
        return JavaElementInfo.NO_NON_JAVA_RESOURCES;
    } else {
        return storedNonJavaResources();
    }
}

From source file:org.eclipse.jdt.internal.core.PackageFragment.java

License:Open Source License

/**
 * Returns an array of non-java resources contained in the receiver.
 *///from ww  w. ja  v  a 2  s.  co m
public Object[] getNonJavaResources() throws JavaModelException {
    if (isDefaultPackage()) {
        // We don't want to show non java resources of the default package (see PR #1G58NB8)
        return JavaElementInfo.NO_NON_JAVA_RESOURCES;
    } else {
        return ((PackageFragmentInfo) getElementInfo()).getNonJavaResources(resource(),
                getPackageFragmentRoot());
    }
}