Does eclipse have a debugger "step into selected" option that prompts for the method to step into? - eclipse

I have used IntelliJ Idea on a few projects and I really like the feature it has in the debugger where I can step into a line of code, but choose which of the methods I REALLY want to step into, instead of going through them all until I hit the one I want.
For example, the debugger stops at this line:
String restult = getMyResult(getParam(), buildSomething(), nextOption(x));
I want to hit ctrl+F5 and have a list popup with:
getMyresult()
getParam()
buildSomething()
nextOption()
and I can select getMyResult and step into that method while skipping the other three.
It sure miss that feature when I am debugging in eclipse, does anyone know if there is something comparable?
I know about the Step Filtering options in Eclipse, but that is not quite what I want.

You can simply put a cursor on method you want and hit Ctrl-F5, so no additional selection needed.
Alternatively you can use Ctrl+Alt-Clik using mouse do do the same.

You can:
Select the text of the method call you want to jump into
Then right-click into context menu
Choose "Step into selection" from there.
Does not work all of the time tho.

In IntelliJ Idea 10.5
It is called Smart Step Into
In menu it can be found "Run -> Smart Step Into"

Related

Go to next compiler error across project in IntelliJ

I spend a lot of time going back and forth between SBT and IntelliJ, getting a file, line number, and error from SBT and navigating to it in IntelliJ. Is there a way to automate this at all? Even if it's only via IntelliJ's compiler, I'd love to be able to navigate to the next error project-wide.
To navigate between errors or warnings in IntelliJ you can do one of the following:
Use keyboard shortcuts F2 (Next) and Shift+F2 (Previous) respectively.
On the main menu, choose Navigate | Next / Previous Highlighted Error.
I am using Ctrl+Alt+Up/Down to scroll through the list of errors. This is inside the Compile Messages window. The SBT Console uses the same shortcut, as stated in the SBT wiki.
For this specific question, just use F2 (Next) and Shift+F2 (Previous);
But for any other questions related to shortcuts of IDEA, searching in the Settings-Keymap is better than in Google.
To go to next compilation error in the next file:
Command-0 (go to messages tab where compile errors are)
Down arrow until get to next error
Enter
Esc to get to back to code where this error is
The highly voted answer has not really answered the question. The provided solution of F2 only navigates through the errors in the current file. But picking up from the comments, the suggestion below is not the ultimate answer but is a little bit closer.
Select Problems as shown in the image below
This will list all files that have errors.
Use F2 to navigate through the errors.
At least with this method, it has narrowed down the files with the errors and are just a click away.
2022 UPDATE
This is a whole project, error to error, one-click solution after a 2-second setup. For both setups, optionally disable generate warnings for your compiler.
Windows/Linux Setup
Alt6 or click Project Errors tab of Problems tool window
CtrlNumPad+ or click
to expand all errors
MacOS Setup
Cmd6 or click Project Errors tab of Problems tool window
Cmd+ or click to expand all errors
Now click the first error in the Project Errors tab, fix it, then click the next error. Works regardless of build tool and may work in older versions of intellij than 2022.1.
Edit: Credit #Manuel Romeiro - the answer in his comment worked for a while, but stopped when intellij got confused somehow. Will update my answer if I figure that out.
Thanks #meridsa for providing setup step 1 for Mac. Also to #K. Symbol for syntax for showing keys in an answer (very cool).
For the mac I couldn't find anything that worked until I discovered the following
cmd + 1 -> f2 (on files) -> escape -> f2 (inside file) -> cmd + 1 -> repeat
For going to the next error across the entire project, use Alt+F2 instead of just F2.
On Mac, you can enable Fn regular key functionality in System Preference.
Choose Apple Menu > System Preferences.
Click Keyboard & Mouse.
Click the Keyboard tab.
Select the option Use All F1, F2, Etc. Keys As Standard Function Keys.
Quit System Preferences.

Intellij idea missing one feature from eclipse

In eclipse, when debugging, let's say you have a method call with parameters, and then when you press step into, it'll evaluate parameters first and only then will go into function. But in eclipse there is a hotkey, so you put your mouse cursor on function name, press it, and debugger will stop inside that function, so it'll skip parameters evaluation (it will evaluate them, but won't stop there). Is there such function in intellij idea?
EDIT: there is a workaround for this, go inside method, put a breakpoint, then resume your application and it'll stop at that breakpoint. But is there a way without setting an additional breakpoing?
If i well understanding,you can you the Smart Step Into debugging features(Smart Selective Step Into). When you press shift+F7 a popup ask you into witch method you want to step into.
You can select the method directly, avoiding the parameters evalutation.

Eclipse Maven Build and Test with One Button

