示例:我创建了一个新单元,声明一个类别的类,例如构造函数,destructor,method1,method2,method 3按该顺序,然后击中ctrl-shift-c。 IDE会自动创建所有方法主体,但是该顺序混合在一起,而不是在接口部分中声明。

现在,这不是问题,但是是否有原因。将其混合起来似乎比在声明顺序上进行混合要困难。

还是有一些我看不到的规则是有道理的?

有帮助吗?

解决方案

这有点复杂,因为它取决于您的方法已经排列的方式。

如果它们已经按字母顺序实施,它将尝试保持这一点。如果IDE无法推断出任何类型的订单,它将诉诸于文件末尾。

还有另一个皱纹,如果您在形式中包含评论,请按照惯例进行:{{u003CClassName> }在实施方法的第一个块之前,然后使用该注释来划定所有后续类实现,它将尝试将方法整合在一起。

字母顺序遵循上述相同的规则,除了它可以将新方法注入由指定注释所描述的逻辑块中。

如果您将课堂完成与全新的课程一起使用,您会注意到IDE将自动生成该划定的评论。

如果让课堂完成自动阵容,则仅使用 Ctrl+转移+UPAR 在方法的实现和声明之间导航的关键,订购应该不太重要。

通常,我将使用上述键序列跳到校准,然后使用箭头键进入我想要的声明中的方法,然后再次使用该键序列快速进入它。

另一个不错的关键序列是 Ctrl+alt+UPAR 或者 Ctrl+alt+达纳尔 它将在文件顺序中迅速从方法impl toss Impl。

其他提示

By default, I'm pretty sure it tries to create them in alphabetical order by method name, and then tries to keep to this when more methods are added afterwards using the same method. The end result can be a bit of a random mix on ordering.

From my experience I find that some times the IDE creates the methods in alphabetical order, but other times it just append the new methods to the end of the file.

The IDE tries to create everything in alpahabetical order. But, if the methods become out of sequence (eg you rename a method) it gets in a muddle. The exact behaviour seems to depend on the version. Older versions would simply append the new method to the end of the file in any order. Newer versions seem a bit cleverer, but I haven't worked out exactly how yet.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top