Search in sources :

Example 6 with SimpleSet

use of org.eclipse.jdt.internal.compiler.util.SimpleSet in project che by eclipse.

the class ClasspathJar method findPackages.

@Override
public void findPackages(String[] name, ISearchRequestor requestor) {
    SimpleSet knownPackageNames = getKnownPackages();
    for (Object value : knownPackageNames.values) {
        if (value == null) {
            continue;
        }
        String pkg = value.toString();
        String[] pkgName = Util.splitOn('/', pkg, 0, pkg.length());
        if (pkgName != null && Util.startsWithIgnoreCase(pkgName, name, true)) {
            requestor.acceptPackage(Util.concatWith(pkgName, '.').toCharArray());
        }
    }
}
Also used : SimpleSet(org.eclipse.jdt.internal.compiler.util.SimpleSet)

Example 7 with SimpleSet

use of org.eclipse.jdt.internal.compiler.util.SimpleSet in project che by eclipse.

the class ClasspathJar method findPackageSet.

/**
     * Calculate and cache the package list available in the zipFile.
     *
     * @param jar
     *         The ClasspathJar to use
     * @return A SimpleSet with the all the package names in the zipFile.
     */
static SimpleSet findPackageSet(ClasspathJar jar) {
    String zipFileName = jar.zipFilename;
    SimpleSet packageSet = new SimpleSet(41);
    //$NON-NLS-1$
    packageSet.add("");
    nextEntry: for (Enumeration e = jar.zipFile.entries(); e.hasMoreElements(); ) {
        String fileName = ((ZipEntry) e.nextElement()).getName();
        // add the package name & all of its parent packages
        int last = fileName.lastIndexOf('/');
        while (last > 0) {
            // extract the package name
            String packageName = fileName.substring(0, last);
            String[] splittedName = Util.splitOn('/', packageName, 0, packageName.length());
            for (String s : splittedName) {
                if (!org.eclipse.jdt.internal.core.util.Util.isValidFolderNameForPackage(s, "1.7", "1.7")) {
                    continue nextEntry;
                }
            }
            if (packageSet.addIfNotIncluded(packageName) == null)
                // already existed
                continue nextEntry;
            last = packageName.lastIndexOf('/');
        }
    }
    return packageSet;
}
Also used : SimpleSet(org.eclipse.jdt.internal.compiler.util.SimpleSet) Enumeration(java.util.Enumeration)

Aggregations

SimpleSet (org.eclipse.jdt.internal.compiler.util.SimpleSet)7 IJavaElement (org.eclipse.jdt.core.IJavaElement)2 IndexLocation (org.eclipse.jdt.internal.core.index.IndexLocation)2 IOException (java.io.IOException)1 Enumeration (java.util.Enumeration)1 LinkedHashSet (java.util.LinkedHashSet)1 ZipFile (java.util.zip.ZipFile)1 IFolder (org.eclipse.core.resources.IFolder)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 IJavaModel (org.eclipse.jdt.core.IJavaModel)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IMethod (org.eclipse.jdt.core.IMethod)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1 IType (org.eclipse.jdt.core.IType)1 ITypeHierarchy (org.eclipse.jdt.core.ITypeHierarchy)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 IJavaSearchScope (org.eclipse.jdt.core.search.IJavaSearchScope)1 ClassFormatException (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException)1