views:

425

answers:

3

Maybe a dumb question, but it would be nice if there was a way to hide or collapse Java annotations when viewing source in Netbeans (or Eclipse). I'm not finding an option and a quick search didn't turn anything up.

Is this one of those "you should never want to do that, code folding is a sin!" things?

Personally I'd find it useful for annotated entity classes. All the hibernate / etc annotations are just fluff that I never look at once my mapping is working fine. It's similar to imports, really.

(Yes, I can use XML instead of annotations, which I might start doing. But I was just wondering...)

+2  A: 

Having only used Eclipse or IDEA, I'm unaware of any IDE options to hide annotations, and in my opinion it's a good thing.

Your annotations affect the way your code compiles and often, how it runs. In my opinion hiding them is tantamount to hiding public/protected/private keywords in method signatures, or any other component of the language. Their exclusion changes the meaning of their surrounding context and therefore, a developer's expectations.

Steve Reed
A: 

Like the guy who wrote the question I need a way of hiding annotations as well. For example I use annotations to enforce "design by contract" rules which are very useful when I am trying to figure out why a unit test wont pass but they just add noise when I am simply trying to read the code, to find out the programmers intention.

Please don't comment on a question in an answer, there are comments for that.
Jorn
+1  A: 

Here's a good solution to how to "hide" @Annotations. Make the color of the @Annotations a lighter color than the rest, such as light green.

How to: Preferences: Java> Editor> Syntax Coloring in the Element box, select Annotations. Click Color button. annotations: lighter green. I use RGB: 0, 240, 0 annotation element references: light green: RGB: 0, 170, 80

This way, the Annotations are visible, but they are much less distracting when you're trying to read and edit the functional code. If you really want to be unaware of your @Annotations, you could make them the same or very close to the background color, such as white. Then only the =values will show. Pero blanco? no es muy inteligente. Juan Reza-Prieur

Juan Reza