IntelliJ - completion suggestions order - intellij-idea

I'm wondering if there is a way to let IDE suggest methods before variables?
When writing code like this it's a pain to select methods yourself (builder class example)
Variable example:
var message = "message"
private set
Thank you

Sorry, it appears you can't reconfigure the IDE or Kotlin plugin in this way. You can file a feature suggestion for Kotlin plugin, but I believe there are cases when variables are preferred over same-named methods, so just reordering them would break someone else's habits, so it's tricky.
You can consider making the variables private (so they won't be shown in the completion list at all) or selecting them and then typing an opening parenthesis manually.

Related

Can Intellij recognize unused instantiated code in tests?

Intellij, of course, highlights my unused code. If I write something like this in the test:
String something= "testValue";
something will be grayed out.
But , if I have some instantiation like:
DccData dccData = new DccData();
even with
dccData.setAmount(12);
If dccData is never assigned to some other object, my FindBugs will eventually find that dccData is useless since it is not assigned or used as a return (thenReturn), etc. and this will crash my build, because that is how my build is set. I need to keep it that way because of the company's policy.
My question is:
Is there a way for Intellij to notice and gray-out this?
Unfortunately you can't set "Unused declaration" inspection to trigger dccData variable from your sample as unused. It will be difficult to prove that dccData is not used anywhere else, i.e. in setter method.

How to make the IDEA to recognize Spock's with() method?

I write on Groovy and use Spock framework for testing.
Some time ago, IDEA completely supports Spock.
When I've writing the code inside feature (test method) in where-block something like this:
with(someObject) {
intField == 1
...
}
IDEA correctly recognize the someObject and understand that intField is field of the object, also, it was offering me other fields of the object. So, inside Spock's with() block I've felt like inside any closure from DefaultGroovyMethods (with{}, each{}, find{}, etc.), but haven't need to use explicit it param.
(So, I's writing with(someObject) { intField == 1 } what is the same is someObject.with { assert it.intField == 1 }.
After a moment IDEA missed Spock's with() method support.
Now, it don't recognize the class of the parameter (ex. someObject) in think that it's object of Object class. Any fields inside closure don't be recognized. Explicit it usage didn't help.
After some IDEA update everything have repaired, but after reboot the problem has come back.
Does anybody know how to fix it??
I'm using the last version of the IDE - 2018.2
I just tested this out with 2018.1 and have the same issue as you. I didn't run the code but I am fairly certain that the code would be recognized and executed. This to me looks like a bug with Intellij, and it might be worth it to submit a bug report in their ticket tracking system.

Lombok: Apply "var" for all local variable declarations automatically

Lombok has a neat feature to use var instead of local variable datatype declarations. Is there a way to "refactor" your entire code base automatically to use var whenever applicable? I'm using IntelliJ IDEA and the Lombok plugin. I didn't find a feature like this.
Also, does it even make sense since var is still considered "experimental" so it might "mess up" the code base when it gets deprecated/is somehow bugged/gets replaced/moved?
No.
Moreover, I wouldn't recommend this.
Being explicit is always better so IMHO var is only good when the cost of being explicit is too high. This is only the case with lengthy LHS where the same information is repeated on the RHS.
Use diamond operator (or factories). Not that var list = new ArrayList<>() can't work as you removed the type parameters from both sides.
Prefer val to var. With val not being longer than var, there's no reason not to use it (unlike when separate final is needed). This way, you can see what variables may change.
I'd bet the Lombok authors would agree with me, so they won't support such a feature. I hope the same holds for the plugin author.

AppCode for reordering code?

Is it possible to use AppCode like the ReSharper in a sense that it allows us to reorder code?
In particular I'm looking for a way to reorder methods and properties alphabetically in my Objective-C* files whilst keeping the comments intact.
A plus would be something more sophisticated like Reshaper allows to use a custom scheme that would e.g. first put the initializers, then the protocol implementation, then public and finally private methods.
Up to now I've failed to locate any such feature in the current AppCode 3 demo..
Any hints much appreciated!

Any way to get JsDoc help in IntelliJ when documenting AMD modules?

I like using JsDoc, as it gives me a lot of help when using WebStorm (or other IntelliJ derivates), such as parameter lookup, quick access to documentation, etc.
Most examples assume that you can write something like
/** #class MyClass */
var MyClass = function() {
}
But if you wrap your code in anonymous functions to avoid polluting the namespace (say, due to concatenating the js files), then WebStorm no longer finds the documentation, and I no longer get much help.
Is there any way around this?