Automatically remove explicit package declarations with import statements in Java

前端 未结 8 1137
不思量自难忘°
不思量自难忘° 2021-01-07 19:46

I have a project created by others that includes thousands of class files and has the package names explicitly typed out for every reference to any of their classes. It look

8条回答
  •  梦谈多话
    2021-01-07 20:00

    I use an Eclipse plugin by Michael Ernst that does what you want. It converts references such as java.util.Collection to Collection with the addition of an import java.util.Collection; at the top of the file.

    It is effectively the same thing as using "Source -> Add Import" for a fully-qualified reference except that it lets you do it for an entire .java file at once.

    Even better, it lets you batch-process all the .java files you have selected in the Package Explorer. Simply right-click on the selection and select "Source -> Clean qualified Type Declarations" form the contextual menu.

    Eclipse update site: http://cqtp.sourceforge.net/eclipse/

提交回复
热议问题