1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

Fix Semantic tag discovery when loading of unloaded files is suppressed

* 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.
This commit is contained in:
Po Lu 2024-04-05 10:39:33 +08:00
parent 21f9be0053
commit 3968b36ae0

View 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)