A simple way to create static imports for constants in existing code?

前端 未结 9 866
心在旅途
心在旅途 2021-01-30 21:17

If I have a constant BAR in Foo, which I will use in a class C I\'ll have to write

Object o = Foo.BAR + \"...\";

which I can use Ctrl-Shift-M i

9条回答
  •  滥情空心
    2021-01-30 21:43

    Eclipse can do a global search and replace with regular expression over all files in the project.

    To add the static import at the beginning of all files you could replace the package declaration by itself plus the static import.

    Then do a project wide organize imports, and you're all set.

    Be careful, though, this could also make a big mess if you do it wrong.

提交回复
热议问题