To speed up the import of static methods in a Java class we need to populate the Eclipse's "Content Assist, Favorites"
Window > Preferences > Java > Editor > Content Assist > Favorites
In mine, I have the following entries (when adding, use "New Type" and omit the .*):
- org.hamcrest.Matchers.*
- org.hamcrest.CoreMatchers.*
- org.junit.*
- org.junit.Assert.*
- org.junit.Assume.*
- org.junit.matchers.JUnitMatchers.*
- org.mockito.Matchers.*
- org.mockito.Mock.*
- org.mockito.Mockito.*
- org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*
- org.springframework.test.web.servlet.result.MockMvcResultMatchers.*
Source Stack Overflow:
- http://stackoverflow.com/questions/288861/eclipse-optimize-imports-to-include-static-imports
- http://stackoverflow.com/questions/11829495/eclipse-has-some-problems-with-auto-import-static-classes
Keys | Action |
---|---|
ALT + SHIFT + X + J | exec the java app |
ALT + SHIFT + X + T | exec the test |
ALT + SHIFT + X + M | exec maven |
ALT + SHIFT + S | open source menu |
ALT + SHIFT + T | open refactor menu |
ALT + SHIFT + R | rename |
ALT + SHIFT + I | inline |
CTRL + 1 | quick fix |
ALT + F5 | update maven project |
ALT * SHIFT + UP | selects a string |
Window > Preferences > Java > Editor > Templates
${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)}
private static final Logger LOGGER = LoggerFactory.getLogger(${enclosing_type}.class);
${:import(java.util.List,
java.util.ArrayList)}
List<${argType}> ${newName} = new ArrayList<${argType}>();
usage: ALT * SHIFT + UP to select the string and double CTRL + SPACE
${:import(java.text.MessageFormat)}
MessageFormat.format(${word_selection}, ${cursor});