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

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

[nongnu] elpa/swift-mode f88e1ac 491/496: Support actor


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode f88e1ac 491/496: Support actor
Date: Sun, 29 Aug 2021 11:34:34 -0400 (EDT)

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

    Support actor
    
    Imenu, indentation, and beginning-of-defun.
---
 swift-mode-beginning-of-defun.el                   |  6 +-
 swift-mode-imenu.el                                |  2 +-
 swift-mode-indent.el                               |  6 +-
 swift-mode-lexer.el                                | 10 +--
 .../beginning-of-defun/beginning-of-defun.swift    |  5 ++
 test/swift-files/imenu/imenu-expected.el           | 81 +++++++++++-----------
 test/swift-files/imenu/imenu.swift                 |  5 ++
 test/swift-files/indent/declarations.swift         | 19 +++++
 test/swift-files/indent/identifiers.swift          |  3 +
 9 files changed, 85 insertions(+), 52 deletions(-)

diff --git a/swift-mode-beginning-of-defun.el b/swift-mode-beginning-of-defun.el
index 539bdcf..f8acaa8 100644
--- a/swift-mode-beginning-of-defun.el
+++ b/swift-mode-beginning-of-defun.el
@@ -168,7 +168,7 @@ The cursor must be at the beginning of a statement."
   (let ((token (swift-mode:forward-token-or-list))
         (defun-keywords
           '("import" "typealias" "associatedtype"
-            "enum" "struct" "protocol" "extension"
+            "enum" "struct" "actor" "protocol" "extension"
             "func" "init" "deinit" "subscript" "get" "set" "willSet" "didSet"
             "prefix" "postfix" "infix" "precedencegroup"
             "var" "let"
@@ -207,7 +207,7 @@ Return nil otherwise."
      (swift-mode:beginning-of-statement)
      (member
       (swift-mode:token:text (swift-mode:find-defun-keyword-simple))
-      '("enum" "struct" "class" "protocol" "extension")))))
+      '("enum" "struct" "actor" "class" "protocol" "extension")))))
 
 (defun swift-mode:beginning-of-statement ()
   "Move backward to the beginning of a statement.
@@ -1418,7 +1418,7 @@ of ancestors."
        (cond
         ((member keyword-text
                  '("typealias" "associatedtype" "precedencegroup" "func"
-                   "class" "enum" "struct" "protocol" "extension"))
+                   "class" "enum" "struct" "actor" "protocol" "extension"))
          (swift-mode:forward-token))
 
         ((member keyword-text '("init" "deinit" "subscript"))
diff --git a/swift-mode-imenu.el b/swift-mode-imenu.el
index c6de9a9..e220235 100644
--- a/swift-mode-imenu.el
+++ b/swift-mode-imenu.el
@@ -159,7 +159,7 @@ Return found declarations in reverse order."
          ;; Ignores the token otherwise.
          ))
 
-       ((member next-text '("struct" "protocol" "extension" "enum"))
+       ((member next-text '("struct" "protocol" "extension" "enum" "actor"))
         (setq last-class-token nil)
         (let ((declaration
                (swift-mode:scan-declarations:handle-struct-like next-token)))
diff --git a/swift-mode-indent.el b/swift-mode-indent.el
index ce942a6..715c34a 100644
--- a/swift-mode-indent.el
+++ b/swift-mode-indent.el
@@ -929,8 +929,8 @@ This function is also used for close-curly-brace."
              '("for" "while" "repeat" "switch" "if" "else" "guard"
                "defer" "do" "catch"
                "get" "set" "willSet" "didSet" "func" "init" "subscript"
-               "enum" "struct" "class" "extension" "prefix" "postfix" "infix"
-               "precedencegroup"))
+               "enum" "struct" "actor" "class" "extension"
+               "prefix" "postfix" "infix" "precedencegroup"))
             (setq is-declaration-or-control-statement-body t)
             (goto-char (1+ pos)))
 
@@ -1497,7 +1497,7 @@ It is a Generic parameter list if:
     \;
     { } \( \) \[ \]
     "true" "false"
-    "class" "struct" "enum" "extension" "func" "operator"
+    "class" "struct" "actor" "enum" "extension" "func" "operator"
     "try" "try?" "try!"
     "as" "as?" "as!"
     "is"
diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el
index 400410e..1448128 100644
--- a/swift-mode-lexer.el
+++ b/swift-mode-lexer.el
@@ -480,7 +480,7 @@ Return nil otherwise."
 
      ;; Suppress implicit semicolon after declaration starters.
      ((member (swift-mode:token:text previous-token)
-              '("class" "struct" "protocol" "enum" "extension" "func"
+              '("class" "struct" "actor" "protocol" "enum" "extension" "func"
                 "typealias" "associatedtype" "precedencegroup" "operator"))
       nil)
 
@@ -556,7 +556,7 @@ Return nil otherwise."
      ;;
      ;; `protocol' is handled by the next rule
      ((member (swift-mode:token:text next-token)
-              '("class" "struct" "enum" "extension" "func" "typealias"
+              '("class" "struct" "actor" "enum" "extension" "func" "typealias"
                 "associatedtype" "precedencegroup"))
       t)
 
@@ -687,8 +687,8 @@ That is supertype declaration or type declaration of let or 
var."
        (member (swift-mode:token:text
                 (swift-mode:backquote-identifier-if-after-dot
                  (swift-mode:backward-token-simple)))
-               '("class" "extension" "enum" "struct" "protocol" "typealias"
-                 "associatedtype"))))))
+               '("class" "extension" "enum" "struct" "actor" "protocol"
+                 "typealias" "associatedtype"))))))
 
 (defvar swift-mode:in-recursive-call-of-case-colon-p nil
   "Non-nil if `case-colon-p' is being evaluated.")
@@ -740,7 +740,7 @@ Return nil otherwise."
     (or (member (swift-mode:token:text (swift-mode:backward-token-simple))
                 '("init" "subscript"))
         (member (swift-mode:token:text (swift-mode:backward-token-simple))
-                '("typealias" "func" "enum" "struct" "class" "init")))))
+                '("typealias" "func" "enum" "struct" "actor" "class" 
"init")))))
 
 (defun swift-mode:fix-operator-type (token)
   "Return new operator token with proper token type.
diff --git a/test/swift-files/beginning-of-defun/beginning-of-defun.swift 
b/test/swift-files/beginning-of-defun/beginning-of-defun.swift
index df07581..5f38a34 100644
--- a/test/swift-files/beginning-of-defun/beginning-of-defun.swift
+++ b/test/swift-files/beginning-of-defun/beginning-of-defun.swift
@@ -197,6 +197,11 @@ foo() {
 /*{*/struct Foo {
 }/*}*/
 
+// /*[*/Actor declarations/*]*/
+
+/*{*/actor Foo {
+}/*}*/
+
 // /*[*/Class declarations/*]*/
 
 /*{*/class Foo {
diff --git a/test/swift-files/imenu/imenu-expected.el 
b/test/swift-files/imenu/imenu-expected.el
index d002c34..9aaf8fb 100644
--- a/test/swift-files/imenu/imenu-expected.el
+++ b/test/swift-files/imenu/imenu-expected.el
@@ -1,40 +1,41 @@
-((precedencegroup (identifier "precedenceGroup" 2661 2676) nil)
- (operator (identifier "*****" 2621 2626) nil)
- (operator (identifier "-----" 2581 2586) nil)
- (operator (identifier "+++++" 2542 2547) nil)
- (extension (identifier "FooClass" 2377 2385)
-            ((class (identifier "NestedClass1" 2417 2429)
-                    ((class (identifier "NestedClass2" 2446 2458)
-                            ((class (identifier "NestedClass3" 2479 2491) 
nil)))))))
- (protocol (identifier "FooProtocol" 2117 2128)
-           ((var (identifier "protocolProperty" 2144 2160) nil)
-            (func (identifier "protocolMethod(a:b:)" 2186 2200) nil)
-            (init (identifier "init(a:b:c:)" 2228 2232) nil)
-            (subscript (identifier "subscript(_:bbb:)" 2263 2272) nil)
-            (associatedtype (identifier "AssociatedType" 2344 2358) nil)))
- (struct (identifier "FooStruct" 2088 2097) nil)
- (enum (identifier "FooEnum2" 2023 2031)
-       ((case (identifier "case1" 2048 2053) nil)
-        (case (identifier "case2" 2068 2073) nil)))
- (enum (identifier "FooEnum1" 1888 1896)
-       ((case (identifier "case1" 1935 1940) nil)
-        (case (identifier "case2" 1966 1971) nil)
-        (case (identifier "case3" 1995 2000) nil)))
- (class (identifier "FooClass" 530 538)
-        ((var (identifier "classVariable1" 607 621) nil)
-         (class (identifier "final" 657 662) nil)
-         (var (identifier "compuatedProperty" 685 702) nil)
-         (var (identifier "observedProperty" 844 860) nil)
-         (typealias (identifier "TypeAlias" 1008 1017) nil)
-         (func (identifier "function1(aaa:_:ddd:eee:)" 1072 1081) nil)
-         (func (identifier "function2()" 1269 1278) nil)
-         (func (identifier "function3(a:)" 1352 1361) nil)
-         (func (identifier "+(_:_:)" 1496 1497) nil)
-         (subscript (identifier "subscript(_:bbb:)" 1658 1667) nil)
-         (init (identifier "init(a:)" 1806 1810) nil)
-         (init (identifier "init(b:)" 1833 1837) nil)
-         (deinit (identifier "deinit" 1860 1866) nil)))
- (var (identifier "globalVariable2" 493 508) nil)
- (var (identifier "globalVariable1" 463 478) nil)
- (let (identifier "globalConstant2" 429 444) nil)
- (let (identifier "globalConstant1" 399 414) nil))
+((precedencegroup (identifier "precedenceGroup" 2753 2768) nil)
+ (operator (identifier "*****" 2713 2718) nil)
+ (operator (identifier "-----" 2673 2678) nil)
+ (operator (identifier "+++++" 2634 2639) nil)
+ (extension (identifier "FooClass" 2469 2477)
+            ((class (identifier "NestedClass1" 2509 2521)
+                    ((class (identifier "NestedClass2" 2538 2550)
+                            ((class (identifier "NestedClass3" 2571 2583) 
nil)))))))
+ (protocol (identifier "FooProtocol" 2209 2220)
+           ((var (identifier "protocolProperty" 2236 2252) nil)
+            (func (identifier "protocolMethod(a:b:)" 2278 2292) nil)
+            (init (identifier "init(a:b:c:)" 2320 2324) nil)
+            (subscript (identifier "subscript(_:bbb:)" 2355 2364) nil)
+            (associatedtype (identifier "AssociatedType" 2436 2450) nil)))
+ (actor (identifier "FooActor" 2181 2189) nil)
+ (struct (identifier "FooStruct" 2155 2164) nil)
+ (enum (identifier "FooEnum2" 2090 2098)
+       ((case (identifier "case1" 2115 2120) nil)
+        (case (identifier "case2" 2135 2140) nil)))
+ (enum (identifier "FooEnum1" 1955 1963)
+       ((case (identifier "case1" 2002 2007) nil)
+        (case (identifier "case2" 2033 2038) nil)
+        (case (identifier "case3" 2062 2067) nil)))
+ (class (identifier "FooClass" 597 605)
+        ((var (identifier "classVariable1" 674 688) nil)
+         (class (identifier "final" 724 729) nil)
+         (var (identifier "compuatedProperty" 752 769) nil)
+         (var (identifier "observedProperty" 911 927) nil)
+         (typealias (identifier "TypeAlias" 1075 1084) nil)
+         (func (identifier "function1(aaa:_:ddd:eee:)" 1139 1148) nil)
+         (func (identifier "function2()" 1336 1345) nil)
+         (func (identifier "function3(a:)" 1419 1428) nil)
+         (func (identifier "+(_:_:)" 1563 1564) nil)
+         (subscript (identifier "subscript(_:bbb:)" 1725 1734) nil)
+         (init (identifier "init(a:)" 1873 1877) nil)
+         (init (identifier "init(b:)" 1900 1904) nil)
+         (deinit (identifier "deinit" 1927 1933) nil)))
+ (var (identifier "globalVariable2" 560 575) nil)
+ (var (identifier "globalVariable1" 530 545) nil)
+ (let (identifier "globalConstant2" 496 511) nil)
+ (let (identifier "globalConstant1" 466 481) nil))
diff --git a/test/swift-files/imenu/imenu.swift 
b/test/swift-files/imenu/imenu.swift
index 3a6ed38..67fc1dd 100644
--- a/test/swift-files/imenu/imenu.swift
+++ b/test/swift-files/imenu/imenu.swift
@@ -9,6 +9,8 @@ import let FooModule3.importedConstant
 import var FooModule3.importedVariable
 import func FooModule3.importedFunction
 
+// Note that `import actor` is invalid (at least with Swift 5.5).
+
 @AAA let globalConstant1 = 1,
          globalConstant2: Int = 2
 @AAA var globalVariable1 = 1,
@@ -92,6 +94,9 @@ enum FooEnum2: Int {
 struct FooStruct: AAA {
 }
 
+actor FooActor: AAA {
+}
+
 protocol FooProtocol: AAA {
     var protocolProperty: Int { get set}
     func protocolMethod(a: Int, b: Int) -> Int
diff --git a/test/swift-files/indent/declarations.swift 
b/test/swift-files/indent/declarations.swift
index 1d5e0ba..abb2b80 100644
--- a/test/swift-files/indent/declarations.swift
+++ b/test/swift-files/indent/declarations.swift
@@ -570,6 +570,25 @@ struct Foo
   > {
 }
 
+// Actor declarations
+
+@A
+fileprivate
+  actor
+  Foo<A, B>
+  : Bar<A, B>,
+    Baz<A, B>,
+    AAA<A, B>
+  where
+    A:
+      C,
+    B =
+      D<E> {
+    func foo()
+    func foo()
+}
+
+
 // Protocol declarations
 
 protocol Foo {
diff --git a/test/swift-files/indent/identifiers.swift 
b/test/swift-files/indent/identifiers.swift
index 2dfd3d8..85ced6c 100644
--- a/test/swift-files/indent/identifiers.swift
+++ b/test/swift-files/indent/identifiers.swift
@@ -95,6 +95,9 @@ func foo() {
       struct: 1
     )
     foo(
+      actor: 1
+    )
+    foo(
       subscript: 1
     )
     foo(



reply via email to

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