MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / gateRustScope

Method gateRustScope

src/resolution/index.ts:4680–4694  ·  view source on GitHub ↗

* A bare Rust name reaches only what is in scope — every strategy's result, * a framework resolver's `Ok(x)` → `struct Ok` construction included (see * isRustNameInScope). A call through a path whose type is from outside the * project reaches only the project's impls for that type (or of th

(result: ResolvedRef | null, ref: UnresolvedRef)

Source from the content-addressed store, hash-verified

4678 * impl on a std type only as Rust would pick it (isRustForeignImplCallable).
4679 */
4680 private gateRustScope(result: ResolvedRef | null, ref: UnresolvedRef): ResolvedRef | null {
4681 if (!result || ref.language !== 'rust') return result;
4682 const bare = /^[A-Za-z_]\w*$/.test(ref.referenceName);
4683 if (!bare && ref.referenceKind !== 'calls') return result;
4684 const target = this.nodeById(result.targetNodeId);
4685 if (!target) return result;
4686 if (bare && !isRustNameInScope(target, ref, this.context)) return null;
4687 if (ref.referenceKind !== 'calls') return result;
4688 if (!bare && !isRustPathCallReachable(target, ref, this.context)) return null;
4689 // What the name alone can't reach: an associated function by a method
4690 // call, an outside trait's impl or another type's method by a guess (#3252).
4691 const guessed = result.byName === true || result.resolvedBy === 'exact-match' || result.resolvedBy === 'fuzzy';
4692 if (isRustCallUnreachable(target, ref, guessed, this.context)) return null;
4693 return isRustForeignImplCallable(target, ref, this.context) ? result : null;
4694 }
4695
4696 /**
4697 * The context production code is resolved in when the project has Jest or

Callers 1

resolveOneInMethod · 0.95

Calls 1

nodeByIdMethod · 0.95

Tested by

no test coverage detected