Wednesday, December 31, 2014

Infix notation and Live templates



IntelliJ lets you complete code statements in several different ways.
  1. Infix notation.
  1. To create a loop that goes over each variable, try typing the variable name, a .fori. It should expand into a for loop that creates an index.
  2. To create a loop that creates a foreach, type the variable name and then a .for. It will expand into a foreach loop.
  1. Live templates. Look at Settings -> Live templates.
  1. With these, you can ifn or ifnn and a tab to get if null or if not null constructs.
  2. You can also construct your own.
  1. I added a logging category and set logdecl to private final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(this.getClass());, as I had done before, in Eclipse.
  2. You can also add variables. I set logstart to be log.info("Entering $METHOD$.");. Then I pressed the Edit Variable button and told it that the expression to use was a predefined methodName().

No comments: