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

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

[elpa] externals/javaimp c04cfe7: * javaimp-parse.el (javaimp--parse-sco


From: Filipp Gunbin
Subject: [elpa] externals/javaimp c04cfe7: * javaimp-parse.el (javaimp--parse-scopes): Reset tail of unknown scope
Date: Tue, 16 Nov 2021 10:03:51 -0500 (EST)

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

    * javaimp-parse.el (javaimp--parse-scopes): Reset tail of unknown scope
---
 javaimp-parse.el | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/javaimp-parse.el b/javaimp-parse.el
index 9c12350..7d28cc4 100644
--- a/javaimp-parse.el
+++ b/javaimp-parse.el
@@ -325,7 +325,11 @@ the position of opening brace.")
   "Attempts to parse COUNT enclosing scopes at point.  Returns most
 nested one, with its parents sets accordingly.  If COUNT is nil
 then goes all the way up.  Examines and sets property
-'javaimp-parse-scope' at each scope's open brace."
+'javaimp-parse-scope' at each scope's open brace.  If neither of
+functions in `javaimp--parse-scope-hook' return non-nil then the
+property value is set to the symbol `unknown'.  Additionally, if
+a scope is recognized, but any of its parents is 'unknown', then
+it's set to 'unknown' too."
   (let ((state (syntax-ppss))
         res)
     (unless (syntax-ppss-context state)
@@ -338,19 +342,28 @@ then goes all the way up.  Examines and sets property
           (let ((scope (get-text-property (point) 'javaimp-parse-scope)))
             (unless scope
               (setq scope (or (run-hook-with-args-until-success
-                               'javaimp--parse-scope-hook (nth 1 state))
+                               'javaimp--parse-scope-hook (point))
                               'unknown))
               (put-text-property (point) (1+ (point))
                                  'javaimp-parse-scope scope))
-            (when (javaimp-scope-p scope)
-              (push scope res)
-              (if (javaimp-scope-start scope)
-                  (goto-char (javaimp-scope-start scope))))))
+            (push scope res)
+            (when (and (javaimp-scope-p scope)
+                       (javaimp-scope-start scope))
+              (goto-char (javaimp-scope-start scope)))))
         (setq state (syntax-ppss))))
-    (let (parent)
+    (let (parent reset-tail)
       (while res
-        (setf (javaimp-scope-parent (car res)) parent)
-        (setq parent (car res))
+        (if reset-tail
+            (when (javaimp-scope-p (car res))
+              (let ((pos (javaimp-scope-open-brace (car res))))
+                (put-text-property pos (1+ pos) 'javaimp-parse-scope 
'unknown)))
+          (if (javaimp-scope-p (car res))
+              (progn
+                (setf (javaimp-scope-parent (car res)) parent)
+                (setq parent (car res)))
+            ;; Just reset remaining scopes, and return nil
+            (setq reset-tail t)
+            (setq parent nil)))
         (setq res (cdr res)))
       parent)))
 



reply via email to

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