Jump to content
Sign in to follow this  
dummzeuch

When did the Delphi built in code formatter become useable?

Recommended Posts

I remember that the first versions of the build in code formatter (Delphi XE +) were little more than a proof of concept. There were so many bugs that using it basically destroyed readability and created more work than it saved. Because of that I never actually used it, so I don't know how much better it is nowadays.

 

What was the first Delphi version in which you started to use it (if any)?

 

(I can't make this a poll because there are so many options: XE1 to XE8 + 10.0 to 10.3 = 12 options)

Edited by dummzeuch

Share this post


Link to post

I've been using it since the first version (which AFAIR was before XE) with no major problems. Maybe because my style is pretty standard (aka the One True Style :classic_smile:).

One thing I've never gotten to work though is formatting a block of text: It always formats the whole file. No biggie.

 

It's usually the first step I do when I'm brought in to fix other peoples code.

Share this post


Link to post

As far as I can remember most of the work in formatter was done by XE4. I had few issues reported and I think they were all resolved by that time period (bugs, not feature requests). I cannot verify because old QC is offline.

 

I don't think there are major differences between XE4 and Rio (including versions in between) or should I say if there are differences, chances are that it is more broken now than before because some newer language constructs are not fully supported.

 

Anyway, I never ever use it to format whole units as it still can destroy readability. I only use it on selections.

Share this post


Link to post
1 hour ago, Anders Melander said:

I've been using it since the first version (which AFAIR was before XE) with no major problems.

Actually it was added in XE4 (I just checked, the editor popup menu entry appears there the first time). So that must have been the first version where I tried it and found it severely lacking.

Share this post


Link to post

I used it by accident twice.  UNDO is a life safer indeed. Never ever since.
I guess we should build a "black list" of IDE feature we should avoid.

  • Like 1

Share this post


Link to post

I am working with the integrated formatter without significant problems. Perhaps my coding style fits better than others. For those cases where the results are not to my liking I have found some workarounds,

 

Nevertheless, I would prefer when Embarcadero would deliver the sources for the formatter. There is always room for improvement.

Share this post


Link to post

Try to format this:

procedure TForm1.Button1Click(Sender: TObject);
var
  test: record
    a: integer;
    b: double;
  end;
  dt1: record
    dt: tdatetime;
    s: string;
  end;
begin
end;

it becomes this:

procedure TForm1.Button1Click(Sender: TObject);
var
  test: record a: Integer;
  b: Double;
end;
dt1:
record dt: tdatetime;
s:
string;
end;

begin
end;

And don't tell me that's any known coding style. 😉

 

Yes, I reported it:

https://quality.embarcadero.com/browse/RSP-18273

 

And yes, the GExperts code formatter works fine for it.

(There are no known problems left.

edit: Now there is: https://sourceforge.net/p/gexperts/feature-requests/89/ )

 

 

 

Edited by dummzeuch
  • Sad 1

Share this post


Link to post

Oh sh*t, I should not have started looking for code formatter bugs in QP. There are just so many and some of them also don't work for the GExperts one:

type
  TListOfList<T: TData; U: TDataList<T>> = class
    procedure foo; overload; virtual;
    procedure foo(i: Integer); overload virtual;
  end;

https://sourceforge.net/p/gexperts/bugs/156/

https://quality.embarcadero.com/browse/RSP-16661

Share this post


Link to post
33 minutes ago, dummzeuch said:

Try to format this:


procedure TForm1.Button1Click(Sender: TObject);
var
  test: record
    a: integer;
    b: double;
  end;
  dt1: record
    dt: tdatetime;
    s: string;
  end;
begin
end;

 

As I said, it heavily depends on the coding style. I would never do this. The last time I wrote this kind of stuff was about Turbo Pascal 4 or so.

 

I would declare explicit types for these records. Even if they are only used locally.

  • Like 2

Share this post


Link to post
33 minutes ago, Uwe Raabe said:

As I said, it heavily depends on the coding style. I would never do this. The last time I wrote this kind of stuff was about Turbo Pascal 4 or so.

 

I would declare explicit types for these records. Even if they are only used locally.

But the formatter is of little use, if it can be confused by coding style. There are many things I don't do that others have done, and in some cases, I will use a formatter to clean things up, but most of the time, I am dealing with old code in source control, and my colleagues would be very unhappy to see files reformatted. 😉

  • Sad 1

Share this post


Link to post

At the end it boils down to the question: Does it work for me or does it not? The answer obviously depends on the one who asks. That's why I am not going to suggest the formatter for everyone. On the other hand, just because it doesn't work for some people doesn't mean that I have to use another tool for myself, too.

Share this post


Link to post

The reason why I asked was because currently GExperts per default disables the Code Formatter expert for Delphi versions that already have one (at least that's what I thought, turned out it was wrong, because there was no built in formatter in Delphi XE). I was hoping to get an answer along the lines "The built in one works fine since version X, but after reading this thread I am not sure what to do there. Maybe I should simply turn it on by default [period].

Edited by dummzeuch

Share this post


Link to post

FWIW I prefer GExperts Code Formatter.  It has more/better options.

What I would like in the GExperts Code Formatter is for it to be able to format all the project files in one hit like the Emb formatter.

 

Ian

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×