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

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

[nongnu] elpa/kotlin-mode e1540a5ddf 087/162: Merge pull request #10 fro


From: ELPA Syncer
Subject: [nongnu] elpa/kotlin-mode e1540a5ddf 087/162: Merge pull request #10 from gregghz/master
Date: Sat, 29 Jan 2022 08:25:25 -0500 (EST)

branch: elpa/kotlin-mode
commit e1540a5ddf21667a18e330abd28f07a4c55f999d
Merge: fa8f063a1e c65c96a51a
Author: Gregg Hernandez <greggory.hz@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #10 from gregghz/master
    
    handle chained method calls on multiple lines
---
 kotlin-mode.el           | 15 ++++++++++++++-
 test/kotlin-mode-test.el | 26 ++++++++++++++++++++++++++
 test/run-tests.sh        |  5 +++++
 test/sample.kt           | 15 ++++++++++-----
 4 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/kotlin-mode.el b/kotlin-mode.el
index 4c748de5f4..4f67c027b3 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -233,9 +233,22 @@
       (progn
         (kotlin-mode--beginning-of-buffer-indent))
     (let ((not-indented t) cur-indent)
-      (cond ((looking-at "^[ \t]*}")
+      (cond ((looking-at "^[ \t]*\\.")
              (save-excursion
                (forward-line -1)
+               (cond ((looking-at "^[ \t]*\\.")
+                      (setq cur-indent (current-indentation)))
+
+                     (t
+                      (setq cur-indent (+ (current-indentation) (* 2 
kotlin-tab-width)))))
+               (if (< cur-indent 0)
+                   (setq cur-indent 0))))
+
+            ((looking-at "^[ \t]*}")
+             (save-excursion
+               (forward-line -1)
+               (while (and (looking-at "^[ \t]*\\.") (not (bobp)))
+                 (forward-line -1))
                (setq cur-indent (- (current-indentation) kotlin-tab-width)))
              (if (< cur-indent 0)
                  (setq cur-indent 0)))
diff --git a/test/kotlin-mode-test.el b/test/kotlin-mode-test.el
index 0ec9a85bbb..c75137cd3b 100644
--- a/test/kotlin-mode-test.el
+++ b/test/kotlin-mode-test.el
@@ -46,3 +46,29 @@ return a + b
       (should (equal (buffer-string) "fun sum(a: Int, b: Int): Int {
        return a + b
 }")))))
+
+;; (ert-deftest kotlin-mode--chained-methods ()
+;;   (with-temp-buffer
+;;     (let ((text "names.filter { it.empty }
+;; .sortedBy { it }
+;; .map { it.toUpperCase() }
+;; .forEach { print(it) }"))
+
+;;       (insert text)
+;;       (beginning-of-buffer)
+
+;;       (kotlin-mode--indent-line)
+
+;;       (next-line)
+;;       (kotlin-mode--indent-line)
+
+;;       (next-line)
+;;       (kotlin-mode--indent-line)
+
+;;       (next-line)
+;;       (kotlin-mode--indent-line)
+
+;;       (should (equal (buffer-string) "names.filter { it.empty }
+;;     .sortedBy { it }
+;;     .map { it.toUpperCase() }
+;;     .forEach { print(it) }")))))
\ No newline at end of file
diff --git a/test/run-tests.sh b/test/run-tests.sh
new file mode 100755
index 0000000000..80faa08d32
--- /dev/null
+++ b/test/run-tests.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cd ../
+emacs -batch -l ert -l test/kotlin-mode-test.el -f ert-run-tests-batch-and-exit
+cd test
diff --git a/test/sample.kt b/test/sample.kt
index 3edfd5a452..1768f0142e 100644
--- a/test/sample.kt
+++ b/test/sample.kt
@@ -104,11 +104,16 @@ println(name)
 if (text in names) // names.contains(text) is called
 print("Yes")
 
-names
-.filter { it.startsWith("A") }
-.sortedBy { it }
-.map { it.toUpperCase() }
-.forEach { print(it) }
+names.filter { it.startsWith("A") }
+        .sortedBy { it }
+        .map { it.toUpperCase() }
+        .forEach { print(it) }
+
+fun f() {
+    things.f()
+            .g()
+            .h()
+}
 
 data class Customer(val name: String, val email: String)
 val positives = list.filter { x -> x > 0 }



reply via email to

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