Implements the resolver's module interface.
(String name)
| 221 | |
| 222 | /** Implements the resolver's module interface. */ |
| 223 | @Override |
| 224 | public Resolver.Scope resolve(String name) throws Undefined { |
| 225 | // global? |
| 226 | if (globalIndex.containsKey(name)) { |
| 227 | return Resolver.Scope.GLOBAL; |
| 228 | } |
| 229 | |
| 230 | // predeclared? |
| 231 | Object v = getPredeclared(name); |
| 232 | if (v != null) { |
| 233 | if (v instanceof GuardedValue) { |
| 234 | // Name is correctly spelled, but access is disabled by a flag or by client data. |
| 235 | throw new Undefined( |
| 236 | ((GuardedValue) v).getErrorFromAttemptingAccess(name), /*candidates=*/ null); |
| 237 | } |
| 238 | return Resolver.Scope.PREDECLARED; |
| 239 | } |
| 240 | |
| 241 | // universal? |
| 242 | if (Starlark.UNIVERSE.containsKey(name)) { |
| 243 | return Resolver.Scope.UNIVERSAL; |
| 244 | } |
| 245 | |
| 246 | // undefined |
| 247 | Set<String> candidates = new HashSet<>(); |
| 248 | candidates.addAll(globalIndex.keySet()); |
| 249 | candidates.addAll(predeclared.keySet()); |
| 250 | candidates.addAll(Starlark.UNIVERSE.keySet()); |
| 251 | throw new Undefined(String.format("name '%s' is not defined", name), candidates); |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Returns the value of the specified global variable, or null if not bound. Does not look in the |
nothing calls this directly
no test coverage detected