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

Implement new patch infrastructure. #45

Closed
wants to merge 2 commits into from

Conversation

olafurpg
Copy link
Contributor

This commit is too big, I'm sorry. Main changes:

  • Patch(from, to, replace) replaced with TokenPatch(token, newToken)
    with helpful combinators such as Add{Left,Right}
  • New high-level TreePatch datatype with can be converted to TokenPatch.
  • Implemented two tree patches, AddGlobalImport and RemoveGlobalImport.
  • Implemented OrganizeImport, which is a prerequisite to use import tree
    patches.
  • OrganizeImports
    • orders imports by configurable groups
    • removes unused imports using scalac -Ywarn-unused-import
      infrastructure. The implementation is requires hijacking a few
      private fields in g.analyzer using evil reflection hackery.
    • option to expand relative imports
    • handles renames
    • configurable "always used" to force keeping an import such as
      acyclic.file

Known bugs:

  • introduces false import on non-existing cats.data.UUID in circe
  • makes an import unused by expanding relative imports to
    fully-qualified imports, requiring you to run scalafix
    twice to fully remove unused imports (e.g. in cats with
    -Ywarn-unused-import)
  • crashes on scala.meta parser bug (in akka), not scalafix problem
    really.

Expand relative

Test that patch is unchanged

@olafurpg olafurpg force-pushed the organize-imports branch 2 times, most recently from e3b83f9 to 91561ea Compare January 27, 2017 18:32
Main changes:

- Patch(from, to, replace) replaced with TokenPatch(token, newToken)
  with helpful combinators such as Add{Left,Right}
- New high-level TreePatch datatype with can be converted to TokenPatch.
- Implemented two tree patches, AddGlobalImport and RemoveGlobalImport.
- Implemented OrganizeImport, which is a prerequisite to use import tree
  patches.
- OrganizeImports
  - orders imports by configurable groups
  - removes unused imports using scalac -Ywarn-unused-import
    infrastructure. The implementation is requires hijacking a few
    private fields in g.analyzer using evil reflection hackery.
  - option to expand relative imports
  - handles renames
  - configurable "always used" to force keeping an import such as
    acyclic.file

Known bugs:

- introduces false import on non-existing cats.data.UUID in circe
- makes an import unused by expanding relative imports to
  fully-qualified imports, requiring you to run scalafix
  twice to fully remove unused imports (e.g. in cats with
  -Ywarn-unused-import)
- crashes on scala.meta parser bug (in akka), not scalafix problem
  really.

Expand relative

Test that patch is unchanged
@olafurpg
Copy link
Contributor Author

Drone seems to be pulling out the wrong commit, it ran against hash 9e5ec2b when it should have run against fc616f0. Gonna close and reopen pr.

@olafurpg olafurpg closed this Jan 28, 2017
@olafurpg
Copy link
Contributor Author

Can't reopen this PR, new #46

bjaglin pushed a commit to liancheng/scalafix that referenced this pull request May 23, 2023
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.

1 participant