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

Function getRootModule

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

Source from the content-addressed store, hash-verified

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

Callers 1

rust.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected