Repository navigation
Commit 5868599
authored
Fix nested type inheritance conversion (#171)
## Summary
- Fixes #137 — when a Java class extends/implements a nested type (e.g.
`GeneratorFactory.AbstractXmlFeatureGeneratorFactory`), the declaring
type qualifier was silently dropped, producing invalid/incorrect C#
(`AbstractXmlFeatureGeneratorFactory` instead of
`GeneratorFactory.AbstractXmlFeatureGeneratorFactory`).
- Root cause: `TypeHelper.GetSyntaxFromType` only read
`ClassOrInterfaceType.getNameAsString()`, which returns just the
simple name. JavaParser exposes the declaring type separately via
`getScope()`, which was never consulted.
- Fix: after resolving the leaf type syntax, check `getScope()` and,
if present, recursively resolve it and wrap the result in a
`QualifiedName`, preserving `Outer.Inner` qualification (valid in
both Java and C#).
## Test plan
- [x] Added `ConvertNestedTypeInheritanceTests` reproducing the exact
scenario from #137 (class extending/implementing nested types keeps
the `GeneratorFactory.` qualifier).
- [x] Added a sanity test confirming plain (non-nested) `extends` is
unaffected.
- [x] Full test suite passes: `dotnet test` — 337/337 passed.
Co-authored-by: Munishwar kalra <kalramunishwar.com>1 parent 1ea0262 commit 5868599
2 files changed
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
| |||
0 commit comments