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

Organize imports adds config script alias import #709

Closed
eric-milles opened this issue Sep 7, 2018 · 1 comment
Closed

Organize imports adds config script alias import #709

eric-milles opened this issue Sep 7, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@eric-milles
Copy link
Member

Consider the following:
config.groovy:

withConfig(configuration) {
  imports {
    star 'groovy.transform'
    alias 'Regexp', 'java.util.regex.Pattern'
  }
}

One.groovy:

@Canonical
class One {
  String string
  Number number
  private Regexp pattern
  void setPattern(Regexp pattern) {
    this.pattern = pattern
  }
}

Tests.groovy:

@CompileStatic
final class Tests {
  @Test
  void testCtors() {
    def one = new One('value') // error: Cannot find matching method ...
    def two = new Two('value')
  }
}
@Canonical @CompileStatic
class Two {
  String value
}

Organize imports (Ctrl+Shift+O) on Tests.groovy is adding the import statement import java.util.regex.Pattern as Regexp to the source.

@eric-milles eric-milles added the bug label Sep 7, 2018
@eric-milles eric-milles self-assigned this Sep 8, 2018
@eric-milles eric-milles added this to the v3.1.0 milestone Sep 8, 2018
@eric-milles
Copy link
Member Author

GROOVY-8399 is causing the alias import to be added twice to rewriter but it is removed only once, so it ends up being added to source.

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