-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rosetta): submodule-qualified names produce invalid Go, Java (#3928)
Java and Go do not support transitive access to a submodule's items via a qualified reference and instead require a dedicated import to be emitted. This adds code to analyze use of imported symbols to detect when a namespace traversal occurs, to inject new imports & replace property access expressions as necessary. In order to facilitate this work, these extra elements were done: - Replaced if-tree in the dispatcher with a switch statement, making the dispatch a lot faster, and also a lot nice to run through in a debugger - Emit `var` instead of a type name for variable declarations with an initializer in C#, to reduce "invalid" code generated in cases where the type name needs some qualification that we are missing - A couple of bug fixes here and there as the tests discovered them Fixes #3551 --- > **Note**: > There are still some awkward issues with the rendered code, but those are significantly more difficult to tackle without profoundly refactoring `jsii-rosetta`... The current work is already chunky enough and I didn't want to make it worse. > - Some synthetic type references lack qualification (e.g: struct type names in Go & C#) > - There might still be edge cases where duplicated or unused imports are emitted > - Import paths (in Go) may not be computed correctly (this might not be too hard to address, though) --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
- Loading branch information
1 parent
49136ac
commit 1ff230d
Showing
42 changed files
with
796 additions
and
279 deletions.
There are no files selected for viewing
16 changes: 8 additions & 8 deletions
16
packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
14 changes: 8 additions & 6 deletions
14
packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.js.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.