annotate lisp/cedet/semantic/db.el @ 106894:b3b9ebd930e1

Fix typos in comments.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 18 Jan 2010 04:58:35 +0100
parents 4cf58c2379f4
children a5ad4f188e19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104441
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1 ;;; semantic/db.el --- Semantic tag database manager
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106568
diff changeset
4 ;; 2009, 2010 Free Software Foundation, Inc.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Keywords: tags
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; (at your option) any later version.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;; Commentary:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Maintain a database of tags for a group of files and enable
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; queries into the database.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; By default, assume one database per directory.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104510
diff changeset
32 ;;; Code:
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104510
diff changeset
33
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 (require 'eieio-base)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 (require 'semantic)
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104510
diff changeset
36
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104510
diff changeset
37 (declare-function semantic-lex-spp-save-table "semantic/lex-spp")
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;;; Variables:
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (defgroup semanticdb nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 "Parser Generator Persistent Database interface."
105260
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104510
diff changeset
42 :group 'semantic)
bbd7017a25d9 CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents: 104510
diff changeset
43
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (defvar semanticdb-database-list nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 "List of all active databases.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (defvar semanticdb-new-database-class 'semanticdb-project-database-file
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 "The default type of database created for new files.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 This can be changed on a per file basis, so that some directories
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 are saved using one mechanism, and some directories via a different
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 mechanism.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (make-variable-buffer-local 'semanticdb-new-database-class)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 (defvar semanticdb-default-find-index-class 'semanticdb-find-search-index
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 "The default type of search index to use for a `semanticdb-table's.
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
56 This can be changed to try out new types of search indices.")
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 (make-variable-buffer-local 'semanticdb-default-find=index-class)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104443
diff changeset
59 ;;;###autoload
104441
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
60 (defvar semanticdb-current-database nil
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
61 "For a given buffer, this is the currently active database.")
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
62 (make-variable-buffer-local 'semanticdb-current-database)
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
63
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104443
diff changeset
64 ;;;###autoload
104441
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
65 (defvar semanticdb-current-table nil
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
66 "For a given buffer, this is the currently active database table.")
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
67 (make-variable-buffer-local 'semanticdb-current-table)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 ;;; ABSTRACT CLASSES
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (defclass semanticdb-abstract-table ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ((parent-db ;; :initarg :parent-db
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 ;; Do not set an initarg, or you get circular writes to disk.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 :documentation "Database Object containing this table.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 (major-mode :initarg :major-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 :documentation "Major mode this table belongs to.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 Sometimes it is important for a program to know if a given table has the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 same major mode as the current buffer.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 (tags :initarg :tags
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 :accessor semanticdb-get-tags
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 :printer semantic-tag-write-list-slot-value
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 :documentation "The tags belonging to this table.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 (index :type semanticdb-abstract-search-index
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 :documentation "The search index.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 Used by semanticdb-find to store additional information about
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 this table for searching purposes.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 Note: This index will not be saved in a persistent file.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (cache :type list
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 :documentation "List of cache information for tools.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 Any particular tool can cache data to a database at runtime
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 with `semanticdb-cache-get'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 Using a semanticdb cache does not save any information to a file,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 so your cache will need to be recalculated at runtime. Caches can be
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 referenced even when the file is not in a buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 Note: This index will not be saved in a persistent file.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 "A simple table for semantic tags.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 This table is the root of tables, and contains the minimum needed
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 for a new table not associated with a buffer."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 :abstract t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 (defmethod semanticdb-in-buffer-p ((obj semanticdb-abstract-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 "Return a nil, meaning abstract table OBJ is not in a buffer."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (defmethod semanticdb-get-buffer ((obj semanticdb-abstract-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 "Return a buffer associated with OBJ.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 If the buffer is not in memory, load it with `find-file-noselect'."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 (defmethod semanticdb-full-filename ((obj semanticdb-abstract-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 "Fetch the full filename that OBJ refers to.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 Abstract tables do not have file names associated with them."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 (defmethod semanticdb-dirty-p ((obj semanticdb-abstract-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 "Return non-nil if OBJ is 'dirty'."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (defmethod semanticdb-set-dirty ((obj semanticdb-abstract-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 "Mark the abstract table OBJ dirty.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 Abstract tables can not be marked dirty, as there is nothing
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 for them to synchronize against."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 ;; The abstract table can not be dirty.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (defmethod semanticdb-normalize-tags ((obj semanticdb-abstract-table) tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 "For the table OBJ, convert a list of TAGS, into standardized form.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 The default is to return TAGS.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 Some databases may default to searching and providing simplified tags
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 based on whichever technique used. This method provides a hook for
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 them to convert TAG into a more complete form."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (defmethod semanticdb-normalize-one-tag ((obj semanticdb-abstract-table) tag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 "For the table OBJ, convert a TAG, into standardized form.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 This method returns a list of the form (DATABASE . NEWTAG).
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 The default is to just return (OBJ TAG).
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 Some databases may default to searching and providing simplified tags
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 based on whichever technique used. This method provides a hook for
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 them to convert TAG into a more complete form."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (cons obj tag))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 (defmethod object-print ((obj semanticdb-abstract-table) &rest strings)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 "Pretty printer extension for `semanticdb-table'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 Adds the number of tags in this file to the object print name."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 (apply 'call-next-method obj
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 (cons (format " (%d tags)"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (length (semanticdb-get-tags obj))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 strings)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 ;;; Index Cache
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 (defclass semanticdb-abstract-search-index ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 ((table :initarg :table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 :type semanticdb-abstract-table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 :documentation "XRef to the table this belongs to.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 "A place where semanticdb-find can store search index information.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 The search index will store data about which other tables might be
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 needed, or perhaps create hash or index tables for the current buffer."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 :abstract t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 (defmethod semanticdb-get-table-index ((obj semanticdb-abstract-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 "Return the search index for the table OBJ.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 If one doesn't exist, create it."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (if (slot-boundp obj 'index)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (oref obj index)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 (let ((idx nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (setq idx (funcall semanticdb-default-find-index-class
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (concat (object-name obj) " index")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 ;; Fill in the defaults
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 :table obj
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (oset obj index idx)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 idx)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (defmethod semanticdb-synchronize ((idx semanticdb-abstract-search-index)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 "Synchronize the search index IDX with some NEW-TAGS."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 ;; The abstract class will do... NOTHING!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (defmethod semanticdb-partial-synchronize ((idx semanticdb-abstract-search-index)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 "Synchronize the search index IDX with some changed NEW-TAGS."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 ;; The abstract class will do... NOTHING!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198
104443
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
199 ;;; SEARCH RESULTS TABLE
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
200 ;;
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
201 ;; Needed for system databases that may not provide
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
202 ;; a semanticdb-table associated with a file.
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
203 ;;
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
204 (defclass semanticdb-search-results-table (semanticdb-abstract-table)
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
205 (
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
206 )
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
207 "Table used for search results when there is no file or table association.
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
208 Examples include search results from external sources such as from
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
209 Emacs' own symbol table, or from external libraries.")
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
210
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
211 (defmethod semanticdb-refresh-table ((obj semanticdb-search-results-table) &optional force)
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
212 "If the tag list associated with OBJ is loaded, refresh it.
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
213 This will call `semantic-fetch-tags' if that file is in memory."
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
214 nil)
a6c7463e3f20 cedet/semantic/db.el: Synch to upstream.
Chong Yidong <cyd@stupidchicken.com>
parents: 104441
diff changeset
215
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 ;;; CONCRETE TABLE CLASSES
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (defclass semanticdb-table (semanticdb-abstract-table)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 ((file :initarg :file
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 :documentation "File name relative to the parent database.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 This is for the file whose tags are stored in this TABLE object.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (buffer :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 :documentation "The buffer associated with this table.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 If nil, the table's buffer is no in Emacs. If it has a value, then
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 it is in Emacs.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (dirty :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 :documentation
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 "Non nil if this table needs to be `Saved'.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 (db-refs :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 :documentation
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 "List of `semanticdb-table' objects refering to this one.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 These aren't saved, but are instead recalculated after load.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 See the file semanticdb-ref.el for how this slot is used.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 (pointmax :initarg :pointmax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 :documentation "Size of buffer when written to disk.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 Checked on retrieval to make sure the file is the same.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 (fsize :initarg :fsize
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 :documentation "Size of the file when it was last referenced.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 Checked when deciding if a loaded table needs updating from changes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 outside of Semantic's control.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 (lastmodtime :initarg :lastmodtime
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 :documentation "Last modification time of the file referenced.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 Checked when deciding if a loaded table needs updating from changes outside of
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 Semantic's control.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 ;; @todo - need to add `last parsed time', so we can also have
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 ;; refresh checks if spp tables or the parser gets rebuilt.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 (unmatched-syntax :initarg :unmatched-syntax
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 :documentation
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 "List of vectors specifying unmatched syntax.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (lexical-table :initarg :lexical-table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 :printer semantic-lex-spp-table-write-slot-value
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 :documentation
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 "Table that might be needed by the lexical analyzer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 For C/C++, the C preprocessor macros can be saved here.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 "A single table of tags derived from file.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (defmethod semanticdb-in-buffer-p ((obj semanticdb-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 "Return a buffer associated with OBJ.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 If the buffer is in memory, return that buffer."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 (let ((buff (oref obj buffer)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 (if (buffer-live-p buff)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 buff
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 (oset obj buffer nil))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (defmethod semanticdb-get-buffer ((obj semanticdb-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 "Return a buffer associated with OBJ.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 If the buffer is in memory, return that buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 If the buffer is not in memory, load it with `find-file-noselect'."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 (or (semanticdb-in-buffer-p obj)
104492
8db96f200ac8 Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents: 104484
diff changeset
276 ;; Save match data to protect against odd stuff in mode hooks.
8db96f200ac8 Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents: 104484
diff changeset
277 (save-match-data
8db96f200ac8 Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents: 104484
diff changeset
278 (find-file-noselect (semanticdb-full-filename obj) t))))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 (defmethod semanticdb-set-buffer ((obj semanticdb-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 "Set the current buffer to be a buffer owned by OBJ.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 If OBJ's file is not loaded, read it in first."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (set-buffer (semanticdb-get-buffer obj)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (defmethod semanticdb-full-filename ((obj semanticdb-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 "Fetch the full filename that OBJ refers to."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (expand-file-name (oref obj file)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (oref (oref obj parent-db) reference-directory)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (defmethod semanticdb-dirty-p ((obj semanticdb-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 "Return non-nil if OBJ is 'dirty'."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (oref obj dirty))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (defmethod semanticdb-set-dirty ((obj semanticdb-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 "Mark the abstract table OBJ dirty."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (oset obj dirty t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (defmethod object-print ((obj semanticdb-table) &rest strings)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 "Pretty printer extension for `semanticdb-table'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 Adds the number of tags in this file to the object print name."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 (apply 'call-next-method obj
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 (cons (if (oref obj dirty) ", DIRTY" "") strings)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 ;;; DATABASE BASE CLASS
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (defclass semanticdb-project-database (eieio-instance-tracker)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 ((tracking-symbol :initform semanticdb-database-list)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (reference-directory :type string
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 :documentation "Directory this database refers to.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 When a cache directory is specified, then this refers to the directory
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 this database contains symbols for.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (new-table-class :initform semanticdb-table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 :type class
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 :documentation
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 "New tables created for this database are of this class.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (cache :type list
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 :initform nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 :documentation "List of cache information for tools.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 Any particular tool can cache data to a database at runtime
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 with `semanticdb-cache-get'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 Using a semanticdb cache does not save any information to a file,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 so your cache will need to be recalculated at runtime.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 Note: This index will not be saved in a persistent file.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (tables :initarg :tables
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 :type list
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 ;; Need this protection so apps don't try to access
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 ;; the tables without using the accessor.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 :accessor semanticdb-get-database-tables
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 :protection :protected
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 :documentation "List of `semantic-db-table' objects."))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 "Database of file tables.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (defmethod semanticdb-full-filename ((obj semanticdb-project-database))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 "Fetch the full filename that OBJ refers to.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 Abstract tables do not have file names associated with them."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 (defmethod semanticdb-dirty-p ((DB semanticdb-project-database))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 "Return non-nil if DB is 'dirty'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 A database is dirty if the state of the database changed in a way
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 where it may need to resynchronize with some persistent storage."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (let ((dirty nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 (tabs (oref DB tables)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (while (and (not dirty) tabs)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (setq dirty (semanticdb-dirty-p (car tabs)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (setq tabs (cdr tabs)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 dirty))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (defmethod object-print ((obj semanticdb-project-database) &rest strings)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 "Pretty printer extension for `semanticdb-project-database'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 Adds the number of tables in this file to the object print name."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (apply 'call-next-method obj
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (cons (format " (%d tables%s)"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 (length (semanticdb-get-database-tables obj))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 (if (semanticdb-dirty-p obj)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 " DIRTY" "")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 strings)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (defmethod semanticdb-create-database :STATIC ((dbc semanticdb-project-database) directory)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 "Create a new semantic database of class DBC for DIRECTORY and return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 If a database for DIRECTORY has already been created, return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 If DIRECTORY doesn't exist, create a new one."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 (let ((db (semanticdb-directory-loaded-p directory)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 (unless db
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 (setq db (semanticdb-project-database
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 (file-name-nondirectory directory)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 :tables nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 ;; Set this up here. We can't put it in the constructor because it
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 ;; would be saved, and we want DB files to be portable.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (oset db reference-directory (file-truename directory)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 db))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (defmethod semanticdb-flush-database-tables ((db semanticdb-project-database))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 "Reset the tables in DB to be empty."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 (oset db tables nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (defmethod semanticdb-create-table ((db semanticdb-project-database) file)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 "Create a new table in DB for FILE and return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 The class of DB contains the class name for the type of table to create.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 If the table for FILE exists, return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 If the table for FILE does not exist, create one."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (let ((newtab (semanticdb-file-table db file)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (unless newtab
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 ;; This implementation will satisfy autoloaded classes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 ;; for tables.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (setq newtab (funcall (oref db new-table-class)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (file-name-nondirectory file)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 :file (file-name-nondirectory file)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (oset newtab parent-db db)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (object-add-to-list db 'tables newtab t))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 newtab))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (defmethod semanticdb-file-table ((obj semanticdb-project-database) filename)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 "From OBJ, return FILENAME's associated table object."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (object-assoc (file-relative-name (file-truename filename)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (oref obj reference-directory))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 'file (oref obj tables)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 ;; DATABASE FUNCTIONS
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (defun semanticdb-get-database (filename)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 "Get a database for FILENAME.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 If one isn't found, create one."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (semanticdb-create-database semanticdb-new-database-class (file-truename filename)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 (defun semanticdb-directory-loaded-p (path)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 "Return the project belonging to PATH if it was already loaded."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 (eieio-instance-tracker-find path 'reference-directory 'semanticdb-database-list))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (defun semanticdb-create-table-for-file (filename)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 "Initialize a database table for FILENAME, and return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 If FILENAME exists in the database already, return that.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 If there is no database for the table to live in, create one."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 (let ((cdb nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (tbl nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 (dd (file-name-directory filename))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 ;; Allow a database override function
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 (setq cdb (semanticdb-create-database semanticdb-new-database-class
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 dd))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 ;; Get a table for this file.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (setq tbl (semanticdb-create-table cdb filename))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 ;; Return the pair.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (cons cdb tbl)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 ;;; Cache Cache.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (defclass semanticdb-abstract-cache ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 ((table :initarg :table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 :type semanticdb-abstract-table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 :documentation
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 "Cross reference to the table this belongs to.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 "Abstract baseclass for tools to use to cache information in semanticdb.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 Tools needing a per-file cache must subclass this, and then get one as
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 needed. Cache objects are identified in semanticdb by subclass.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 In order to keep your cache up to date, be sure to implement
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 `semanticdb-synchronize', and `semanticdb-partial-synchronize'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 See the file semantic-scope.el for an example."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 :abstract t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (defmethod semanticdb-cache-get ((table semanticdb-abstract-table)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 desired-class)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 "Get a cache object on TABLE of class DESIRED-CLASS.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 This method will create one if none exists with no init arguments
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 other than :table."
106568
a54ddff7ac90 * cedet/semantic/mru-bookmark.el (global-semantic-mru-bookmark-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
453 (unless (child-of-class-p desired-class 'semanticdb-abstract-cache)
a54ddff7ac90 * cedet/semantic/mru-bookmark.el (global-semantic-mru-bookmark-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
454 (error "Invalid SemanticDB cache"))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (let ((cache (oref table cache))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (obj nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 (while (and (not obj) cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (if (eq (object-class-fast (car cache)) desired-class)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (setq obj (car cache)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (setq cache (cdr cache)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (if obj
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 obj ;; Just return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 ;; No object, lets create a new one and return that.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 (setq obj (funcall desired-class "Cache" :table table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 (object-add-to-list table 'cache obj)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 obj)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 (defmethod semanticdb-cache-remove ((table semanticdb-abstract-table)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 "Remove from TABLE the cache object CACHE."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (object-remove-from-list table 'cache cache))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 (defmethod semanticdb-synchronize ((cache semanticdb-abstract-cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 "Synchronize a CACHE with some NEW-TAGS."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 ;; The abstract class will do... NOTHING!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (defmethod semanticdb-partial-synchronize ((cache semanticdb-abstract-cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 "Synchronize a CACHE with some changed NEW-TAGS."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 ;; The abstract class will do... NOTHING!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 (defclass semanticdb-abstract-db-cache ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 ((db :initarg :db
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 :type semanticdb-project-database
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 :documentation
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 "Cross reference to the database this belongs to.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 "Abstract baseclass for tools to use to cache information in semanticdb.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 Tools needing a database cache must subclass this, and then get one as
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 needed. Cache objects are identified in semanticdb by subclass.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 In order to keep your cache up to date, be sure to implement
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 `semanticdb-synchronize', and `semanticdb-partial-synchronize'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 See the file semantic-scope.el for an example."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497 :abstract t)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 (defmethod semanticdb-cache-get ((db semanticdb-project-database)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 desired-class)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 "Get a cache object on DB of class DESIRED-CLASS.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 This method will create one if none exists with no init arguments
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 other than :table."
106568
a54ddff7ac90 * cedet/semantic/mru-bookmark.el (global-semantic-mru-bookmark-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
504 (unless (child-of-class-p desired-class 'semanticdb-abstract-cache)
a54ddff7ac90 * cedet/semantic/mru-bookmark.el (global-semantic-mru-bookmark-mode)
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
505 (error "Invalid SemanticDB cache"))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 (let ((cache (oref db cache))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 (obj nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 (while (and (not obj) cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (if (eq (object-class-fast (car cache)) desired-class)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 (setq obj (car cache)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 (setq cache (cdr cache)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 (if obj
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 obj ;; Just return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 ;; No object, lets create a new one and return that.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 (setq obj (funcall desired-class "Cache" :db db))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 (object-add-to-list db 'cache obj)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 obj)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 (defmethod semanticdb-cache-remove ((db semanticdb-project-database)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 "Remove from TABLE the cache object CACHE."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 (object-remove-from-list db 'cache cache))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 (defmethod semanticdb-synchronize ((cache semanticdb-abstract-db-cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 "Synchronize a CACHE with some NEW-TAGS."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 ;; The abstract class will do... NOTHING!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 (defmethod semanticdb-partial-synchronize ((cache semanticdb-abstract-db-cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 "Synchronize a CACHE with some changed NEW-TAGS."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 ;; The abstract class will do... NOTHING!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 ;;; REFRESH
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 (defmethod semanticdb-refresh-table ((obj semanticdb-table) &optional force)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 "If the tag list associated with OBJ is loaded, refresh it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 Optional argument FORCE will force a refresh even if the file in question
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 is not in a buffer. Avoid using FORCE for most uses, as an old cache
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543 may be sufficient for the general case. Forced updates can be slow.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544 This will call `semantic-fetch-tags' if that file is in memory."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545 (when (or (semanticdb-in-buffer-p obj) force)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 (semanticdb-set-buffer obj)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548 (semantic-fetch-tags))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 (defmethod semanticdb-needs-refresh-p ((obj semanticdb-table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 "Return non-nil of OBJ's tag list is out of date.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 The file associated with OBJ does not need to be in a buffer."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 (let* ((ff (semanticdb-full-filename obj))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 (buff (semanticdb-in-buffer-p obj))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 (if buff
105799
3fe6da4a95a9 * cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105377
diff changeset
557 (with-current-buffer buff
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558 ;; Use semantic's magic tracker to determine of the buffer is up
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 ;; to date or not.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560 (not (semantic-parse-tree-up-to-date-p))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561 ;; We assume that semanticdb is keeping itself up to date.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562 ;; via all the clever hooks
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564 ;; Buffer isn't loaded. The only clue we have is if the file
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 ;; is somehow different from our mark in the semanticdb table.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 (let* ((stats (file-attributes ff))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 (actualsize (nth 7 stats))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568 (actualmod (nth 5 stats))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
571 (or (not (slot-boundp obj 'tags))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
572 ;; (not (oref obj tags)) --> not needed anymore?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 (/= (or (oref obj fsize) 0) actualsize)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574 (not (equal (oref obj lastmodtime) actualmod))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 ))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 ;;; Synchronization
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 (defmethod semanticdb-synchronize ((table semanticdb-abstract-table)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583 "Synchronize the table TABLE with some NEW-TAGS."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 (oset table tags new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 (oset table pointmax (point-max))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586 (let ((fattr (file-attributes (semanticdb-full-filename table))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587 (oset table fsize (nth 7 fattr))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 (oset table lastmodtime (nth 5 fattr))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
590 ;; Assume it is now up to date.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
591 (oset table unmatched-syntax semantic-unmatched-syntax-cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 ;; The lexical table should be good too.
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
593 (when (featurep 'semantic/lex-spp)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (oset table lexical-table (semantic-lex-spp-save-table)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 ;; this implies dirtyness
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
596 (semanticdb-set-dirty table)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 ;; Synchronize the index
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 (when (slot-boundp table 'index)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600 (let ((idx (oref table index)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
601 (when idx (semanticdb-synchronize idx new-tags))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
602
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 ;; Synchronize application caches.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 (dolist (C (oref table cache))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
605 (semanticdb-synchronize C new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 ;; Update cross references
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609 ;; (semanticdb-refresh-references table)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 (defmethod semanticdb-partial-synchronize ((table semanticdb-abstract-table)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614 "Synchronize the table TABLE where some NEW-TAGS changed."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 ;; You might think we need to reset the tags, but since the partial
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616 ;; parser splices the lists, we don't need to do anything
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 ;;(oset table tags new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618 ;; We do need to mark ourselves dirty.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 (semanticdb-set-dirty table)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
621 ;; The lexical table may be modified.
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
622 (when (featurep 'semantic/lex-spp)
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 (oset table lexical-table (semantic-lex-spp-save-table)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 ;; Incremental parser doesn't mokey around with this.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
626 (oset table unmatched-syntax semantic-unmatched-syntax-cache)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
628 ;; Synchronize the index
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629 (when (slot-boundp table 'index)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 (let ((idx (oref table index)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631 (when idx (semanticdb-partial-synchronize idx new-tags))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 ;; Synchronize application caches.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 (dolist (C (oref table cache))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 (semanticdb-synchronize C new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
636 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 ;; Update cross references
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639 ;;(when (semantic-find-tags-by-class 'include new-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 ;; (semanticdb-refresh-references table))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 ;;; SAVE/LOAD
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 (defmethod semanticdb-save-db ((DB semanticdb-project-database)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646 &optional supress-questions)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 "Cause a database to save itself.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 The database base class does not save itself persistently.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 Subclasses could save themselves to a file, or to a database, or other
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650 form."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 (defun semanticdb-save-current-db ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 "Save the current tag database."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 (interactive)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 (message "Saving current tag summaries...")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 (semanticdb-save-db semanticdb-current-database)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658 (message "Saving current tag summaries...done"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659
104510
8c44231178fc * cedet/semantic/db.el (semanticdb--inhibit-make-directory): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104492
diff changeset
660 ;; This prevents Semanticdb from querying multiple times if the users
8c44231178fc * cedet/semantic/db.el (semanticdb--inhibit-make-directory): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104492
diff changeset
661 ;; answers "no" to creating the Semanticdb directory.
8c44231178fc * cedet/semantic/db.el (semanticdb--inhibit-make-directory): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104492
diff changeset
662 (defvar semanticdb--inhibit-create-file-directory)
8c44231178fc * cedet/semantic/db.el (semanticdb--inhibit-make-directory): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104492
diff changeset
663
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664 (defun semanticdb-save-all-db ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 "Save all semantic tag databases."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
666 (interactive)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
667 (message "Saving tag summaries...")
104510
8c44231178fc * cedet/semantic/db.el (semanticdb--inhibit-make-directory): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104492
diff changeset
668 (let ((semanticdb--inhibit-make-directory nil))
8c44231178fc * cedet/semantic/db.el (semanticdb--inhibit-make-directory): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104492
diff changeset
669 (mapc 'semanticdb-save-db semanticdb-database-list))
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 (message "Saving tag summaries...done"))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672 (defun semanticdb-save-all-db-idle ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673 "Save all semantic tag databases from idle time.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674 Exit the save between databases if there is user input."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
675 (semantic-safe "Auto-DB Save: %S"
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676 (semantic-exit-on-input 'semanticdb-idle-save
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 (mapc (lambda (db)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678 (semantic-throw-on-input 'semanticdb-idle-save)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 (semanticdb-save-db db t))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 semanticdb-database-list))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
683 ;;; Directory Project support
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 (defvar semanticdb-project-predicate-functions nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 "List of predicates to try that indicate a directory belongs to a project.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 This list is used when `semanticdb-persistent-path' contains the value
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 'project. If the predicate list is nil, then presume all paths are valid.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
690 Project Management software (such as EDE and JDE) should add their own
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
691 predicates with `add-hook' to this variable, and semanticdb will save tag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 caches in directories controlled by them.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 (defmethod semanticdb-write-directory-p ((obj semanticdb-project-database))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695 "Return non-nil if OBJ should be written to disk.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 Uses `semanticdb-persistent-path' to determine the return value."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 ;;; Utilities
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
700 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
701 ;; What is the current database, are two tables of an equivalent mode,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
702 ;; and what databases are a part of the same project.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
703 (defun semanticdb-current-database ()
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 "Return the currently active database."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 (or semanticdb-current-database
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706 (and default-directory
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
707 (semanticdb-create-database semanticdb-new-database-class
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
708 default-directory)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 (defvar semanticdb-match-any-mode nil
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
713 "Non-nil to temporarily search any major mode for a tag.
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 If a particular major mode wants to search any mode, put the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 `semantic-match-any-mode' symbol onto the symbol of that major mode.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 Do not set the value of this variable permanently.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
718 (defmacro semanticdb-with-match-any-mode (&rest body)
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
719 "A Semanticdb search occurring withing BODY will search tags in all modes.
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
720 This temporarily sets `semanticdb-match-any-mode' while executing BODY."
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721 `(let ((semanticdb-match-any-mode t))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
722 ,@body))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 (put 'semanticdb-with-match-any-mode 'lisp-indent-function 0)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 (defmethod semanticdb-equivalent-mode-for-search (table &optional buffer)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 "Return non-nil if TABLE's mode is equivalent to BUFFER.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 See `semanticdb-equivalent-mode' for details.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 This version is used during searches. Major-modes that opt
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 to set the `semantic-match-any-mode' property will be able to search
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 all files of any type."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 (or (get major-mode 'semantic-match-any-mode)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 semanticdb-match-any-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 (semanticdb-equivalent-mode table buffer))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
736 (defmethod semanticdb-equivalent-mode ((table semanticdb-abstract-table) &optional buffer)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 "Return non-nil if TABLE's mode is equivalent to BUFFER.
106860
4cf58c2379f4 Mario Lang <mlang@delysid.org>: Remove some duplicated words.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
738 Equivalent modes are specified by the `semantic-equivalent-major-modes'
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 local variable."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
741
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 (defmethod semanticdb-equivalent-mode ((table semanticdb-table) &optional buffer)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
743 "Return non-nil if TABLE's mode is equivalent to BUFFER.
106860
4cf58c2379f4 Mario Lang <mlang@delysid.org>: Remove some duplicated words.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
744 Equivalent modes are specified by the `semantic-equivalent-major-modes'
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
745 local variable."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
747 (if buffer (set-buffer buffer))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
748 (or
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
749 ;; nil major mode in table means we don't know yet. Assume yes for now?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
750 (null (oref table major-mode))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
751 ;; nil means the same as major-mode
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752 (and (not semantic-equivalent-major-modes)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 (mode-local-use-bindings-p major-mode (oref table major-mode)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 (and semantic-equivalent-major-modes
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 (member (oref table major-mode) semantic-equivalent-major-modes))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
760 ;;; Associations
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
761 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
762 ;; These routines determine associations between a file, and multiple
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
763 ;; associated databases.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
764
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
765 (defcustom semanticdb-project-roots nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
766 "*List of directories, where each directory is the root of some project.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
767 All subdirectories of a root project are considered a part of one project.
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 105260
diff changeset
768 Values in this string can be overridden by project management programs
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
769 via the `semanticdb-project-root-functions' variable."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 :group 'semanticdb
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
771 :type '(repeat string))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
772
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
773 (defvar semanticdb-project-root-functions nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
774 "List of functions used to determine a given directories project root.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
775 Functions in this variable can override `semanticdb-project-roots'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 Functions set in the variable are given one argument (a directory) and
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
777 must return a string, (the root directory) or a list of strings (multiple
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
778 root directories in a more complex system). This variable should be used
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
779 by project management programs like EDE or JDE.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
780
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
781 (defvar semanticdb-project-system-databases nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
782 "List of databases containing system library information.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
783 Mode authors can create their own system databases which know
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
784 detailed information about the system libraries for querying purposes.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
785 Put those into this variable as a buffer-local, or mode-local
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
786 value.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
787 (make-variable-buffer-local 'semanticdb-project-system-databases)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
788
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789 (defvar semanticdb-search-system-databases t
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
790 "Non nil if search routines are to include a system database.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
791
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
792 (defun semanticdb-current-database-list (&optional dir)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793 "Return a list of databases associated with the current buffer.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
794 If optional argument DIR is non-nil, then use DIR as the starting directory.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
795 If this buffer has a database, but doesn't have a project associated
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
796 with it, return nil.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
797 First, it checks `semanticdb-project-root-functions', and if that
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
798 has no results, it checks `semanticdb-project-roots'. If that fails,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
799 it returns the results of function `semanticdb-current-database'.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
800 Always append `semanticdb-project-system-databases' if
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801 `semanticdb-search-system' is non-nil."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
802 (let ((root nil) ; found root directory
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
803 (dbs nil) ; collected databases
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
804 (roots semanticdb-project-roots) ;all user roots
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
805 (dir (file-truename (or dir default-directory)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
806 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
807 ;; Find the root based on project functions.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
808 (setq root (run-hook-with-args-until-success
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
809 'semanticdb-project-root-functions
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
810 dir))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
811 ;; Find roots based on strings
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
812 (while (and roots (not root))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
813 (let ((r (file-truename (car roots))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
814 (if (string-match (concat "^" (regexp-quote r)) dir)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
815 (setq root r)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
816 (setq roots (cdr roots)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
817
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
818 ;; If no roots are found, use this directory.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
819 (unless root (setq root dir))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
820
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
821 ;; Find databases based on the root directory.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
822 (when root
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
823 ;; The rootlist allows the root functions to possibly
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
824 ;; return several roots which are in different areas but
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
825 ;; all apart of the same system.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
826 (let ((regexp (concat "^" (regexp-quote root)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
827 (adb semanticdb-database-list) ; all databases
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
828 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
829 (while adb
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
830 ;; I don't like this part, but close enough.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
831 (if (and (slot-boundp (car adb) 'reference-directory)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
832 (string-match regexp (oref (car adb) reference-directory)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
833 (setq dbs (cons (car adb) dbs)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
834 (setq adb (cdr adb))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
835 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
836 ;; Add in system databases
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
837 (when semanticdb-search-system-databases
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
838 (setq dbs (nconc dbs semanticdb-project-system-databases)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
839 ;; Return
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
840 dbs))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
841
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
842
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
843 ;;; Generic Accessor Routines
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
844 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
845 ;; These routines can be used to get at tags in files w/out
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
846 ;; having to know a lot about semanticDB.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
847 (defvar semanticdb-file-table-hash (make-hash-table :test 'equal)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
848 "Hash table mapping file names to database tables.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
849
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
850 (defun semanticdb-file-table-object-from-hash (file)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
851 "Retrieve a DB table from the hash for FILE.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
852 Does not use `file-truename'."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
853 (gethash file semanticdb-file-table-hash 'no-hit))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
854
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
855 (defun semanticdb-file-table-object-put-hash (file dbtable)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
856 "For FILE, associate DBTABLE in the hash table."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
857 (puthash file dbtable semanticdb-file-table-hash))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
858
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104443
diff changeset
859 ;;;###autoload
104414
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
860 (defun semanticdb-file-table-object (file &optional dontload)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
861 "Return a semanticdb table belonging to FILE, make it up to date.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
862 If file has database tags available in the database, return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
863 If file does not have tags available, and DONTLOAD is nil,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
864 then load the tags for FILE, and create a new table object for it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
865 DONTLOAD does not affect the creation of new database objects."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
866 ;; (message "Object Translate: %s" file)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
867 (when (file-exists-p file)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
868 (let* ((default-directory (file-name-directory file))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
869 (tab (semanticdb-file-table-object-from-hash file))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
870 (fullfile nil))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
871
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
872 ;; If it is not in the cache, then extract the more traditional
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
873 ;; way by getting the database, and finding a table in that database.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
874 ;; Once we have a table, add it to the hash.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
875 (when (eq tab 'no-hit)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
876 (setq fullfile (file-truename file))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
877 (let ((db (or ;; This line will pick up system databases.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
878 (semanticdb-directory-loaded-p default-directory)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
879 ;; this line will make a new one if needed.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
880 (semanticdb-get-database default-directory))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
881 (setq tab (semanticdb-file-table db fullfile))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
882 (when tab
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
883 (semanticdb-file-table-object-put-hash file tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
884 (when (not (string= fullfile file))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
885 (semanticdb-file-table-object-put-hash fullfile tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
886 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
887 ))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
888
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
889 (cond
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
890 ((and tab
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
891 ;; Is this in a buffer?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
892 ;;(find-buffer-visiting (semanticdb-full-filename tab))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
893 (semanticdb-in-buffer-p tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
894 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
895 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
896 ;;(set-buffer (find-buffer-visiting (semanticdb-full-filename tab)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
897 (semanticdb-set-buffer tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
898 (semantic-fetch-tags)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
899 ;; Return the table.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
900 tab))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
901 ((and tab dontload)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
902 ;; If we have table, and we don't want to load it, just return it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
903 tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
904 ((and tab
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
905 ;; Is table fully loaded, or just a proxy?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
906 (number-or-marker-p (oref tab pointmax))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
907 ;; Is this table up to date with the file?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
908 (not (semanticdb-needs-refresh-p tab)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
909 ;; A-ok!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
910 tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
911 ((or (and fullfile (get-file-buffer fullfile))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
912 (get-file-buffer file))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
913 ;; are these two calls this faster than `find-buffer-visiting'?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
914
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
915 ;; If FILE is being visited, but none of the above state is
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
916 ;; true (meaning, there is no table object associated with it)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
917 ;; then it is a file not supported by Semantic, and can be safely
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
918 ;; ignored.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
919 nil)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
920 ((not dontload) ;; We must load the file.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
921 ;; Full file should have been set by now. Debug why not?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
922 (when (and (not tab) (not fullfile))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
923 ;; This case is if a 'nil is erroneously put into the hash table. This
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
924 ;; would need fixing
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
925 (setq fullfile (file-truename file))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
926 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
927
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
928 ;; If we have a table, but no fullfile, that's ok. Lets get the filename
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
929 ;; from the table which is pre-truenamed.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
930 (when (and (not fullfile) tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
931 (setq fullfile (semanticdb-full-filename tab)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
932
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
933 (setq tab (semanticdb-create-table-for-file-not-in-buffer fullfile))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
934
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
935 ;; Save the new table.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
936 (semanticdb-file-table-object-put-hash file tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
937 (when (not (string= fullfile file))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
938 (semanticdb-file-table-object-put-hash fullfile tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
939 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
940 ;; Done!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
941 tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
942 (t
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
943 ;; Full file should have been set by now. Debug why not?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
944 ;; One person found this. Is it a file that failed to parse
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
945 ;; in the past?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
946 (when (not fullfile)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
947 (setq fullfile (file-truename file)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
948
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
949 ;; We were asked not to load the file in and parse it.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
950 ;; Instead just create a database table with no tags
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
951 ;; and a claim of being empty.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
952 ;;
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
953 ;; This will give us a starting point for storing
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
954 ;; database cross-references so when it is loaded,
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
955 ;; the cross-references will fire and caches will
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
956 ;; be cleaned.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
957 (let ((ans (semanticdb-create-table-for-file file)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
958 (setq tab (cdr ans))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
959
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
960 ;; Save the new table.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
961 (semanticdb-file-table-object-put-hash file tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
962 (when (not (string= fullfile file))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
963 (semanticdb-file-table-object-put-hash fullfile tab)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
964 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
965 ;; Done!
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
966 tab))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
967 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
968 )))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
969
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
970 (defvar semanticdb-out-of-buffer-create-table-fcn nil
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
971 "When non-nil, a function for creating a semanticdb table.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
972 This should take a filename to be parsed.")
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
973 (make-variable-buffer-local 'semanticdb-out-of-buffer-create-table-fcn)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
974
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
975 (defun semanticdb-create-table-for-file-not-in-buffer (filename)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
976 "Create a table for the file FILENAME.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
977 If there are no language specific configurations, this
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
978 function will read in the buffer, parse it, and kill the buffer."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
979 (if (and semanticdb-out-of-buffer-create-table-fcn
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
980 (not (file-remote-p filename)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
981 ;; Use external parser only of the file is accessible to the
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
982 ;; local file system.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
983 (funcall semanticdb-out-of-buffer-create-table-fcn filename)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
984 (save-excursion
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
985 (let* ( ;; Remember the buffer to kill
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
986 (kill-buffer-flag (find-buffer-visiting filename))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
987 (buffer-to-kill (or kill-buffer-flag
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
988 (semantic-find-file-noselect filename t))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
989
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
990 ;; This shouldn't ever be set. Debug some issue here?
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
991 ;; (when kill-buffer-flag (debug))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
992
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
993 (set-buffer buffer-to-kill)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
994 ;; Find file should automatically do this for us.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
995 ;; Sometimes the DB table doesn't contains tags and needs
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
996 ;; a refresh. For example, when the file is loaded for
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
997 ;; the first time, and the idle scheduler didn't get a
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
998 ;; chance to trigger a parse before the file buffer is
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
999 ;; killed.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1000 (when semanticdb-current-table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1001 (semantic-fetch-tags))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1002 (prog1
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1003 semanticdb-current-table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1004 (when (not kill-buffer-flag)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1005 ;; If we had to find the file, then we should kill it
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1006 ;; to keep the master buffer list clean.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1007 (kill-buffer buffer-to-kill)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1008 )))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1009 )
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1010
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1011 (defun semanticdb-file-stream (file)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1012 "Return a list of tags belonging to FILE.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1013 If file has database tags available in the database, return them.
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1014 If file does not have tags available, then load the file, and create them."
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1015 (let ((table (semanticdb-file-table-object file)))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1016 (when table
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1017 (semanticdb-get-tags table))))
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1018
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1019 (provide 'semantic/db)
b2b72cdd9d90 cedet/semantic/db.el, cedet/semantic/decorate.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1020
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104443
diff changeset
1021 ;; Local variables:
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104443
diff changeset
1022 ;; generated-autoload-file: "loaddefs.el"
104447
273e528a9f9b * emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
1023 ;; generated-autoload-load-name: "semantic/db"
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104443
diff changeset
1024 ;; End:
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104443
diff changeset
1025
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105340
diff changeset
1026 ;; arch-tag: d9f75280-737d-494f-9f70-09a649d27433
104441
902d22a2d922 cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
Chong Yidong <cyd@stupidchicken.com>
parents: 104416
diff changeset
1027 ;;; semantic/db.el ends here