4

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...)

Boden
  • 4,149
  • 9
  • 43
  • 56
  • @all here you can find a corresponding eclipse bugzilla and vote for it: https://bugs.eclipse.org/bugs/show_bug.cgi?id=384256 – Chriss Jul 04 '12 at 11:45
  • It's good idea to make layer, you can put annotations or console.logs on this layer and turn on/off it as you need. Is anybody knows such IDE? – Igor Fomenko Jun 07 '20 at 17:22

2 Answers2

4

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
  • 41
  • 1
3

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
  • 2,481
  • 2
  • 20
  • 20
  • Except for when some IDEs (Looking at you, Eclipse) get stuck on an annotation that isn't relevant anymore. I.E: `Unexpected example_function()` when that line of code has already been removed and there's nothing there anymore. – Berry M. Jan 26 '17 at 08:47