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

Method gateRustScope

src/resolution/index.ts:4751–4765  ·  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

4749 * impl on a std type only as Rust would pick it (isRustForeignImplCallable).
4750 */
4751 private gateRustScope(result: ResolvedRef | null, ref: UnresolvedRef): ResolvedRef | null {
4752 if (!result || ref.language !== 'rust') return result;
4753 const bare = /^[A-Za-z_]\w*$/.test(ref.referenceName);
4754 if (!bare && ref.referenceKind !== 'calls') return result;
4755 const target = this.nodeById(result.targetNodeId);
4756 if (!target) return result;
4757 if (bare && !isRustNameInScope(target, ref, this.context)) return null;
4758 if (ref.referenceKind !== 'calls') return result;
4759 if (!bare && !isRustPathCallReachable(target, ref, this.context)) return null;
4760 // What the name alone can't reach: an associated function by a method
4761 // call, an outside trait's impl or another type's method by a guess (#3252).
4762 const guessed = result.byName === true || result.resolvedBy === 'exact-match' || result.resolvedBy === 'fuzzy';
4763 if (isRustCallUnreachable(target, ref, guessed, this.context)) return null;
4764 return isRustForeignImplCallable(target, ref, this.context) ? result : null;
4765 }
4766
4767 /**
4768 * 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