Clearing coverage highlighting in Eclipse - java

After running coverage reports in Eclipse (using cobertura or an EMMA plugin), my source code files get highlighted in green, red and yellow depending on which lines of code were covered by tests.
How can I clear this highlighting after I'm done?

Click the "Remove all Sessions" button in the toolbar of the "Coverage" view.

On 4.2 eclipse it seems to be impossible to remove the eCobertura highlights. Sadly eCobertura plugins seems to be not maintained anymore. However if you start writing into the class, its gone. So type a space, and then undo, and its gone.

For people who are not able to find the coverage view , follow these steps :
Go to Windows Menu bar > Show View > Other > Type coverage and open it.
Click on Coverage.
To clear highlightings, click on X or XX icon as per convenience.

I found a workaround over on GitHub: https://github.com/jmhofer/eCobertura/issues/8
For those who don't want to click the link, here's the text of the comment:
Good workaround:
Create a run configuration with a filter, that excludes everything ("*") and let it run just a single test. Name it "Undo coverage".
I did this and it worked quite well in Eclipse Juno.
Credit for this goes to UsulSK.

If you remove the coverage session, also the coverage coloring will disappear. For this, hit Remove Session or Remove All Sessions in the Coverage view's toolbar.
http://eclemma.org/faq.html

For those using Cobertura and only have the Coverage Session View like I do,just try closing Eclipse and starting it up again. This got rid of the highlighting for me.

Added shortcut Ctrl+Shift+X C to Keybindings (Window -> Preferences -> filter for Keys) when 'Editing Java Source' for 'Remove Active Session'.

If you would like to remove active session/project/folder then you can follow
Click the "Remove Active Session" button in the toolbar of the "Coverage" view.

I have used the Open Clover Tool for the code coverage, I have also been searching this for a long time.
Its pretty straightforward, in the Coverage Explorer tab, you can find three square buttons which says the code lines you wanted to display, click on hide the coverage square box and its gone. Last button in the image below:

Close the IDE and open it again. This works if you did not use any code coverage tools and have just clicked the basic "Coverage" icon in the IDE.

Related

Eclipse doesn't suggest a class that needs to be imported later

I don't know if this is a bug or it's just how it's supposed to be، but whenever I try to type a class like the class random, in eclipse it doesn't give me a suggestion for it. Even when I press Ctrl + Space.
PS: However eclipse does tell me to import the class when I hover the mouse over it.
First thing to try is cleaning your projects via top menus: Project > Clean
note: pressing Ctrl+Space multiple times will cycle through different content assist proposals. Also Ctrl+1 will bring up the quick fixes dialog for errors on your current cursor's line.
I had a similar issue recently, go to:
Window > Preferences then Java > Editor > Content Assist > Advanced
In there I unchecked all the boxes and clicked Apply at the bottom. Then turned on the same options I had just disabled and clicked Apply again and that fixed it.

Running Projects in IntelliJ

I've got a project from my teacher, in which i should add my implementation for a certain aspect.
The Project already got a main method but still the "Run" and "Debug" buttons in the top right corner are greyed out.
I've also tried right clicking the main method and java file, but it doesnt show me run or debug.
Also tried using the "Make Project" Button (top right corner), but it doesnt let me run it either.
How can i run the project?
Help would be much appreciated cause I cant seem to find a solution...
the "run" and "debug"-button in the top run the currently selected main-method. As long as you haven't selected one, you can't run it. In the current version on the left side of the editor-pane, there should be a green arrow right next to the main-button. Run it once via clicking that arrow and from that point on you can run/debug the program using the buttons on the top-window.
In this image you can see the green arrows (version 2016.2.4).
Alternatively, you can use the following more complicated, but also more versatile option:
Directly from the run- and debug-buttons is a button that toggles a list. In the initial configuration of the project, this list contains exactly one Item: "Edit Configurations...". Use it to create a custom-target - go for Application, if your using a java-class as entry-point - and set up the configuration as you wish. Clicking the arrow mentioned earlier does basically the same with a bit of automatic configuration.
Third alternative:
Open the context-menu on the main-method. It as well contains options to run and debug the program with the marked method as entry-point. Works for the context-menu of the respective class as well.
You have to add a run configuration. Do this with clicking the grey button and then clicking at sth with configurations (i am not in front of my PC), then add there the config
Does your main method have the proper syntax for arguments? I found that in Eclipse, the program will not let you run the main method if it is not in the format of public static void main(String[] args). Also, does your code compile properly and your IDE just doesn't let you run it?

