delphi - 如何使类完成即使对于空参数列表也包含括号?

标签 delphi ide class-completion

在 Visual Studio 工作几年后,我再次回到 Delphi 2010。我想让 IDE 以不同的方式运行:

我希望在声明函数/过程时 IDE 的自动完成功能能够遵循括号。示例:如果我声明过程 x();我希望自动完成创建 procedure myobj.x(); 而不是 procedure myobject.x; 。是的,这并不重要,但我很迂腐。有什么想法吗?

最佳答案

当没有参数时,Delphi 不需要括号;我怀疑这是可能的。

在接口(interface)或实现中这应该不重要,因为它是方法声明的事实很清楚。

function TMyClass.IsDefaultPropValue: Boolean;

我可以看到调用该方法的实际代码中哪些地方很重要,您需要澄清它不是一个变量,如

// Unit MyClass
type
  TMyClass=class(TSomething)
  public
    function IsDefaultPropValue: Boolean;
  end;

// In a far distant block  of code in another unit that uses the above unit, using the
// nasty "with" (not you, of course - one of your coworkers):
with MyClassInstance do
begin
  // More lines of code. FirstPass is a local boolean variable.
  if FirstPass then
  begin
    if IsDefaultPropValue then
    begin
      // More lines of code
    end
    else
    begin
      // Alternate branch of code 
    end;
  end
  else
  begin
    if IsDefaultPropValue then
    //.....
  end;
end;

在这种情况下,不清楚 IsDefaultPropValue 是一个函数而不是 bool 变量,我将其用作

if IsDefaultPropertyValue() then ... 

// or better yet: 
if MyClassInstance.IsDefaultPropValue() then ...

说清楚。

关于delphi - 如何使类完成即使对于空参数列表也包含括号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7908372/

相关文章:

java - Intellij Idea中方法注释模板的编辑方法

Delphi-IDE : how to change the way class-completion works?

delphi - 尝试了解 Delphi 接口(interface)

delphi - 无法定义记录指针

windows - 应用程序在任务栏上可见吗?

delphi - Delphi中如何向TRichEdit插入图片?

ide - 恢复IntelliJ IDEA "Project tab"

c# - 如何在 Java 中执行 GUI 任务