How can I navigate to Lombok generated implementations - intellij-idea

I'm wondering if it would be possible to navigate directly to the methods generated by Lombok using Intellij IDEA.
For instance, for this given example:
#Builder
public class AClass {
private String body;
}
trying to go to the implementation of AClass#builder in an instruction like AClass.builder().build() results in Intellij navigating to AClass, instead of taking me to the real compiled method, which is generated under target directory

Please feel free to create an issue here: https://youtrack.jetbrains.com/issues/IDEA
Currently you can't change the behavior.

Related

Intellisense - deduce right Class by its methods

I'm used to work with NetBeans and now I'm trying IntelliJ. So my question is: Does IntelliJ has a way to get right class by its methods?
For example, in NetBeans if I write:
glGenBu // Intellisense will kick in and will suggest me
to use GL15.glGenBuffers() method from GL15 class
This will automatically import the right library.
This is very handy because I'm working with LWJGL and it has a bad way to manage OpenGL methods ('GLXX' where XX is the version of OpenGL and all methods that appeared in that version are stored in that class) and I never remember the right class where my desired method is.
Thank you.
Pressing Ctrl+Space when you already see completion list will show more suggestions, with static methods from the entire project among them. See https://www.jetbrains.com/help/idea/auto-completing-code.html for more details.

How to move a function from one Kotlin class to another using IntelliJ?

I'm using IntelliJ IDEA to refactor some Kotlin code. I have two classes in the same file and I want to move a function from one class to another using Refactor -> Move (F6), but that doesn't work, and I get tooltip message that says: "Cannot perform refactoring. Move declaration is only supported for top-level declarations and nested classes".
Am I doing something wrong? Or that refactoring is simply not supported?
[edit1] I tried to do the same operation with Java classes and everything works perfectly; so why this is not allowed for Kotlin?
[edit2] I thought that the problem is only when to two classes are in the same file, but it turns out that is not possible to move a function between classes in separate files!
It's a well-known Kotlin-only problem.
in IDEA (both free and paid editions);
in Android Studio.
Official ticket
There is an easy, but slightly janky, work around.
You just need to wrap the function you want to move in a class:
class TopLevelClass {
fun functionToMove() {
//...
}
}
wrap it in a new class
class TopLevelClass {
class TemporaryMoveClass{ /** you can now move this entire new class */
fun functionToMove() {
//...
}
}
}
and after you do the refactor, delete the temporary wrapper class you created.
The janky part is that you need to replace all instances of functionToMove() with NewTopLevelClass.functionToMove() yourself.
One of the major benefits of doing it this way, rather than just cut and pasting it yourself, is that as soon as you wrap it in the TemporaryMoveClass it will tell you any parameters you need to introduce(Refactor>Extract>Parameter). And then you can do that inside the original TopLevelClass before you move it. (this preserves the types of any TopLevelClass properties you were using, and automatically introduces the new parameter(s) into the existing function calls)

Changing the implementation of Objective C method in Swift subclass

I am using an external library in my project. It is integrated via CocoaPods. I have access to the source code. The library is working well, but I need some modifications at some places in order for it to serve my purposes. It is written in Objective C. My project is in Swift.
I need to change the implementation of one method in the library. The problem is it is in the .m file and uses a lot of stuff declared only in the .m file. For example:
-(NSString*)methodToChange
{
NSArray<NSNumber*>* data = [self someInternalMethod:1];
uint value = data[0].unsignedIntValue;
return [self anotherInternalMethod:value];
}
I tried subclassing it like this:
class MySubclass : MySuperclassWithMethodToChange {
override var methodToChange: String {
//trying to use someInternalMethod and anotherInternalMethod
//unsuccessfully because they are not visible
}
}
The internal methods are using and modifying properties from the .m file that are also not accessible. Is there any way to solve this?
I would suggest forking the original library repository and making the necessary changes in your fork. You can then have your Podfile point to that. If your changes could be useful to others, make them in a way that doesn't break existing functionality and contribute them back to the library by opening a pull request.
If the original library gets updated later, you will have to merge those changes from the so-called "upstream" repository into yours. This does not happen automatically, so you'll have full control (and responsibility) over that process. See https://help.github.com/en/articles/syncing-a-fork for how this would look like.

Intelllij IDEA Ultimate 2018.1 groovy code completion does not work

I can create a Groovy project and even run it. But when I type main or print there are no auto-complete / code completion suggestions at all. I have groovy-2.4.1 in the external library folder along with Java 1.8. I find Intellij frustrating and non-intuitive to use.
In a groovy script main does show correct code completion but when I click enter it puts "main()" without the String[] args that I can see in the suggestion.
You have created a Groovy class where code has to be embedded into a class to be executable and where only class member declarations are expected (e.g. functions, fields). Select to create a Groovy script (or just delete class declaration) to be able to write executable code in top level file. See also Scripts versus classes.
I was having the same problem when I was in a rush and forgot to add a method in which to write the code. Just type 'psvm + Enter' inside the class. This will create a main method in which code completion will work. Also, you can remove the public keyword as classes and methods in Groovy are by default public.

Aptana Code Assist with custom Class Loader

Is it possible to setup Aptanta to provide code assist for classes loaded with a framework's autoloading class?
For example:
$myInstance = Project_Loader::load('MyClass');
Here, my class would be loaded from a hierarchy as soon as it was found, so if I had these libraries setup:
/library/Library1
/library/Library2
/library/Library3
If MyClass was in Library2, it wound find Library2_MyClass. Aptana works great if I initiate the object using:
$myInstance = new Library2_MyClass();
But is there any way to let Aptana know to load it and use Code Assist/Intellisense based on Project_Loader::load('MyClass')?
Not possible at the moment, as it's very dynamic, and specific to a framework.
What you can do is to add a comment that will hint for the type.
For example:
/* #var $myInstance MyClass*/
$myInstance-> // and you'll get the MyClass code-assist.