是否有办法让Eclipse自动查找静态导入?例如,现在我终于升级到Junit 4,我希望能够编写:
资产质量(期望值、实际值);
点击Ctrl+Shift+O并让Eclipse添加:
导入静态org.junit.Assert.assertEquals;
也许我要求太多了
我使用的是Eclipse Europa,它还有最喜欢的首选项部分:
窗口>首选项>Java>编辑器>内容辅助>收藏夹
在我的中,我有以下条目(添加时,使用“New Type”并省略*):
org.hamcrest.Matchers*
org.hamcrest.CoreMatchers*
org.junit*
org.junit.Assert*
org.junit.aspect*
org.junit.matchers.JUnitMatchers*
除了第三个以外,所有这些都是静态进口。通过将它们作为收藏夹,如果我键入“assertT”并点击Ctrl+Space,Eclipse将提供assertThat作为建议,如果我选择它,它将向文件添加正确的静态导入