Re: [GSoC][PATCH v2] userdiff: add built-in pattern for golang
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Mar 1, 2018, 18:24 UTC
- Message-ID
- <CAPig+cSPHa_A05iLBKUSr8dZcaOoEJ28TF+nAZzvQN2dQc6csw@mail.gmail.com>
- 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:
Show 14 quoted lines
> 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>