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

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

[nongnu] elpa/swift-mode adfe341 190/496: Add grammar for the protocol d


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode adfe341 190/496: Add grammar for the protocol definitions
Date: Sun, 29 Aug 2021 11:33:34 -0400 (EDT)

branch: elpa/swift-mode
commit adfe341f8f03b5e00f55d00001150aae38c722dc
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>

    Add grammar for the protocol definitions
---
 swift-mode.el             | 11 +++++++++-
 test/indentation-tests.el | 53 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/swift-mode.el b/swift-mode.el
index 3f638b1..3626fc6 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -99,13 +99,19 @@
        (top-level-st
         ("import" type)
         (decl)
-        ("ACCESSMOD" "class" class-decl-exp "{" class-level-sts "}"))
+        ("ACCESSMOD" "class" class-decl-exp "{" class-level-sts "}")
+        ("ACCESSMOD" "protocol" class-decl-exp "{" protocol-level-sts "}"))
 
        (class-level-sts (class-level-st) (class-level-st ";" class-level-st))
        (class-level-st
         (decl)
         (func))
 
+       (protocol-level-sts (protocol-level-st) (protocol-level-st ";" 
protocol-level-st))
+       (protocol-level-st
+        (decl)
+        (func))
+
        (func ("DECSPEC" "func" func-header) (func "{" insts "}"))
        (func-header (id "(" func-params ")") (func-header "->" type))
        (func-param (decl-exp) ("..."))
@@ -340,6 +346,9 @@
      (if (smie-rule-prev-p "->") swift-indent-offset
        (smie-rule-parent)))
     (`(:after . "->") swift-indent-offset)
+
+    ;; Normalize behaviour with and without declaration specifier
+    (`(:before . "DECSPEC") swift-indent-offset)
     ))
 
 ;;; Font lock
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index c0b5d61..c6a493d 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -795,6 +795,59 @@ func foo() ->
 func foo() ->
     |[A] {}
 ")
+
+(check-indentation indents-protocol-declaration/1
+                   "
+protocol Foo {
+    func foo()
+|func bar()
+}
+" "
+protocol Foo {
+    func foo()
+    |func bar()
+}
+")
+
+(check-indentation indents-protocol-declaration/2
+                   "
+protocol Foo {
+    func foo() -> Foo
+|func bar() -> Bar
+}
+" "
+protocol Foo {
+    func foo() -> Foo
+    |func bar() -> Bar
+}
+")
+
+(check-indentation indents-protocol-declaration/3
+                   "
+protocol Foo {
+    func foo() -> Foo<A>
+|func bar() -> Bar<A>
+}
+" "
+protocol Foo {
+    func foo() -> Foo<A>
+    |func bar() -> Bar<A>
+}
+")
+
+(check-indentation indents-protocol-declaration/4
+                   "
+protocol Foo {
+    func foo() -> [A]
+|func bar() -> [A]
+}
+" "
+protocol Foo {
+    func foo() -> [A]
+    |func bar() -> [A]
+}
+")
+
 (check-indentation indents-declaration/1
   "
 var foo = bar + baz



reply via email to

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