emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/swift-mode 1339e24d23 4/9: Add `discard self`


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 1339e24d23 4/9: Add `discard self`
Date: Sat, 30 Sep 2023 07:01:19 -0400 (EDT)

branch: elpa/swift-mode
commit 1339e24d23de597ea318d836e162cd13b79e5d59
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>

    Add `discard self`
    
    
https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md
---
 swift-mode-font-lock.el                   |  2 +-
 swift-mode-indent.el                      |  2 +-
 swift-mode-lexer.el                       | 14 ++++++++------
 test/swift-files/indent/expressions.swift | 10 ++++++++++
 test/swift-files/indent/identifiers.swift |  3 +++
 5 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/swift-mode-font-lock.el b/swift-mode-font-lock.el
index 32d8cb790b..53c01a4faf 100644
--- a/swift-mode-font-lock.el
+++ b/swift-mode-font-lock.el
@@ -535,7 +535,7 @@ Return nil otherwise."
 
 (defconst swift-mode:expression-keywords
   '("as" "catch" "dynamicType" "is" "rethrows" "super" "self" "Self" "throws"
-    "throw" "try" "async" "await" "consume" "copy")
+    "throw" "try" "async" "await" "consume" "copy" "discard")
   "Keywords used in expressions and types.
 
 Excludes true, false, and keywords begin with a number sign.")
diff --git a/swift-mode-indent.el b/swift-mode-indent.el
index bf3e2839f9..1d286bc150 100644
--- a/swift-mode-indent.el
+++ b/swift-mode-indent.el
@@ -1649,7 +1649,7 @@ It is a Generic parameter list if:
     "as" "as?" "as!"
     "is"
     "await"
-    "consume" "copy"
+    "consume" "copy" "discard"
     "in"
     "init" "deinit" "get" "set" "willSet" "didSet" "subscript"
     "for" "case" "default" "while" "let" "var" "repeat" "if" "else"
diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el
index 9f688f2201..3c13a8205f 100644
--- a/swift-mode-lexer.el
+++ b/swift-mode-lexer.el
@@ -99,7 +99,8 @@ END is the point after the token."
 
 ;; Token types is one of the following symbols:
 ;;
-;; - prefix-operator (including try, try?, try!, await, consume, and copy)
+;; - prefix-operator (including try, try?, try!, await, consume, copy, and
+;;   discard)
 ;; - postfix-operator
 ;; - binary-operator (including as, as?, as!, is, =, ., and ->)
 ;; - attribute (e.g. @objc, @abc(def))
@@ -988,7 +989,8 @@ Other properties are the same as the TOKEN."
        (type
         (cond
          (is-declaration 'identifier)
-         ((member text '("try" "try?" "try!" "await" "consume" "copy"))
+         ((member text '("try" "try?" "try!" "await" "consume" "copy"
+                         "discard"))
           'prefix-operator)
          ((equal text ".") 'binary-operator)
          ((and has-preceding-space has-following-space) 'binary-operator)
@@ -1147,7 +1149,7 @@ This function does not return `implicit-;' or `type-:'."
        pos-after-comment
        (point))))
 
-   ;; Operator (other than as, try, is, await, consume, or copy)
+   ;; Operator (other than as, try, is, await, consume, copy, or discard)
    ;;
    ;; Operators starts with a dot can contains dots. Other operators cannot
    ;; contain dots.
@@ -1246,7 +1248,7 @@ This function does not return `implicit-;' or `type-:'."
                           text
                           (- (point) (length text))
                           (point)))
-       ((member text '("await" "consume" "copy"))
+       ((member text '("await" "consume" "copy" "discard"))
         (swift-mode:token 'prefix-operator
                           text
                           (- (point) (length text))
@@ -1419,7 +1421,7 @@ This function does not return `implicit-;' or `type-:'."
        (point)
        pos-before-comment)))
 
-   ;; Operator (other than as, try, is, await, consume, or copy)
+   ;; Operator (other than as, try, is, await, consume, copy, or discard)
    ;;
    ;; Operators which starts with a dot can contain other dots. Other
    ;; operators cannot contain dots.
@@ -1501,7 +1503,7 @@ This function does not return `implicit-;' or `type-:'."
                           text
                           (point)
                           (+ (point) (length text))))
-       ((member text '("try" "await" "consume" "copy"))
+       ((member text '("try" "await" "consume" "copy" "discard"))
         (swift-mode:token 'prefix-operator
                           text
                           (point)
diff --git a/test/swift-files/indent/expressions.swift 
b/test/swift-files/indent/expressions.swift
index 2d8d6abf74..00ce5fbcaa 100644
--- a/test/swift-files/indent/expressions.swift
+++ b/test/swift-files/indent/expressions.swift
@@ -843,3 +843,13 @@ func foo() {
     copy
     x
 }
+
+
+// discard self
+// 
https://github.com/apple/swift-evolution/blob/main/proposals/0390-noncopyable-structs-and-enums.md
+
+func foo() {
+    // discard operator cannot be followed by a line break.
+    discard
+    self
+}
diff --git a/test/swift-files/indent/identifiers.swift 
b/test/swift-files/indent/identifiers.swift
index 4af41593c8..6aad794ad8 100644
--- a/test/swift-files/indent/identifiers.swift
+++ b/test/swift-files/indent/identifiers.swift
@@ -227,6 +227,9 @@ func foo() {
     foo(
       copy: 1
     )
+    foo(
+      discard: 1
+    )
 
     // Keywords reserved in particular contexts
     foo(



reply via email to

[Prev in Thread] Current Thread [Next in Thread]