import net.sourceforge.phpdt.core.compiler.CharOperation;
import net.sourceforge.phpdt.internal.compiler.env.INameEnvironment;
import net.sourceforge.phpdt.internal.compiler.env.NameEnvironmentAnswer;
-import net.sourceforge.phpdt.internal.compiler.util.SuffixConstants;
+//import net.sourceforge.phpdt.internal.compiler.util.SuffixConstants;
public class FileSystem implements INameEnvironment, SuffixConstants {
Classpath[] classpaths;
* '.java' will be removed if its not already.
*/
- public FileSystem(String[] classpathNames, String[] initialFileNames,
- String encoding) {
- this(classpathNames, initialFileNames, encoding, null);
- }
-
- public FileSystem(String[] classpathNames, String[] initialFileNames,
- String encoding, int[] classpathDirectoryModes) {
- int classpathSize = classpathNames.length;
- this.classpaths = new Classpath[classpathSize];
- String[] pathNames = new String[classpathSize];
- int problemsOccured = 0;
- for (int i = 0; i < classpathSize; i++) {
- // try {
- File file = new File(convertPathSeparators(classpathNames[i]));
- if (file.isDirectory()) {
- if (file.exists()) {
- if (classpathDirectoryModes == null) {
- this.classpaths[i] = new ClasspathDirectory(file,
- encoding);
- } else {
- this.classpaths[i] = new ClasspathDirectory(file,
- encoding, classpathDirectoryModes[i]);
- }
- pathNames[i] = ((ClasspathDirectory) this.classpaths[i]).path;
- }
- } else {
- String lowercaseClasspathName = classpathNames[i].toLowerCase();
- // if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar)
- // || lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) {
- // this.classpaths[i] = this.getClasspathJar(file); // will
- // throw an IOException if file does not exist
- // pathNames[i] = classpathNames[i].substring(0,
- // classpathNames[i].lastIndexOf('.'));
- // }
- }
- // } catch (IOException e) {
- // this.classpaths[i] = null;
- // }
- if (this.classpaths[i] == null)
- problemsOccured++;
- }
- if (problemsOccured > 0) {
- Classpath[] newPaths = new Classpath[classpathSize
- - problemsOccured];
- String[] newNames = new String[classpathSize - problemsOccured];
- for (int i = 0, current = 0; i < classpathSize; i++)
- if (this.classpaths[i] != null) {
- newPaths[current] = this.classpaths[i];
- newNames[current++] = pathNames[i];
- }
- classpathSize = newPaths.length;
- this.classpaths = newPaths;
- pathNames = newNames;
- }
-
- this.knownFileNames = new String[initialFileNames.length];
- for (int i = initialFileNames.length; --i >= 0;) {
- String fileName = initialFileNames[i];
- String matchingPathName = null;
- if (fileName.lastIndexOf(".") != -1) //$NON-NLS-1$
- fileName = fileName.substring(0, fileName.lastIndexOf('.')); // remove
- // trailing
- // ".java"
-
- fileName = convertPathSeparators(fileName);
- for (int j = 0; j < classpathSize; j++)
- if (fileName.startsWith(pathNames[j]))
- matchingPathName = pathNames[j];
- if (matchingPathName == null)
- this.knownFileNames[i] = fileName; // leave as is...
- else
- this.knownFileNames[i] = fileName.substring(matchingPathName
- .length());
- }
- }
+// public FileSystem(String[] classpathNames, String[] initialFileNames,
+// String encoding) {
+// this(classpathNames, initialFileNames, encoding, null);
+// }
+
+// public FileSystem(String[] classpathNames, String[] initialFileNames,
+// String encoding, int[] classpathDirectoryModes) {
+// int classpathSize = classpathNames.length;
+// this.classpaths = new Classpath[classpathSize];
+// String[] pathNames = new String[classpathSize];
+// int problemsOccured = 0;
+// for (int i = 0; i < classpathSize; i++) {
+// // try {
+// File file = new File(convertPathSeparators(classpathNames[i]));
+// if (file.isDirectory()) {
+// if (file.exists()) {
+// if (classpathDirectoryModes == null) {
+// this.classpaths[i] = new ClasspathDirectory(file,
+// encoding);
+// } else {
+// this.classpaths[i] = new ClasspathDirectory(file,
+// encoding, classpathDirectoryModes[i]);
+// }
+// pathNames[i] = ((ClasspathDirectory) this.classpaths[i]).path;
+// }
+// } else {
+// //String lowercaseClasspathName = classpathNames[i].toLowerCase();
+// // if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar)
+// // || lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) {
+// // this.classpaths[i] = this.getClasspathJar(file); // will
+// // throw an IOException if file does not exist
+// // pathNames[i] = classpathNames[i].substring(0,
+// // classpathNames[i].lastIndexOf('.'));
+// // }
+// }
+// // } catch (IOException e) {
+// // this.classpaths[i] = null;
+// // }
+// if (this.classpaths[i] == null)
+// problemsOccured++;
+// }
+// if (problemsOccured > 0) {
+// Classpath[] newPaths = new Classpath[classpathSize
+// - problemsOccured];
+// String[] newNames = new String[classpathSize - problemsOccured];
+// for (int i = 0, current = 0; i < classpathSize; i++)
+// if (this.classpaths[i] != null) {
+// newPaths[current] = this.classpaths[i];
+// newNames[current++] = pathNames[i];
+// }
+// classpathSize = newPaths.length;
+// this.classpaths = newPaths;
+// pathNames = newNames;
+// }
+//
+// this.knownFileNames = new String[initialFileNames.length];
+// for (int i = initialFileNames.length; --i >= 0;) {
+// String fileName = initialFileNames[i];
+// String matchingPathName = null;
+// if (fileName.lastIndexOf(".") != -1) //$NON-NLS-1$
+// fileName = fileName.substring(0, fileName.lastIndexOf('.')); // remove
+// // trailing
+// // ".java"
+//
+// fileName = convertPathSeparators(fileName);
+// for (int j = 0; j < classpathSize; j++)
+// if (fileName.startsWith(pathNames[j]))
+// matchingPathName = pathNames[j];
+// if (matchingPathName == null)
+// this.knownFileNames[i] = fileName; // leave as is...
+// else
+// this.knownFileNames[i] = fileName.substring(matchingPathName
+// .length());
+// }
+// }
public void cleanup() {
for (int i = 0, max = this.classpaths.length; i < max; i++)
this.classpaths[i].reset();
}
- private String convertPathSeparators(String path) {
- return File.separatorChar == '/' ? path.replace('\\', '/') : path
- .replace('/', '\\');
- }
+// private String convertPathSeparators(String path) {
+// return File.separatorChar == '/' ? path.replace('\\', '/') : path
+// .replace('/', '\\');
+// }
// private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[]
// typeName){