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

Method gateRustScope

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

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