@Override public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) { if ("package-info".equals(new String(typeDeclaration.name))) { context.enter(factory.Package().getOrCreate(new String(typeDeclaration.binding.fPackage.readableName())), typeDeclaration); return true; } else { CtModule module; // skip the type declaration that are already declared if (typeDeclaration.binding == null && getFactory().getEnvironment().isIgnoreDuplicateDeclarations()) { return false; } if (typeDeclaration.binding.module != null && !typeDeclaration.binding.module.isUnnamed() && typeDeclaration.binding.module.shortReadableName() != null && typeDeclaration.binding.module.shortReadableName().length > 0) { module = factory.Module().getOrCreate(String.valueOf(typeDeclaration.binding.module.shortReadableName())); } else { module = factory.Module().getUnnamedModule(); } CtPackage pack; if (typeDeclaration.binding.fPackage.shortReadableName() != null && typeDeclaration.binding.fPackage.shortReadableName().length > 0) { pack = factory.Package().getOrCreate(new String(typeDeclaration.binding.fPackage.shortReadableName()), module); } else { pack = module.getRootPackage(); } context.enter(pack, typeDeclaration); pack.addType(helper.createType(typeDeclaration)); return true; } }
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()); } }
public void setRequires(ModuleBinding[] requires, ModuleBinding[] requiresTransitive) { // TODO(SHMOD): it's a bit awkward that we may get called after applyModuleUpdates() has already worked. ModuleBinding javaBase = this.environment.javaBaseModule(); if (javaBase.isUnnamed()) // happens when no java.base can be found in the name environment. javaBase = null; this.requires = merge(this.requires, requires, javaBase, ModuleBinding[]::new); this.requiresTransitive = merge(this.requiresTransitive, requiresTransitive, null, ModuleBinding[]::new); }
if (!enclosingModule.isUnnamed() && enclosingModule.shortReadableName() != null && enclosingModule.shortReadableName().length > 0) { module = getFactory().Module().getOrCreate(String.valueOf(enclosingModule.shortReadableName())); } else {
unique.add(getModulesPackageBinding(p)); if (module.isUnnamed()) { PackageBinding def = module.environment.defaultPackage;
SimpleSetOfCharArray restrictions = this.exportRestrictions.get(export); if (restrictions != null) { if (client.isUnnamed()) return restrictions.includes(ALL_UNNAMED); else
SimpleSetOfCharArray restrictions = this.exportRestrictions.get(export); if (restrictions != null) { if (client.isUnnamed()) return restrictions.includes(ALL_UNNAMED); else
/** * Check if the given package is declared in this module, * and if so, remember this fact for later. * The package can be a {@code SplitPackageBinding} in which case * only one of its incarnations needs to be declared in this module. * @param packageBinding the package to add * @param checkForSplit if true then we should try to construct a split package from * same named packages in required modules. * @return the given package, possibly enriched to a {@link SplitPackageBinding} */ PackageBinding addPackage(PackageBinding packageBinding, boolean checkForSplit) { if (packageBinding.isDeclaredIn(this)) { char[] packageName = packageBinding.readableName(); if (checkForSplit && this.environment.useModuleSystem) { char[][] declaringModuleNames = null; if (isUnnamed()) { IModuleAwareNameEnvironment moduleEnv = (IModuleAwareNameEnvironment) this.environment.nameEnvironment; declaringModuleNames = moduleEnv.getUniqueModulesDeclaringPackage(null, packageName, ANY); } packageBinding = combineWithPackagesFromOtherRelevantModules(packageBinding, packageBinding.compoundName, declaringModuleNames); } this.declaredPackages.put(packageName, packageBinding); if (packageBinding.parent == null) { this.environment.knownPackages.put(packageName, packageBinding); } } return packageBinding; }
char[] packageName = packageBinding.readableName(); if (checkForSplit && this.environment.useModuleSystem) { if (isUnnamed()) { IModuleAwareNameEnvironment moduleEnv = (IModuleAwareNameEnvironment) this.environment.nameEnvironment; char[][] declaringModuleNames = moduleEnv.getModulesDeclaringPackage(null, packageName, ANY);
if (packageBinding == null || packageBinding == TheNotFoundPackage) { if (this.useModuleSystem) { if (this.module.isUnnamed()) { char[][] declaringModules = ((IModuleAwareNameEnvironment) this.nameEnvironment).getModulesDeclaringPackage(null, constantPoolName[0], ModuleBinding.ANY); if (declaringModules != null) { if ((packageBinding = parent.getPackage0(constantPoolName[i])) == null || packageBinding == TheNotFoundPackage) { if (this.useModuleSystem) { if (this.module.isUnnamed()) { char[][] declaringModules = ((IModuleAwareNameEnvironment) this.nameEnvironment).getModulesDeclaringPackage(parent.compoundName, constantPoolName[i], ModuleBinding.ANY); if (declaringModules != null) {
if (packageBinding == null || packageBinding == TheNotFoundPackage) { if (this.useModuleSystem) { if (this.module.isUnnamed()) { char[][] declaringModules = ((IModuleAwareNameEnvironment) this.nameEnvironment).getUniqueModulesDeclaringPackage(null, constantPoolName[0], ModuleBinding.ANY); if (declaringModules != null) { if ((packageBinding = parent.getPackage0(constantPoolName[i])) == null || packageBinding == TheNotFoundPackage) { if (this.useModuleSystem) { if (this.module.isUnnamed()) { char[][] declaringModules = ((IModuleAwareNameEnvironment) this.nameEnvironment).getModulesDeclaringPackage(parent.compoundName, constantPoolName[i], ModuleBinding.ANY); if (declaringModules != null) {
char[][] declaringModuleNames = moduleEnv.getModulesDeclaringPackage(parentName, name, nameForLookup()); if (declaringModuleNames != null) { if (!this.isUnnamed() && CharOperation.containsEqual(declaringModuleNames, this.moduleName)) { if (!isUnnamed()) { binding = combineWithPackagesFromRequired(binding, subPkgCompoundName);