git/t/t4018
Shlok Kulshreshtha 113d62b141 userdiff: add support for Swift
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 <diy2903@gmail.com>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-07-23 07:14:34 -07:00
..
README
…
bash-arithmetic-function
…
bash-bashism-style-compact
…
bash-bashism-style-complete-line-capture
…
bash-bashism-style-function
…
bash-bashism-style-whitespace
…
bash-conditional-function
…
bash-missing-parentheses
…
bash-mixed-style-compact
…
bash-mixed-style-function
…
bash-nested-functions
…
bash-other-characters
…
bash-posix-style-compact
…
bash-posix-style-complete-line-capture
…
bash-posix-style-function
…
bash-posix-style-single-command-function
…
bash-posix-style-whitespace
…
bash-subshell-function
…
bash-trailing-comment
…
cpp-c++-function
…
cpp-class-constructor userdiff: have 'cpp' hunk header pattern catch more C++ anchor points 2014-03-21 15:03:32 -07:00
cpp-class-constructor-mem-init
…
cpp-class-definition
…
cpp-class-definition-derived
…
cpp-class-destructor
…
cpp-function-returning-global-type
…
cpp-function-returning-nested
…
cpp-function-returning-pointer
…
cpp-function-returning-reference
…
cpp-gnu-style-function
…
cpp-namespace-definition
…
cpp-operator-definition userdiff: have 'cpp' hunk header pattern catch more C++ anchor points 2014-03-21 15:03:32 -07:00
cpp-skip-access-specifiers
…
cpp-skip-comment-block
…
cpp-skip-labels
…
cpp-struct-definition t4018: test cases for the built-in cpp pattern 2014-03-21 15:03:29 -07:00
cpp-struct-single-line
…
cpp-template-function-definition userdiff: have 'cpp' hunk header pattern catch more C++ anchor points 2014-03-21 15:03:32 -07:00
cpp-union-definition
…
cpp-void-c-function
…
csharp-exclude-assignments
…
csharp-exclude-control-statements
…
csharp-exclude-exceptions
…
csharp-exclude-generic-method-calls
…
csharp-exclude-init-dispose
…
csharp-exclude-iterations
…
csharp-exclude-method-calls
…
csharp-exclude-other
…
csharp-method
…
csharp-method-array
…
csharp-method-explicit
…
csharp-method-generics
…
csharp-method-generics-alternate-spaces
…
csharp-method-modifiers
…
csharp-method-multiline
…
csharp-method-params
…
csharp-method-special-chars
…
csharp-method-with-spacing
…
csharp-property
…
csharp-property-braces-same-line
…
css-attribute-value-selector
…
css-block-level-@-statements
…
css-brace-in-col-1
…
css-class-selector
…
css-colon-eol
…
css-colon-selector
…
css-common
…
css-id-selector
…
css-long-selector-list
…
css-prop-sans-indent
…
css-root-selector
…
css-short-selector-list
…
css-trailing-space
…
custom1-pattern
…
custom2-match-to-end-of-line
…
custom3-alternation-in-pattern
…
dts-labels
…
dts-node-unitless
…
dts-nodes
…
dts-nodes-boolean-prop
…
dts-nodes-comment1
…
dts-nodes-comment2
…
dts-nodes-multiline-prop
…
dts-reference
…
dts-root
…
dts-root-comment
…
elixir-do-not-pick-end
…
elixir-ex-unit-test
…
elixir-function
…
elixir-macro
…
elixir-module
…
elixir-module-func
…
elixir-nested-module
…
elixir-private-function userdiff: add Elixir to supported userdiff languages 2019-11-10 15:26:26 +09:00
elixir-protocol
…
elixir-protocol-implementation
…
fortran-block-data
…
fortran-comment
…
fortran-comment-keyword
…
fortran-comment-legacy
…
fortran-comment-legacy-star
…
fortran-external-function
…
fortran-external-subroutine
…
fortran-module
…
fortran-module-procedure
…
fortran-program
…
fountain-scene
…
golang-complex-function
…
golang-func
…
golang-interface
…
golang-long-func
…
golang-struct
…
ini-section
…
ini-section-noindent
…
ini-section-same-line
…
ini-subsection
…
ini-subsection-noindent
…
java-class-brace-on-separate-line
…
java-class-member-function userdiff: improve java hunk header regex 2021-08-11 11:11:30 -07:00
java-class-space-before-type-parameters
…
java-class-type-parameters
…
java-class-type-parameters-implements
…
java-enum-constant userdiff: improve java hunk header regex 2021-08-11 11:11:30 -07:00
java-interface-type-parameters userdiff: support Java type parameters 2023-02-08 12:56:57 -08:00
java-interface-type-parameters-extends userdiff: support Java type parameters 2023-02-08 12:56:57 -08:00
java-method-return-generic-bounded userdiff: improve java hunk header regex 2021-08-11 11:11:30 -07:00
java-method-return-generic-wildcard
…
java-nested-field userdiff: improve java hunk header regex 2021-08-11 11:11:30 -07:00
java-non-sealed
…
java-record userdiff: support Java record types 2023-02-08 12:57:11 -08:00
java-record-space-before-components
…
java-record-type-parameters
…
java-sealed userdiff: support Java sealed classes 2023-02-08 12:57:13 -08:00
java-sealed-permits
…
java-sealed-type-parameters
…
java-sealed-type-parameters-implements-permits
…
java-sealed-type-parameters-permits
…
kotlin-class
…
kotlin-enum-class
…
kotlin-fun
…
kotlin-inheritace-class
…
kotlin-inline-class
…
kotlin-interface
…
kotlin-nested-fun
…
kotlin-public-class
…
kotlin-sealed-class
…
markdown-heading-indented
…
markdown-heading-non-headings
…
matlab-class-definition
…
matlab-function
…
matlab-octave-section-1
…
matlab-octave-section-2
…
matlab-section
…
perl-skip-end-of-heredoc
…
perl-skip-forward-decl
…
perl-skip-sub-in-pod
…
perl-sub-definition
…
perl-sub-definition-kr-brace
…
php-abstract-class
…
php-abstract-method
…
php-class
…
php-enum userdiff: support enum keyword in PHP hunk header 2021-08-31 12:13:36 -07:00
php-final-class
…
php-final-method
…
php-function
…
php-interface userdiff: support new keywords in PHP hunk header 2018-07-06 14:59:28 -07:00
php-method t4018: add missing test cases for PHP 2018-07-06 14:56:42 -07:00
php-trait
…
python-async-def userdiff: support Python async functions 2019-11-20 16:31:43 +09:00
python-class
…
python-def userdiff: support Python async functions 2019-11-20 16:31:43 +09:00
python-indented-async-def
…
python-indented-class
…
python-indented-def
…
r-indent
…
r-indent-nested
…
r-noindent
…
rust-fn
…
rust-impl
…
rust-macro-rules
…
rust-struct
…
rust-trait
…
scheme-class
…
scheme-def
…
scheme-def-variant
…
scheme-define-slash-public
…
scheme-define-syntax
…
scheme-define-variant
…
scheme-library
…
scheme-lisp-defun-a
…
scheme-lisp-defun-b
…
scheme-lisp-eval-when
…
scheme-local-define
…
scheme-module-a
…
scheme-module-b
…
scheme-top-level-define
…
scheme-user-defined-define
…
swift-actor
…
swift-attribute-with-args
…
swift-class
…
swift-enum
…
swift-extension
…
swift-failable-init
…
swift-func
…
swift-generic-subscript
…
swift-init
…
swift-inline-attribute
…
swift-modifiers
…
swift-protocol
…
swift-struct
…

README

How to write RIGHT test cases
=============================

Insert the word "ChangeMe" (exactly this form) at a distance of
at least two lines from the line that must appear in the hunk header.

The text that must appear in the hunk header must contain the word
"right", but in all upper-case, like in the title above.

This text is a bit twisted and out of order, but it is itself a
test case for the default hunk header pattern. Know what you are doing
if you change it.

BTW, this tests that the head line goes to the hunk header, not the line
of equal signs.