Skip to content

[jextract] Misc improvements #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025
Merged

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Apr 15, 2025

  • Introduce Swift2JavaVisitor.typeContext to handle nested types
  • Unify shouldImport(log:) method using WithModifiersSyntax & WithAttributesSyntax
  • Unify accessControlModifiers as an extention to WithModifiersSyntax
  • Import open declarations
  • Don't import JavaKit declarations. e.g. @JavaClass
  • Don't import non-public variable decls.
  • Introduce DeclSyntaxProtocol.qualifiedNameForDebug and use it for log messages
  • Introduce DeclSyntaxProtocol.signatureString and use it as the snippet in the exported .java files.

* Introduce `Swift2JavaVisitor.typeContext` to handle nested types
* Unify `shouldImport(log:)` method using `WithModifiersSyntax &
  WithAttributesSyntax`
* Unify `accessControlModifiers` as an extention to `WithModifiersSyntax`
* Don't import `JavaKit` declarations. e.g. `@JavaClass`
* Don't import non-public variable decls.
* Introduce `DeclSyntaxProtocol.qualifiedNameForDebug` and use it for
  log messages
* Introduce `DeclSyntaxProtocol.signatureString` and use it as the
  snippet in the exported `.java` files.
fatalError("unimplemented \(self.kind)")
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s neat, thanks!

@@ -26,7 +26,11 @@ final class Swift2JavaVisitor: SyntaxVisitor {
/// store this along with type names as we import them.
let targetJavaPackage: String

var currentType: ImportedNominalType? = nil
/// Type context stack associated with the syntax.
var typeContext: [(syntaxID: Syntax.ID, type: ImportedNominalType)] = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you!

@rintaro rintaro merged commit 0b1fc44 into swiftlang:main Apr 16, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants