Skip to content
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

Java2Swift: Improve diagnostics when we suppress import due to a missing Java class import #112

Open
DougGregor opened this issue Oct 25, 2024 · 0 comments
Labels

Comments

@DougGregor
Copy link
Member

When we run Java2Swift, we generally get a large number of warnings like this:

warning: Unable to translate 'java.util.Collection' method 'removeIf': Java class 'java.util.function.Predicate' has not been translated into Swift
warning: Unable to translate 'java.util.Collection' method 'parallelStream': Java class 'java.util.stream.Stream' has not been translated into Swift
warning: Unable to translate 'java.util.Collection' method 'forEach': Java class 'java.util.function.Consumer' has not been translated into Swift

The user experience isn't great for several reasons:

  1. There are often a large number of warnings.
  2. It's not obvious how to address those warnings.
  3. It's not clear after-the-fact which APIs were dropped.

We should re-work how we report these kinds of issues. Specifically, I think we should report just one warning per target, and have that warning also produce the contents of a Java2Swift.config file that contains suggested mappings for those types, e.g.,

{
  "classes" : {
    "java.util.function.Consumer" : "Consumer",
    "java.util.function.Predicate" : "Predicate",
    "java.util.stream.Stream" : "Stream"
  }
}

Additionally, we could emit comments into the generated Swift sources indicating which APIs weren't mapped into Swift, and why, e.g.,

// Java API not available in Swift because java.util.Predicate has not been translated into Swift:
//   boolean removeIf(Predicate<? super E> filter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant