MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / buildReferencePatterns

Function buildReferencePatterns

src/tools/codegraph/find-dead-code.ts:118–137  ·  view source on GitHub ↗

Build the set of "anything that looks like an import or reference TO `target`'s stem".

(targetRel: string)

Source from the content-addressed store, hash-verified

116
117/** Build the set of "anything that looks like an import or reference TO `target`'s stem". */
118function buildReferencePatterns(targetRel: string): string[] {
119 const stem = path.basename(targetRel).replace(/\.[^.]+$/, '');
120 const noExt = targetRel.replace(/\.[^.]+$/, '');
121 return [
122 // ES imports
123 `from './${stem}'`, `from "./${stem}"`,
124 `from '../${stem}'`, `from "../${stem}"`,
125 `from '${noExt}'`, `from "${noExt}"`,
126 `from '/${noExt}'`, `from "/${noExt}"`,
127 // require
128 `require('${stem}')`, `require("${stem}")`,
129 `require('${noExt}')`, `require("${noExt}")`,
130 // module path (in path-alias projects)
131 `'/${stem}'`, `"/${stem}"`,
132 `/${stem}'`, `/${stem}"`,
133 // Python
134 `import ${noExt.replace(/[/\\]/g, '.')}`,
135 `from ${noExt.replace(/[/\\]/g, '.')} import`,
136 ];
137}
138
139/** Extract `export` names (ES/TS only) from file content. Imperfect but pragmatic. */
140function extractExports(content: string): { name: string; line: number }[] {

Callers 1

executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected