@Override public ModuleBinding[] getAllRequiredModules() { if (this.scope != null) this.scope.referenceContext.moduleDeclaration.resolveModuleDirectives(this.scope); return super.getAllRequiredModules(); } @Override
@Override public ModuleBinding[] getAllRequiredModules() { if (this.scope != null) this.scope.referenceContext.moduleDeclaration.resolveModuleDirectives(this.scope); return super.getAllRequiredModules(); } public long getAnnotationTagBits() {
private void addRequiredModules(MatchLocator matchLocator) { if (matchLocator.matchBinding == null) return; for (Binding b :matchLocator.matchBinding.values()) { if (b instanceof ModuleBinding && ((ModuleBinding) b).moduleName != null) { ModuleBinding m = (ModuleBinding) b; tmpGraph.add(new String(m.moduleName)); for (ModuleBinding r : m.getAllRequiredModules()) { char[] name = r.moduleName; if (name == null || CharOperation.equals(name, CharOperation.NO_CHAR)) continue; tmpGraph.add(new String(name)); } } } } };
private void addRequiredModules(MatchLocator matchLocator) { if (matchLocator.matchBinding == null) return; for (Binding b :matchLocator.matchBinding.values()) { if (b instanceof ModuleBinding && ((ModuleBinding) b).moduleName != null) { ModuleBinding m = (ModuleBinding) b; tmpGraph.add(new String(m.moduleName)); for (ModuleBinding r : m.getAllRequiredModules()) { char[] name = r.moduleName; if (name == null || CharOperation.equals(name, CharOperation.NO_CHAR)) continue; tmpGraph.add(new String(name)); } } } } };
List<ModuleBinding> otherRelevantModules(char[][] declaringModuleNames) { if (isUnnamed() && declaringModuleNames != null) { // unnamed module reads all named modules, // so all modules declaring the given package are relevant: return Arrays.stream(declaringModuleNames) .filter(modName -> modName != UNNAMED) .map(modName -> this.environment.getModule(modName)) .filter(Objects::nonNull) .collect(Collectors.toList()); } else { return Arrays.asList(getAllRequiredModules()); } }
private PackageBinding combineWithPackagesFromRequired(PackageBinding currentBinding, char[][] compoundName) { boolean save = this.isPackageLookupActive; this.isPackageLookupActive = true; try { for (ModuleBinding moduleBinding : getAllRequiredModules()) if (!moduleBinding.isPackageLookupActive) currentBinding = SplitPackageBinding.combine(moduleBinding.getVisiblePackage(compoundName), currentBinding, this); return currentBinding; } finally { this.isPackageLookupActive = save; } }
/** * Check if the given package is accessible by this module. True when the package is declared in * this module or exported by some required module to this module. * See {@link #isPackageExportedTo(PackageBinding, ModuleBinding)} * * @param pkg * * @return True, if the package is accessible by this module, false otherwise */ public boolean canAccess(PackageBinding pkg) { if (pkg.isDeclaredIn(this)) return true; for (ModuleBinding requiredModule : getAllRequiredModules()) { // If pkg is a SplitPackageBinding, we actually ask the intersection of all required modules // and modules declaring the package, if any of them exports the package to this module. // The intersection is computed when inside isPackageExportedTo we ask for pkg's incarnation in requiredModule. if (requiredModule.isPackageExportedTo(pkg, ModuleBinding.this)) return true; // TODO(SHMOD): store export status in the PackageBinding? } return false; } @Override
/** * Check if the given package is accessible by this module. True when the package is declared in * this module or exported by some required module to this module. * See {@link #isPackageExportedTo(PackageBinding, ModuleBinding)} * * @param pkg * * @return True, if the package is accessible by this module, false otherwise */ public boolean canAccess(PackageBinding pkg) { if (pkg.isDeclaredIn(this)) return true; for (ModuleBinding requiredModule : getAllRequiredModules()) { // If pkg is a SplitPackageBinding, we actually ask the intersection of all required modules // and modules declaring the package, if any of them exports the package to this module. // The intersection is computed when inside isPackageExportedTo we ask for pkg's incarnation in requiredModule. if (requiredModule.isPackageExportedTo(pkg, ModuleBinding.this)) return true; // TODO(SHMOD): store export status in the PackageBinding? } return false; } @Override
public void analyseModuleGraph(CompilationUnitScope skope) { if (this.requires != null) { // collect transitively: Map<String, Set<ModuleBinding>> pack2mods = new HashMap<>(); for (ModuleBinding requiredModule : this.binding.getAllRequiredModules()) { for (PackageBinding exportedPackage : requiredModule.getExports()) { if (this.binding.canAccess(exportedPackage)) { String packName = String.valueOf(exportedPackage.readableName()); Set<ModuleBinding> mods = pack2mods.get(packName); if (mods == null) pack2mods.put(packName, mods = new HashSet<>()); mods.add(requiredModule); } } } // report against the causing requires directives: for (RequiresStatement requiresStat : this.requires) { ModuleBinding requiredModule = requiresStat.resolvedBinding; if (requiredModule != null) { analyseOneDependency(requiresStat, requiredModule, skope, pack2mods); if (requiresStat.isTransitive()) { for (ModuleBinding secondLevelModule : requiredModule.getAllRequiredModules()) analyseOneDependency(requiresStat, secondLevelModule, skope, pack2mods); } } } } }
public void analyseModuleGraph(CompilationUnitScope skope) { if (this.requires != null) { // collect transitively: Map<String, Set<ModuleBinding>> pack2mods = new HashMap<>(); for (ModuleBinding requiredModule : this.binding.getAllRequiredModules()) { for (PackageBinding exportedPackage : requiredModule.getExports()) { if (this.binding.canAccess(exportedPackage)) { String packName = String.valueOf(exportedPackage.readableName()); Set<ModuleBinding> mods = pack2mods.get(packName); if (mods == null) pack2mods.put(packName, mods = new HashSet<>()); mods.add(requiredModule); } } } // report against the causing requires directives: for (RequiresStatement requiresStat : this.requires) { ModuleBinding requiredModule = requiresStat.resolvedBinding; if (requiredModule != null) { if (requiredModule.isDeprecated()) skope.problemReporter().deprecatedModule(requiresStat.module, requiredModule); analyseOneDependency(requiresStat, requiredModule, skope, pack2mods); if (requiresStat.isTransitive()) { for (ModuleBinding secondLevelModule : requiredModule.getAllRequiredModules()) analyseOneDependency(requiresStat, secondLevelModule, skope, pack2mods); } } } } }
/** * Find a type in the given module or any module read by it. * Does not check accessibility / unique visibility, but returns the first observable type found. * @param compoundTypeName name of the sought type * @param module start into the module graph * @return the answer :) */ public NameEnvironmentAnswer findTypeInModules(char[][] compoundTypeName, ModuleBinding module) { char[] nameForLookup = module.nameForLookup(); NameEnvironmentAnswer answer = findType(compoundTypeName, nameForLookup); if (answer != null) return answer; if (LookupStrategy.get(nameForLookup) == LookupStrategy.Named) { for (ModuleBinding required : module.getAllRequiredModules()) { answer = findType(compoundTypeName, required.nameForLookup()); if (answer != null) return answer; } } return null; }
/** * Find a type in the given module or any module read by it. * Does not check accessibility / unique visibility, but returns the first observable type found. * @param compoundTypeName name of the sought type * @param module start into the module graph * @return the answer :) */ public NameEnvironmentAnswer findTypeInModules(char[][] compoundTypeName, ModuleBinding module) { char[] nameForLookup = module.nameForLookup(); NameEnvironmentAnswer answer = findType(compoundTypeName, nameForLookup); if (answer != null) return answer; if (LookupStrategy.get(nameForLookup) == LookupStrategy.Named) { for (ModuleBinding required : module.getAllRequiredModules()) { answer = findType(compoundTypeName, required.nameForLookup()); if (answer != null) return answer; } } return null; }
private void matchModuleReferences(SearchPattern pattern, MatchLocator locator) throws CoreException { // Only process Module patterns switch (pattern.kind) { case MODULE_PATTERN: break; case OR_PATTERN: SearchPattern[] patterns = ((OrPattern) pattern).patterns; for (int i = 0, length = patterns.length; i < length; i++) { SearchPattern p = patterns[i]; if (p.kind == MODULE_PATTERN) matchModuleReferences(patterns[i], locator); } // $FALL-THROUGH$ - fall through default to return default: return; } ModulePattern modulePattern = (ModulePattern) pattern; matchModuleReferences(locator, modulePattern, this.binaryModule.exports()); matchModuleReferences(locator, modulePattern, this.binaryModule.opens()); matchModuleReferences(locator, modulePattern, this.module.getAllRequiredModules()); } private void matchModuleReference(MatchLocator locator, ModulePattern modulePattern,
private void matchModuleReferences(SearchPattern pattern, MatchLocator locator) throws CoreException { // Only process Module patterns switch (pattern.kind) { case MODULE_PATTERN: break; case OR_PATTERN: SearchPattern[] patterns = ((OrPattern) pattern).patterns; for (int i = 0, length = patterns.length; i < length; i++) { SearchPattern p = patterns[i]; if (p.kind == MODULE_PATTERN) matchModuleReferences(patterns[i], locator); } // $FALL-THROUGH$ - fall through default to return default: return; } ModulePattern modulePattern = (ModulePattern) pattern; matchModuleReferences(locator, modulePattern, this.binaryModule.exports()); matchModuleReferences(locator, modulePattern, this.binaryModule.opens()); matchModuleReferences(locator, modulePattern, this.module.getAllRequiredModules()); } private void matchModuleReference(MatchLocator locator, ModulePattern modulePattern,
if (this.useModuleSystem) { IModuleAwareNameEnvironment moduleEnv = (IModuleAwareNameEnvironment) this.nameEnvironment; answers = askForTypeFromModules(clientModule, clientModule.getAllRequiredModules(), mod -> moduleEnv.findType(compoundName, mod.nameForLookup())); } else {
if (this.useModuleSystem) { IModuleAwareNameEnvironment moduleEnv = (IModuleAwareNameEnvironment) this.nameEnvironment; answers = askForTypeFromModules(clientModule, clientModule.getAllRequiredModules(), mod -> moduleEnv.findType(compoundName, mod.nameForLookup())); } else {