aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2009-08-31 00:13:42 +0000
committerChong Yidong2009-08-31 00:13:42 +0000
commitafa85dfef0d74a70c383cdcd7ed7dc10f4e50025 (patch)
tree86ed68f34787bc39b461e2f58f2eb9516fbe70a4
parentaa8724aeadb56751cb464fd5ebbf5f2e631fd3fa (diff)
downloademacs-afa85dfef0d74a70c383cdcd7ed7dc10f4e50025.tar.gz
emacs-afa85dfef0d74a70c383cdcd7ed7dc10f4e50025.zip
cedet/semantic/db-search.el: File removed (obsolete).
-rw-r--r--lisp/cedet/semantic/db-search.el451
1 files changed, 0 insertions, 451 deletions
diff --git a/lisp/cedet/semantic/db-search.el b/lisp/cedet/semantic/db-search.el
deleted file mode 100644
index acfb788fe16..00000000000
--- a/lisp/cedet/semantic/db-search.el
+++ /dev/null
@@ -1,451 +0,0 @@
1;;; db-search.el --- Searching through semantic databases.
2
3;;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2008, 2009
4;;; Free Software Foundation, Inc.
5
6;; Author: Eric M. Ludlam <zappo@gnu.org>
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23;;; Commentary:
24;;
25;; NOTE: THESE APIs ARE OBSOLETE:
26;;
27;; Databases of various forms can all be searched. These routines
28;; cover many common forms of searching.
29;;
30;; There are three types of searches that can be implemented:
31;;
32;; Basic Search:
33;; These searches allow searching on specific attributes of tags,
34;; such as name or type.
35;;
36;; Advanced Search:
37;; These are searches that were needed to accomplish some tasks
38;; during in utilities. Advanced searches include matching methods
39;; defined outside some parent class.
40;;
41;; The reason for advanced searches are so that external
42;; repositories such as the Emacs obarray, or java .class files can
43;; quickly answer these needed questions without dumping the entire
44;; symbol list into Emacs for a regular semanticdb search.
45;;
46;; Generic Search:
47;; The generic search, `semanticdb-find-nonterminal-by-function'
48;; accepts a Emacs Lisp predicate that tests tags in Semantic
49;; format. Most external searches cannot perform this search.
50
51(require 'semantic/db)
52(require 'semantic/find)
53
54;;; Code:
55;;
56;;; Classes:
57
58;; @TODO MOVE THIS CLASS?
59(defclass semanticdb-search-results-table (semanticdb-abstract-table)
60 (
61 )
62 "Table used for search results when there is no file or table association.
63Examples include search results from external sources such as from
64Emacs' own symbol table, or from external libraries.")
65
66(defmethod semanticdb-refresh-table ((obj semanticdb-search-results-table) &optional force)
67 "If the tag list associated with OBJ is loaded, refresh it.
68This will call `semantic-fetch-tags' if that file is in memory."
69 nil)
70
71;;; Utils
72;;
73;; Convenience routines for searches
74(defun semanticdb-collect-find-results (result-in-databases
75 result-finding-function
76 ignore-system
77 find-file-on-match)
78 "OBSOLETE:
79Collect results across RESULT-IN-DATABASES for RESULT-FINDING-FUNCTION.
80If RESULT-IN-DATABASES is nil, search a range of associated databases
81calculated by `semanticdb-current-database-list'.
82RESULT-IN-DATABASES is a list of variable `semanticdb-project-database'
83objects.
84RESULT-FINDING-FUNCTION should accept one argument, the database being searched.
85Argument IGNORE-SYSTEM specifies if any available system databases should
86be ignored, or searched.
87Argument FIND-FILE-ON-MATCH indicates that the found databases
88should be capable of doing so."
89 (if (not (listp result-in-databases))
90 (signal 'wrong-type-argument (list 'listp result-in-databases)))
91 (let* ((semanticdb-search-system-databases
92 (if ignore-system
93 nil
94 semanticdb-search-system-databases))
95 (dbs (or result-in-databases
96 ;; Calculate what database to use.
97 ;; Something simple and dumb for now.
98 (or (semanticdb-current-database-list)
99 (list (semanticdb-current-database)))))
100 (case-fold-search semantic-case-fold)
101 (res (mapcar
102 (lambda (db)
103 (if (or (not find-file-on-match)
104 (not (child-of-class-p
105 (oref db new-table-class)
106 semanticdb-search-results-table)))
107 (funcall result-finding-function db)))
108 dbs))
109 out)
110 ;; Flatten the list. The DB is unimportant at this stage.
111 (setq res (apply 'append res))
112 (setq out nil)
113 ;; Move across results, and throw out empties.
114 (while res
115 (if (car res)
116 (setq out (cons (car res) out)))
117 (setq res (cdr res)))
118 ;; Results
119 out))
120
121;;; Programatic interfaces
122;;
123;; These routines all perform different types of searches, and are
124;; interfaces to the database methods used to also perform those searches.
125
126(defun semanticdb-find-nonterminal-by-token
127 (token &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
128 "OBSOLETE:
129Find all occurances of nonterminals with token TOKEN in databases.
130See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
131SEARCH-PARTS, SEARCH-INCLUDES, DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
132Return a list ((DB-TABLE . TOKEN-LIST) ...)."
133 (semanticdb-collect-find-results
134 databases
135 (lambda (db)
136 (semanticdb-find-nonterminal-by-token-method
137 db token search-parts search-includes diff-mode find-file-match))
138 ignore-system
139 find-file-match))
140(make-obsolete 'semanticdb-find-nonterminal-by-token
141 "Please don't use this function")
142
143(defun semanticdb-find-nonterminal-by-name
144 (name &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
145 "OBSOLETE:
146Find all occurances of nonterminals with name NAME in databases.
147See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
148SEARCH-PARTS, SEARCH-INCLUDES, DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
149Return a list ((DB-TABLE . TOKEN) ...)."
150 (semanticdb-collect-find-results
151 databases
152 (lambda (db)
153 (semanticdb-find-nonterminal-by-name-method
154 db name search-parts search-includes diff-mode find-file-match))
155 ignore-system
156 find-file-match))
157(make-obsolete 'semanticdb-find-nonterminal-by-name
158 "Please don't use this function")
159
160(defun semanticdb-find-nonterminal-by-name-regexp
161 (regex &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
162 "OBSOLETE:
163Find all occurances of nonterminals with name matching REGEX in databases.
164See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
165SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
166Return a list ((DB-TABLE . TOKEN-LIST) ...)."
167 (semanticdb-collect-find-results
168 databases
169 (lambda (db)
170 (semanticdb-find-nonterminal-by-name-regexp-method
171 db regex search-parts search-includes diff-mode find-file-match))
172 ignore-system
173 find-file-match))
174(make-obsolete 'semanticdb-find-nonterminal-by-name-regexp
175 "Please don't use this function")
176
177
178(defun semanticdb-find-nonterminal-by-type
179 (type &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
180 "OBSOLETE:
181Find all nonterminals with a type of TYPE in databases.
182See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
183SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
184Return a list ((DB-TABLE . TOKEN-LIST) ...)."
185 (semanticdb-collect-find-results
186 databases
187 (lambda (db)
188 (semanticdb-find-nonterminal-by-type-method
189 db type search-parts search-includes diff-mode find-file-match))
190 ignore-system
191 find-file-match))
192(make-obsolete 'semanticdb-find-nonterminal-by-type
193 "Please don't use this function")
194
195
196(defun semanticdb-find-nonterminal-by-property
197 (property value &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
198 "OBSOLETE:
199Find all nonterminals with a PROPERTY equal to VALUE in databases.
200See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
201SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
202Return a list ((DB-TABLE . TOKEN-LIST) ...)."
203 (semanticdb-collect-find-results
204 databases
205 (lambda (db)
206 (semanticdb-find-nonterminal-by-property-method
207 db property value search-parts search-includes diff-mode find-file-match))
208 ignore-system
209 find-file-match))
210(make-obsolete 'semanticdb-find-nonterminal-by-property
211 "Please don't use this function")
212
213(defun semanticdb-find-nonterminal-by-extra-spec
214 (spec &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
215 "OBSOLETE:
216Find all nonterminals with a SPEC in databases.
217See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
218SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
219Return a list ((DB-TABLE . TOKEN-LIST) ...)."
220 (semanticdb-collect-find-results
221 databases
222 (lambda (db)
223 (semanticdb-find-nonterminal-by-extra-spec-method
224 db spec search-parts search-includes diff-mode find-file-match))
225 ignore-system
226 find-file-match))
227(make-obsolete 'semanticdb-find-nonterminal-by-extra-spec
228 "Please don't use this function")
229
230(defun semanticdb-find-nonterminal-by-extra-spec-value
231 (spec value &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
232 "OBSOLETE:
233Find all nonterminals with a SPEC equal to VALUE in databases.
234See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
235SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
236Return a list ((DB-TABLE . TOKEN-LIST) ...)."
237 (semanticdb-collect-find-results
238 databases
239 (lambda (db)
240 (semanticdb-find-nonterminal-by-extra-spec-value-method
241 db spec value search-parts search-includes diff-mode find-file-match))
242 ignore-system
243 find-file-match))
244(make-obsolete 'semanticdb-find-nonterminal-by-extra-spec-value
245 "Please don't use this function")
246
247;;; Advanced Search Routines
248;;
249(defun semanticdb-find-nonterminal-external-children-of-type
250 (type &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
251 "OBSOLETE:
252Find all nonterminals which are child elements of TYPE.
253See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
254SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
255Return a list ((DB-TABLE . TOKEN-LIST) ...)."
256 (semanticdb-collect-find-results
257 databases
258 (lambda (db)
259 (semanticdb-find-nonterminal-external-children-of-type-method
260 db type search-parts search-includes diff-mode find-file-match))
261 ignore-system
262 find-file-match))
263
264;;; Generic Search routine
265;;
266
267(defun semanticdb-find-nonterminal-by-function
268 (function &optional databases search-parts search-includes diff-mode find-file-match ignore-system)
269 "OBSOLETE:
270Find all occurances of nonterminals which match FUNCTION.
271Search in all DATABASES. If DATABASES is nil, search a range of
272associated databases calculated `semanticdb-current-database-list' and
273DATABASES is a list of variable `semanticdb-project-database' objects.
274When SEARCH-PARTS is non-nil the search will include children of tags.
275When SEARCH-INCLUDES is non-nil, the search will include dependency files.
276When DIFF-MODE is non-nil, search databases which are of a different mode.
277A Mode is the `major-mode' that file was in when it was last parsed.
278When FIND-FILE-MATCH is non-nil, the make sure any found token's file is
279in an Emacs buffer.
280When IGNORE-SYSTEM is non-nil, system libraries are not searched.
281Return a list ((DB-TABLE . TOKEN-OR-TOKEN-LIST) ...)."
282 (semanticdb-collect-find-results
283 databases
284 (lambda (db)
285 (semanticdb-find-nonterminal-by-function-method
286 db function search-parts search-includes diff-mode find-file-match))
287 ignore-system
288 find-file-match))
289
290;;; Search Methods
291;;
292;; These are the base routines for searching semantic databases.
293;; Overload these with your subclasses to participate in the searching
294;; mechanism.
295(defmethod semanticdb-find-nonterminal-by-token-method
296 ((database semanticdb-project-database) token search-parts search-includes diff-mode find-file-match)
297 "OBSOLETE:
298In DB, find all occurances of nonterminals with token TOKEN in databases.
299See `semanticdb-find-nonterminal-by-function-method' for details on,
300SEARCH-PARTS, SEARCH-INCLUDES, DIFF-MODE, and FIND-FILE-MATCH.
301Return a list ((DB-TABLE . TOKEN-LIST) ...)."
302 (let ((goofy-token-name token))
303 (semanticdb-find-nonterminal-by-function-method
304 database (lambda (stream sp si)
305 (semantic-brute-find-tag-by-class goofy-token-name stream sp si))
306 search-parts search-includes diff-mode find-file-match)))
307
308(defmethod semanticdb-find-nonterminal-by-name-method
309 ((database semanticdb-project-database) name search-parts search-includes diff-mode find-file-match)
310 "OBSOLETE:
311Find all occurances of nonterminals with name NAME in databases.
312See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
313SEARCH-PARTS, SEARCH-INCLUDES, DIFF-MODE, and FIND-FILE-MATCH.
314Return a list ((DB-TABLE . TOKEN) ...)."
315 (semanticdb-find-nonterminal-by-function-method
316 database
317 (lambda (stream sp si)
318 (semantic-brute-find-first-tag-by-name name stream sp si))
319 search-parts search-includes diff-mode find-file-match))
320
321(defmethod semanticdb-find-nonterminal-by-name-regexp-method
322 ((database semanticdb-project-database) regex search-parts search-includes diff-mode find-file-match)
323 "OBSOLETE:
324Find all occurances of nonterminals with name matching REGEX in databases.
325See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
326SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, and FIND-FILE-MATCH.
327Return a list ((DB-TABLE . TOKEN-LIST) ...)."
328 (semanticdb-find-nonterminal-by-function-method
329 database
330 (lambda (stream sp si)
331 (semantic-brute-find-tag-by-name-regexp regex stream sp si))
332 search-parts search-includes diff-mode find-file-match))
333
334(defmethod semanticdb-find-nonterminal-by-type-method
335 ((database semanticdb-project-database) type search-parts search-includes diff-mode find-file-match)
336 "OBSOLETE:
337Find all nonterminals with a type of TYPE in databases.
338See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
339SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, and FIND-FILE-MATCH.
340Return a list ((DB-TABLE . TOKEN-LIST) ...)."
341 (semanticdb-find-nonterminal-by-function-method
342 database
343 (lambda (stream sp si)
344 (semantic-brute-find-tag-by-type type stream sp si))
345 search-parts search-includes diff-mode find-file-match))
346
347(defmethod semanticdb-find-nonterminal-by-property-method
348 ((database semanticdb-project-database) property value search-parts search-includes diff-mode find-file-match)
349 "OBSOLETE:
350Find all nonterminals with a PROPERTY equal to VALUE in databases.
351See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
352SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, and FIND-FILE-MATCH.
353Return a list ((DB-TABLE . TOKEN-LIST) ...)."
354 (semanticdb-find-nonterminal-by-function-method
355 database
356 (lambda (stream sp si)
357 (semantic-brute-find-tag-by-property property value stream sp si))
358 search-parts search-includes diff-mode find-file-match))
359
360(defmethod semanticdb-find-nonterminal-by-extra-spec-method
361 ((database semanticdb-project-database) spec search-parts search-includes diff-mode find-file-match)
362 "OBSOLETE:
363Find all nonterminals with a SPEC in databases.
364See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
365SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, and FIND-FILE-MATCH.
366Return a list ((DB-TABLE . TOKEN-LIST) ...)."
367 (semanticdb-find-nonterminal-by-function-method
368 database
369 (lambda (stream sp si)
370 (semantic-brute-find-tag-by-attribute spec stream sp si))
371 search-parts search-includes diff-mode find-file-match))
372
373(defmethod semanticdb-find-nonterminal-by-extra-spec-value-method
374 ((database semanticdb-project-database) spec value search-parts search-includes diff-mode find-file-match)
375 "OBSOLETE:
376Find all nonterminals with a SPEC equal to VALUE in databases.
377See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
378SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, and FIND-FILE-MATCH.
379Return a list ((DB-TABLE . TOKEN-LIST) ...)."
380 (semanticdb-find-nonterminal-by-function-method
381 database
382 (lambda (stream sp si)
383 (semantic-brute-find-tag-by-attribute-value spec value stream sp si))
384 search-parts search-includes diff-mode find-file-match))
385
386;;; Advanced Searches
387;;
388(defmethod semanticdb-find-nonterminal-external-children-of-type-method
389 ((database semanticdb-project-database) type search-parts search-includes diff-mode find-file-match)
390 "OBSOLETE:
391Find all nonterminals which are child elements of TYPE
392See `semanticdb-find-nonterminal-by-function' for details on DATABASES,
393SEARCH-PARTS, SEARCH-INCLUDES DIFF-MODE, FIND-FILE-MATCH and IGNORE-SYSTEM.
394Return a list ((DB-TABLE . TOKEN-LIST) ...)."
395 (semanticdb-find-nonterminal-by-function-method
396 database
397 `(lambda (stream sp si)
398 (semantic-brute-find-tag-by-function
399 (lambda (tok)
400 (let ((p (semantic-nonterminal-external-member-parent tok)))
401 (and (stringp p) (string= ,type p)))
402 )
403 stream sp si))
404 nil nil t))
405
406;;; Generic Search
407;;
408(defmethod semanticdb-find-nonterminal-by-function-method
409 ((database semanticdb-project-database)
410 function &optional search-parts search-includes diff-mode find-file-match)
411 "OBSOLETE:
412In DATABASE, find all occurances of nonterminals which match FUNCTION.
413When SEARCH-PARTS is non-nil the search will include children of tags.
414When SEARCH-INCLUDES is non-nil, the search will include dependency files.
415When DIFF-MODE is non-nil, search databases which are of a different mode.
416A mode is the `major-mode' that file was in when it was last parsed.
417When FIND-FILE-MATCH is non-nil, the make sure any found token's file is
418in an Emacs buffer.
419Return a list of matches."
420 (let* ((ret nil)
421 (files (semanticdb-get-database-tables database))
422 (found nil)
423 (orig-buffer (current-buffer)))
424 (while files
425 (when (or diff-mode
426 (semanticdb-equivalent-mode (car files) orig-buffer))
427 ;; This can cause unneeded refreshes while typing with
428 ;; senator-eldoc mode.
429 ;;(semanticdb-refresh-table (car files))
430 (setq found (funcall function
431 (semanticdb-get-tags (car files))
432 search-parts
433 search-includes
434 )))
435 (if found
436 (progn
437 ;; When something is found, make sure we read in that buffer if it
438 ;; had not already been loaded.
439 (if find-file-match
440 (save-excursion (semanticdb-set-buffer (car files))))
441 ;; In theory, the database is up-to-date with what is in the file, and
442 ;; these tags are ready to go.
443 ;; There is a bug lurking here I don't have time to fix.
444 (setq ret (cons (cons (car files) found) ret))
445 (setq found nil)))
446 (setq files (cdr files)))
447 (nreverse ret)))
448
449(provide 'semantic/db-search)
450
451;;; semanticdb-search.el ends here