Intellij IDEA go to previous method shortcut - java

Do you know if IDEA has a shortcut which will bring me to the last method I was looking into, not necessary changing it, just looking into. I know that there is Ctrl+Alt+Left/Right but it is slightly different.

If you are on a Mac, press Command+Shift+A.
If you are on a Windows, press Ctrl+Shift+A.
This will bring up a searchable list of ALL of the possible shortcuts. Just type what you want to do and it'll come up there. Very handy. I use it all the time.
Hope that helps. Good luck :)
EDIT:
Just took a look myself. Doesn't look like there is anything like what you wanted. The closest thing is moving to the the next method or the previous method, but this is just in order of how you have them written in the code, not in the order that you look at them. Sorry!

Related

Java function on following function

Yesterday I made this question: Java function on function
For help and get marked as Duplicate but I think I didn't get understand there what I want and now I try again.
I want methods can be only called on methods for example we have the class Roads and on the road we will go a Way.
Roads.Way1()
After we choose the Way1 we will go to Path1
Roads.Way1().Path1()
But if we choose Way2
Roads.Way2()
We are not able to go to Path1() cause Way2() goes to Garden1() so
Roads.Way2().Garden1()
So what I try to say you can only use the methods(functions) in a wanted way and I saw this on different API or Library. So for the good understanding
Way1 goes to Path1 and ISN't able to go to Garden1
Way2 goes to Garden1 and ISN't able to go to Path1
So how to manager that I can make different roads that has there own ways so I could make like
Roads.Way1().
/*
Goes to:
Path1()
Fountain()
Market()
*/
And Way to cant access them and can only use there own destinations.
I think what you are asking for is: how can I express "control flow" using "language features". And well, there would be ways to get there: you would need a lot of different classes (or maybe interfaces); so something that is a "Way2" would simply not offer a "Path1" method.
But: doing so sounds like bad idea. It will work fine initially, but as soon as you start extending your system, you will be running into problems all the time:
"Hmm, I need to change Way2; it should now allow to go Path1; but uups; there are some Way2-thingies that should not allow Path1; so I actually need a Way3-thingy" and so on. Chances are extremely high that maintaining this code will turn into a nightmare very soon.
I know, this is just an opinion, but my gut feeling is: you are looking for the wrong solution to your problem. Instead, you should spent time on identifying what your actual problem is; and then think about better ways to solve that problem!

How to compare two identical methods in eclipse?

I'm doing android app from a book, for some reason the exact method source code I wrote myself does not work as expected and I am trying to debug it.
I have two exact chunks of code, my method and the sample method.
How to compare them in eclipse?
Select both files by clicking the first, then while holding CTRL click on the second.
Now both of them got selected.
Now click one of them (doesn't matter which one) with the right mouse button.
From the appearing context menu choose:
Compare
Each other
Now you can do a text compare.
Did I get right that neither of the sample method nor your method do what they should?
Then there are two possibilities why the code won't do what it should:
The book is obsolet
You made something wrong
either way, google for your specific problem, maybe someone else has encountered it as well and already solved it.
for your Question: already answered in another comment
use beyond compare, it's a great tool for comparing classes, and methods! download beyond compare

Autocomplete in eclipse like in visual studio

I know there is a Ctrl+Space dialog box that show the methods options that I have.
But if i have a method that I not fully remember the name of it and I remember only a part of the name.
For example: There is a big static class which contains tons of methods starting with "add"
add1_Buffer, add2_Render, add7_Function and so on..
now I don't remember the fully name but i remember only "Buffer".
so I want to type "buffer" press Ctrl+Space and get the "add1_Buffer" method and all the names
that contain the name "buffer" in it.
Edit:
By the way, i need it on the OpenGL api where there are tons of functions and i am not familiar with all of them i know only keywords, I was searching for something like in visual studio that is really fast and easy.
If you start typing the a in add1_Buffer and then an upper B and then press Ctrl + Space you will find the correct method.
You can then continue writing the word Buffer if there are more methods starting with add and then having an upper B.
This means that you'll have to remember at least the first part of your method but hopefully you do.
Add the CodeRecommenders plugin to your installation. That has a subwords completion, which the normal JDT code completion does not have.
Use search. From the Search menu at the top of the window, select "Java Search". You can limit your search to methods and use wildcards to search for *Buffer* if you know that Buffer is in the method name.
The shortcut Ctrl + O gives an outline of the current source. So you can view and search all your methods in your current class. Use wildcards when needed.
This merely meets you req: alt+/, just a replacement for ctrl+space
Currently there is no direct way to do that in eclipse. But i found these are helpful. here
This post resembles your's look at it. Similar one here

ComboFieldEditor. Dynamically changing the values

I am working on an eclipse RCP project. As I was going through the walkthroughs I came across preference page and started working around it.
Now I need to change the values of the ComboFieldEditor dynamically. As in when I make a selection on a TextFieldEditor the values of the ComboFieldEditor must change. I tried searching for an answer and even tried one of the solutions I found on Stack Overflow, but I always ended up with NullPointerException. Can someone help me in this regard?
Technically I want to change the values in the ComboFieldEditor dynamically. As in, when a listener is triggered I want to put new values in my combobox. I tried this solution but I kept getting a NullPointerException.
Ok. This is something that I did for the time being.
I created a class named CustomComboFieldEditor and added all the methods present in the ComboFieldEditor. I changed the methods that helped to input the values in the combo box. Works fine for me as of now.
I am sure its not the prettiest of all ways and I bet I would be crucified for this solution, but time and situation forced me into using it. Anyother way would be appreciated.
Thanks :)

