From: Eric Sunshine <sunshine@sunshineco.com>
To: Alban Gruin <alban.gruin@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [GSoC][PATCH v2] userdiff: add built-in pattern for golang
Date: Thu, 1 Mar 2018 13:24:30 -0500 [thread overview]
Message-ID: <CAPig+cSPHa_A05iLBKUSr8dZcaOoEJ28TF+nAZzvQN2dQc6csw@mail.gmail.com> (raw)
In-Reply-To: <20180301111907.17607-1-alban.gruin@gmail.com>
On Thu, Mar 1, 2018 at 6:19 AM, Alban Gruin <alban.gruin@gmail.com> wrote:
> This adds xfuncname and word_regex patterns for golang, a quite
> popular programming language. It also includes test cases for the
> xfuncname regex (t4018) and updated documentation.
>
> The xfuncname regex finds functions, structs and interfaces. Although
> the Go language prohibits the opening brace from being on its own
> line, the regex does not makes it mandatory, to be able to match
> `func` statements like this:
>
> func foo(bar int,
> baz int) {
> }
>
> This is covered by the test case t4018/golang-long-func.
A possible suggested rewrite to make it flow a bit better and to
mention the loose whitespace matching:
The xfuncname regex finds functions, structs and interfaces.
Although the Go language prohibits the opening brace of a 'func'
from being on its own line, the regex makes the brace optional so
it can match function declarations wrapped over multiple lines
(covered by new test case t4018/golang-long-func):
func foo(bar int,
baz int) {
}
Whitespace matching is also a bit lax in order to handle
non-standard formatting of method declarations. For instance:
func(x *X) foo() {
versus typical 'gofmt' formatted:
func (x *x) foo() {
(Not necessarily worth a re-roll; perhaps Junio can pick it up when
queueing if he considers it an improvement.)
Thanks.
> The word_regex pattern finds identifiers, integers, floats, complex
> numbers and operators, according to the go specification.
>
> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
prev parent reply other threads:[~2018-03-01 18:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 17:29 [GSoC][PATCH] userdiff: add built-in pattern for golang Alban Gruin
2018-02-28 18:47 ` Eric Sunshine
2018-02-28 21:31 ` Alban Gruin
2018-02-28 22:00 ` Eric Sunshine
2018-02-28 22:17 ` Alban Gruin
2018-02-28 22:22 ` Eric Sunshine
2018-02-28 22:32 ` Junio C Hamano
2018-02-28 22:43 ` Alban Gruin
2018-03-01 11:19 ` [GSoC][PATCH v2] " Alban Gruin
2018-03-01 18:24 ` Eric Sunshine [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPig+cSPHa_A05iLBKUSr8dZcaOoEJ28TF+nAZzvQN2dQc6csw@mail.gmail.com \
--to=sunshine@sunshineco.com \
--cc=alban.gruin@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).