Re: Preliminary results for proposed new pgindent implementation

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Stephen Frost <sfrost@snowman.net>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, Piotr Stefaniak <postgres@piotr-stefaniak.me>
Date: 2017-05-19T15:42:10Z
Lists: pgsql-hackers
On 05/19/2017 06:05 PM, Stephen Frost wrote:
> * Tom Lane (tgl@sss.pgh.pa.us) wrote:
>> Robert Haas <robertmhaas@gmail.com> writes:
>>> On Thu, May 18, 2017 at 11:00 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>>> The reason PGSSTrackLevel is "unrecognized" is that it's not in
>>>> typedefs.list, which is a deficiency in our typedef-collection
>>>> technology not in indent.  (I believe the problem is that there
>>>> are no variables declared with that typename, causing there to
>>>> not be any of the kind of symbol table entries we are looking for.)
>>
>>> This, however, doesn't sound so good.  Isn't there some way this can be fixed?
>>
>> I'm intending to look into it, but I think it's mostly independent of
>> whether we replace pgindent itself.  The existing code has the same
>> problem, really.
>>
>> One brute-force way we could deal with the problem is to have a "manual"
>> list of names to be treated as typedefs, in addition to whatever the
>> buildfarm produces.  I see no other way than that to get, for instance,
>> simplehash.h's SH_TYPE to be formatted as a typedef.  There are also
>> some typedefs that don't get formatted correctly because they are only
>> used for wonky options that no existing typedef-reporting buildfarm member
>> builds.  Manual addition might be the path of least resistance there too.
>>
>> Now the other side of this coin is that, by definition, such typedefs
>> are not getting used in a huge number of places.  If we just had to
>> live with it, it might not be awful.
>
> Dealing with the typedef lists in general is a bit of a pain to get
> right, to make sure that new just-written code gets correctly indented.
> Perhaps we could find a way to incorporate the buildfarm typedef lists
> and a manual list and a locally generated/provided set in a simpler
> fashion in general.

You can get a pretty good typedefs list just by looking for the pattern 
"} <type name>;". Something like this:

grep -o -h -I --perl-regexp -r "}\W(\w+);" src/ contrib/ | perl -pe 
's/}\W(.*);/\1/' | sort | uniq > typedefs.list

It won't cover system headers and non-struct typedefs, but it catches 
those simplehash typedefs and PGSSTrackLevel. Maybe we should run that 
and merge the result with the typedef lists we collect in the buildfarm.

- Heikki



Commits

  1. Manually un-break a few URLs that pgindent used to insist on splitting.

  2. Remove entab and associated detritus.

  3. Phase 3 of pgindent updates.

  4. Phase 2 of pgindent updates.

  5. Initial pgindent run with pg_bsd_indent version 2.0.

  6. Adjust pgindent script to use pg_bsd_indent 2.0.

  7. Final pgindent run with old pg_bsd_indent (version 1.3).