我想在Eclipse中使用区域进行代码折叠;在Java中怎么做到呢?
c#中的一个例子:
#region name
//code
#endregion
我想在Eclipse中使用区域进行代码折叠;在Java中怎么做到呢?
c#中的一个例子:
#region name
//code
#endregion
当前回答
满足自定义折叠区域⌘T
其他回答
没有这样的标准对等物。一些ide(例如Intellij或Eclipse)可以根据所涉及的代码类型(构造函数、导入等)进行折叠,但没有像#region这样的ide。
#region
// code
#endregion
只有在IDE中才有好处。在Java中,IDE中没有固定的标准,因此实际上没有与#region并行的标准。
这里有一个例子:
//region regionName
//code
//endregion
100%适用于Android studio
在Visual Studio Code中,尝试这样做:
//region Variables
// Code you need
//endregion
在Eclipse中,您可以折叠括号来包装可变区域块。最接近的方法是这样做:
public class counter_class
{
{ // Region
int variable = 0;
}
}