MCPcopy Index your code
hub / github.com/bazelbuild/bazel / resolve

Method resolve

src/main/java/net/starlark/java/eval/Module.java:223–252  ·  view source on GitHub ↗

Implements the resolver's module interface.

(String name)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

getPredeclaredMethod · 0.95
containsKeyMethod · 0.65
addAllMethod · 0.45
keySetMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected