mirror of
https://github.com/git/git.git
synced 2026-08-09 01:21:47 +00:00
Merge branch 'sk/userdiff-swift'
Userdiff patterns for Swift have been added, with support for Swift-specific constructs such as attributes, modifiers, failable initializers, and generics. * sk/userdiff-swift: userdiff: add support for Swift
This commit is contained in:
@@ -914,6 +914,8 @@ patterns are available:
|
||||
- `scheme` suitable for source code in most Lisp dialects,
|
||||
including Scheme, Emacs Lisp, Common Lisp, and Clojure.
|
||||
|
||||
- `swift` suitable for source code in the Swift language.
|
||||
|
||||
- `tex` suitable for source code for LaTeX documents.
|
||||
|
||||
|
||||
|
||||
5
t/t4018/swift-actor
Normal file
5
t/t4018/swift-actor
Normal file
@@ -0,0 +1,5 @@
|
||||
actor RIGHT {
|
||||
let a = 1
|
||||
// a comment
|
||||
let b = ChangeMe
|
||||
}
|
||||
7
t/t4018/swift-attribute-with-args
Normal file
7
t/t4018/swift-attribute-with-args
Normal file
@@ -0,0 +1,7 @@
|
||||
struct View {
|
||||
@available(iOS 13, *) public func RIGHT() {
|
||||
let a = 1
|
||||
// a comment
|
||||
print(ChangeMe)
|
||||
}
|
||||
}
|
||||
5
t/t4018/swift-class
Normal file
5
t/t4018/swift-class
Normal file
@@ -0,0 +1,5 @@
|
||||
class RIGHT {
|
||||
let a = 1
|
||||
// a comment
|
||||
let b = ChangeMe
|
||||
}
|
||||
5
t/t4018/swift-enum
Normal file
5
t/t4018/swift-enum
Normal file
@@ -0,0 +1,5 @@
|
||||
enum RIGHT {
|
||||
case first
|
||||
// a comment
|
||||
case ChangeMe
|
||||
}
|
||||
5
t/t4018/swift-extension
Normal file
5
t/t4018/swift-extension
Normal file
@@ -0,0 +1,5 @@
|
||||
extension RIGHT {
|
||||
static let a = 1
|
||||
// a comment
|
||||
static let b = ChangeMe
|
||||
}
|
||||
7
t/t4018/swift-failable-init
Normal file
7
t/t4018/swift-failable-init
Normal file
@@ -0,0 +1,7 @@
|
||||
class Bar {
|
||||
init?(RIGHT: Int) {
|
||||
let x = 0
|
||||
// a comment
|
||||
print(ChangeMe)
|
||||
}
|
||||
}
|
||||
5
t/t4018/swift-func
Normal file
5
t/t4018/swift-func
Normal file
@@ -0,0 +1,5 @@
|
||||
func RIGHT(x: Int) -> Int {
|
||||
let y = x
|
||||
// a comment
|
||||
return ChangeMe
|
||||
}
|
||||
7
t/t4018/swift-generic-subscript
Normal file
7
t/t4018/swift-generic-subscript
Normal file
@@ -0,0 +1,7 @@
|
||||
struct Container {
|
||||
subscript<RIGHT>(index: Int) -> Int {
|
||||
let a = 0
|
||||
// a comment
|
||||
return ChangeMe
|
||||
}
|
||||
}
|
||||
7
t/t4018/swift-init
Normal file
7
t/t4018/swift-init
Normal file
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
init(RIGHT: Int) {
|
||||
let x = 0
|
||||
// a comment
|
||||
print(ChangeMe)
|
||||
}
|
||||
}
|
||||
7
t/t4018/swift-inline-attribute
Normal file
7
t/t4018/swift-inline-attribute
Normal file
@@ -0,0 +1,7 @@
|
||||
class Service {
|
||||
@objc func RIGHT() {
|
||||
let path = "/api"
|
||||
// a comment
|
||||
log(ChangeMe)
|
||||
}
|
||||
}
|
||||
4
t/t4018/swift-modifiers
Normal file
4
t/t4018/swift-modifiers
Normal file
@@ -0,0 +1,4 @@
|
||||
public static func RIGHT() -> Int {
|
||||
// a comment
|
||||
return ChangeMe
|
||||
}
|
||||
5
t/t4018/swift-protocol
Normal file
5
t/t4018/swift-protocol
Normal file
@@ -0,0 +1,5 @@
|
||||
protocol RIGHT {
|
||||
var first: Int { get }
|
||||
// a comment
|
||||
var second: ChangeMe { get }
|
||||
}
|
||||
5
t/t4018/swift-struct
Normal file
5
t/t4018/swift-struct
Normal file
@@ -0,0 +1,5 @@
|
||||
struct RIGHT {
|
||||
let a = 1
|
||||
// a comment
|
||||
let b = ChangeMe
|
||||
}
|
||||
10
userdiff.c
10
userdiff.c
@@ -362,6 +362,16 @@ PATTERNS("scheme",
|
||||
"\\|([^|\\\\]|\\\\.)*\\|"
|
||||
/* All other words should be delimited by spaces or parentheses. */
|
||||
"|([^][)(}{ \t])+"),
|
||||
PATTERNS("swift",
|
||||
"^[ \t]*((@[A-Za-z_][A-Za-z0-9_]*(\\([^()]*\\))?[ \t]+)*([a-z]+[ \t]+)*(func|init|deinit|subscript|class|struct|enum|protocol|extension|actor)[ \t(?!<].*)$",
|
||||
/* -- */
|
||||
"[a-zA-Z_][a-zA-Z0-9_]*"
|
||||
/* hexadecimal, octal, and binary literals */
|
||||
"|0[xX][0-9a-fA-F_]+|0[oO][0-7_]+|0[bB][01_]+"
|
||||
/* integers and floating-point numbers */
|
||||
"|[0-9][0-9_]*([.][0-9_]+)?([eE][-+]?[0-9]+)?"
|
||||
/* unary and binary operators */
|
||||
"|[-+*/%<>=!&|^~?]=|&&|\\|\\||<<=?|>>=?|\\?\\?|\\.\\.[.<]|->"),
|
||||
PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
|
||||
"\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+"),
|
||||
{ .name = "default", .binary = -1 },
|
||||
|
||||
Reference in New Issue
Block a user