[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/javaimp 7096049: * javaimp-parse.el: Fix class scope pa
From: |
Filipp Gunbin |
Subject: |
[elpa] externals/javaimp 7096049: * javaimp-parse.el: Fix class scope parsing when declaration contains Enum class name |
Date: |
Fri, 30 Jul 2021 19:06:27 -0400 (EDT) |
branch: externals/javaimp
commit 7096049eaa7a5f7bddedb3baf4fac51c94a5aa86
Author: Filipp Gunbin <fgunbin@fastmail.fm>
Commit: Filipp Gunbin <fgunbin@fastmail.fm>
* javaimp-parse.el: Fix class scope parsing when declaration contains Enum
class name
---
javaimp-parse.el | 21 +++++++++++++++++----
javaimp-tests.el | 2 ++
javaimp-util.el | 14 --------------
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/javaimp-parse.el b/javaimp-parse.el
index e123c2a..fca0369 100644
--- a/javaimp-parse.el
+++ b/javaimp-parse.el
@@ -73,6 +73,19 @@ present."
(string-trim (substring str 0 end))
str)))
+(defun javaimp--parse-rsb-keyword (regexp &optional bound noerror count)
+ "Like `re-search-backward', but count only occurences outside
+syntactic context as given by `syntax-ppss-context'. Assumes
+point is outside of any context initially."
+ (or count (setq count 1))
+ (let ((step (if (>= count 0) 1 -1))
+ (case-fold-search nil)
+ res)
+ (dotimes (_ (abs count))
+ (while (and (setq res (re-search-backward regexp bound noerror step))
+ (syntax-ppss-context (syntax-ppss)))))
+ res))
+
(defun javaimp--parse-arglist (beg end &optional only-type)
"Parse arg list between BEG and END, of the form 'TYPE NAME,
...'. Return list of conses (TYPE . NAME). If ONLY-TYPE is
@@ -178,7 +191,7 @@ is checked to be SKIP-COUNT lists away from the SCOPE-START
(1 is
for scope start itself, so if you want to skip one additional
list, use 2 etc.). If a match is found, then match-data is set,
as for `re-search-backward'."
- (and (javaimp--rsb-outside-context regexp nil t)
+ (and (javaimp--parse-rsb-keyword regexp nil t)
(ignore-errors
;; Does our match belong to the right block?
(= (scan-lists (match-end 0) (or skip-count 1) -1)
@@ -192,7 +205,7 @@ is left before the match. Otherwise, the result is nil and
point
is unchanged."
(let ((pos (point)))
(catch 'found
- (while (javaimp--rsb-outside-context regexp bound t)
+ (while (javaimp--parse-rsb-keyword regexp bound t)
(let ((scan-pos (match-end 0)))
(javaimp--parse-with-arglist-syntax scan-pos
(while (and scan-pos (<= scan-pos (nth 1 state)))
@@ -403,14 +416,14 @@ nil then goes all the way up."
(defun javaimp--parse-get-package ()
(goto-char (point-max))
- (when (javaimp--rsb-outside-context
+ (when (javaimp--parse-rsb-keyword
"^\\s-*package\\s-+\\([^;\n]+\\)\\s-*;" nil t 1)
(match-string 1)))
(defun javaimp--parse-get-file-classes ()
(goto-char (point-max))
(let (res)
- (while (javaimp--rsb-outside-context
+ (while (javaimp--parse-rsb-keyword
(regexp-opt javaimp--parse-class-keywords 'words) nil t)
(save-excursion
(let ((parse-sexp-ignore-comments t) ; FIXME remove with major mode
diff --git a/javaimp-tests.el b/javaimp-tests.el
index d46ee37..0ca4593 100644
--- a/javaimp-tests.el
+++ b/javaimp-tests.el
@@ -58,6 +58,8 @@ implements Interface1<Bar, Baz>, Interface2 {"
class "Foo")
'("class Foo<E extends Bar> {"
class "Foo")
+ '("class Foo<Enum<?>> {"
+ class "Foo")
'("class Foo<T extends Baz<? extends Baz2>> \
extends Bar<? extends Baz<? extends Baz2>> {"
class "Foo")
diff --git a/javaimp-util.el b/javaimp-util.el
index 0231f17..1544cc4 100644
--- a/javaimp-util.el
+++ b/javaimp-util.el
@@ -137,20 +137,6 @@ buffer and returns its result"
(concat "[" path-separator "\n]+")
t)))
-
-(defun javaimp--rsb-outside-context (regexp &optional bound noerror count)
- "Like `re-search-backward', but count only occurences outside
-syntactic context as given by `syntax-ppss-context'. Assumes
-point is outside of any context initially."
- (or count (setq count 1))
- (let ((step (if (>= count 0) 1 -1))
- res)
- (dotimes (_ (abs count))
- (while (and (setq res (re-search-backward regexp bound noerror step))
- (syntax-ppss-context (syntax-ppss)))))
- res))
-
-
;; Tree building & search
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/javaimp 7096049: * javaimp-parse.el: Fix class scope parsing when declaration contains Enum class name,
Filipp Gunbin <=