/** Combine up-to two candidate types. If both types are present let accessibility from the given clientModule decide. */ private ReferenceBinding combine(ReferenceBinding one, ReferenceBinding two, ModuleBinding clientModule) { if (one == null) return two; if (two == null) return one; if (!clientModule.canAccess(one.fPackage)) return two; if (!clientModule.canAccess(two.fPackage)) return one; if (one == two) return one; //$IDENTITY-COMPARISON$ return new ProblemReferenceBinding(one.compoundName, one, ProblemReasons.Ambiguous); // TODO(SHMOD): use a new problem ID } /** Collect answers from the oracle concerning the given clientModule (if present) and each of a set of other modules. */
/** Combine up-to two candidate types. If both types are present let accessibility from the given clientModule decide. */ private ReferenceBinding combine(ReferenceBinding one, ReferenceBinding two, ModuleBinding clientModule) { if (one == null) return two; if (two == null) return one; if (!clientModule.canAccess(one.fPackage)) return two; if (!clientModule.canAccess(two.fPackage)) return one; if (one == two) return one; //$IDENTITY-COMPARISON$ return new ProblemReferenceBinding(one.compoundName, one, ProblemReasons.Ambiguous); // TODO(SHMOD): use a new problem ID } /** Collect answers from the oracle concerning the given clientModule (if present) and each of a set of other modules. */
public boolean canTypeBeAccessed(SourceTypeBinding binding, Scope scope) { ModuleBinding client = scope.module(); return client.canAccess(binding.fPackage); }
public boolean canTypeBeAccessed(SourceTypeBinding binding, Scope scope) { ModuleBinding client = scope.module(); return client.canAccess(binding.fPackage); }
@Override public PackageBinding getVisibleFor(ModuleBinding clientModule) { int visibleCount = 0; PackageBinding unique = null; for (PackageBinding incarnation : this.incarnations) { if (incarnation.hasCompilationUnit(false)) { if (incarnation.enclosingModule == clientModule) { return incarnation; // prefer local package over foreign } else { if (clientModule.canAccess(incarnation)) { if (++visibleCount > 1) return this; unique = incarnation; } } } } return unique; }
@Override public PackageBinding getVisibleFor(ModuleBinding clientModule) { int visibleCount = 0; PackageBinding unique = null; for (PackageBinding incarnation : this.incarnations) { if (incarnation.hasCompilationUnit(false)) { if (incarnation.enclosingModule == clientModule) { return incarnation; // prefer local package over foreign } else { if (clientModule.canAccess(incarnation)) { if (++visibleCount > 1) return this; unique = incarnation; } } } } return unique; }
@Override public boolean canBeSeenBy(Scope sco) { ModuleBinding mod = sco.module(); return mod.canAccess(this.fPackage) && super.canBeSeenBy(sco); } /**
public boolean canBeSeenBy(Scope sco) { ModuleBinding mod = sco.module(); return mod.canAccess(this.fPackage) && super.canBeSeenBy(sco); } /**
@Override ReferenceBinding getType(char[] name, ModuleBinding mod) { ReferenceBinding candidate = null; boolean accessible = false; for (PackageBinding incarnation : this.incarnations) { ReferenceBinding type = incarnation.getType(name, mod); if (type != null) { if (candidate == null || !accessible) { candidate = type; accessible = mod.canAccess(incarnation); } else if (mod.canAccess(incarnation)) { return new ProblemReferenceBinding(type.compoundName, candidate, ProblemReasons.Ambiguous); // TODO(SHMOD) add module information } } } if (candidate != null && !accessible) return new ProblemReferenceBinding(candidate.compoundName, candidate, ProblemReasons.NotAccessible); // TODO(SHMOD) more info // at this point we have only checked unique accessibility of the package, accessibility of the type will be checked by callers return candidate; }
@Override ReferenceBinding getType(char[] name, ModuleBinding mod) { ReferenceBinding candidate = null; boolean accessible = false; for (PackageBinding incarnation : this.incarnations) { ReferenceBinding type = incarnation.getType(name, mod); if (type != null) { if (candidate == null || !accessible) { candidate = type; accessible = mod.canAccess(incarnation); } else if (mod.canAccess(incarnation)) { return new ProblemReferenceBinding(type.compoundName, candidate, ProblemReasons.Ambiguous); // TODO(SHMOD) add module information } } } if (candidate != null && !accessible) return new ProblemReferenceBinding(candidate.compoundName, candidate, ProblemReasons.NotAccessible); // TODO(SHMOD) more info // at this point we have only checked unique accessibility of the package, accessibility of the type will be checked by callers return candidate; }
public void checkPackageConflict(CompilationUnitScope scope) { ModuleBinding module = scope.module(); PackageBinding visiblePackage = module.getVisiblePackage(this.tokens); if (visiblePackage instanceof SplitPackageBinding) { Set<ModuleBinding> declaringMods = new HashSet<>(); for (PackageBinding incarnation : ((SplitPackageBinding) visiblePackage).incarnations) { if (incarnation.enclosingModule != module && module.canAccess(incarnation)) declaringMods.add(incarnation.enclosingModule); } if (!declaringMods.isEmpty()) { scope.problemReporter().conflictingPackagesFromOtherModules(this, declaringMods); } } }
public void checkPackageConflict(CompilationUnitScope scope) { ModuleBinding module = scope.module(); PackageBinding visiblePackage = module.getVisiblePackage(this.tokens); if (visiblePackage instanceof SplitPackageBinding) { Set<ModuleBinding> declaringMods = new HashSet<>(); for (PackageBinding incarnation : ((SplitPackageBinding) visiblePackage).incarnations) { if (incarnation.enclosingModule != module && module.canAccess(incarnation)) declaringMods.add(incarnation.enclosingModule); } if (!declaringMods.isEmpty()) { scope.problemReporter().conflictingPackagesFromOtherModules(this, declaringMods); } } }
ReferenceBinding getType(char[] name, ModuleBinding mod) { ReferenceBinding referenceBinding = getType0(name); if (referenceBinding == null) { if ((referenceBinding = this.environment.askForType(this, name, mod)) == null) { // not found so remember a problem type binding in the cache for future lookups addNotFoundType(name); return null; } } if (referenceBinding == LookupEnvironment.TheNotFoundType) return null; referenceBinding = (ReferenceBinding) BinaryTypeBinding.resolveType(referenceBinding, this.environment, false /* no raw conversion for now */); if (referenceBinding.isNestedType()) return new ProblemReferenceBinding(new char[][]{ name }, referenceBinding, ProblemReasons.InternalNameProvided); if (!mod.canAccess(this)) return new ProblemReferenceBinding(referenceBinding.compoundName, referenceBinding, ProblemReasons.NotAccessible); // at this point we have only checked accessibility of the package, accessibility of the type will be checked by callers return referenceBinding; } /* Answer the type named name if it exists in the cache.
ReferenceBinding getType(char[] name, ModuleBinding mod) { ReferenceBinding referenceBinding = getType0(name); if (referenceBinding == null) { if ((referenceBinding = this.environment.askForType(this, name, mod)) == null) { // not found so remember a problem type binding in the cache for future lookups addNotFoundType(name); return null; } } if (referenceBinding == LookupEnvironment.TheNotFoundType) return null; referenceBinding = (ReferenceBinding) BinaryTypeBinding.resolveType(referenceBinding, this.environment, false /* no raw conversion for now */); if (referenceBinding.isNestedType()) return new ProblemReferenceBinding(new char[][]{ name }, referenceBinding, ProblemReasons.InternalNameProvided); if (!mod.canAccess(this)) return new ProblemReferenceBinding(referenceBinding.compoundName, referenceBinding, ProblemReasons.NotAccessible); // at this point we have only checked accessibility of the package, accessibility of the type will be checked by callers return referenceBinding; } /* Answer the type named name if it exists in the cache.
if (!isSameModule && referenceBinding.isValidBinding() && !mod.canAccess(referenceBinding.fPackage)) { problemBinding = new ProblemReferenceBinding(referenceBinding.compoundName, referenceBinding, ProblemReasons.NotAccessible); break lookForType0; return new ProblemReferenceBinding(new char[][]{name}, referenceBinding, ProblemReasons.InternalNameProvided); if (referenceBinding.isValidBinding() && !mod.canAccess(referenceBinding.fPackage)) { problemBinding = new ProblemReferenceBinding(referenceBinding.compoundName, referenceBinding, ProblemReasons.NotAccessible); break lookForType;
if (!isSameModule && referenceBinding.isValidBinding() && !mod.canAccess(referenceBinding.fPackage)) { problemBinding = new ProblemReferenceBinding(referenceBinding.compoundName, referenceBinding, ProblemReasons.NotAccessible); break lookForType0; return new ProblemReferenceBinding(new char[][]{name}, referenceBinding, ProblemReasons.InternalNameProvided); if (referenceBinding.isValidBinding() && !mod.canAccess(referenceBinding.fPackage)) { problemBinding = new ProblemReferenceBinding(referenceBinding.compoundName, referenceBinding, ProblemReasons.NotAccessible); break lookForType;
if (packageBinding.isValidBinding() && !module.canAccess(packageBinding)) return new ProblemPackageBinding(compoundName, ProblemReasons.NotAccessible); return packageBinding;
if (packageBinding.isValidBinding() && !module.canAccess(packageBinding)) return new ProblemPackageBinding(compoundName, ProblemReasons.NotAccessible); return packageBinding;
throw new SourceTypeCollisionException(); // resolved a type ref before APT generated the type ReferenceBinding typeBinding = this.fPackage.getType0(typeDecl.name); if (Binding.isValid(typeBinding) && this.fPackage instanceof SplitPackageBinding && !this.environment.module.canAccess(typeBinding.fPackage)) typeBinding = null;
throw new SourceTypeCollisionException(); // resolved a type ref before APT generated the type ReferenceBinding typeBinding = this.fPackage.getType0(typeDecl.name); if (Binding.isValid(typeBinding) && this.fPackage instanceof SplitPackageBinding && !this.environment.module.canAccess(typeBinding.fPackage)) typeBinding = null;