Disable real-time error and warning check in Eclipse - eclipse

I find it distracting that Eclipse checks the code for errors and warnings during typing. Is it possible to change this behavior, so that it only checks when I'm done writing a line?

If you were talking about java code, the checkbox can be found via 'Preferences - Java - Editor' -> 'Report problems as you type'.
String tmp = // no syntax error here
String tmp = ; // line end -> syntax error
For other editors use 'General - Editors - Structured Text Editors'-> 'Report problems as you type'. It's not necessary to deactivate 'build automatically'.

I don't think it's possible to change it to compile after each line. But you can turn automatic compilation off altogether in the menu Project->Build Automatically.

Related

How to make Eclipse format according to template when typing

I'm using eclipse Version: 2019-09 R (4.13.0) on mac High Sierra.
I didn't like the default formatting. For example when I write a method, it puts a space before the brace like this myMethod() { instead of myMethod(){ which I prefer.
So I changed the formatting template in Preferences -> Java -> Code Style -> Formatter
Now when I do CMD+shift+F it formats it how I want without the whitespace.
However, it STILL adds the white space as I type in the method! I can't figure out how to stop it doing that. When I type CMD+shift+F it corrects it, so it knows what I want, but retains the old behaviour when I type. Please save my sanity!
(Yes I've tried restarting eclipse!)
Thanks!
In Preferences: Java > Editor > Typing in section Automatically insert at correct position uncheck the checkbox Braces.

Disable line breaks after loops without body

Consider a Java while-loop without a body, for example this:
while (map.values().remove(value));
When formatting it (Shift + Alt + F), Eclipse breaks the line before the semicolon and indents it:
while (map.values().remove(value))
;
How can I configure the formatter to not add these line breaks?
Be aware that by setting this semicolon to a new line, you may avoid unintended endless loops and a long search to find them.
However, in Eclipse all code formatting properties are 1) in the project properties and 2) in the Eclipse properties. The project properties inherit from the Eclipse properties.
So if you open the project properties, type "format" in the search field. It will show you a "Formatter" menu item, that may depend on the current language (at least in Java it is called "Formatter"). Then, in this example, allow the project-specific settings, and then click edit. You will see a flood of possible details you can decide.
See here:
Then, in the tab "New Lines", uncheck the checkbox "Put empty statement on new line", in the section "Empty statements".
Often you have to try and search a bit because there are really many options. The part at right shows you a preview of the code formatting.

Eclipse mark occurrences doesn't mark all occurrences

Just installed Eclipse Juno Release, Build id: 20120614-1722.
I have 'Mark Occurrences' turned on, and I can see that it does indeed mark some of the occurrences in the JS file I'm editing. However, there's a function call that it doesn't mark.
var trackView = function() {
saveData();
},
saveData = function() {
// do something
};
When I click into the saveData occurrence where it is defined (line 4), it highlights, but it doesn't highlight the occurrence on line 2 where the function is being called. When I click into the saveData occurrence on line 2, neither highlights.
Any ideas?
The bug report in Eclipse also mentions another workaround: select something in the Outline view, and then select the field in your source again.
This works mostly always for me.
If you toggle from eclipse window to another window using ATL+TAB and come back to Eclipse window it is higlighted.
This is a known bug in Eclipse Juno and is actively (as of this writing) being investigated by Eclipse developers.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400661
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509
UPDATE 6/2: This bug has been resolved in Release 4.2.2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509
If you uncheck the below option it will work fine
Preference > Java > Editor > Mark Ocurrences > Uncheck: Keep marks when the selection changes.
This is a bug in Eclipse - the occurrence-highlight seems to "stick" to the first thing you point to.
Two "solutions" that at least get the highlight stuck on a new item (!!):
As #Subas Raj mentioned, defocus and refocus the window - when you come back, your current position is occurrence-highlighted. Either hit AltTab twice, or use your mouse to click/focus some other window, then back.
As #Leo and #Gorky mentions, hit AltShiftO twice. This is the shortcut for toggling highlight occurrences, and when you turn it back on, your current position is occurrence-highlighted.
And finally, a third ACTUAL solution: Replace one specific jar with a patched one: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509#c60
.. or upgrade to M7 (4.3), which now are released: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398509#c62
All configuration and settings for "Mark Occurrences" are proper but it seems this is Eclipse JUNO problem.
I have been observing this issue and tried to resolve many way but in Juno, highlighting occurrences is not consistent.
Sometimes it works pretty fast, sometimes it takes time to highlight, sometimes it doesn't at all.
Also observed that once we restart Eclipse, things works proper but gradually, highlighting occurrences become slow and stops also.
~Chirag
Go to Window -> Preferences -> General -> Editors -> Text Editors -> Annotations
Under both Occurrences & Write Occurrences, make sure you have the Text as Highlighted option selected.
Also, under General -> JavaScript -> Editor -> Mark Occurrences make sure all of the check boxes are checked.
I unchecked General -- Appearance Use mixed fonts and colors for labels and now it works better...
Same as I encountered, you can try to click "Toggle Mark Occurrences" twice (turn it off and turn on) or you can also try to use Alt+Shift+O twice.
And can also try the solution of #Subas Raj, is good.
For now there is only workaround (push "Alt + Shift + O" twice):
Cannot highlight all occurrences of a selected word in Eclipse

