Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Organize Imports in Defs avoiding tree printer #142

Closed
wants to merge 7 commits into from
Closed

Organize Imports in Defs avoiding tree printer #142

wants to merge 7 commits into from

Conversation

wpopielarski
Copy link
Member

REMARK: @sschaef commit is rather irrelevant.

Attempt (proof of concept) to organize imports with no modification of original tree.
There are 2 files which are the machinery:
1 DefImportsOrganizer.scala
2 NotPackageImportPratitioners.scala
The first one is the heart of engine

An example of usage is in OrganizeImports.scala. Main idea concerns
creation of TextChanges and adding them to those produced by
"PackageDef" old fashionable part.

@ghprb-bot
Copy link

@wpopielarski wpopielarski changed the title [WIP] Organize Imports in Defs avoiding tree printer Organize Imports in Defs avoiding tree printer Mar 10, 2016
kiritsuku and others added 7 commits March 10, 2016 11:34
Tree printing is buggy and in this case it led to an exception because
some synthetic tree of a for comprehension was printed. In order to
avoid the exception we no longer call the tree printing logic at all.
Instead we compare symbols and their names, which leads along the way
to even better performance.

Fix #1002476

Organize imports in ClassDef Tree Node

this commit is to make available organize imports in ClassDef

Implements 'organize imports' in methods body.

Additionally keeps imports for stable identifiers.

Drops to isLocal (2.10), guards position against NoPosition

Adds '\r' to stripFromCode, needed for Win

small optimization of logical statement

Organizes imports in blocks only, just like Intellij

Draws back \r improvement for Win in source generator

Enhancements suggested by @sschaef

Moves method participants into separate class

Extracts IsNotInImports to separate class

Enables tests after merge of #136

Adds possibility to shadow imports. Simple scenario
Attempt to organize imports with no modification of original tree.
There are 2 files which are the machinery:
1 DefImportsOrganizer.scala
2 NotPackageImportPratitioners.scala
The first one is the heart of engine

An example of usage is in OrganizeImports.scala. Main idea concerns
creation of `TextChanges` and adding them to those produced by
"PackageDef" old fashionable part.
@wpopielarski
Copy link
Member Author

Superseded by #144

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants