Lines 13-21
Link Here
|
13 |
import java.io.File; |
13 |
import java.io.File; |
14 |
import java.io.IOException; |
14 |
import java.io.IOException; |
15 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
|
|
16 |
import java.util.HashMap; |
16 |
import java.util.HashSet; |
17 |
import java.util.HashSet; |
17 |
import java.util.Iterator; |
18 |
import java.util.Iterator; |
18 |
import java.util.List; |
19 |
import java.util.List; |
|
|
20 |
import java.util.Map; |
19 |
import java.util.Set; |
21 |
import java.util.Set; |
20 |
|
22 |
|
21 |
import org.eclipse.jdt.core.compiler.CharOperation; |
23 |
import org.eclipse.jdt.core.compiler.CharOperation; |
Lines 40-46
Link Here
|
40 |
* @return a list of the jar file names defined in the Class-Path |
42 |
* @return a list of the jar file names defined in the Class-Path |
41 |
* section of the jar file manifest if any |
43 |
* section of the jar file manifest if any |
42 |
*/ |
44 |
*/ |
43 |
List fetchLinkedJars(ClasspathSectionProblemReporter problemReporter); |
45 |
List fetchLinkedJars(ClasspathProblemReporter problemReporter); |
44 |
/** |
46 |
/** |
45 |
* This method resets the environment. The resulting state is equivalent to |
47 |
* This method resets the environment. The resulting state is equivalent to |
46 |
* a new name environment without creating a new object. |
48 |
* a new name environment without creating a new object. |
Lines 68-76
Link Here
|
68 |
*/ |
70 |
*/ |
69 |
void initialize() throws IOException; |
71 |
void initialize() throws IOException; |
70 |
} |
72 |
} |
71 |
public interface ClasspathSectionProblemReporter { |
73 |
public interface ClasspathProblemReporter { |
72 |
void invalidClasspathSection(String jarFilePath); |
74 |
void invalidClasspathSection(String jarFilePath); |
73 |
void multipleClasspathSections(String jarFilePath); |
75 |
void multipleClasspathSections(String jarFilePath); |
|
|
76 |
void nestedClasspath(String classpathOne, String classpathTwo); |
74 |
} |
77 |
} |
75 |
|
78 |
|
76 |
/** |
79 |
/** |
Lines 103-116
Link Here
|
103 |
|
106 |
|
104 |
Classpath[] classpaths; |
107 |
Classpath[] classpaths; |
105 |
Set knownFileNames; |
108 |
Set knownFileNames; |
|
|
109 |
private ClasspathProblemReporter problemReporter; |
106 |
|
110 |
|
107 |
/* |
111 |
/* |
108 |
classPathNames is a collection is Strings representing the full path of each class path |
112 |
classPathNames is a collection is Strings representing the full path of each class path |
109 |
initialFileNames is a collection is Strings, the trailing '.java' will be removed if its not already. |
113 |
initialFileNames is a collection is Strings, the trailing '.java' will be removed if its not already. |
110 |
*/ |
114 |
*/ |
111 |
public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding) { |
115 |
public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding) { |
|
|
116 |
this(classpathNames, initialFileNames, encoding, null); |
117 |
} |
118 |
|
119 |
public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding, ClasspathProblemReporter problemReporter) { |
112 |
final int classpathSize = classpathNames.length; |
120 |
final int classpathSize = classpathNames.length; |
113 |
this.classpaths = new Classpath[classpathSize]; |
121 |
this.classpaths = new Classpath[classpathSize]; |
|
|
122 |
this.problemReporter = problemReporter; |
114 |
int counter = 0; |
123 |
int counter = 0; |
115 |
for (int i = 0; i < classpathSize; i++) { |
124 |
for (int i = 0; i < classpathSize; i++) { |
116 |
Classpath classpath = getClasspath(classpathNames[i], encoding, null); |
125 |
Classpath classpath = getClasspath(classpathNames[i], encoding, null); |
Lines 126-135
Link Here
|
126 |
} |
135 |
} |
127 |
initializeKnownFileNames(initialFileNames); |
136 |
initializeKnownFileNames(initialFileNames); |
128 |
} |
137 |
} |
129 |
protected FileSystem(Classpath[] paths, String[] initialFileNames) { |
138 |
protected FileSystem(Classpath[] paths, String[] initialFileNames, ClasspathProblemReporter problemReporter) { |
130 |
final int length = paths.length; |
139 |
final int length = paths.length; |
131 |
int counter = 0; |
140 |
int counter = 0; |
132 |
this.classpaths = new FileSystem.Classpath[length]; |
141 |
this.classpaths = new FileSystem.Classpath[length]; |
|
|
142 |
this.problemReporter = problemReporter; |
133 |
for (int i = 0; i < length; i++) { |
143 |
for (int i = 0; i < length; i++) { |
134 |
final Classpath classpath = paths[i]; |
144 |
final Classpath classpath = paths[i]; |
135 |
try { |
145 |
try { |
Lines 145-150
Link Here
|
145 |
} |
155 |
} |
146 |
initializeKnownFileNames(initialFileNames); |
156 |
initializeKnownFileNames(initialFileNames); |
147 |
} |
157 |
} |
|
|
158 |
protected FileSystem(Classpath[] paths, String[] initialFileNames) { |
159 |
this(paths, initialFileNames, null); |
160 |
} |
148 |
public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) { |
161 |
public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) { |
149 |
return getClasspath(classpathName, encoding, false, accessRuleSet, null); |
162 |
return getClasspath(classpathName, encoding, false, accessRuleSet, null); |
150 |
} |
163 |
} |
Lines 185-191
Link Here
|
185 |
this.knownFileNames = new HashSet(0); |
198 |
this.knownFileNames = new HashSet(0); |
186 |
return; |
199 |
return; |
187 |
} |
200 |
} |
|
|
201 |
if (this.problemReporter == null) { |
202 |
this.problemReporter = new ClasspathProblemReporter() { |
203 |
public void nestedClasspath(String classpathOne, String classpathTwo) { |
204 |
System.err.println("Nested classpath " + classpathOne + " and " + classpathTwo); //$NON-NLS-1$ //$NON-NLS-2$ |
205 |
} |
206 |
public void multipleClasspathSections(String jarFilePath) { |
207 |
System.err.println("Multiple classpath sections in " + jarFilePath); //$NON-NLS-1$ |
208 |
} |
209 |
public void invalidClasspathSection(String jarFilePath) { |
210 |
System.err.println("Invalid classpath section in " + jarFilePath); //$NON-NLS-1$ |
211 |
} |
212 |
}; |
213 |
} |
214 |
|
188 |
this.knownFileNames = new HashSet(initialFileNames.length * 2); |
215 |
this.knownFileNames = new HashSet(initialFileNames.length * 2); |
|
|
216 |
|
217 |
Map conflictingClasspath = new HashMap(); |
218 |
|
189 |
for (int i = initialFileNames.length; --i >= 0;) { |
219 |
for (int i = initialFileNames.length; --i >= 0;) { |
190 |
File compilationUnitFile = new File(initialFileNames[i]); |
220 |
File compilationUnitFile = new File(initialFileNames[i]); |
191 |
char[] fileName = null; |
221 |
char[] fileName = null; |
Lines 204-219
Link Here
|
204 |
for (int j = 0, max = this.classpaths.length; j < max; j++) { |
234 |
for (int j = 0, max = this.classpaths.length; j < max; j++) { |
205 |
char[] matchCandidate = this.classpaths[j].normalizedPath(); |
235 |
char[] matchCandidate = this.classpaths[j].normalizedPath(); |
206 |
if (this.classpaths[j] instanceof ClasspathDirectory && |
236 |
if (this.classpaths[j] instanceof ClasspathDirectory && |
207 |
CharOperation.prefixEquals(matchCandidate, fileName) && |
237 |
CharOperation.prefixEquals(matchCandidate, fileName)) { |
208 |
(matchingPathName == null || |
238 |
this.knownFileNames.add(new String(CharOperation.subarray(fileName, matchCandidate.length, fileName.length))); |
209 |
matchCandidate.length < matchingPathName.length)) { |
239 |
if (matchingPathName != null && matchingPathName.length != matchCandidate.length) { |
210 |
matchingPathName = matchCandidate; |
240 |
if (!conflictingClasspath.containsKey(matchCandidate)) { |
|
|
241 |
conflictingClasspath.put(matchCandidate, matchingPathName); |
242 |
this.problemReporter.nestedClasspath(new String(matchCandidate), new String(matchingPathName)); |
243 |
} |
244 |
} |
245 |
matchingPathName = matchCandidate; |
211 |
} |
246 |
} |
212 |
} |
247 |
} |
213 |
if (matchingPathName == null) { |
248 |
if (matchingPathName == null) { |
214 |
this.knownFileNames.add(new String(fileName)); // leave as is... |
249 |
this.knownFileNames.add(new String(fileName)); // leave as is... |
215 |
} else { |
|
|
216 |
this.knownFileNames.add(new String(CharOperation.subarray(fileName, matchingPathName.length, fileName.length))); |
217 |
} |
250 |
} |
218 |
matchingPathName = null; |
251 |
matchingPathName = null; |
219 |
} |
252 |
} |