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

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

[nongnu] elpa/swift-mode 1178d72a37 5/9: Add init accessors


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 1178d72a37 5/9: Add init accessors
Date: Sat, 30 Sep 2023 07:01:19 -0400 (EDT)

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

    Add init accessors
    
    
https://github.com/apple/swift-evolution/blob/main/proposals/0400-init-accessors.md
---
 swift-mode-beginning-of-defun.el                   |  5 +--
 .../beginning-of-defun/beginning-of-defun.swift    | 18 +++++-----
 test/swift-files/indent/declarations.swift         | 40 ++++++++++++++++++++++
 3 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/swift-mode-beginning-of-defun.el b/swift-mode-beginning-of-defun.el
index 399d4f24e9..7b99f075e2 100644
--- a/swift-mode-beginning-of-defun.el
+++ b/swift-mode-beginning-of-defun.el
@@ -24,7 +24,7 @@
 ;; `beginning-of-defun' and `end-of-defun'
 ;;
 ;; A defun is a declaration except local variable, "get", "set", "willSet",
-;; "didSet", or "case" within enum.
+;; "didSet", "case" within enum, or "init" within var.
 ;;
 ;; A defun include modifiers, attributes, and comments on the same line.
 ;;
@@ -1417,7 +1417,8 @@ of ancestors."
                       (when (eq (swift-mode:token:type next-token) 'identifier)
                         next-token))))
             name-tokens)
-        '()))))
+        (swift-mode:backward-sexps-until-open-curly-bracket)
+        (swift-mode:current-defun-name-token-list)))))
 
 (defun swift-mode:current-defun-name-token ()
   "Return the name token of the defun under the point."
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 b23fbefc24..01a5a327be 100644
--- a/test/swift-files/beginning-of-defun/beginning-of-defun.swift
+++ b/test/swift-files/beginning-of-defun/beginning-of-defun.swift
@@ -166,17 +166,17 @@ foo() {
 /*{*/enum Foo<A> where A: B {
     /*{*/case Foo(a: Int)/*}*/
     /*{*/case Bar(b: Int), Baz/*}*/
-    /*{*/case
-      A(
-        b
-          :
-          Int)
-            ,
-      @Foo
+    /*{*/@Foo
       indirect
+        case
+        A(
+          b
+            :
+            Int)
+           ,
         B
-        =
-        0/*}*/
+          =
+          0/*}*/
 
     /*{*/func foo() -> a {
         /*[*/switch this {
diff --git a/test/swift-files/indent/declarations.swift 
b/test/swift-files/indent/declarations.swift
index 93caf11b10..2adef2a3b7 100644
--- a/test/swift-files/indent/declarations.swift
+++ b/test/swift-files/indent/declarations.swift
@@ -220,6 +220,10 @@ class Foo {
     }
 
     var x {
+        init {
+            x = 1
+        }
+
         get {
             1
         }
@@ -230,6 +234,11 @@ class Foo {
     }
 
     var x {
+        init
+        {
+            x = 1
+        }
+
         get
         {
             1
@@ -241,6 +250,37 @@ class Foo {
         }
     }
 
+    var x {
+        init(newValue) {
+            x = 1
+        }
+
+        get {
+            1
+        }
+
+        set(newValue) {
+            foo()
+        }
+    }
+
+    var x {
+        init(newValue)
+        {
+            x = 1
+        }
+
+        get
+        {
+            1
+        }
+
+        set(newValue)
+        {
+            foo()
+        }
+    }
+
     var x {
         get
           async



reply via email to

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