MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / extractJavaImports

Function extractJavaImports

src/resolution/import-resolver.ts:828–855  ·  view source on GitHub ↗

* Extract Java / Kotlin import mappings. * * Java/Kotlin imports carry the full qualified name of the imported * symbol — `import com.example.dao.converter.FooConverter;` — which is * exactly the disambiguation signal we need when two packages both * declare a `FooConverter`. Pre-#314 the resol

(content: string)

Source from the content-addressed store, hash-verified

826 * (`bar(...)`) can resolve through the same import lookup.
827 */
828function extractJavaImports(content: string): ImportMapping[] {
829 const mappings: ImportMapping[] = [];
830 // Strip line and block comments so `// import foo;` doesn't false-match.
831 const stripped = content
832 .replace(/\/\*[\s\S]*?\*\//g, '')
833 .replace(/\/\/[^\n]*/g, '');
834 // `import [static] <fqn>[.*];`
835 const re = /^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)\s*;/gm;
836 let match: RegExpExecArray | null;
837 while ((match = re.exec(stripped)) !== null) {
838 const fqn = match[2]!;
839 // `import com.example.*;` — wildcard. We can't materialize a single
840 // local name; skip and let name-matching handle members reachable
841 // through the wildcard. (Future enhancement: enumerate package files.)
842 if (fqn.endsWith('.*')) continue;
843 const parts = fqn.split('.');
844 const localName = parts[parts.length - 1];
845 if (!localName) continue;
846 mappings.push({
847 localName,
848 exportedName: localName,
849 source: fqn,
850 isDefault: false,
851 isNamespace: false,
852 });
853 }
854 return mappings;
855}
856
857/**
858 * Extract PHP import mappings (use statements)

Callers 1

extractImportMappingsFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected