Class Completion 将其结果按什么顺序排列? [英] In what order does Class Completion put its results?

查看:7
本文介绍了Class Completion 将其结果按什么顺序排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:我创建了一个新单元,按顺序声明了一个包含多个方法(如构造函数、析构函数、方法 1、方法 2、方法 3)的类,然后按 Ctrl-Shift-C.IDE 会自动创建所有方法体,但顺序是混淆的,与接口部分中声明的不同.

Example: I create a new unit, declare a class with several methods like constructor, destructor, method1, method2, method3 in that order and then hit Ctrl-Shift-C. The IDE creates all the method bodies automatically, but the order is mixed up and not as it was declared in the interface section.

现在,这不是问题,但是否有原因.混合起来似乎比仅仅按照声明的顺序来做更难.

Now, this is not a problem, but is there a reason for it. It seems to be more difficult to mix that up than to just do it in the order of the declaration.

或者是否有一些我看不到的有意义的规则?

Or is there some rule to it that makes sense which I cannot see?

推荐答案

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

This is a bit complicated to answer since it is dependent on how your methods are already arranged.

如果它们已经按字母顺序实现,它将尝试并保持它.如果 IDE 无法推断出任何类型的顺序,它会求助于将它们放在文件末尾.

If they're already implemented in alphabetical order, it will try and maintain that. If the IDE cannot infer any kind of order, it resorts to dropping them at the end of the file.

还有另一个问题,按照惯例,如果您在表单中包含注释:{ <ClassName>} 在实现方法的第一个块之前,然后使用该注释来描述所有后续类实现,它将尝试将方法组合在一起.

There is another wrinkle where, by convention, if you include a comment in the form: { <ClassName> } before the first block of implemented method and then use that comment to delineate all subsequent class implementations, it will attempt to keep the methods grouped together.

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

The alphabetical ordering follows the same rules above, except it may inject the new methods into that logical block delineated by the indicated comment.

如果您对全新的类使用类完成,您会注意到 IDE 会自动生成该描述性注释.

If you use class-completion with a brand new class, you'll notice that the IDE will automatically generate that delineating comment.

如果您让类完成自动排列方法并且仅使用 Ctrl+Shift+UpAr 键在方法的实现之间导航和声明,排序应该不那么重要.

If you let class completion auto-arrange the methods and only use the Ctrl+Shift+UpAr key to navigate between a method's implementation and the declaration, the ordering should be less important.

通常,我会使用上面的键序列跳转到类 decl,然后使用箭头键转到我想要的 decl 中的方法,然后再次使用该键序列快速到达它.

Typically, I'll jump to the class decl using the above key-sequence, then use the arrow keys to go to the method in the decl I want, and then use that key-sequence again to quickly get to it.

另一个不错的键序列是 Ctrl+Alt+UpArCtrl+Alt+DnAr 会按文件顺序快速从方法 impl 跳转到方法 impl.

Another nice key-sequence is the Ctrl+Alt+UpAr or Ctrl+Alt+DnAr which will quickly jump from method impl to method impl in file-order.

这篇关于Class Completion 将其结果按什么顺序排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