Re: [PATCH v2] userdiff: add support for Swift
From: Johannes Sixt <hidden>
Date: 2026-07-23 08:00:39
Am 21.07.26 um 21:33 schrieb Junio C Hamano:
Shlok Kulshreshtha [off-list ref] writes:quoted
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 <redacted> --- v2, addressing Johannes Sixt's review of v1 ([ref]). Changes since v1: - t4018/swift-{init,failable-init,generic-subscript}: "RIGHT" now appears only once, on the declaration line, so the expected header is unambiguous. - word regex: dropped the redundant "?" after the single-character operator class. Single characters are already covered by the "|[^[:space:]]" fallback that the PATTERNS macro appends, so only the two-character forms need to be spelled out. (A couple of Hannes's other suggestions I kept as-is; I have explained the reasoning in a reply to his review.)Thanks for an update. Let's wait for a few days to see if we hear more comments and otherwise mark the topic for 'next'.
This round looks good to me. Acked-by: Johannes Sixt <redacted> -- Hannes