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

Function getRootModule

src/extraction/languages/rust.ts:163–175  ·  view source on GitHub ↗
(scopedNode: SyntaxNode)

Source from the content-addressed store, hash-verified

161
162 // Helper to get the root crate/module from a scoped path
163 const getRootModule = (scopedNode: SyntaxNode): string => {
164 const firstChild = scopedNode.namedChild(0);
165 if (!firstChild) return source.substring(scopedNode.startIndex, scopedNode.endIndex);
166 if (firstChild.type === 'identifier' ||
167 firstChild.type === 'crate' ||
168 firstChild.type === 'super' ||
169 firstChild.type === 'self') {
170 return source.substring(firstChild.startIndex, firstChild.endIndex);
171 } else if (firstChild.type === 'scoped_identifier') {
172 return getRootModule(firstChild);
173 }
174 return source.substring(firstChild.startIndex, firstChild.endIndex);
175 };
176
177 // Find the use argument (scoped_use_list or scoped_identifier)
178 const useArg = node.namedChildren.find((c: SyntaxNode) =>

Callers 1

rust.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected