gpt4 book ai didi

Delphi 2010 代码格式化程序 : "(MyVar as TMyType).MyMethod" is split in two lines

转载 作者:行者123 更新时间:2023-12-02 01:19:08 25 4
gpt4 key购买 nike

如何防止代码格式化程序执行此操作?似乎它总是以“as”来移动 Actor 阵容。这是一个错误,还是格式化程序中有任何设置?

// Before formatting:
procedure TMyFrame.WidthEditChange(Sender: TObject);
begin
(Properties as TMyProperties).Width := (Sender as TJvSpinEdit).AsInteger;
end;


// After formatting:
procedure TMyFrame.WidthEditChange(Sender: TObject);
begin (Properties as TMyProperties) // <----- I want this untouched
.Width := (Sender as TJvSpinEdit).AsInteger;
end;

事情变得很奇怪:

// Before formatting:
procedure TMyFrame.WidthEditChange(Sender: TObject);
begin
(Properties as TMyProperties).Width := (Sender as TJvSpinEdit).AsInteger;
(Properties as TMyProperties).MyMethod;
end;

// After formatting:
procedure TMyFrame.WidthEditChange(Sender: TObject);
begin (Properties as TMyProperties)
.Width := (Sender as TJvSpinEdit).AsInteger; (Properties as TMyProperties)
.MyMethod;
end;

最佳答案

一个解决方法是在行尾添加注释:

   if Assigned(aDBControl) then //
(aDBControl as TcxDBLookupComboBox)
.Properties.ListSource := aDataSource;

这并不理想,下一行的缩进是错误的,但这比等待更新 2 是否修复它要好。

编辑:包裹安全 Actor 的硬 Actor 效果稍好一些。

   if Assigned(aDBControl) then
TcxDBLookupComboBox(aDBControl as TcxDBLookupComboBox)
.Properties.ListSource := aDataSource;

关于Delphi 2010 代码格式化程序 : "(MyVar as TMyType).MyMethod" is split in two lines,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2787467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com