* 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)
| 1009 | * (`bar(...)`) can resolve through the same import lookup. |
| 1010 | */ |
| 1011 | function extractJavaImports(content: string): ImportMapping[] { |
| 1012 | const mappings: ImportMapping[] = []; |
| 1013 | // Strip line and block comments so `// import foo;` doesn't false-match. |
| 1014 | const stripped = content |
| 1015 | .replace(/\/\*[\s\S]*?\*\//g, '') |
| 1016 | .replace(/\/\/[^\n]*/g, ''); |
| 1017 | // `import [static] <fqn>[.*];` |
| 1018 | const re = /^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)\s*;/gm; |
| 1019 | let match: RegExpExecArray | null; |
| 1020 | while ((match = re.exec(stripped)) !== null) { |
| 1021 | const fqn = match[2]!; |
| 1022 | // `import com.example.*;` — wildcard. We can't materialize a single |
| 1023 | // local name; skip and let name-matching handle members reachable |
| 1024 | // through the wildcard. (Future enhancement: enumerate package files.) |
| 1025 | if (fqn.endsWith('.*')) continue; |
| 1026 | const parts = fqn.split('.'); |
| 1027 | const localName = parts[parts.length - 1]; |
| 1028 | if (!localName) continue; |
| 1029 | mappings.push({ |
| 1030 | localName, |
| 1031 | exportedName: localName, |
| 1032 | source: fqn, |
| 1033 | isDefault: false, |
| 1034 | isNamespace: false, |
| 1035 | }); |
| 1036 | } |
| 1037 | return mappings; |
| 1038 | } |
| 1039 | |
| 1040 | /** |
| 1041 | * Extract PHP import mappings (use statements) |
no test coverage detected