Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Code Editor/Formatting    [ Add a report in this area ]  
Report #:  77648   Status: Closed
Typecasting reformats poorly
Project:  Delphi Build #:  24210
Version:    14.0 Submitted By:   Andrew Tuck
Report Type:  Issue Date Reported:  9/13/2009 1:48:01 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   272849
Resolution: Fixed (Resolution Comments) Resolved in Build: : 15.0.3665.27232
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 2
Description



Added by Sysop
<<<<<<<<<
Please see [Steps] for more details.
>>>>>>>>>
Steps to Reproduce:
Code was:
        (FindComponent('sqlGiftRedeemed') as TIBSQL).Close;
        (FindComponent('sqlGiftRedeemed') as TIBSQL).ParamByName('Business').AsInteger := Business;
        (FindComponent('sqlGiftRedeemed') as TIBSQL).ParamByName('Gift').AsInteger := qryGift.FieldByName('Gift_Number').AsInteger;
        (FindComponent('sqlGiftRedeemed') as TIBSQL).ExecQuery;

Ctrl+D converted it to:
(FindComponent('sqlGiftRedeemed') as TIBSQL)
    .Close; (FindComponent('sqlGiftRedeemed') as TIBSQL)
    .ParamByName('Business').AsInteger := Business;
(FindComponent('sqlGiftRedeemed') as TIBSQL)
    .ParamByName('Gift').AsInteger :=
qryGift.FieldByName('Gift_Number').AsInteger;
(FindComponent('sqlGiftRedeemed') as TIBSQL)
    .ExecQuery;

Note that it has inserted whitespace between the cast and to 'dot' operator, and continued on a line after a ';' (second line with .Close).
Workarounds
None
Attachment
None
Comments

Chris Moseley at 6/27/2010 10:36:15 PM -
One workaround is using unsafe casts.

TIBSQL(FindComponent('sqlGiftRedeemed')).Close;

is formatted properly. So you can go

if (FindComponent('sqlGiftRedeemed') is TIBSQL) then
  TIBSQL(FindComponent('sqlGiftRedeemed')).Close;

Which is an ugly workaround but no worse than 4 consecutive identical safecasts.

Chris Moseley at 6/27/2010 11:23:32 PM -
A comment on the end of the line also helps
   if Assigned(aDBControl) then //
   (aDBControl as TcxDBLookupComboBox)
      .Properties.ListSource := aDataSource;
This is our current work-around, but it really does need a fix. It bugs me not being able to ctrl-D to fix formatting and inconsistent case.

Server Response from: ETNACODE01