### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java,v retrieving revision 1.17 diff -u -r1.17 ClasspathSourceDirectory.java --- search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java 7 Dec 2005 11:27:15 -0000 1.17 +++ search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java 9 Dec 2005 16:37:24 -0000 @@ -15,7 +15,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; import org.eclipse.jdt.internal.core.builder.ClasspathLocation; @@ -26,7 +25,7 @@ IContainer sourceFolder; SimpleLookupTable directoryCache; - String[] missingPackageHolder = new String[1]; + SimpleLookupTable missingPackageHolder = new SimpleLookupTable(); char[][] fullExclusionPatternChars; char[][] fulInclusionPatternChars; @@ -41,27 +40,31 @@ this.directoryCache = null; } -String[] directoryList(String qualifiedPackageName) { - String[] dirList = (String[]) directoryCache.get(qualifiedPackageName); - if (dirList == missingPackageHolder) return null; // package exists in another classpath directory or jar - if (dirList != null) return dirList; +SimpleLookupTable directoryTable(String qualifiedPackageName) { + SimpleLookupTable dirTable = (SimpleLookupTable) directoryCache.get(qualifiedPackageName); + if (dirTable == missingPackageHolder) return null; // package exists in another classpath directory or jar + if (dirTable != null) return dirTable; try { IResource container = sourceFolder.findMember(qualifiedPackageName); // this is a case-sensitive check if (container instanceof IContainer) { IResource[] members = ((IContainer) container).members(); - dirList = new String[members.length]; - int index = 0; + dirTable = new SimpleLookupTable(); for (int i = 0, l = members.length; i < l; i++) { IResource m = members[i]; String name; - if (m.getType() == IResource.FILE && org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(name = m.getName())) - dirList[index++] = name; + if (m.getType() == IResource.FILE) { + int index = Util.indexOfJavaLikeExtension(name = m.getName()); + if (index >= 0) { + String fullPath = m.getFullPath().toString(); + if (!org.eclipse.jdt.internal.compiler.util.Util.isExcluded(fullPath.toCharArray(), this.fulInclusionPatternChars, this.fullExclusionPatternChars, false/*not a folder path*/)) { + dirTable.put(name.substring(0, index), m); + } + } + } } - if (index < dirList.length) - System.arraycopy(dirList, 0, dirList = new String[index], 0, index); - directoryCache.put(qualifiedPackageName, dirList); - return dirList; + directoryCache.put(qualifiedPackageName, dirTable); + return dirTable; } } catch(CoreException ignored) { // treat as if missing @@ -70,16 +73,6 @@ return null; } -boolean doesFileExist(String fileName, String qualifiedPackageName) { - String[] dirList = directoryList(qualifiedPackageName); - if (dirList == null) return false; // most common case - - for (int i = dirList.length; --i >= 0;) - if (fileName.equals(dirList[i])) - return true; - return false; -} - public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ClasspathSourceDirectory)) return false; @@ -88,20 +81,12 @@ } public NameEnvironmentAnswer findClass(String sourceFileWithoutExtension, String qualifiedPackageName, String qualifiedSourceFileWithoutExtension) { - - String sourceFolderPath = this.sourceFolder.getFullPath().toString() + IPath.SEPARATOR; - char[][] javaLikeExtensions = Util.getJavaLikeExtensions(); - for (int i = 0, length = javaLikeExtensions.length; i < length; i++) { - String extension = '.' + new String(javaLikeExtensions[i]); - String sourceFileName = sourceFileWithoutExtension + extension; - if (!doesFileExist(sourceFileName, qualifiedPackageName)) continue; // most common case - - String qualifiedSourceFileName = qualifiedSourceFileWithoutExtension + extension; - if (org.eclipse.jdt.internal.compiler.util.Util.isExcluded((sourceFolderPath + qualifiedSourceFileName).toCharArray(), this.fulInclusionPatternChars, this.fullExclusionPatternChars, false/*not a folder path*/)) - continue; - IPath path = new Path(qualifiedSourceFileName); - IFile file = this.sourceFolder.getFile(path); - return new NameEnvironmentAnswer(new ResourceCompilationUnit(file), null /* no access restriction */); + SimpleLookupTable dirTable = directoryTable(qualifiedPackageName); + if (dirTable != null && dirTable.elementSize > 0) { + IFile file = (IFile) dirTable.get(sourceFileWithoutExtension); + if (file != null) { + return new NameEnvironmentAnswer(new ResourceCompilationUnit(file), null /* no access restriction */); + } } return null; } @@ -111,7 +96,7 @@ } public boolean isPackage(String qualifiedPackageName) { - return directoryList(qualifiedPackageName) != null; + return directoryTable(qualifiedPackageName) != null; } public void reset() {