]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Semantic tag discovery when loading of unloaded files is suppressed
authorPo Lu <luangruo@yahoo.com>
Fri, 5 Apr 2024 02:39:33 +0000 (10:39 +0800)
committerEshel Yaron <me@eshelyaron.com>
Fri, 5 Apr 2024 12:12:13 +0000 (14:12 +0200)
* lisp/cedet/semantic/db-find.el
(semanticdb-find-tags-by-name-method)
(semanticdb-find-tags-by-name-regexp-method)
(semanticdb-find-tags-for-completion-method)
(semanticdb-find-tags-by-class-method)
(semanticdb-find-tags-external-children-of-type-method)
(semanticdb-find-tags-subclasses-of-type-method)
(semanticdb-deep-find-tags-by-name-method)
(semanticdb-deep-find-tags-by-name-regexp-method)
(semanticdb-deep-find-tags-for-completion-method): Verify that
tags is bound before accessing it; this slot is unbound in
tables created for unloaded files when the `unloaded' throttle
is disabled.

(cherry picked from commit 3968b36ae0641e929426991028b49ce66a15af5f)

lisp/cedet/semantic/db-find.el

index 6d42c3125c0adc23119bdcb843bd6a4d58659aa3..551f86a792ebba483295e28776c7d68cf0ffab90 100644 (file)
@@ -1307,19 +1307,25 @@ associated with that tag should be loaded into a buffer."
   "In TABLE, find all occurrences of tags with NAME.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
-  (semantic-find-tags-by-name name (or tags (semanticdb-get-tags table))))
+  (semantic-find-tags-by-name name
+                              (or tags (and (slot-boundp table 'tags)
+                                            (semanticdb-get-tags table)))))
 
 (cl-defmethod semanticdb-find-tags-by-name-regexp-method ((table semanticdb-abstract-table) regexp &optional tags)
   "In TABLE, find all occurrences of tags matching REGEXP.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
-  (semantic-find-tags-by-name-regexp regexp (or tags (semanticdb-get-tags table))))
+  (semantic-find-tags-by-name-regexp regexp
+                                     (or tags (and (slot-boundp table 'tags)
+                                                   (semanticdb-get-tags table)))))
 
 (cl-defmethod semanticdb-find-tags-for-completion-method ((table semanticdb-abstract-table) prefix &optional tags)
   "In TABLE, find all occurrences of tags matching PREFIX.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
-  (semantic-find-tags-for-completion prefix (or tags (semanticdb-get-tags table))))
+  (semantic-find-tags-for-completion prefix
+                                     (or tags (and (slot-boundp table 'tags)
+                                                   (semanticdb-get-tags table)))))
 
 (cl-defmethod semanticdb-find-tags-by-class-method ((table semanticdb-abstract-table) class &optional tags)
   "In TABLE, find all occurrences of tags of CLASS.
@@ -1329,8 +1335,12 @@ Returns a table of all matching tags."
   ;; `semantic-find-tags-included', which by default will just call
   ;; `semantic-find-tags-by-class'.
   (if (eq class 'include)
-      (semantic-find-tags-included (or tags (semanticdb-get-tags table)))
-    (semantic-find-tags-by-class class (or tags (semanticdb-get-tags table)))))
+      (semantic-find-tags-included
+       (or tags (and (slot-boundp table 'tags)
+                     (semanticdb-get-tags table))))
+    (semantic-find-tags-by-class class
+                                 (or tags (and (slot-boundp table 'tags)
+                                               (semanticdb-get-tags table))))))
 
 (declare-function semantic-find-tags-external-children-of-type
                  "semantic/find" (type &optional table))
@@ -1340,7 +1350,9 @@ Returns a table of all matching tags."
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
    (require 'semantic/find)
-   (semantic-find-tags-external-children-of-type parent (or tags (semanticdb-get-tags table))))
+   (semantic-find-tags-external-children-of-type
+    parent (or tags (and (slot-boundp table 'tags)
+                         (semanticdb-get-tags table)))))
 
 (declare-function semantic-find-tags-subclasses-of-type
                  "semantic/find" (type &optional table))
@@ -1350,7 +1362,9 @@ Returns a table of all matching tags."
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
    (require 'semantic/find)
-   (semantic-find-tags-subclasses-of-type parent (or tags (semanticdb-get-tags table))))
+   (semantic-find-tags-subclasses-of-type
+    parent (or tags (and (slot-boundp table 'tags)
+                         (semanticdb-get-tags table)))))
 
 ;;; Deep Searches
 (cl-defmethod semanticdb-deep-find-tags-by-name-method ((table semanticdb-abstract-table) name &optional tags)
@@ -1359,7 +1373,10 @@ Search in all tags in TABLE, and all components of top level tags in
 TABLE.
 Optional argument TAGS is a list of tags to search.
 Return a table of all matching tags."
-  (semantic-find-tags-by-name name (semantic-flatten-tags-table (or tags (semanticdb-get-tags table)))))
+  (semantic-find-tags-by-name
+   name (semantic-flatten-tags-table
+         (or tags (and (slot-boundp table 'tags)
+                       (semanticdb-get-tags table))))))
 
 (cl-defmethod semanticdb-deep-find-tags-by-name-regexp-method ((table semanticdb-abstract-table) regexp &optional tags)
   "In TABLE, find all occurrences of tags matching REGEXP.
@@ -1367,7 +1384,10 @@ Search in all tags in TABLE, and all components of top level tags in
 TABLE.
 Optional argument TAGS is a list of tags to search.
 Return a table of all matching tags."
-  (semantic-find-tags-by-name-regexp regexp (semantic-flatten-tags-table (or tags (semanticdb-get-tags table)))))
+  (semantic-find-tags-by-name-regexp
+   regexp (semantic-flatten-tags-table
+           (or tags (and (slot-boundp table 'tags)
+                         (semanticdb-get-tags table))))))
 
 (cl-defmethod semanticdb-deep-find-tags-for-completion-method ((table semanticdb-abstract-table) prefix &optional tags)
   "In TABLE, find all occurrences of tags matching PREFIX.
@@ -1375,7 +1395,11 @@ Search in all tags in TABLE, and all components of top level tags in
 TABLE.
 Optional argument TAGS is a list of tags to search.
 Return a table of all matching tags."
-  (semantic-find-tags-for-completion prefix (semantic-flatten-tags-table (or tags (semanticdb-get-tags table)))))
+  (semantic-find-tags-for-completion
+   prefix
+   (semantic-flatten-tags-table
+           (or tags (and (slot-boundp table 'tags)
+                         (semanticdb-get-tags table))))))
 
 (provide 'semantic/db-find)