即使对于空的参数列表,如何使Class Completion包含括号? [英] How can I make Class Completion include parentheses even for empty parameter lists?

查看:98
本文介绍了即使对于空的参数列表,如何使Class Completion包含括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio工作了几年之后,我又回到了Delphi 2010.我想使IDE表现为不同的方式:

I'm back in Delphi 2010 again after having worked several years in Visual Studio. I would like to make the IDE behave in a differnet way:

当我声明一个函数/过程时,我希望IDE的自动完成功能能够遵守括号.示例:如果我声明过程x();我想让自动完成功能创建过程myobj.x(); ,而不是像这样自动完成过程myobject.x; .是的,这并不重要,但我很书呆子.有什么想法吗?

I'd like the IDE's auto-completion to respect the parenthesis when I declare a function/procedure. Example: if I declare procedure x(); Id like the auto-completion to create procedure myobj.x(); and NOT procedure myobject.x; as it does. Yes, it doesn't really matter but I'm pedantic. Any ideas?

推荐答案

在没有参数的情况下,Delphi不需要括号.我怀疑这是可能的.

Delphi doesn't require the parentheses when there are no parameters; I doubt this is possible.

在接口或实现中,它是方法声明这一事实很明显,这无关紧要.

It shouldn't matter in the interface or implementation, where the fact that it's a method declaration is clear.

function TMyClass.IsDefaultPropValue: Boolean;

我可以看到在调用该方法的实际代码中有什么要注意的地方,如

I can see where it would matter in actual code that calls the method, where you would want to clarify that it was not a variable, as in

// 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是一个函数而不是布尔变量,我将其用作

In this case, it's not clear that IsDefaultPropValue is a function and not a Boolean variable and I'd use it as

if IsDefaultPropertyValue() then ... 

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

使其清晰起来.

这篇关于即使对于空的参数列表,如何使Class Completion包含括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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