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

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

[elpa] externals/javaimp aae4d63bd9: Improve doc and tests of low-level


From: Filipp Gunbin
Subject: [elpa] externals/javaimp aae4d63bd9: Improve doc and tests of low-level parsing functions
Date: Thu, 21 Jul 2022 15:55:18 -0400 (EDT)

branch: externals/javaimp
commit aae4d63bd9678cc3997b6f5c85e6aaba3dd42e37
Author: Filipp Gunbin <fgunbin@fastmail.fm>
Commit: Filipp Gunbin <fgunbin@fastmail.fm>

    Improve doc and tests of low-level parsing functions
---
 javaimp-parse.el | 12 ++++++++----
 tests/parse.el   | 19 +++++++++++++++++--
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/javaimp-parse.el b/javaimp-parse.el
index 513900245f..bab4249823 100644
--- a/javaimp-parse.el
+++ b/javaimp-parse.el
@@ -294,10 +294,14 @@ the start of the last successful match, or nil."
 
 (defun javaimp-parse--decl-prefix (start-pos &optional bound)
   "Attempt to parse defun declaration prefix backwards from
-START-POS, but not farther than BOUND.  START-POS should be
-somewhere inside the defun declaration, but not inside nested
-lists like argument list.  Return the beginning of the
-declaration or nil."
+START-POS, but not farther than BOUND or previous semicolon,
+whichever comes first.  START-POS should be somewhere inside the
+defun declaration, but outside any nested lists like argument
+list.  Return the beginning of the declaration or nil.
+
+Go back by sexps until we either reach BOUND or a semicolon, or
+arrive at something which doesn't look like a part of defun
+declaration."
   (goto-char start-pos)
   (javaimp-parse--skip-back-until)
   (let* ((fence (save-excursion
diff --git a/tests/parse.el b/tests/parse.el
index d586d4ccaf..b9c8f64d26 100644
--- a/tests/parse.el
+++ b/tests/parse.el
@@ -61,14 +61,29 @@ Exception4<? super Exception5>>")
       (should (equal (javaimp-parse--arglist (point-min) (point-max) t)
                      (cdr data))))))
 
+(ert-deftest javaimp-parse-decl-suffix ()
+  (dolist (data '(;; ok
+                  (" extends C1 {" "extends" . 2)
+                  (" extends C1 implements I1, I2 {" "extends\\|implements" . 
13)
+
+                  ;; fail
+                  (" extends C1 ({" "extends")
+                  ("{" "extends")))
+    (javaimp-with-temp-buffer nil
+      (insert (car data))
+      (should (equal (cddr data)
+                     (javaimp-parse--decl-suffix
+                      (cadr data) (1- (point)) (point-min)))))))
+
 (ert-deftest javaimp-parse-decl-prefix ()
   (dolist (data '(;; simple
                   (" void " . 2)
                   (" public static void " . 2)
 
-                  ;; no sexps
+                  ;; fail - no sexps
+                  ("")
                   (" ")
-                  ;; incomplete sexps
+                  ;; fail - incomplete sexps
                   ("var)")
                   (")   ")
 



reply via email to

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