How to disable auto formatting upon save in Eclipse?

Eclipse keeps auto formatting upon save, for example: it is insisting the following code should be in a single line once I save, despite breaking it up the way I want to.
#Transactional(rollbackFor = DataAccessException.class, readOnly = false, timeout = 30, propagation = Propagation.SUPPORTS, isolation = Isolation.DEFAULT)
Window > Preferences > Java > Editor > Save Actions.
Can also be configured at the project level. Project > Properties > Java Editor > Save Actions.
Absolutely maddening improvement. For if statements do the following:
Window | Preferences | Java | Code Style | Formatter | Control statements tab
Select Keep simple if on one line.
You might also try the Line wrapping tab
This is a Late answer, But just for novice to understand it clearly I have a snapshot of the setting.
Please follow the path on left.
And change highlighted setting.
If you wish to keep the auto-formatter, but don't want this behavior, you can also configure it in the fomatter :
right click on the project -> properties -> java code style -> formatter
(If you don't have a project specific formatter the global configuration can be accessed this way : Window -> Preference -> Java -> Code Style -> Formatter).
Edit... the active profile, open the Line Wrapping tab, and there check the Never join already wrapped lines option.
This way you can wrap lines wherever you want and eclipse won't remove your line breaks (which is a must if you wish to have readable lambda expressions), but keep the formatter active.
This option is there at least since eclipse Luna
Here is a screenshot where this option is :
Just wanted to add a tip. If you want to avoid the line wrapping you can simply increase the "Maximum line width" value to something enormous. As long as that is sufficiently high eclipse won't do any wrapping.
Preferences > Java > Code Style > Formatter > Edit > Line Wrapping > Maximum line width

JSP EL (Expression Language) causing problems in Eclipse

My system: Ubuntu 9.10. Eclipse 3.5.1 with Java EE 1.2.1 (manual install - NOT from synaptic). Web Developer Tools 3.1.1
I've recently adopted someone else's code (a Dynamic Web Project), and run into lots of errors, warnings and incorrect syntax highlighting in Eclipse. I've narrowed it down to these 4 lines of code (create a new Dynamic Web Project, and then a new JSP page, and put this in the body):
${(1<2)? "" : "no"}
<%for (int i = 0; i < 5; i++) {%>
<div>${5}</div>
<%}%>
Errors / Warnings / Incorrect syntax highlighting
line1: yellow warning line under '<': Invalid character used in text string
(${(1<2)? "yes" : "no"}).
line2: red error line under 'f':
Multiple annotations found at this line: 1) Syntax error, insert "Finally" to complete TryStatement. 2) Syntax error, insert "}" to complete ClassBody
line2: red error line under ')': Syntax error on token ")", try expected after this token
line3: yellow warning line under 'div': No end tag (/div).
line3: yellow warning line under '<' of closing div: Multiple annotations
found at this line: 1) Invalid character used in text string (${5} <%}%>). 2) Invalid character used in text string (${5} <%}%>).
line3: '/div' is black and purple (for scriptlet code?) instead of green for HTML code
line4: The opening and closing scriplet tags '<%' and '%>' are black instead of orange
The page works as expected in a browser: you get '5' five times. If you change the empty quotes on line 1 to "yes" then save, close the file in the editor, r click it in the project explorer > validate, then re-open it: all errors / warnings / incorrect syntax highlighting disappear, except the first one (invalid character). This is incredibly irritating. Any thoughts would be greatly appreciated.
Eclipse WTP is great, but exactly this problem is an epic fail in Eclipse WTP for me as well. They seem to be working on that, but until then I just disable/set-to-ignore all of the validation related to this stuff in the workspace preferences through Web > JSP Files > Validation > scroll list to very bottom and set all EL validation settings to Ignore. Also in the main Validation preference uncheck all checkboxes related to JSP. This however doesn't seem to remove every warning/error, but it at least minimizes the annoyance.
IntelliJ IDEA handles JSP/EL validation much better.
To me, the symptoms make me think that WTP is using regexp instead of a stackbased parser to validate HTML/JSP/EL. This is a big no-no in case of structured markup.