@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; } }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
@NonNull @Override public String getName() { return new String(mBinding.readableName()); }
/** @return array of names, which may contain nulls. */ public char[][] getPackageNamesForClassFile() { if (this.packageNames == null) return null; for (PackageBinding packageBinding : this.exportedPackages) this.packageNames.add(packageBinding.readableName()); for (PackageBinding packageBinding : this.openedPackages) this.packageNames.add(packageBinding.readableName()); if (this.implementations != null) for (TypeBinding[] types : this.implementations.values()) for (TypeBinding typeBinding : types) this.packageNames.add(((ReferenceBinding)typeBinding).fPackage.readableName()); return this.packageNames.values; }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** * Answer the qualified name of the receiver's package separated by periods * or an empty string if its the default package. * * For example, {java.util}. */ public char[] qualifiedPackageName() { PackageBinding packageBinding = getPackage(); return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR : packageBinding.readableName(); }
/** @return array of names, which may contain nulls. */ public char[][] getPackageNamesForClassFile() { if (this.packageNames == null) return null; for (PackageBinding packageBinding : this.exportedPackages) this.packageNames.add(packageBinding.readableName()); for (PackageBinding packageBinding : this.openedPackages) this.packageNames.add(packageBinding.readableName()); if (this.implementations != null) for (TypeBinding[] types : this.implementations.values()) for (TypeBinding typeBinding : types) this.packageNames.add(((ReferenceBinding)typeBinding).fPackage.readableName()); return this.packageNames.values; }
private void analyseOneDependency(RequiresStatement requiresStat, ModuleBinding requiredModule, CompilationUnitScope skope, Map<String, Set<ModuleBinding>> pack2mods) { for (PackageBinding pack : requiredModule.getExports()) { Set<ModuleBinding> mods = pack2mods.get(String.valueOf(pack.readableName())); if (mods != null && mods.size() > 1) skope.problemReporter().conflictingPackagesFromModules(pack, mods, requiresStat.sourceStart, requiresStat.sourceEnd); } }
private void analyseOneDependency(RequiresStatement requiresStat, ModuleBinding requiredModule, CompilationUnitScope skope, Map<String, Set<ModuleBinding>> pack2mods) { for (PackageBinding pack : requiredModule.getExports()) { Set<ModuleBinding> mods = pack2mods.get(String.valueOf(pack.readableName())); if (mods != null && mods.size() > 1) skope.problemReporter().conflictingPackagesFromModules(pack, mods, requiresStat.sourceStart, requiresStat.sourceEnd); } }
@Override public void addReads(char[] requiredModuleName) { ModuleBinding requiredModule = this.environment.getModule(requiredModuleName); if (requiredModule != null) { int len = this.requires.length; if (len == 0) { this.requires = new ModuleBinding[] { requiredModule }; } else { System.arraycopy(this.requires, 0, this.requires = new ModuleBinding[len+1], 0, len); this.requires[len] = requiredModule; } } else { // TODO(SHMOD) report error } // update known packages: HashtableOfPackage knownPackages = this.environment.knownPackages; for (int i = 0; i < knownPackages.valueTable.length; i++) { PackageBinding packageBinding = knownPackages.valueTable[i]; if (packageBinding == null) continue; PackageBinding newBinding = requiredModule.getVisiblePackage(packageBinding.compoundName); newBinding = SplitPackageBinding.combine(newBinding, packageBinding, this); if (packageBinding != newBinding) { knownPackages.valueTable[i] = newBinding; if (this.declaredPackages.containsKey(newBinding.readableName())) this.declaredPackages.put(newBinding.readableName(), newBinding); } } } @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) { 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); } } } } }
/** * 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; }