Lines 12-17
Link Here
|
12 |
|
12 |
|
13 |
import java.io.File; |
13 |
import java.io.File; |
14 |
import java.io.IOException; |
14 |
import java.io.IOException; |
|
|
15 |
import java.util.HashSet; |
16 |
import java.util.Set; |
15 |
|
17 |
|
16 |
import org.eclipse.jdt.core.compiler.CharOperation; |
18 |
import org.eclipse.jdt.core.compiler.CharOperation; |
17 |
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; |
19 |
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; |
Lines 21-27
Link Here
|
21 |
|
23 |
|
22 |
public class FileSystem implements INameEnvironment, SuffixConstants { |
24 |
public class FileSystem implements INameEnvironment, SuffixConstants { |
23 |
Classpath[] classpaths; |
25 |
Classpath[] classpaths; |
24 |
String[] knownFileNames; |
26 |
Set knownFileNames; |
25 |
|
27 |
|
26 |
interface Classpath { |
28 |
interface Classpath { |
27 |
NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName); |
29 |
NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName); |
Lines 37-43
Link Here
|
37 |
* (resp. '.zip') extension for jar (resp. zip) files. |
39 |
* (resp. '.zip') extension for jar (resp. zip) files. |
38 |
* @return a normalized path for file based classpath entries |
40 |
* @return a normalized path for file based classpath entries |
39 |
*/ |
41 |
*/ |
40 |
String normalizedPath(); |
42 |
char[] normalizedPath(); |
41 |
/** |
43 |
/** |
42 |
* Return the path for file based classpath entries. This is an absolute path |
44 |
* Return the path for file based classpath entries. This is an absolute path |
43 |
* ending with a file separator for directories, an absolute path including the '.jar' |
45 |
* ending with a file separator for directories, an absolute path including the '.jar' |
Lines 117-142
Link Here
|
117 |
return result; |
119 |
return result; |
118 |
} |
120 |
} |
119 |
private void initializeKnownFileNames(String[] initialFileNames) { |
121 |
private void initializeKnownFileNames(String[] initialFileNames) { |
120 |
this.knownFileNames = new String[initialFileNames.length]; |
122 |
this.knownFileNames = new HashSet(initialFileNames.length * 2); |
121 |
for (int i = initialFileNames.length; --i >= 0;) { |
123 |
for (int i = initialFileNames.length; --i >= 0;) { |
122 |
String fileName = initialFileNames[i]; |
124 |
char[] fileName = initialFileNames[i].toCharArray(); |
123 |
String matchingPathName = null; |
125 |
char[] matchingPathName = null; |
124 |
if (fileName.lastIndexOf(".") != -1) //$NON-NLS-1$ |
126 |
final int lastIndexOf = CharOperation.lastIndexOf('.', fileName); |
125 |
fileName = fileName.substring(0, fileName.lastIndexOf('.')); // remove trailing ".java" |
127 |
if (lastIndexOf != -1) { |
126 |
|
128 |
fileName = CharOperation.subarray(fileName, 0, lastIndexOf); |
127 |
fileName = convertPathSeparators(fileName); |
129 |
} |
|
|
130 |
CharOperation.replace(fileName, '\\', '/'); |
128 |
for (int j = 0; j < classpaths.length; j++){ |
131 |
for (int j = 0; j < classpaths.length; j++){ |
129 |
String matchCandidate = this.classpaths[j].normalizedPath(); |
132 |
char[] matchCandidate = this.classpaths[j].normalizedPath(); |
130 |
if (this.classpaths[j] instanceof ClasspathDirectory && |
133 |
if (this.classpaths[j] instanceof ClasspathDirectory && |
131 |
fileName.startsWith(matchCandidate) && |
134 |
CharOperation.prefixEquals(matchCandidate, fileName) && |
132 |
(matchingPathName == null || |
135 |
(matchingPathName == null || |
133 |
matchCandidate.length() < matchingPathName.length())) |
136 |
matchCandidate.length < matchingPathName.length)) |
134 |
matchingPathName = matchCandidate; |
137 |
matchingPathName = matchCandidate; |
135 |
} |
138 |
} |
136 |
if (matchingPathName == null) |
139 |
if (matchingPathName == null) { |
137 |
this.knownFileNames[i] = fileName; // leave as is... |
140 |
this.knownFileNames.add(new String(fileName)); // leave as is... |
138 |
else |
141 |
} else { |
139 |
this.knownFileNames[i] = fileName.substring(matchingPathName.length()); |
142 |
this.knownFileNames.add(new String(CharOperation.subarray(fileName, matchingPathName.length, fileName.length))); |
|
|
143 |
} |
140 |
matchingPathName = null; |
144 |
matchingPathName = null; |
141 |
} |
145 |
} |
142 |
} |
146 |
} |
Lines 150-158
Link Here
|
150 |
: path.replace('/', '\\'); |
154 |
: path.replace('/', '\\'); |
151 |
} |
155 |
} |
152 |
private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName){ |
156 |
private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName){ |
153 |
for (int i = 0, length = this.knownFileNames.length; i < length; i++) |
157 |
if (this.knownFileNames.contains(qualifiedTypeName)) return null; // looking for a file which we know was provided at the beginning of the compilation |
154 |
if (qualifiedTypeName.equals(this.knownFileNames[i])) |
|
|
155 |
return null; // looking for a file which we know was provided at the beginning of the compilation |
156 |
|
158 |
|
157 |
String qualifiedBinaryFileName = qualifiedTypeName + SUFFIX_STRING_class; |
159 |
String qualifiedBinaryFileName = qualifiedTypeName + SUFFIX_STRING_class; |
158 |
String qualifiedPackageName = |
160 |
String qualifiedPackageName = |