[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/javaimp 3c5faf1: Remove 'unknown' scope and parse only
From: |
Filipp Gunbin |
Subject: |
[elpa] externals/javaimp 3c5faf1: Remove 'unknown' scope and parse only classes in javaimp--get-file-classes |
Date: |
Thu, 11 Nov 2021 13:05:58 -0500 (EST) |
branch: externals/javaimp
commit 3c5faf1432e3e5d6b3c42d6220483549ad8f3bf2
Author: Filipp Gunbin <fgunbin@fastmail.fm>
Commit: Filipp Gunbin <fgunbin@fastmail.fm>
Remove 'unknown' scope and parse only classes in javaimp--get-file-classes
This gives 2.5x perfomance improvement.
---
javaimp-parse.el | 22 ++++++++--------------
javaimp-util.el | 4 +---
javaimp.el | 5 ++++-
3 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/javaimp-parse.el b/javaimp-parse.el
index ebe1576..9c12350 100644
--- a/javaimp-parse.el
+++ b/javaimp-parse.el
@@ -201,7 +201,6 @@ is unchanged."
javaimp--parse-scope-class
javaimp--parse-scope-simple-stmt
javaimp--parse-scope-method-or-stmt
- javaimp--parse-scope-unknown
)
"List of parser functions, each of which is called with BRACE-POS,
the position of opening brace.")
@@ -322,13 +321,6 @@ the position of opening brace.")
:start nil
:open-brace brace-pos))))
-(defun javaimp--parse-scope-unknown (brace-pos)
- "Catch-all parser which produces 'unknown' scope."
- (make-javaimp-scope :type 'unknown
- :name "unknown"
- :start nil
- :open-brace brace-pos))
-
(defun javaimp--parse-scopes (count)
"Attempts to parse COUNT enclosing scopes at point. Returns most
nested one, with its parents sets accordingly. If COUNT is nil
@@ -345,13 +337,15 @@ then goes all the way up. Examines and sets property
(when (= (char-after) ?{)
(let ((scope (get-text-property (point) 'javaimp-parse-scope)))
(unless scope
- (setq scope (run-hook-with-args-until-success
- 'javaimp--parse-scope-hook (nth 1 state)))
+ (setq scope (or (run-hook-with-args-until-success
+ 'javaimp--parse-scope-hook (nth 1 state))
+ 'unknown))
(put-text-property (point) (1+ (point))
'javaimp-parse-scope scope))
- (push scope res)
- (if (javaimp-scope-start scope)
- (goto-char (javaimp-scope-start scope)))))
+ (when (javaimp-scope-p scope)
+ (push scope res)
+ (if (javaimp-scope-start scope)
+ (goto-char (javaimp-scope-start scope))))))
(setq state (syntax-ppss))))
(let (parent)
(while res
@@ -459,7 +453,7 @@ them should move point."
scope res)
(while (setq pos (previous-single-property-change pos
'javaimp-parse-scope))
(setq scope (get-text-property pos 'javaimp-parse-scope))
- (when (and scope
+ (when (and (javaimp-scope-p scope)
(or (null pred)
(funcall pred scope)))
(setq scope (javaimp--copy-scope scope))
diff --git a/javaimp-util.el b/javaimp-util.el
index 32eecfe..a4569b9 100644
--- a/javaimp-util.el
+++ b/javaimp-util.el
@@ -37,8 +37,7 @@
method
simple-statement
statement
- array
- unknown)
+ array)
javaimp--classlike-scope-types))
(defconst javaimp--help-scope-type-abbrevs
@@ -46,7 +45,6 @@
(statement . "st")
(simple-statement . "ss")
(array . "ar")
- (unknown . "un")
(method . "me")
(class . "cl")
(interface . "in")
diff --git a/javaimp.el b/javaimp.el
index ed4cc16..722095e 100644
--- a/javaimp.el
+++ b/javaimp.el
@@ -510,7 +510,10 @@ If there's no such directive, then the last resort is just
(javaimp--get-buffer-classes))))
(with-temp-buffer
(insert-file-contents file)
- (javaimp--get-buffer-classes))))
+ ;; We need only class-likes, and this is temp buffer, so for
+ ;; efficiency avoid parsing anything else
+ (let ((javaimp--parse-scope-hook #'javaimp--parse-scope-class))
+ (javaimp--get-buffer-classes)))))
(defun javaimp--get-buffer-classes ()
"Return fully-qualified names of all class-like scopes."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/javaimp 3c5faf1: Remove 'unknown' scope and parse only classes in javaimp--get-file-classes,
Filipp Gunbin <=