Re: [PATCH 6/6] grep: show non-empty lines before functions with -W
- From
Stefan Beller <sbeller@google.com>
- Date
- Nov 20, 2017, 20:39 UTC
- Message-ID
- <CAGZ79kZxiEPE4LPEo-eb4Ta4bYXVr9xQM0dFeiJk9XXKU4AR+w@mail.gmail.com>
- In-Reply-To
- <9c3462e3-2d1d-05bc-9f7d-4bc93d32e7ff@web.de>
On Sat, Nov 18, 2017 at 10:08 AM, René Scharfe <l.s.r@web.de> wrote:
Show 7 quoted lines
> Non-empty lines before a function definition are most likely comments > for that function and thus relevant. Include them in function context. > > Such a non-empty line might also belong to the preceding function if > there is no separating blank line. Stop extending the context upwards > also at the next function line to make sure only one extra function body > is shown at most.
Can we add another heuristic, that checks for common function body ends, e.g. if the preceding line contains '}' but is not commented (the line doesn't contain '*/' '//', '#'), we have a strong hint that it is a function, not an additional comment.