Eclipse Not Showing Errors on Lefthand Side

So I've been using Eclipse on my mac for the past 4 months with no problems but suddenly things are acting up. Before, Eclipse would show me a red dot on the lefthand scroll bar when I was working on a class in a project. Now, for some reason, all it does is grey-out that line number but it does not show me that dot like it used to. I've tried restarting both Eclipse and my computer, I've tried working on different projects and classes, I've made sure a project builder is selected, and I've checked that the "show errors" options are all checked. I do not like having to have another window open to see exactly where all my errors are; I preferred just having the red section on my class screen. Any other suggestions?
Thanks everyone!
You could try looking here: Error indicators in file margin in eclipse indigo
Open Preferences, select General/Editors/Text editors/Annotations, and make sure that the errors/warnings are selected to be displayed in the Vertical and Overview rulers.
or
Figured it out, if you go to system preferences > general > click the "when scrolling" button, to only show the scroll bar when scrolling it fixes it. Mine was previously on "always". I restarted eclipse and it shows the errors/warning message etc now.'

Is there a way to use breakpoint in eclipse android, the same we use breakpoint in Visual Studio or Netbeans?

I have tried to use breakpoint in the same way we use break point in Visual Studio or Netbeans, we simply mark the break point and when statement executes, the breakpoint highlights and we can see the values in respective data structure or variable using breakpoint explore.
As far as i have used eclipse, i have found break point is there too, but it is not in that way, means on runtime it does not pick the respective point and neither i can see values nor the application works perfectly while doing that. Is it not possible in eclipse or some tool is required, or i am wrong, please guide.
Ctrl+Shift+B while on the line.
Double click on the left most bar in Editor View.
Right click > Toggle Breakpoints on the left most bar in Editor View.
put a breakpoint at you code line you want,
then right click on project-> debug as -> android application
then go to window menu -> show view -> other... -> debug
or as show bellow
You must set a breakpoint and run the application in debug mode.
You have to launch application in Debug Mode. You can find Debug button left to Run button. It has bug as an icon.
Also could be useful: Setting up a Device for Development. It describes how to enable debugging on your device

Stop spacebar keypress from triggering autocomplete in Eclipse

