summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2016-05-12 13:08:34 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2016-05-12 13:08:34 -0400
commit28e8e49e08c19dd8f23aca4293d9cccc9477f2bf (patch)
tree3ea315057e4c9bf5033aee5f49a77bdcf6e2a708
parent73071b4cdb45deb27052788c5c928ab809e878e0 (diff)
* lisp/cedet/semantic: Silence some warnings
* lisp/cedet/semantic/db-el.el (emacs-lisp-mode) (semanticdb-get-database-tables): Use make-instance to silence warnings. * lisp/cedet/semantic/symref.el: Require semantic/find since we use some macros from there. Silence compilation warnings: Replace initargs with slot names in oref/oset. Move `SYMREF TOOLS' section earlier so definitions precede their use.
-rw-r--r--lisp/cedet/semantic/db-el.el4
-rw-r--r--lisp/cedet/semantic/symref.el181
2 files changed, 93 insertions, 92 deletions
diff --git a/lisp/cedet/semantic/db-el.el b/lisp/cedet/semantic/db-el.el
index a85b9024eb..e7858ce36b 100644
--- a/lisp/cedet/semantic/db-el.el
+++ b/lisp/cedet/semantic/db-el.el
@@ -79,7 +79,7 @@ Adds the number of tags in this file to the object print name."
;; Create the database, and add it to searchable databases for Emacs Lisp mode.
(defvar-mode-local emacs-lisp-mode semanticdb-project-system-databases
(list
- (semanticdb-project-database-emacs-lisp "Emacs"))
+ (make-instance 'semanticdb-project-database-emacs-lisp))
"Search Emacs core for symbols.")
(defvar-mode-local emacs-lisp-mode semanticdb-find-default-throttle
@@ -96,7 +96,7 @@ Create one of our special tables that can act as an intermediary."
;; We need to return something since there is always the "master table"
;; The table can then answer file name type questions.
(when (not (slot-boundp obj 'tables))
- (let ((newtable (semanticdb-table-emacs-lisp "Emacs System Table")))
+ (let ((newtable (make-instance 'semanticdb-table-emacs-lisp)))
(oset obj tables (list newtable))
(oset newtable parent-db obj)
(oset newtable tags nil)
diff --git a/lisp/cedet/semantic/symref.el b/lisp/cedet/semantic/symref.el
index 8b3196a398..a03e99b988 100644
--- a/lisp/cedet/semantic/symref.el
+++ b/lisp/cedet/semantic/symref.el
@@ -65,6 +65,8 @@
;; Your tool should then create an instance of `semantic-symref-result'.
(require 'semantic)
+(eval-when-compile (require 'semantic/find)) ;For semantic-find-tags-*
+(eval-when-compile (require 'ede/proj)) ;For `metasubproject' warning.
(defvar ede-minor-mode)
(declare-function data-debug-new-buffer "data-debug")
@@ -109,7 +111,7 @@ Start with an EDE project, or use the default directory."
default-directory)))
(if (and rootproj (condition-case nil
;; Hack for subprojects.
- (oref rootproj :metasubproject)
+ (oref rootproj metasubproject)
(error nil)))
(ede-up-directory rootdirbase)
rootdirbase)))
@@ -284,6 +286,80 @@ Returns an object of class `semantic-symref-result'."
(semantic-symref-data-debug-last-result))))
)
+;;; SYMREF TOOLS
+;;
+;; The base symref tool provides something to hang new tools off of
+;; for finding symbol references.
+(defclass semantic-symref-tool-baseclass ()
+ ((searchfor :initarg :searchfor
+ :type string
+ :documentation "The thing to search for.")
+ (searchtype :initarg :searchtype
+ :type symbol
+ :documentation "The type of search to do.
+Values could be 'symbol, 'regexp, 'tagname, or 'completion.")
+ (searchscope :initarg :searchscope
+ :type symbol
+ :documentation
+ "The scope to search for.
+Can be 'project, 'target, or 'file.")
+ (resulttype :initarg :resulttype
+ :type symbol
+ :documentation
+ "The kind of search results desired.
+Can be 'line, 'file, or 'tag.
+The type of result can be converted from 'line to 'file, or 'line to 'tag,
+but not from 'file to 'line or 'tag.")
+ )
+ "Baseclass for all symbol references tools.
+A symbol reference tool supplies functionality to identify the locations of
+where different symbols are used.
+
+Subclasses should be named `semantic-symref-tool-NAME', where
+NAME is the name of the tool used in the configuration variable
+`semantic-symref-tool'"
+ :abstract t)
+
+(cl-defmethod semantic-symref-get-result ((tool semantic-symref-tool-baseclass))
+ "Calculate the results of a search based on TOOL.
+The symref TOOL should already contain the search criteria."
+ (let ((answer (semantic-symref-perform-search tool))
+ )
+ (when answer
+ (let ((answersym (if (eq (oref tool resulttype) 'file)
+ :hit-files
+ (if (stringp (car answer))
+ :hit-text
+ :hit-lines))))
+ (semantic-symref-result (oref tool searchfor)
+ answersym
+ answer
+ :created-by tool))
+ )
+ ))
+
+(cl-defmethod semantic-symref-perform-search ((tool semantic-symref-tool-baseclass))
+ "Base search for symref tools should throw an error."
+ (error "Symref tool objects must implement `semantic-symref-perform-search'"))
+
+(cl-defmethod semantic-symref-parse-tool-output ((tool semantic-symref-tool-baseclass)
+ outputbuffer)
+ "Parse the entire OUTPUTBUFFER of a symref tool.
+Calls the method `semantic-symref-parse-tool-output-one-line' over and
+over until it returns nil."
+ (with-current-buffer outputbuffer
+ (goto-char (point-min))
+ (let ((result nil)
+ (hit nil))
+ (while (setq hit (semantic-symref-parse-tool-output-one-line tool))
+ (setq result (cons hit result)))
+ (nreverse result)))
+ )
+
+(cl-defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-baseclass))
+ "Base tool output parser is not implemented."
+ (error "Symref tool objects must implement `semantic-symref-parse-tool-output-one-line'"))
+
;;; RESULTS
;;
;; The results class and methods provide features for accessing hits.
@@ -316,9 +392,9 @@ Use the `semantic-symref-hit-tags' method to get this list.")
(cl-defmethod semantic-symref-result-get-files ((result semantic-symref-result))
"Get the list of files from the symref result RESULT."
- (if (slot-boundp result :hit-files)
+ (if (slot-boundp result 'hit-files)
(oref result hit-files)
- (let* ((lines (oref result :hit-lines))
+ (let* ((lines (oref result hit-lines))
(files (mapcar (lambda (a) (cdr a)) lines))
(ans nil))
(setq ans (list (car files))
@@ -359,12 +435,12 @@ Optional OPEN-BUFFERS indicates that the buffers that the hits are
in should remain open after scanning.
Note: This can be quite slow if most of the hits are not in buffers
already."
- (if (and (slot-boundp result :hit-tags) (oref result hit-tags))
+ (if (and (slot-boundp result 'hit-tags) (oref result hit-tags))
(oref result hit-tags)
;; Calculate the tags.
- (let ((lines (oref result :hit-lines))
- (txt (oref (oref result :created-by) :searchfor))
- (searchtype (oref (oref result :created-by) :searchtype))
+ (let ((lines (oref result hit-lines))
+ (txt (oref (oref result created-by) searchfor))
+ (searchtype (oref (oref result created-by) searchtype))
(ans nil)
(out nil))
(save-excursion
@@ -390,7 +466,7 @@ already."
(semantic--tag-put-property (car out) :hit lines)))
))
;; Out is reversed... twice
- (oset result :hit-tags (nreverse out)))))
+ (oset result hit-tags (nreverse out)))))
(defun semantic-symref-hit-to-tag-via-db (hit searchtxt searchtype)
"Convert the symref HIT into a TAG by looking up the tag via a database.
@@ -407,16 +483,15 @@ If there is no database, of if the searchtype is wrong, return nil."
(file (cdr hit))
;; FAIL here vv - don't load is not obeyed if no table found.
(db (semanticdb-file-table-object file t))
- (found nil)
+ (found
+ (cond ((eq searchtype 'tagname)
+ (semantic-find-tags-by-name searchtxt db))
+ ((eq searchtype 'tagregexp)
+ (semantic-find-tags-by-name-regexp searchtxt db))
+ ((eq searchtype 'tagcompletions)
+ (semantic-find-tags-for-completion searchtxt db))))
(hit nil)
)
- (cond ((eq searchtype 'tagname)
- (setq found (semantic-find-tags-by-name searchtxt db)))
- ((eq searchtype 'tagregexp)
- (setq found (semantic-find-tags-by-name-regexp searchtxt db)))
- ((eq searchtype 'tagcompletions)
- (setq found (semantic-find-tags-for-completion searchtxt db)))
- )
;; Loop over FOUND to see if we can line up a match with a line number.
(when (= (length found) 1)
(setq hit (car found)))
@@ -501,80 +576,6 @@ buffers that were opened."
(semantic--tag-put-property tag :hit (list line)))
tag))
-;;; SYMREF TOOLS
-;;
-;; The base symref tool provides something to hang new tools off of
-;; for finding symbol references.
-(defclass semantic-symref-tool-baseclass ()
- ((searchfor :initarg :searchfor
- :type string
- :documentation "The thing to search for.")
- (searchtype :initarg :searchtype
- :type symbol
- :documentation "The type of search to do.
-Values could be 'symbol, 'regexp, 'tagname, or 'completion.")
- (searchscope :initarg :searchscope
- :type symbol
- :documentation
- "The scope to search for.
-Can be 'project, 'target, or 'file.")
- (resulttype :initarg :resulttype
- :type symbol
- :documentation
- "The kind of search results desired.
-Can be 'line, 'file, or 'tag.
-The type of result can be converted from 'line to 'file, or 'line to 'tag,
-but not from 'file to 'line or 'tag.")
- )
- "Baseclass for all symbol references tools.
-A symbol reference tool supplies functionality to identify the locations of
-where different symbols are used.
-
-Subclasses should be named `semantic-symref-tool-NAME', where
-NAME is the name of the tool used in the configuration variable
-`semantic-symref-tool'"
- :abstract t)
-
-(cl-defmethod semantic-symref-get-result ((tool semantic-symref-tool-baseclass))
- "Calculate the results of a search based on TOOL.
-The symref TOOL should already contain the search criteria."
- (let ((answer (semantic-symref-perform-search tool))
- )
- (when answer
- (let ((answersym (if (eq (oref tool :resulttype) 'file)
- :hit-files
- (if (stringp (car answer))
- :hit-text
- :hit-lines))))
- (semantic-symref-result (oref tool searchfor)
- answersym
- answer
- :created-by tool))
- )
- ))
-
-(cl-defmethod semantic-symref-perform-search ((tool semantic-symref-tool-baseclass))
- "Base search for symref tools should throw an error."
- (error "Symref tool objects must implement `semantic-symref-perform-search'"))
-
-(cl-defmethod semantic-symref-parse-tool-output ((tool semantic-symref-tool-baseclass)
- outputbuffer)
- "Parse the entire OUTPUTBUFFER of a symref tool.
-Calls the method `semantic-symref-parse-tool-output-one-line' over and
-over until it returns nil."
- (with-current-buffer outputbuffer
- (goto-char (point-min))
- (let ((result nil)
- (hit nil))
- (while (setq hit (semantic-symref-parse-tool-output-one-line tool))
- (setq result (cons hit result)))
- (nreverse result)))
- )
-
-(cl-defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-baseclass))
- "Base tool output parser is not implemented."
- (error "Symref tool objects must implement `semantic-symref-parse-tool-output-one-line'"))
-
(provide 'semantic/symref)
;; Local variables: