public FileSystem getLibraryAccess() { return new FileSystem(this.checkedClasspaths, this.filenames); }
public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding) { final int classpathSize = classpathNames.length; this.classpaths = new Classpath[classpathSize]; int counter = 0; for (int i = 0; i < classpathSize; i++) { Classpath classpath = getClasspath(classpathNames[i], encoding, null, null); try { classpath.initialize(); this.classpaths[counter++] = classpath; } catch (IOException e) { // ignore } } if (counter != classpathSize) { System.arraycopy(this.classpaths, 0, (this.classpaths = new Classpath[counter]), 0, counter); } initializeKnownFileNames(initialFileNames); } protected FileSystem(Classpath[] paths, String[] initialFileNames, boolean annotationsFromClasspath) {
@Override public void cleanup() { super.cleanup(); m_overrideSupport.clear(); } }
String destinationPath) { Classpath result = null; File file = new File(convertPathSeparators(classpathName)); if (file.isDirectory()) { if (file.exists()) { destinationPath == null || destinationPath == Main.NONE ? convertPathSeparators(destinationPath)); destinationPath == null || destinationPath == Main.NONE ? convertPathSeparators(destinationPath)); } else if (destinationPath == null) {
public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) { return getClasspath(classpathName, encoding, false, accessRuleSet, null, null); } public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet, Map options) {
public NameEnvironmentAnswer findType(char[][] compoundName) { if (compoundName != null) return findClass( new String(CharOperation.concatWith(compoundName, '/')), compoundName[compoundName.length - 1], false); return null; } public char[][][] findTypeNames(char[][] packageName) {
public static Classpath getJrtClasspath(String jdkHome, String encoding, AccessRuleSet accessRuleSet, Map<String, String> options) { return new ClasspathJrt(new File(convertPathSeparators(jdkHome)), true, accessRuleSet, null); } public static Classpath getOlderSystemRelease(String jdkHome, String release, AccessRuleSet accessRuleSet) {
public NameEnvironmentAnswer findType(char[][] compoundName) { checkCanceled(); return super.findType(compoundName); } public boolean isPackage(char[][] compoundName, char[] packageName) {
@Override public boolean isPackage(char[][] compoundName, char[] packageName) { checkCanceled(); return super.isPackage(compoundName, packageName); }
@Override public List<? extends Element> getEnclosedElements() { PackageBinding binding = (PackageBinding)_binding; LookupEnvironment environment = binding.environment; char[][][] typeNames = null; INameEnvironment nameEnvironment = binding.environment.nameEnvironment; if (nameEnvironment instanceof FileSystem) { typeNames = ((FileSystem) nameEnvironment).findTypeNames(binding.compoundName); } HashSet<Element> set = new HashSet<Element>(); if (typeNames != null) { for (char[][] typeName : typeNames) { ReferenceBinding type = environment.getType(typeName); if (type != null && type.isValidBinding()) { set.add(_env.getFactory().newElement(type)); } } } ArrayList<Element> list = new ArrayList<Element>(set.size()); list.addAll(set); return Collections.unmodifiableList(list); }
FileSystem(Classpath[] paths, String[] initialFileNames) { final int length = paths.length; int counter = 0; this.classpaths = new FileSystem.Classpath[length]; for (int i = 0; i < length; i++) { final Classpath classpath = paths[i]; try { classpath.initialize(); this.classpaths[counter++] = classpath; } catch(IOException exception) { // ignore } } if (counter != length) { // should not happen System.arraycopy(this.classpaths, 0, (this.classpaths = new FileSystem.Classpath[counter]), 0, counter); } initializeKnownFileNames(initialFileNames); } public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) {
private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName, boolean asBinaryOnly){ NameEnvironmentAnswer answer = internalFindClass(qualifiedTypeName, typeName, asBinaryOnly); if (this.annotationsFromClasspath && answer != null && answer.getBinaryType() instanceof ClassFileReader) { for (int i = 0, length = this.classpaths.length; i < length; i++) { Classpath classpathEntry = this.classpaths[i]; if (classpathEntry.hasAnnotationFileFor(qualifiedTypeName)) { ZipFile zip = classpathEntry instanceof ClasspathJar ? ((ClasspathJar) classpathEntry).zipFile : null; try { ((ClassFileReader) answer.getBinaryType()).setExternalAnnotationProvider(classpathEntry.getPath(), qualifiedTypeName, zip, null); break; } catch (IOException e) { // ignore broken entry, keep searching } } } } return answer; } private NameEnvironmentAnswer internalFindClass(String qualifiedTypeName, char[] typeName, boolean asBinaryOnly){
String destinationPath) { Classpath result = null; File file = new File(convertPathSeparators(classpathName)); if (file.isDirectory()) { if (file.exists()) { destinationPath == null || destinationPath == Main.NONE ? convertPathSeparators(destinationPath)); destinationPath == null || destinationPath == Main.NONE ? convertPathSeparators(destinationPath)); } else if (destinationPath == null) {
public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) { return getClasspath(classpathName, encoding, false, accessRuleSet, null, null); } public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet, Map options) {
public NameEnvironmentAnswer findType(char[][] compoundName, boolean asBinaryOnly) { if (compoundName != null) return findClass( new String(CharOperation.concatWith(compoundName, '/')), compoundName[compoundName.length - 1], asBinaryOnly); return null; } public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
public static Classpath getOlderSystemRelease(String jdkHome, String release, AccessRuleSet accessRuleSet) { return new ClasspathJep247(new File(convertPathSeparators(jdkHome)), release, accessRuleSet); } public static Classpath getClasspath(String classpathName, String encoding,
@Override public NameEnvironmentAnswer findType(final char[][] compoundName) { final NameEnvironmentAnswer answer = searchInOverrideSupport(compoundName); if (answer != null) { return answer; } return super.findType(compoundName); }
public boolean isPackage(char[][] compoundName, char[] packageName) { checkCanceled(); return super.isPackage(compoundName, packageName); }
@Override public List<? extends Element> getEnclosedElements() { PackageBinding binding = (PackageBinding)_binding; LookupEnvironment environment = binding.environment; char[][][] typeNames = null; INameEnvironment nameEnvironment = binding.environment.nameEnvironment; if (nameEnvironment instanceof FileSystem) { typeNames = ((FileSystem) nameEnvironment).findTypeNames(binding.compoundName); } HashSet<Element> set = new HashSet<>(); if (typeNames != null) { for (char[][] typeName : typeNames) { ReferenceBinding type = environment.getType(typeName); if (type != null && type.isValidBinding()) { set.add(_env.getFactory().newElement(type)); } } } ArrayList<Element> list = new ArrayList<>(set.size()); list.addAll(set); return Collections.unmodifiableList(list); }
protected FileSystem(Classpath[] paths, String[] initialFileNames, boolean annotationsFromClasspath) { final int length = paths.length; int counter = 0; this.classpaths = new FileSystem.Classpath[length]; for (int i = 0; i < length; i++) { final Classpath classpath = paths[i]; try { classpath.initialize(); this.classpaths[counter++] = classpath; } catch(IOException exception) { // ignore } } if (counter != length) { // should not happen System.arraycopy(this.classpaths, 0, (this.classpaths = new FileSystem.Classpath[counter]), 0, counter); } initializeKnownFileNames(initialFileNames); this.annotationsFromClasspath = annotationsFromClasspath; } public static Classpath getClasspath(String classpathName, String encoding, AccessRuleSet accessRuleSet) {