Organize imports functionality in Eclipse plugin
Migrated from http://lampsvn.epfl.ch/trac/scala/ticket/390
Reporter joel.neely
For Java development, ctl+shift+o (command+shift+o on OSX) organizes the imports used/needed in a Java source file. The net effect is that only/all imports for classes used within the source file are listed alphabetically at the top of the source file. Wildcard imports are expanded, unused imports are dropped, and missing imports (required for classes actually used in the file) are added. In the case of ambiguity (e.g. use of unqualified List type), a dialog containing all relevant types (e.g. java.util.List, com.sun.tools.javac.util.List, and java.awt.List) is displayed and the user is prompted to select the type to import. There has been discussion on the [scala] mailing list re having equivalent functionality in the Scala plugin.
Reporter joel.neely
For Java development, ctl+shift+o (command+shift+o on OSX) organizes the imports used/needed in a Java source file. The net effect is that only/all imports for classes used within the source file are listed alphabetically at the top of the source file. Wildcard imports are expanded, unused imports are dropped, and missing imports (required for classes actually used in the file) are added. In the case of ambiguity (e.g. use of unqualified List type), a dialog containing all relevant types (e.g. java.util.List, com.sun.tools.javac.util.List, and java.awt.List) is displayed and the user is prompted to select the type to import. There has been discussion on the [scala] mailing list re having equivalent functionality in the Scala plugin.
Leave a comment
on 2009-02-15 15:06 *
By tracImporter
Trac author: mbana
CC Change: mbana.lists@…
CC Change: mbana.lists@…
on 2009-04-02 03:18 *
By tracImporter
Trac author: pelotom
CC Change: pelotom@…
We would love to see this!
CC Change: pelotom@…
We would love to see this!
on 2009-06-01 06:47 *
By tracImporter
Trac author: arya
CC Change: arya.irani@…
I use this feature constantly in the Java IDE, and have felt somewhat handicapped without it in Scala.
In a Scala editor, what it seems to do is still call the Java-source version (does that make it a defect?) It will still pull in imports to the extent that your Scala code may also resemble valid Java.
class Foo extends Group { val x = new Color() } // two imports
class Foo(val y: Int) extends Group { val x = new Color() } // one import
class Foo(val y: Int) extends Group { val x = new Color } // no imports
It would be great if it were not a pain to reuse some of the existing mechanism, while updating to recognize types in Scala syntax...
CC Change: arya.irani@…
I use this feature constantly in the Java IDE, and have felt somewhat handicapped without it in Scala.
In a Scala editor, what it seems to do is still call the Java-source version (does that make it a defect?) It will still pull in imports to the extent that your Scala code may also resemble valid Java.
class Foo extends Group { val x = new Color() } // two imports
class Foo(val y: Int) extends Group { val x = new Color() } // one import
class Foo(val y: Int) extends Group { val x = new Color } // no imports
It would be great if it were not a pain to reuse some of the existing mechanism, while updating to recognize types in Scala syntax...
on 2009-06-01 08:58 *
By
Reusing as much as possible of the JDT's functionality is indeed the plan. I'm quite hopeful that some progress will be made on this for 2.8.0 or very soon after that.
on 2009-07-10 13:52 *
By tracImporter
Trac author: andrey.lomakin
CC Change: lomakin.andrey@…
CC Change: lomakin.andrey@…
on 2009-07-10 13:54 *
By tracImporter
Trac author: andrey.lomakin
It will be excelent to have this functionality.
It will be excelent to have this functionality.
on 2009-12-04 14:31 *
By tracImporter
Trac author: mbana
any thoughts on how this would be implemented?
any thoughts on how this would be implemented?
on 2009-12-04 14:32 *
By tracImporter
Trac author: mbana
CC Change: mohamed@…
CC Change: mohamed@…
on 2009-12-06 15:08 *
By
The core functionality should come out of Mirko Stockers work on IDE-independent refactorings. If you're hoping to contribute I'd suggest contacting him via the scala-tools list.
Fixed on tycho-reorg by Mirko.