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

Add support for specifying badEnclosingTypes for BadImport via flags #4231

Closed
wants to merge 0 commits into from

Conversation

copybara-service[bot]
Copy link
Contributor

Add support for specifying badEnclosingTypes for BadImport via flags

Following the discussions in #2236, this PR introduces the BadImport:BadEnclosingTypes flag to disallow nested types of specified enclosing type.

This PR also takes the flag into account in UnnecessarilyFullyQualified to suggest importing EnclosingType.NestedType when possible.

For instance, when -XepOpt:BadImport:BadEnclosingTypes=org.immutables.value.Value is set, it would suggest the following:

final class Test {
  @org.immutables.value.Value.Immutable
  abstract class AbstractType {}
}

->

final class Test {
  @Value.Immutable
  abstract class AbstractType {}
}

Also, it won't require suppressing UnnecessarilyFullyQualified in the example in #2236.

import org.springframework.beans.factory.annotation.Value;

final class Test {
  Demo(@Value("some.property") String property) {}

  @org.immutables.value.Value.Immutable
  abstract class AbstractType {}
}

Closes #2236.

Fixes #4228

FUTURE_COPYBARA_INTEGRATE_REVIEW=#4228 from hisener:halil.sener/bad-import-bad-enclosing-types 67aa36d

@hisener
Copy link
Contributor

hisener commented Jan 8, 2024

@cushon can we merge this PR?

@cushon
Copy link
Collaborator

cushon commented Jan 8, 2024

@cushon can we merge this PR?

It's waiting on an internal review before it can be merged, which I have pinged.

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

2 participants