IntelliJ Plugin Development - Parameter / Method Hints - intellij-plugin

I am looking into writing plugin for the IntelliJ IDE for testing. I would like methods and classes to have something to indicate the number of tests and coverage they have. i.e. I have a method in my class and I can see that it has 3 tests written for it and 50% coverage.
I want this to be done without editing the code at all, almost exactly like how parameter hints work.
My problem is that I am fairly new to this and after reading the documentation I am struggling to see if an interface like this is even possible? Is there a way of doing this? Is there a better way of doing this?
Many Thanks,
James

I'd use codeInsight.lineMarkerProvider extension for this.
Implementing LineMarkerProvider interface allows to show an interactive icon on left gutter. It's the extension used to "Has implementations" icon etc.

Related

Best practices writing Espresso tests for a multi modular Android projects (MVI/MVVM)

I am looking into Espresso Framework to adopt the best practices for writing tests for a multi modular Android projects (MVI/MVVM).
Is it a good idea to cover/write all the Espresso tests inside the app module (or) it needs to be isolated specific to each modules?
Is there any other best practices for MVI/MVVM based Android projects? if so, please comment and provide references if any
Language used: Kotlin
I have recently been implementing espresso tests in the multi-modular project where I work. Through some research and help from senior developers, I think I will be able to guide you a bit in the proper direction.
For the first question, Yes, it's essential that all the tests related to a particular activity remain in their corresponding 'test' class. That keeps it modular and easy to debug. So, one should make a test class for a particular activity and that should be in the corresponding module that the 'activity' belongs.
All these test classes can then help you to build a 'TestSuite' which could be used to make a flow for testing the app's specific features. In a test suite, one needs to mention those classes that make that flow.
After all this research and as per knowledge, I guess, this approach is good enough for large projects as well since the app I am working on is really big.
Blocker :
In a multi-modular project, I am still not able to create the test suite since I am not able to import those test classes in the main app module. But this issue will be fixed very soon. I'll definitely update it here when I'll get the method to do so.
Please do comment, if I am doing something wrong. Suggestions are a warm welcome.

How to find production methods only used by tests in Intellij

Does anyone know if it's possible to identify production methods that are only referenced by unit test class methods?
I can see if a method has production or test uses by using the Find Usages option but I want to scan my whole codebase.
Thanks.
Unfortunately this feature is not yet implemented, but there is an issue for it, please follow:
https://youtrack.jetbrains.com/issue/IDEA-212420

Is there functionality in IntelliJ that let us find the most referred functions or methods?

I'm trying to find a way in IntelliJ IDEA to find all the usages of method calls in a particular project, sorted descendingly from the most used methods to the least. Is that possible?
The background for finding such function is to be able to write tests for the most critical methods and functions in the project.
Just right-mouse-button and click on find-usage

Why doesn't rearrange code work in Kotlin files in Intellij?

I love Jetbrain's Idea IDE and its ergonomics. One of my favorite tools is idea's rearrange code 'action'(you can bring it up by hitting ctrl+shift+a). It rearranges the code in the java file to put methods in alphabetical order and order the fields in an organized fashion that the user defines. For whatever reason, it doesn't work with Jetbrain's own language, kotlin :(. This sucks even more with the fact that kotlin quickfixes the fields right above the method instead of the beginning of the file like most java files. When is Idea going to support rearrange code for kotlin files?
The reason why the feature does not work is simple: because it has not been implemented. IntelliJ's current Java support feature set has been developed over more than 15 years, and replicating all of Java support features in a new language plugin takes time. We're prioritizing features in the Kotlin plugin for IntelliJ IDEA based on user feedback and language evolution requirements, and so far we haven't seen an indication that code rearranging is in high demand.
Specifically the issue of placing properties by the Create from Usage fix can be fixed with relatively little effort, and doesn't require a full rearrange implementation. I've filed an issue for it.

non-XCode IDE for Cocoa?

I think Xcode is a good IDE, but having used Eclipse for Java development in the past I am quite underwhelmed by XCode's code completion and error/warning feedback. (Most of the time, XCode seems to simply try to match the beginning of a text fragment to "words" in the same document, without even using type information to try to determine the appropriateness of a suggested completion.)
Does anyone have ideas or tricks to make XCode approach Eclipse's cleverness, or to realistically develop Cocoa apps with other IDE:s than XCode?
EDIT: Worth keeping an eye on this: code.google.com/p/objectiveclipse/
The good news is, Apple’s working on the problem. One of the goals of the clang compiler project is to create a reusable parser which can be used for better code completion and refactoring support. Indications are that this has borne fruit in the latest Snow Leopard seeds.
Quite simply: no.
You can do almost everything by hand using your favorite text editor but it's not at all recommended. Try designing interfaces without Interface Builder for example.
My advice would be to just stick with Xcode and learn its way of doing things. Yes, it will be different and sometimes might not be "better" in your Eclipsed eyes. Console yourself in the fact that Apple's managed to release some great products using Xcode.
My personal experience is that, each time I use Xcode, I find a new trick which I can add to my bag. Xcode is far more full-featured than what you might think at first (or second) glance.
I've long voiced my rants about what's wrong with Xcode (and what's not wrong with Xcode). But you really don't want to use another tool. And without breaking NDA: Xcode 3.2 with SnowLeopard: Hooray. (Compared to what we have; not compared to what we might want.)
That said, to your original question about code completion, I personally turn off auto-completion in favor of on-demand completion. I find it far more useful and less distracting. In the Code Sense panel, set "Automatically Suggest" to "Never" and make sure the other two options are selected ("Show arguments in pop-up list" and "Insert argument placeholders...") This will do completion in a pop-up box when you hit Escape, making it easy to scroll through looking for what you want. I find that I have to type a lot less this way, especially for methods that are not unique for many characters. 80% of the time, it's highlighting the right thing already.
I have certainly felt your pain — as an experienced Java developer and frequent Eclipse user, I've wished for the same features myself. Unfortunately, I'm not aware of anything that fits the bill. I don't think there was any satisfactory resolution to this SO question, either.
However, I think you'll be quite happy with the improvements to Xcode code completion coming in Snow Leopard — it's vastly smarter about filtering the list of possible completions. Also, there are new conveniences for coding, such as inserting a starting bracket when you forgot one, etc. To my knowledge, there is still no predictive compiling like Eclipse, though.
Is anyone aware of an IDE other than Eclipse that supports predictive compiling and warning/error reporting? Does Eclipse itself support the feature for languages other than Java, such as C++? I'm led to wonder whether the fact that Java is built with independent .java files rather than .h and .c/.cpp/.m files makes it simpler to predictively compile. Also, anything compiled with gcc requires a little more care and attention than the comparatively simpler javac command. Any thoughts?
Check out JetBrains' new IDE called "App Code". It's still in the Early Access Program, but even with the Early Access bugs it is hands-down better than xcode 4.
http://www.jetbrains.com/objc/
emacs and/or vim
Xcode does have some context awareness, when you are sending a message to an object it will generally have the "ESC" list pull up meaningful arguments.
One thing I strongly recommend is looking into text macros. These are not really type aware, but they can save a ton of typing - for instance, after #implementation type "init" and then hit control-. (period) to activate the text macro. It will fill out a whole init method for you. You can create your own, or override the existing macros.