Delphi 中的类补全可以节省大量时间,但我还没有找到自定义它的方法。
我希望属性的 getter 和 setter 能够组合在一起,而不是被扔到我的整个单元中;接口(interface)部分可以正确生成,但如果将事情留给 IDE,实现部分就会变得一团糟。我希望方法默认按如下顺序排序:
function TAaa.getAaa();
procedure TAaa.setAaa();
procedure TAaa.Baa();
function TAaa.getCow();
procedure TAaa.setCow();
procedure TBbb.getAaa()
我希望实现部分的顺序与接口(interface)的顺序相同;
我希望生成的方法的主体看起来像这样:
.
procedure TMyClass.MyProc;
begin
{ TODO -oWouter -cimplement autogenerated stuff : implement Procedure MyProc() }
raise Exception.create('procedure TMyClass.MyProc() is not yet implemented');
end;
是否有工具可以做到这一点,或者是否需要深入研究 opentools API 才能完成类似的事情?
<小时/>最佳答案
Question 1: I would like a getter and setter for a property to be grouped together.
Modelmaker Code Explorer (MMX) 有一个排序工具。该工具对接口(interface)和实现中的类成员进行排序。我正在使用的 4.05 版本不支持您的排序方式。但是,Modelmaker 网站包含 page that shows the most up to date sorting functionality看来他们通过许多新选项扩展了排序功能。也许您可以使用最新的 MMX 工具对 getter/setter 方法进行分组。 方便的功能:
- MMX 类资源管理器中的拖放排序:将方法拖到新位置,模型制作者会移动代码
- 排序提示:如果某个方法未按照您的默认排序模板进行排序,MMX 会通知您
Question 2: I want the implementation section to be in the same order as the interface.
MMX 排序功能可以做到这一点。执行排序后,接口(interface)和实现的顺序将相同。
Question 3: I want the body of a generated method to look something like this...
MMX [添加新方法] 会自动将可自定义的代码 stub 添加到方法的主体中。代码 stub 中支持参数,但我还没有看到支持的参数列表。这是一个示例
过程TForm1.NewMethod;
开始
//TODO TForm1.NewMethod 默认正文插入
结束;
关于Delphi-IDE : how to change the way class-completion works?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/580983/