private void rehash() { HashtableOfArrayToObject newHashtable = new HashtableOfArrayToObject(this.elementSize * 2); // double the number of expected elements Object[] currentKey; for (int i = this.keyTable.length; --i >= 0;) if ((currentKey = this.keyTable[i]) != null) newHashtable.put(currentKey, this.valueTable[i]); this.keyTable = newHashtable.keyTable; this.valueTable = newHashtable.valueTable; this.threshold = newHashtable.threshold; }
public boolean isPackage(String[] pkgName) { return this.packageFragments.get(pkgName) != null; }
public Object put(Object[] key, Object value) { int length = this.keyTable.length; int index = hashCode(key) % length; int keyLength = key.length; Object[] currentKey; while ((currentKey = this.keyTable[index]) != null) { if (currentKey.length == keyLength && Util.equalArraysOrNull(currentKey, key)) return this.valueTable[index] = value; if (++index == length) { index = 0; } } this.keyTable[index] = key; this.valueTable[index] = value; // assumes the threshold is never equal to the size of the table if (++this.elementSize > this.threshold) rehash(); return value; }
Util.verbose(" BUILDING NameLoopkup"); //$NON-NLS-1$ Util.verbose(" -> pkg roots size: " + (packageFragmentRoots == null ? 0 : packageFragmentRoots.length)); //$NON-NLS-1$ Util.verbose(" -> pkgs size: " + (packageFragments == null ? 0 : packageFragments.size())); //$NON-NLS-1$ Util.verbose(" -> working copy size: " + (workingCopies == null ? 0 : workingCopies.length)); //$NON-NLS-1$ start = System.currentTimeMillis(); this.packageFragments = (HashtableOfArrayToObject) packageFragments.clone(); } catch (CloneNotSupportedException e1) { Object existing = this.packageFragments.get(pkgName); if (existing == null || existing == JavaProjectElementInfo.NO_ROOTS) { this.packageFragments.put(pkgName, root); int exisitingPosition = rootPositions.get(existing); if (rootPosition != exisitingPosition) { // if not equal this.packageFragments.put( pkgName, exisitingPosition < rootPosition ? newRoots[insertionIndex] = root; System.arraycopy(roots, insertionIndex, newRoots, insertionIndex+1, rootLength-insertionIndex); this.packageFragments.put(pkgName, newRoots);
int existingLength = length; while (existingLength >= 0) { existing = (String[]) rawPackageInfo.getKey(pkgName, existingLength); if (existing != null) break; existingLength--; System.arraycopy(existing, 0, existing = new String[i+1], 0, i); existing[i] = manager.intern(pkgName[i]); rawPackageInfo.put(existing, new ArrayList[] { EMPTY_LIST, EMPTY_LIST }); } else { ArrayList[] children = (ArrayList[]) rawPackageInfo.get(existing); if (children[1/*NON_JAVA*/] == EMPTY_LIST) children[1/*NON_JAVA*/] = new ArrayList(); children[1/*NON_JAVA*/].add(entryName); ArrayList[] children = (ArrayList[]) rawPackageInfo.get(pkgName); if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(entryName)) { if (children[0/*JAVA*/] == EMPTY_LIST) children[0/*JAVA*/] = new ArrayList();
HashtableOfArrayToObject rawPackageInfo = new HashtableOfArrayToObject(); IJavaElement[] children; ZipFile jar = null; rawPackageInfo.put(CharOperation.NO_STRINGS, new ArrayList[] { EMPTY_LIST, EMPTY_LIST }); children = new IJavaElement[rawPackageInfo.size()]; int index = 0; for (int i = 0, length = rawPackageInfo.keyTable.length; i < length; i++) {
this.lastPkgFragmentRootPath= jarPath; this.lastPkgFragmentRoot= root; this.packageHandles= new HashtableOfArrayToObject(5); pkgName = CharOperation.NO_STRINGS; IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName); if (pkgFragment == null) { pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName, moduleName); //BUG 478143 return null; this.packageHandles.put(pkgName, pkgFragment);
private int hashCode(Object[] element) { return hashCode(element, element.length); }
private void seekModuleAwarePartialPackageFragments(String name, IJavaElementRequestor requestor, IPackageFragmentRoot[] moduleContext) { boolean allPrefixMatch = CharOperation.equals(name.toCharArray(), CharOperation.ALL_PREFIX); String lName = name.toLowerCase(); Arrays.stream(this.packageFragments.keyTable) .filter(k -> k != null) .filter(k -> allPrefixMatch || Util.concatWith((String[])k, '.').toLowerCase().startsWith(lName)) .forEach(k -> { checkModulePackages(requestor, moduleContext, this.packageFragments.getIndex(k)); }); }
/** * @see IJavaElement */ public boolean exists() { if (JavaModelManager.getJavaModelManager().getInfo(this) != null) return true; switch (getElementType()) { case IJavaElement.PACKAGE_FRAGMENT: PackageFragmentRoot root = getPackageFragmentRoot(); if (root.isArchive()) { // pkg in a jar -> need to open root to know if this pkg exists JarPackageFragmentRootInfo rootInfo; try { rootInfo = (JarPackageFragmentRootInfo) root.getElementInfo(); } catch (JavaModelException e) { return false; } return rootInfo.rawPackageInfo.containsKey(((PackageFragment) this).names); } break; case IJavaElement.CLASS_FILE: if (getPackageFragmentRoot().isArchive()) { // class file in a jar -> need to open this class file to know if it exists return super.exists(); } break; } return validateExistence(resource()).isOK(); } public String findRecommendedLineSeparator() throws JavaModelException {
protected IJavaElement[] createChildren(final HashtableOfArrayToObject rawPackageInfo) { IJavaElement[] children; // loop through all of referenced packages, creating package fragments if necessary // and cache the entry names in the rawPackageInfo table children = new IJavaElement[rawPackageInfo.size()]; int index = 0; for (int i = 0, length = rawPackageInfo.keyTable.length; i < length; i++) { String[] pkgName = (String[]) rawPackageInfo.keyTable[i]; if (pkgName == null) continue; children[index++] = getPackageFragment(pkgName); } return children; } /**
Util.verbose(" BUILDING NameLoopkup"); //$NON-NLS-1$ Util.verbose(" -> pkg roots size: " + (packageFragmentRoots == null ? 0 : packageFragmentRoots.length)); //$NON-NLS-1$ Util.verbose(" -> pkgs size: " + (packageFragments == null ? 0 : packageFragments.size())); //$NON-NLS-1$ Util.verbose(" -> working copy size: " + (workingCopies == null ? 0 : workingCopies.length)); //$NON-NLS-1$ start = System.currentTimeMillis(); this.packageFragments = (HashtableOfArrayToObject) packageFragments.clone(); } catch (CloneNotSupportedException e1) { Object existing = this.packageFragments.get(pkgName); if (existing == null || existing == JavaProjectElementInfo.NO_ROOTS) { this.packageFragments.put(pkgName, root); int exisitingPosition = rootPositions.get(existing); if (rootPosition != exisitingPosition) { // if not equal this.packageFragments.put( pkgName, exisitingPosition < rootPosition ? newRoots[insertionIndex] = root; System.arraycopy(roots, insertionIndex, newRoots, insertionIndex+1, rootLength-insertionIndex); this.packageFragments.put(pkgName, newRoots);
int existingLength = length; while (existingLength >= 0) { existing = (String[]) rawPackageInfo.getKey(pkgName, existingLength); if (existing != null) break; existingLength--; System.arraycopy(existing, 0, existing = new String[i+1], 0, i); existing[i] = manager.intern(pkgName[i]); rawPackageInfo.put(existing, new ArrayList[] { EMPTY_LIST, EMPTY_LIST }); } else { ArrayList[] children = (ArrayList[]) rawPackageInfo.get(existing); if (children[1/*NON_JAVA*/] == EMPTY_LIST) children[1/*NON_JAVA*/] = new ArrayList(); children[1/*NON_JAVA*/].add(entryName); ArrayList[] children = (ArrayList[]) rawPackageInfo.get(pkgName); if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(entryName)) { if (children[0/*JAVA*/] == EMPTY_LIST) children[0/*JAVA*/] = new ArrayList();
HashtableOfArrayToObject rawPackageInfo = new HashtableOfArrayToObject(); IJavaElement[] children; ZipFile jar = null; rawPackageInfo.put(CharOperation.NO_STRINGS, new ArrayList[] { EMPTY_LIST, EMPTY_LIST }); children = new IJavaElement[rawPackageInfo.size()]; int index = 0; for (int i = 0, length = rawPackageInfo.keyTable.length; i < length; i++) {
this.lastPkgFragmentRootPath= jarPath; this.lastPkgFragmentRoot= root; this.packageHandles= new HashtableOfArrayToObject(5); pkgName = CharOperation.NO_STRINGS; IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName); if (pkgFragment == null) { pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName); return null; this.packageHandles.put(pkgName, pkgFragment);
public Object[] getKey(Object[] key, int keyLength) { int length = this.keyTable.length; int index = hashCode(key, keyLength) % length; Object[] currentKey; while ((currentKey = this.keyTable[index]) != null) { if (currentKey.length == keyLength && Util.equalArrays(currentKey, key, keyLength)) return currentKey; if (++index == length) { index = 0; } } return null; }
private void seekModuleAwarePartialPackageFragments(String name, IJavaElementRequestor requestor, IPackageFragmentRoot[] moduleContext) { boolean allPrefixMatch = CharOperation.equals(name.toCharArray(), CharOperation.ALL_PREFIX); Arrays.stream(this.packageFragments.keyTable) .filter(k -> k != null) .filter(k -> allPrefixMatch || Util.concatWith((String[])k, '.').startsWith(name)) .forEach(k -> { checkModulePackages(requestor, moduleContext, this.packageFragments.getIndex(k)); }); }
/** * @see IJavaElement */ public boolean exists() { if (JavaModelManager.getJavaModelManager().getInfo(this) != null) return true; switch (getElementType()) { case IJavaElement.PACKAGE_FRAGMENT: PackageFragmentRoot root = getPackageFragmentRoot(); if (root.isArchive()) { // pkg in a jar -> need to open root to know if this pkg exists JarPackageFragmentRootInfo rootInfo; try { rootInfo = (JarPackageFragmentRootInfo) root.getElementInfo(); } catch (JavaModelException e) { return false; } return rootInfo.rawPackageInfo.containsKey(((PackageFragment) this).names); } break; case IJavaElement.CLASS_FILE: if (getPackageFragmentRoot().isArchive()) { // class file in a jar -> need to open this class file to know if it exists return super.exists(); } break; } return validateExistence(resource()).isOK(); } public String findRecommendedLineSeparator() throws JavaModelException {