Re: [PATCH] userdiff: add support for Swift

Junio C Hamano <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
Johannes Sixt <[email protected]> writes:

> Am 17.07.26 um 16:02 schrieb Shlok Kulshreshtha:
>> Add a built-in userdiff driver for the Swift programming language so that
>> diff hunk headers and word diffs work out of the box for ".swift" files.
>> 
>> The funcname pattern is built for Swift's own declaration grammar: an
>> optional run of attributes ("@objc", "@available(iOS 13, *)", ...),
>> followed by an optional run of lowercase modifiers ("public", "static",
>> "final", ...), followed by a declaration keyword (func, class, struct,
>> enum, protocol, extension, actor, init, deinit, subscript). The keyword
>> is followed by a boundary that allows whitespace, "(" (init/subscript),
>> "?" or "!" (failable init), or "<" (generics), while still acting as a
>> word boundary so e.g. "initialize(" does not match.
>> 
>> The word regex recognizes Swift identifiers, hexadecimal, octal, binary,
>> integer and floating-point literals, and the language's operators.
>> 
>> Signed-off-by: Shlok Kulshreshtha <[email protected]>
>> ---
>> This addresses the "add a userdiff driver for a language" microproject.
>
> I am mildly surprised that userdiff drivers can count as microproject.
> At a minimum, they are on the challenging side of the spectrum.

I am, too ;-)  It is hard to get them right, even though thanks to
your earlier work long time ago, writing a test that demonstrates
what is expected of the patterns is fairly easy to write.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.