Update
This was fixed in Eclipse 2018-12. This behaviour is still default, but can be configured off - see the accepted answer for how
I'll leave the question as it was for posterity, and for those on earlier versions of Eclipse
In Eclipse, I've enabled intellisense-style suggestions for Java by going to
Window -> Preferences -> Java/Editor/Content Assist
and setting the following
Auto activation delay (ms) -> 0
Auto activation triggers for Java -> .(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
source = Eclipse Intellisense?
This works brilliantly, apart from one annoying problem. When I hit spacebar, the token being typed is autocompleted with whatever is at the top of the suggestions list. Fair enough, except that sometimes I'll type a class/variable name with an exact legal match, but this won't appear as the top suggestion. So when I naturally hit spacebar Eclipse inserts something completely wrong.
E.G. after typing Cookie I'll hit spacebar and get CookieMonster.
This seems like a bug, and happens often enough to be annoying, but even despite this I don't want spacebar to trigger autocomplete in general. I may want to type a variable name which hasn't been declared yet, or something similar. I want to use autocomplete as a helper tool, but my natural typing should always take priority over it.
I'd like to stop spacebar triggering autocomplete, and either fall back to using enter, or better still trigger autocomplete with a custom key not used in ordinary typing. Is any of this possible?
I've played around with all the settings in Content Assist to no avail. Googling the question just returns a bunch of results about disabling the autocomplete feature.
This issue is fixed from Eclipse 2018-12 [4.10] see the accepted answer
It's present in all prior versions, i.e. 2018-09 [4.9], Photon [4.8], Oxygen [4.7], Neon [4.6], etc..
Eclipse 2018-12 was already patched for this!
A patch for Bug 348857 was recently merged to the Eclipse project and was released as part of Eclipse 2018-12. You can download that version here.
You now have a new option to disable all insertion triggers apart from enter, which will prevent spacebar from causing autocompletion.
Simply go to Preferences... -> Java -> Editor -> Content Assist (or Window -> Preferences -> Java -> Editor -> Content Assist on Windows) and select Disable insertion triggers except 'Enter', as shown in the screenshot below:
There is a solution on the issue tracker for this.
Copy the jar in the eclipse/dropins folder. With the next restart space is diabled as autocompletion trigger.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=348857
Eclipse 12-2018 and newer: This is working natively, check Pyves answer.
Use a SDK version of eclipse
1.open Plug-ins View and find org.eclipse.jface.text, right click, choose import as Source Project. After import, you find it in your workspace.
2.In src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
char[] triggers = t.getTriggerCharacter();
if(contains(triggers,key))
change to
if(key!='='&&key!=0x20&&contains(triggers,key))
3.Export org.eclipse.jface.text
Right click the project folder of org.eclipse.jface.text, choose export-->Deployable plugins and fragments, next, destination choose archive file, finish. Replace the one in eclipse/plugins with the one you generate.
The spacebar has been a key to select the autocomplete even in Indigo. To my knowledge, this can't be configured.
In fact, that is probably why the delay exists.
I suggest setting the delay to some optimal value that allows you to type things like private void ... comfortably without triggering suggestions for private and void. Then in case you get a suggestion because you waited too long, press Escape to abort Content Assist.
Same configuration as davnicwil, same issue, still on eclipse 4.4.
Solution: Intercept (hook) SHIFT+SPACE (press and hold) on (editor-window) eclipse and replace it with ESC,SPACE (sequence). Now you my decide between
Autocomplete+SPACE: press SPACE when autosuggestion present
just SPACE: press predefined key combination or sequence (e.g. SHIFT+SPACE)
On windows you may use http://www.heise.de/download/activaid.html (you can also use AutoHotkey, java native hook, ...)
HowTo with ActivAid:
Open Ac'tivAid, select "UserHotkeys"
click on "+", set a description
click on "short cut", press e.g. SHIFT+SPACE
Command: "{ESC}{SPACE}" (without quotes)
click "+", select eclipse editor frame, press ENTER
click OK, OK in Ac'tivAid
My config file:activAid/settings/ac'tivAid.ini:[UserHotkeys]
Hotkey11=+Space
Path11=<Send>{ESC}{SPACE}
Description11=Eclipse Shift+Space -> Esc,Space
Category11=
Application11=ahk_class SWT_Window0
You may also remap keys on non-english keyboards with "HotStrings", e.g. ö->{,ä->} etc.
Finally worked it out.
Try download this org.eclipse.jface.text.jar and copy it to your plugin folder(Typically eclipse/plugin). Do not forget to backup your own one.
Works on Eclipse Juno.
If the link doesn't work, comment on this, thanks.
In Eclipse go to Window -> Preferences -> General -> Keys and remove the binding for the command Content Assist.
You could disable Auto activation via the check box in
Window -> Preferences -> Java/Editor/Content Assist
and activate the auto-complete feature on demand. The default hotkey for this is
CTRL+Space

Categories