Rather than represent import statements as flat lists, which are
difficult and inefficient to work with, construct an import tree and
flatten it before sorting and writing to the buffer.
Trees are a much smarter way to represent imports. With trees, we no
longer need to filter duplicate imports because dictionary keys are
inherently unique. It also allows for a bit more flexibility and
features down the road.
One such feature is the ability to control how import statements are
merged into single wildcard import statements. A new configuration
option was introduced to allow the user to configure how to handle
wildcards. By default, leaf nodes are only merged into a wildcard if a
wildcard import statement already exists at that node level.
Rather than represent import statements as flat lists, which are difficult and inefficient to work with, construct an import tree and flatten it before sorting and writing to the buffer.
Trees are a much smarter way to represent imports. With trees, we no longer need to filter duplicate imports because dictionary keys are inherently unique. It also allows for a bit more flexibility and features down the road.
One such feature is the ability to control how import statements are merged into single wildcard import statements. A new configuration option was introduced to allow the user to configure how to handle wildcards. By default, leaf nodes are only merged into a wildcard if a wildcard import statement already exists at that node level.
A few minor bugs were fixed.
Fixes #2