The most common build activity I do in Eclipse (other than allowing auto-build to do its thing) is to perform a "Maven Build..." with parameters of clean and package. This runs all my tests. m2eclipse does a great job with this, and I like the output. If a test breaks, I then jump to using the JUnit plug-in, the debugger, etc.
I've used "Organize favorites..." under the Run (and Debug) button's drop down menu to make this kind of build "permanent" and somewhat easy to access and use.
But not easy enough.
What I have now is a button that morphs from moment to moment, based on my last activity, what file I have open, or what item I have selected in the project window. Yes, I can click the down-arrow next to the run button, select the favorite for "clean-and-package" but for something that I do hundreds of times a day, that's too difficult.
I want ONE BUTTON. A big ol' button on the tool bar that I just click and boom goes the dynamite. I'll also accept a way of assigning a hot key to my build favorite so I can press, say, ctrl+r or something to run my favorite item.
What'cha got for me?
I've rediscovered key bindings in Eclipse. It's not exactly what I want, but it works well enough, I suppose. I simply bind F7 to Maven's test hook. It's not the same as "mvn clean package" but it'll do until I find a better solution.
Here's how I did it:
Open preferences
Open General->Keys
Search for "maven test" (or "run maven test")
Select the Run Maven Test entry
Click on the field labeled Binding
Press F7 (or whatever keystroke you want to bind)
Probably best to set the When field to in Windows
Now, when you press F7, eclipse will run "mvn test".
For whatever reason, and I'm sure it's a perfectly good one, the m2eclipse plugin authors didn't provide a "Run Maven package" hook. Sigh.
It looks like there's a couple of ways to do this - none directly in Eclipse:
Create your own small plugin that defines the key binding, see here: eclipse: put keyboard shortcuts on specific launch configurations
Use Practically Macro - also see here: Assigning a keyboard shortcut for a specific Eclipse build configuration
Use some form of scripting, e.g. this: http://mackaz.de/72
If you create a Maven Run Configuration and put a number as the first character in the name, then you can use Shift-Alt-X Ctrl-M N, where N is the number you gave as first character in the name. For your case, do the following.
Right click on your project, select Run As and then select Maven
build... This will open a dialog to create a new Maven Run
Configuration.
Make the name of the configuration 1 - test.
Put test as the goal.
Press Apply and then Close.
Type Shift-Alt-X Ctrl-M 1. This will select the configuration you just created.
Press enter will launch it.

Debug in Eclipse - ClassNotFoundException

when i debug in Eclipse a simple console application, I get a lot of ClassNotFoundException lines in the debug Window. It is not an error, somewhat lower in another pane I get "Source not found.". I understand that it is because the source code of the required class is not available, buI would like to skip over these lines... I have to press a lot of times the "step over" or "step out" button to get out of these states.
What can I do in order to avoid these useless lines at all?
Thanks
I've been having this problem for a few months now. I'd be debugging a java app and every time I'd hit a constructor, eclipse would try to find matching java core library ClassNotFoundException's source code.
I solved this problem by right-clicking in Debug window on the ClassNotFoundException when I hit it, and clicking on Filter Type. I would then right-click in the debug window again and choose Edit Step Filters.... In the Edit Step Filters window I checked everything in the Defined Step Filters section and unchecked everything in the bottom of the window (Filter synthetic methods, Filter static initializers, etc).
Hope this helps others in the future.
After Launching Debug Mode.
Go to Window → Show View → Break Points.
Now you would be able to see Break Point tab in Debugging mode.
Uncheck the option "ClassNotFoundException: caught and uncaught".
While debugging try Step Return (F7 as shortcut) to get one level up at a time and thus out of the libs you don't have the source attached for.
In a normal application your own code (your java files) is mixed together with code of others (class files in libraries, runtime environment, etc.).
Each time you step into a class file you will get this "Source not found"-Warning. (as you already mentioned in your question)
At first you could try to get the source codes for the libraries and link them to your libraries (for example in "project setup => Preferences.../Java Build Path/Libraries => unfold a jar-libraries => Source attachment").
If no source code is available you have to use the debugger-comands to avoid jumping into that class files. "Step Out/Return" might help, but the "Debug View" (which can be found in the top left corner in your "Debug Perspective") could be even more helpful.
In the "Debug View" you can see each thread of your application. If you are currently debugging a thread you can there see the current stacktrace. Instead of clicking F6 and F7 all the time you can also navigate by clicking on an stacktrace-item there.
Tipp: I am using - (Rightclick->"run to line") a lot - this is quite helpful to run over loops, etc.
An occurence of ClassNotFoundException is most common in debugging in order to avoid these exceptions, In breakpoints window(Windows>Show View>BreakPoints) uncheck the "ClassNotFoundException: caught and uncaught" to continue with the normal debugging.

Debugger / Profiler for Eclipse?

Is there any tutorial for debugging applications/ running profiler in eclipse? Please let me know thanks..
This will depend on what language you are using. How you setup for debugging PHP vs C++ is a little different as they use different underlying tools (PHP - Xdebug vs C++ - gdb)
In a general sense, you will configure the app much like you would set it up to run within Eclipse. In some cases you will have to be sure to enable debugging information within the code base for the debuggers to provide detailed information. From there you're looking at setting breakpoints, stepping, and setting up watches which is very similar language-to-language within the Debug Perspective in Eclipse.
A common scenario is to set a breakpoint within the codebase by clicking on the left bar in the editor, and selecting toggle breakpoint. Then click the debug button in the IDE and it should open the Debug Perspective and either break at the beginning of main, or will run to the breakpoint you set in the code. Once the break is hit, you will be able to browse the stack frames within one of the views within the perspective and you will see tabs for watches, breakpoints, etc. The buttons near the top that look similar to play, and then arrows jumping over dots are the way you control the execution from your breakpoint. If you click "step over" the code will go line by line in the source file you're in until it must goto another file to follow the execution of your code. It will not go into a function call, rather call it execute it and return to the next line in the current source. If you want to go into the function call and continue debugging from there, you would use the "step into" button which is right next to "step over" in most cases. Resume restarts regular execution and will run your program normally until the end or another breakpoint is hit.
Start from there and get comfortable with it and then start playing with things like conditional breakpoints and watches. Conditional breaks are exactly like breakpoints but they only stop execution if the condition you specify is met. With C++ this is usually done by right clicking on the breakpoint and providing the conditional expression where appropriate in the menu. (I forget the exact verbage)
Watches allow you to watch memory and have the program break when memory is read, written to, or both so you can inspect your application.
Some debuggers in Eclipse may lack some of these features or offer more advanced features than those listed above, but these concepts should get you well on your way.
Good luck!