Automatically remove explicit package declarations with import statements in Java

前端 未结 8 1113
不思量自难忘°
不思量自难忘° 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

    This thread says:

    select the package explorer view, right click on your project, choose source then organise imports. Bobs your uncle - all unwanted imports are removed

    To make it better formatted:

    Right click project > Source > Organize imports

    Now, what remains, is to find a way to strip the fully-qualified names from the code. You may think of some regular expression. Take a look at this library - it seems helpful. This article should also be useful.

提交回复
热议问题