Eclipse: Fulltext autocompletion for Java?

can I has fulltext autocompletion for Java # Eclipse? Let's demonstrate:
Final piece of code:
getVariants().add(new Variant(MediaType.TEXT_XML));
How do I code now:
getv[ctrl+space].a[Enter]new
V[ctrl+space, down arrow,
Enter]M[Ctrl+Space, Enter].text_x
Basically, Eclipse completes word "TEXT_XML" when I provide letters "TEXT_X".
How would I like to code:
getv[ctrl+space].a[Enter]new
V[ctrl+space, down arrow,
Enter]M[Ctrl+Space, Enter].xml
and Eclipse should realise I meant "TEXT_XML" (fulltext autocompletion).
As far as I'm aware, there is no way of enabling a full-text code completion in the Eclipse preferences view. This has been bugging me for a while, too. I did quite a bit of digging and I'm pretty certain there is no easy way of achieving this.
However,
there are two ways of implementing the desired, but I assume both of which are way to much work for fixing this little nuisance.
There is an Eclipse plug-in extension point for the JDT Java Completion Proposal Computer - reference page
A sample project which implements this extension point can be found in this repository.
This is fairly convenient, but still a lot of boilerplate and tedious coding.
You can change the findKeywords method in the internal org.eclipse.jdt.internal.codeassist.CompletionEngine class and compile your own JDT fork. But this is discouraged for so many reasons. First of all, this class is a 12000 line monster and hard to just jump in. And of course, if you'd only hack a kludge in, there is little chance of this becoming an official contribution, so you'd need to worry about every eclipse release.
Additionally, there might be a very chillaxed way in the future. Although this might exceed your requirements a bit.
Have a look at the Code Recommenders project. This blog has an outline of the project objectives
It doesn't mention full-text auto-completion specifically, but I'd assume its matching algorithms go even beyond that.
Edit: In the proper SO-spirit, I'll keep this answer up to date:
Apparently the feature is now implemented in the Code Recommenders plug-in. See this blog post and this forum thread. I'm quite surprised it only took 10 locs. To me the extension point appeared more complex.
If your MediaType class does not contain a large number of accessible fields/methods you could simply use
getv[ctrl+space].a[Enter]new V[ctrl+space, down arrow, Enter]M[Ctrl+Space, Enter].[Ctrl+Space, down arrow, Enter]
you may need to press the down arrow more than once, though to select the desired field.
Yes, you can using Templates. (Window -> Preferences -> Java -> Editor -> Templates)
The basic usage is you set the name to what you want to type and you set the pattern to what you want to appear.
In my testing I set the name to xml, the Context to Java, the Pattern to TEXT_XML and Automatically insert turned on. Then when I typed out your example I was able to follow a pattern like...
getv[ctrl+space].a[enter]new V[ctrl+space, down arrow, Enter]M[ctrl+Space, Enter].xml[ctrl+space]
and since Automatically insert was turned on poof TEXT_XML was inserted.
Templates have much more functionality than that and the one source I used for this answer was Effective Eclipse.
I hope this helps!

Categories