简体   繁体   English

有没有办法在Netbeans或Eclipse中隐藏注释?

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

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). 也许这是一个愚蠢的问题,但是如果在Netbeans(或Eclipse)中查看源代码时,有一种隐藏或折叠Java注释的方法,那就太好了。 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. 所有的hibernate / etc批注只是绒毛,一旦映射正常,我就再也看不到。 It's similar to imports, really. 确实类似于进口。

(Yes, I can use XML instead of annotations, which I might start doing. But I was just wondering...) (是的,我可以使用XML代替注解,而我可能会开始这样做。但是我只是想知道...)

Here's a good solution to how to "hide" @Annotations. 这是如何“隐藏” @Annotations的好方法。 Make the color of the @Annotations a lighter color than the rest, such as light green. 使@Annotations的颜色比其他颜色更浅,例如浅绿色。

How to: Preferences: Java> Editor> Syntax Coloring in the Element box, select Annotations. 如何操作: 首选项:Java>编辑器>语法着色在“元素”框中,选择“注释”。 Click Color button. 单击颜色按钮。 annotations: lighter green. 注释:浅绿色。 I use RGB: 0, 240, 0 annotation element references: light green: RGB: 0, 170, 80 我使用RGB:0、240、0注释元素引用:浅绿色: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. 如果您真的不想知道自己的@Annotations,则可以使它们与背景颜色相同或非常接近,例如白色。 Then only the =values will show. 然后,仅显示= values。 Pero blanco? 佩罗布兰科? no es muy inteligente. 不懂。 Juan Reza-Prieur 胡安·雷扎·普里耶尔

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. 仅使用Eclipse或IDEA,我不知道任何用于隐藏注释的IDE选项,我认为这是一件好事。

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. 我认为隐藏它们无异于在方法签名或语言的任何其他组件中隐藏public / protected / private关键字。 Their exclusion changes the meaning of their surrounding context and therefore, a developer's expectations. 他们的排斥改变了周围环境的含义,因此改变了开发商的期望。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM