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

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

[nongnu] elpa/swift-mode 107195e 219/496: Improve lexer rule for generic


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 107195e 219/496: Improve lexer rule for generics with optional or implicit unwrapping
Date: Sun, 29 Aug 2021 11:33:39 -0400 (EDT)

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

    Improve lexer rule for generics with optional or implicit unwrapping
---
 swift-mode.el             |  3 ++-
 test/indentation-tests.el | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/swift-mode.el b/swift-mode.el
index aa665ec..c5412fb 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -285,7 +285,8 @@
 
      ((eq (char-before) ?<) (backward-char 1)
       (if (looking-at "<[[:upper:]]") "<T" "OP"))
-     ((eq (char-before) ?>) (backward-char 1)
+     ((looking-back ">[?!]?" (- (point) 2) t)
+      (goto-char (match-beginning 0))
       (if (looking-back "[[:space:]]" 1 t) "OP" "T>"))
 
      ((looking-back swift-smie--operators-regexp (- (point) 3) t)
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index d522756..65897e9 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1752,6 +1752,33 @@ var object: JsonObject?
 |var object: JsonObject
 ")
 
+(check-indentation indents-expression-with-optional-type/2
+                   "
+var object: JsonObject<Foo>?
+    |var object: JsonObject
+" "
+var object: JsonObject<Foo>?
+|var object: JsonObject
+")
+
+(check-indentation indents-expression-with-implicit-unwrapped-type/1
+                   "
+var object: JsonObject!
+    |var object: JsonObject
+" "
+var object: JsonObject!
+|var object: JsonObject
+")
+
+(check-indentation indents-expression-with-implicit-unwrapped-type/2
+                   "
+var object: JsonObject<Foo>!
+    |var object: JsonObject
+" "
+var object: JsonObject<Foo>!
+|var object: JsonObject
+")
+
 (provide 'indentation-tests)
 
 ;;; indentation-tests.el ends here



reply via email to

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