public char[][] singletonModuleNameIf(boolean condition) { if (!condition) return null; if (this.module != null) return new char[][] { this.module.name() }; return new char[][] { ModuleBinding.UNNAMED }; } }
public AutomaticModuleBinding(IModule module, LookupEnvironment existingEnvironment) { super(module.name(), existingEnvironment); existingEnvironment.root.knownModules.put(this.moduleName, this); this.isAuto = true; this.requires = Binding.NO_MODULES; this.requiresTransitive = Binding.NO_MODULES; this.exportedPackages = Binding.NO_PACKAGES; } public ModuleBinding[] getRequiresTransitive() {
@Override public Collection<String> getModuleNames(Collection<String> limitModules, Function<String,IModule> getModule) { if (this.module != null) { String name = String.valueOf(this.module.name()); return selectModules(Collections.singleton(name), limitModules, getModule); } return Collections.emptyList(); } protected Collection<String> selectModules(Set<String> modules, Collection<String> limitModules, Function<String,IModule> getModule) {
@Override public boolean isPackage(String qualifiedPackageName, String moduleName) { if (moduleName != null) { if (this.module == null || !moduleName.equals(String.valueOf(this.module.name()))) return false; } return directoryTable(qualifiedPackageName) != null; } @Override
@Override public char[] getModuleName() { IModule mod = this.sourceLocation.module(); return mod == null ? null : mod.name(); } }
@Override public IModule getModule(char[] moduleName) { Set<IModule> modules = ModulesCache.get(this.zipFilename); if (modules != null) { for (IModule mod : modules) { if (CharOperation.equals(mod.name(), moduleName)) return mod; } } return null; } @Override
@Override public char[][] getAllAutomaticModules() { if (this.modulePathEntries == null) return CharOperation.NO_CHAR_CHAR; Set<char[]> set = this.modulePathEntries.values().stream().filter(m -> m.isAutomaticModule()).map(e -> e.getModule().name()) .collect(Collectors.toSet()); return set.toArray(new char[set.size()][]); } @Override
@Override public char[][] getAllAutomaticModules() { if (this.modulePathEntries == null) return CharOperation.NO_CHAR_CHAR; Set<char[]> set = this.modulePathEntries.values().stream().filter(m -> m.isAutomaticModule()).map(e -> e.getModule().name()) .collect(Collectors.toSet()); return set.toArray(new char[set.size()][]); } @Override
@Override public char[][] getAllAutomaticModules() { Set<char[]> set = new HashSet<>(); for (int i = 0, l = this.classpaths.length; i < l; i++) { if (this.classpaths[i].isAutomaticModule()) { set.add(this.classpaths[i].getModule().name()); } } return set.toArray(new char[set.size()][]); }
/** TESTS ONLY */ public void scanForModules(Parser parser) { for (int i = 0, max = this.classpaths.length; i < max; i++) { File file = new File(this.classpaths[i].getPath()); IModule iModule = ModuleFinder.scanForModule(this.classpaths[i], file, parser, false, null); if (iModule != null) this.moduleLocations.put(String.valueOf(iModule.name()), this.classpaths[i]); } } @Override
@Override public char[][] getAllAutomaticModules() { Set<char[]> set = new HashSet<>(); for (int i = 0, l = this.classpaths.length; i < l; i++) { if (this.classpaths[i].isAutomaticModule()) { set.add(this.classpaths[i].getModule().name()); } } return set.toArray(new char[set.size()][]); }
public boolean isPackage(String qualifiedPackageName, String moduleName) { if (moduleName != null) { if (this.module == null || !moduleName.equals(String.valueOf(this.module.name()))) return false; } if (this.knownPackageNames == null) scanContent(); return this.knownPackageNames.includes(qualifiedPackageName); } @Override
public ClassFileReader getClassfile(String fileName, IModule module) throws IOException, ClassFormatException { ClassFileReader reader = null; if (module == null) { reader = getClassfile(fileName, (Predicate<String>)null); } else { byte[] content = getClassfileBytes(fileName, new String(module.name())); if (content != null) { reader = new ClassFileReader(content, fileName.toCharArray()); } } return reader; }
public IModule getModuleFromEnvironment(char[] name) { if (this.module != null && CharOperation.equals(name, this.module.name())) { return this.module; } for (Classpath classpath : this.classpaths) { IModule mod = classpath.getModule(name); if (mod != null) { return mod; } } return null; }
public IModule getModuleFromEnvironment(char[] name) { if (this.module != null && CharOperation.equals(name, this.module.name())) { return this.module; } for (Classpath classpath : this.classpaths) { IModule mod = classpath.getModule(name); if (mod != null) { return mod; } } return null; }
public NameEnvironmentAnswer findSecondaryInClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { //"package-info" is a reserved class name and can never be a secondary type (it is much faster to stop the search here). if(CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeName)) { return null; } String typeNameString = new String(typeName); String moduleName = this.module != null ? String.valueOf(this.module.name()) : null; // TODO(SHMOD): test for ModuleBinding.ANY & UNNAMED boolean prereqs = this.options != null && isPackage(qualifiedPackageName, moduleName) && ((this.mode & SOURCE) != 0) && doesFileExist(typeNameString + SUFFIX_STRING_java, qualifiedPackageName); return prereqs ? null : findSourceSecondaryType(typeNameString, qualifiedPackageName, qualifiedBinaryFileName); /* only secondary types */ }
public NameEnvironmentAnswer findSecondaryInClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { //"package-info" is a reserved class name and can never be a secondary type (it is much faster to stop the search here). if(CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeName)) { return null; } String typeNameString = new String(typeName); String moduleName = this.module != null ? String.valueOf(this.module.name()) : null; // TODO(SHMOD): test for ModuleBinding.ANY & UNNAMED boolean prereqs = this.options != null && isPackage(qualifiedPackageName, moduleName) && ((this.mode & SOURCE) != 0) && doesFileExist(typeNameString + SUFFIX_STRING_java, qualifiedPackageName); return prereqs ? null : findSourceSecondaryType(typeNameString, qualifiedPackageName, qualifiedBinaryFileName); /* only secondary types */ }
private void addRequired(String mod, Set<String> allModules) { IModule iMod = getModule(mod.toCharArray()); for (IModuleReference requiredRef : iMod.requires()) { IModule reqMod = getModule(requiredRef.name()); if (reqMod != null) { String reqModName = String.valueOf(reqMod.name()); if (allModules.add(reqModName)) addRequired(reqModName, allModules); } } } @Override
@Override public NameEnvironmentAnswer findClass(String sourceFileWithoutExtension, String qualifiedPackageName, String moduleName, String qualifiedSourceFileWithoutExtension) { 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, this.module == null ? null : this.module.name()), null /* no access restriction */); } } return null; }
public NameEnvironmentAnswer findClass(String sourceFileWithoutExtension, String qualifiedPackageName, String moduleName, String qualifiedSourceFileWithoutExtension) { 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, this.module == null ? null : this.module.name()), null /* no access restriction */); } } return null; }