aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/cedet
diff options
context:
space:
mode:
authorStefan Monnier2016-05-12 13:08:34 -0400
committerStefan Monnier2016-05-12 13:08:34 -0400
commit28e8e49e08c19dd8f23aca4293d9cccc9477f2bf (patch)
tree3ea315057e4c9bf5033aee5f49a77bdcf6e2a708 /lisp/cedet
parent73071b4cdb45deb27052788c5c928ab809e878e0 (diff)
downloademacs-28e8e49e08c19dd8f23aca4293d9cccc9477f2bf.tar.gz
emacs-28e8e49e08c19dd8f23aca4293d9cccc9477f2bf.zip
* 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.
Diffstat (limited to 'lisp/cedet')
-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 a85b9024eb0..e7858ce36b5 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."
79;; Create the database, and add it to searchable databases for Emacs Lisp mode. 79;; Create the database, and add it to searchable databases for Emacs Lisp mode.
80(defvar-mode-local emacs-lisp-mode semanticdb-project-system-databases 80(defvar-mode-local emacs-lisp-mode semanticdb-project-system-databases
81 (list 81 (list
82 (semanticdb-project-database-emacs-lisp "Emacs")) 82 (make-instance 'semanticdb-project-database-emacs-lisp))
83 "Search Emacs core for symbols.") 83 "Search Emacs core for symbols.")
84 84
85(defvar-mode-local emacs-lisp-mode semanticdb-find-default-throttle 85(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."
96 ;; We need to return something since there is always the "master table" 96 ;; We need to return something since there is always the "master table"
97 ;; The table can then answer file name type questions. 97 ;; The table can then answer file name type questions.
98 (when (not (slot-boundp obj 'tables)) 98 (when (not (slot-boundp obj 'tables))
99 (let ((newtable (semanticdb-table-emacs-lisp "Emacs System Table"))) 99 (let ((newtable (make-instance 'semanticdb-table-emacs-lisp)))
100 (oset obj tables (list newtable)) 100 (oset obj tables (list newtable))
101 (oset newtable parent-db obj) 101 (oset newtable parent-db obj)
102 (oset newtable tags nil) 102 (oset newtable tags nil)
diff --git a/lisp/cedet/semantic/symref.el b/lisp/cedet/semantic/symref.el
index 8b3196a3982..a03e99b9886 100644
--- a/lisp/cedet/semantic/symref.el
+++ b/lisp/cedet/semantic/symref.el
@@ -65,6 +65,8 @@
65;; Your tool should then create an instance of `semantic-symref-result'. 65;; Your tool should then create an instance of `semantic-symref-result'.
66 66
67(require 'semantic) 67(require 'semantic)
68(eval-when-compile (require 'semantic/find)) ;For semantic-find-tags-*
69(eval-when-compile (require 'ede/proj)) ;For `metasubproject' warning.
68 70
69(defvar ede-minor-mode) 71(defvar ede-minor-mode)
70(declare-function data-debug-new-buffer "data-debug") 72(declare-function data-debug-new-buffer "data-debug")
@@ -109,7 +111,7 @@ Start with an EDE project, or use the default directory."
109 default-directory))) 111 default-directory)))
110 (if (and rootproj (condition-case nil 112 (if (and rootproj (condition-case nil
111 ;; Hack for subprojects. 113 ;; Hack for subprojects.
112 (oref rootproj :metasubproject) 114 (oref rootproj metasubproject)
113 (error nil))) 115 (error nil)))
114 (ede-up-directory rootdirbase) 116 (ede-up-directory rootdirbase)
115 rootdirbase))) 117 rootdirbase)))
@@ -284,6 +286,80 @@ Returns an object of class `semantic-symref-result'."
284 (semantic-symref-data-debug-last-result)))) 286 (semantic-symref-data-debug-last-result))))
285 ) 287 )
286 288
289;;; SYMREF TOOLS
290;;
291;; The base symref tool provides something to hang new tools off of
292;; for finding symbol references.
293(defclass semantic-symref-tool-baseclass ()
294 ((searchfor :initarg :searchfor
295 :type string
296 :documentation "The thing to search for.")
297 (searchtype :initarg :searchtype
298 :type symbol
299 :documentation "The type of search to do.
300Values could be 'symbol, 'regexp, 'tagname, or 'completion.")
301 (searchscope :initarg :searchscope
302 :type symbol
303 :documentation
304 "The scope to search for.
305Can be 'project, 'target, or 'file.")
306 (resulttype :initarg :resulttype
307 :type symbol
308 :documentation
309 "The kind of search results desired.
310Can be 'line, 'file, or 'tag.
311The type of result can be converted from 'line to 'file, or 'line to 'tag,
312but not from 'file to 'line or 'tag.")
313 )
314 "Baseclass for all symbol references tools.
315A symbol reference tool supplies functionality to identify the locations of
316where different symbols are used.
317
318Subclasses should be named `semantic-symref-tool-NAME', where
319NAME is the name of the tool used in the configuration variable
320`semantic-symref-tool'"
321 :abstract t)
322
323(cl-defmethod semantic-symref-get-result ((tool semantic-symref-tool-baseclass))
324 "Calculate the results of a search based on TOOL.
325The symref TOOL should already contain the search criteria."
326 (let ((answer (semantic-symref-perform-search tool))
327 )
328 (when answer
329 (let ((answersym (if (eq (oref tool resulttype) 'file)
330 :hit-files
331 (if (stringp (car answer))
332 :hit-text
333 :hit-lines))))
334 (semantic-symref-result (oref tool searchfor)
335 answersym
336 answer
337 :created-by tool))
338 )
339 ))
340
341(cl-defmethod semantic-symref-perform-search ((tool semantic-symref-tool-baseclass))
342 "Base search for symref tools should throw an error."
343 (error "Symref tool objects must implement `semantic-symref-perform-search'"))
344
345(cl-defmethod semantic-symref-parse-tool-output ((tool semantic-symref-tool-baseclass)
346 outputbuffer)
347 "Parse the entire OUTPUTBUFFER of a symref tool.
348Calls the method `semantic-symref-parse-tool-output-one-line' over and
349over until it returns nil."
350 (with-current-buffer outputbuffer
351 (goto-char (point-min))
352 (let ((result nil)
353 (hit nil))
354 (while (setq hit (semantic-symref-parse-tool-output-one-line tool))
355 (setq result (cons hit result)))
356 (nreverse result)))
357 )
358
359(cl-defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-baseclass))
360 "Base tool output parser is not implemented."
361 (error "Symref tool objects must implement `semantic-symref-parse-tool-output-one-line'"))
362
287;;; RESULTS 363;;; RESULTS
288;; 364;;
289;; The results class and methods provide features for accessing hits. 365;; 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.")
316 392
317(cl-defmethod semantic-symref-result-get-files ((result semantic-symref-result)) 393(cl-defmethod semantic-symref-result-get-files ((result semantic-symref-result))
318 "Get the list of files from the symref result RESULT." 394 "Get the list of files from the symref result RESULT."
319 (if (slot-boundp result :hit-files) 395 (if (slot-boundp result 'hit-files)
320 (oref result hit-files) 396 (oref result hit-files)
321 (let* ((lines (oref result :hit-lines)) 397 (let* ((lines (oref result hit-lines))
322 (files (mapcar (lambda (a) (cdr a)) lines)) 398 (files (mapcar (lambda (a) (cdr a)) lines))
323 (ans nil)) 399 (ans nil))
324 (setq ans (list (car files)) 400 (setq ans (list (car files))
@@ -359,12 +435,12 @@ Optional OPEN-BUFFERS indicates that the buffers that the hits are
359in should remain open after scanning. 435in should remain open after scanning.
360Note: This can be quite slow if most of the hits are not in buffers 436Note: This can be quite slow if most of the hits are not in buffers
361already." 437already."
362 (if (and (slot-boundp result :hit-tags) (oref result hit-tags)) 438 (if (and (slot-boundp result 'hit-tags) (oref result hit-tags))
363 (oref result hit-tags) 439 (oref result hit-tags)
364 ;; Calculate the tags. 440 ;; Calculate the tags.
365 (let ((lines (oref result :hit-lines)) 441 (let ((lines (oref result hit-lines))
366 (txt (oref (oref result :created-by) :searchfor)) 442 (txt (oref (oref result created-by) searchfor))
367 (searchtype (oref (oref result :created-by) :searchtype)) 443 (searchtype (oref (oref result created-by) searchtype))
368 (ans nil) 444 (ans nil)
369 (out nil)) 445 (out nil))
370 (save-excursion 446 (save-excursion
@@ -390,7 +466,7 @@ already."
390 (semantic--tag-put-property (car out) :hit lines))) 466 (semantic--tag-put-property (car out) :hit lines)))
391 )) 467 ))
392 ;; Out is reversed... twice 468 ;; Out is reversed... twice
393 (oset result :hit-tags (nreverse out))))) 469 (oset result hit-tags (nreverse out)))))
394 470
395(defun semantic-symref-hit-to-tag-via-db (hit searchtxt searchtype) 471(defun semantic-symref-hit-to-tag-via-db (hit searchtxt searchtype)
396 "Convert the symref HIT into a TAG by looking up the tag via a database. 472 "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."
407 (file (cdr hit)) 483 (file (cdr hit))
408 ;; FAIL here vv - don't load is not obeyed if no table found. 484 ;; FAIL here vv - don't load is not obeyed if no table found.
409 (db (semanticdb-file-table-object file t)) 485 (db (semanticdb-file-table-object file t))
410 (found nil) 486 (found
487 (cond ((eq searchtype 'tagname)
488 (semantic-find-tags-by-name searchtxt db))
489 ((eq searchtype 'tagregexp)
490 (semantic-find-tags-by-name-regexp searchtxt db))
491 ((eq searchtype 'tagcompletions)
492 (semantic-find-tags-for-completion searchtxt db))))
411 (hit nil) 493 (hit nil)
412 ) 494 )
413 (cond ((eq searchtype 'tagname)
414 (setq found (semantic-find-tags-by-name searchtxt db)))
415 ((eq searchtype 'tagregexp)
416 (setq found (semantic-find-tags-by-name-regexp searchtxt db)))
417 ((eq searchtype 'tagcompletions)
418 (setq found (semantic-find-tags-for-completion searchtxt db)))
419 )
420 ;; Loop over FOUND to see if we can line up a match with a line number. 495 ;; Loop over FOUND to see if we can line up a match with a line number.
421 (when (= (length found) 1) 496 (when (= (length found) 1)
422 (setq hit (car found))) 497 (setq hit (car found)))
@@ -501,80 +576,6 @@ buffers that were opened."
501 (semantic--tag-put-property tag :hit (list line))) 576 (semantic--tag-put-property tag :hit (list line)))
502 tag)) 577 tag))
503 578
504;;; SYMREF TOOLS
505;;
506;; The base symref tool provides something to hang new tools off of
507;; for finding symbol references.
508(defclass semantic-symref-tool-baseclass ()
509 ((searchfor :initarg :searchfor
510 :type string
511 :documentation "The thing to search for.")
512 (searchtype :initarg :searchtype
513 :type symbol
514 :documentation "The type of search to do.
515Values could be 'symbol, 'regexp, 'tagname, or 'completion.")
516 (searchscope :initarg :searchscope
517 :type symbol
518 :documentation
519 "The scope to search for.
520Can be 'project, 'target, or 'file.")
521 (resulttype :initarg :resulttype
522 :type symbol
523 :documentation
524 "The kind of search results desired.
525Can be 'line, 'file, or 'tag.
526The type of result can be converted from 'line to 'file, or 'line to 'tag,
527but not from 'file to 'line or 'tag.")
528 )
529 "Baseclass for all symbol references tools.
530A symbol reference tool supplies functionality to identify the locations of
531where different symbols are used.
532
533Subclasses should be named `semantic-symref-tool-NAME', where
534NAME is the name of the tool used in the configuration variable
535`semantic-symref-tool'"
536 :abstract t)
537
538(cl-defmethod semantic-symref-get-result ((tool semantic-symref-tool-baseclass))
539 "Calculate the results of a search based on TOOL.
540The symref TOOL should already contain the search criteria."
541 (let ((answer (semantic-symref-perform-search tool))
542 )
543 (when answer
544 (let ((answersym (if (eq (oref tool :resulttype) 'file)
545 :hit-files
546 (if (stringp (car answer))
547 :hit-text
548 :hit-lines))))
549 (semantic-symref-result (oref tool searchfor)
550 answersym
551 answer
552 :created-by tool))
553 )
554 ))
555
556(cl-defmethod semantic-symref-perform-search ((tool semantic-symref-tool-baseclass))
557 "Base search for symref tools should throw an error."
558 (error "Symref tool objects must implement `semantic-symref-perform-search'"))
559
560(cl-defmethod semantic-symref-parse-tool-output ((tool semantic-symref-tool-baseclass)
561 outputbuffer)
562 "Parse the entire OUTPUTBUFFER of a symref tool.
563Calls the method `semantic-symref-parse-tool-output-one-line' over and
564over until it returns nil."
565 (with-current-buffer outputbuffer
566 (goto-char (point-min))
567 (let ((result nil)
568 (hit nil))
569 (while (setq hit (semantic-symref-parse-tool-output-one-line tool))
570 (setq result (cons hit result)))
571 (nreverse result)))
572 )
573
574(cl-defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-baseclass))
575 "Base tool output parser is not implemented."
576 (error "Symref tool objects must implement `semantic-symref-parse-tool-output-one-line'"))
577
578(provide 'semantic/symref) 579(provide 'semantic/symref)
579 580
580;; Local variables: 581;; Local variables: