Java 中 C-sharp 的“#region”和“#endregion”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3772781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C-sharp's "#region" & "#endregion" in Java?
提问by Ta Sas
Possible Duplicate:
Java equivalent to #region in c#
可能的重复:
Java 相当于 C# 中的 #region
Is there something in Java that would allow for structuring the source code as it is done in C# with the pre-processor directives
Java 中是否有一些东西可以像在 C# 中使用预处理器指令那样构造源代码
#region
and
和
#endregion
?
?
回答by Oded
No, there is nothing equivalent.
不,没有任何等价物。
Code folding is an IDE feature, not a language feature.
代码折叠是 IDE 功能,而不是语言功能。
Eclipse has code folding for classes and members when Java files are loaded in it. It may be extended (for example) to add code folding on carefully crafted comment lines.
当 Java 文件加载到 Eclipse 中时,它会为类和成员进行代码折叠。可以扩展(例如)在精心制作的注释行上添加代码折叠。
回答by Gamlor
No, there's no built-in solution to that.
不,没有内置的解决方案。
However there are some Java IDE's which support folding for certain comment-patterns. And of course all IDE's support folding the code by classes, methods etc.
然而,有一些 Java IDE 支持某些注释模式的折叠。当然,所有 IDE 都支持按类、方法等折叠代码。
回答by Johann
region is a language feature and NOT an IDE feature. Specifically, it is part of the C# programming language and Visual Studio knows how to interpret it.
region 是一种语言功能,而不是 IDE 功能。具体来说,它是 C# 编程语言的一部分,Visual Studio 知道如何解释它。
回答by KeithS
Not as such. Bear in mind that these preprocessor directives are more for VS's benefit than they are a part of the C# or VB language spec. Preprocessor directives in Java would be the IDE's business.
不是这样。请记住,这些预处理器指令更多的是为了 VS 的利益,而不是它们是 C# 或 VB 语言规范的一部分。Java 中的预处理器指令将是 IDE 的业务。