Is there a way to hide annotations in Netbeans or Eclipse?

陌路散爱 提交于 2020-01-04 03:16:30

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/739009/is-there-a-way-to-hide-annotations-in-netbeans-or-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!