I've found something of a workaround that does prevent IntelliJ from adding parentheses, however it isn't a setting and involves the code itself so it may not actually fully relieve your annoyance.
If you write out an object, then you write a method call on the object, IntelliJ will create the parentheses and insert your cursor between them. Below is an example, |
represents the cursor.
//Start with:
objectA method|
//Press `RETURN` and it becomes:
objectA method(|)
However, if IntelliJ detects that an argument is already present when you write the method call, then it should omit the parentheses.
//Start with:
objectA| objectB
//Write the method call:
objectA method| objectB
//Press `RETURN` and it becomes:
objectA method |objectB
The problem is that people generally write the argument after the method call. Although you could use a placeholder to trick IntelliJ into thinking there is an argument present, while you can still write normally. Note that you can either write the placeholder on the same line as the method call, or the line immediately below it (with only whitespace in between), in order for IntelliJ to detect it as an argument.
//Start with:
objectA|
"placeholder"
//Write the method call:
objectA method|
"placeholder"
//Press `RETURN` and it becomes
objectA method |
"placeholder"
//Continue to write the argument
objectA method objectB|
"placeholder"
The above behaviour only appears to occur when infix notation would be valid, such as where method
is defined within objectA
's class. However, it seems as though the placeholder argument doesn't actually have to be the type specified as the method's argument in order for IntelliJ to detect it as an argument of the method.