cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
semanticdb-current-database and semanticdb-current-table are now in
semantic/db.el.
cedet/semantic/db-ebrowse.el: Don't require semantic/db-mode, since
semanticdb-current-database and semanticdb-current-table are now in
semantic/db.el.
cedet/semantic/db-el.el: Require semantic/lex-spp.
Require semantic/db instead of semantic/db-search.
cedet/semantic/db-file.el: Declare inversion-test and
data-debug-insert-thing.
(semanticdb-load-database): Load inversion only if necessary.
cedet/semantic/db-find.el: Autoload semanticdb-find-default-throttle.
Defvar data-debug-thing-alist, and ede-current-project.
Declare data-debug-insert-stuff-list, data-debug-insert-tag-list,
semantic-scope-reset-cache, and semanticdb-typecache-notify-reset.
Require semantic/tag-file, and semantic/sort.
(semantic-reset): Require semantic/scope.
(semanticdb-partial-synchronize): Require semantic/db-typecache.
(semanticdb-find-table-for-include) Move up to avoid compiler warning.
cedet/semantic/db-global.el: Declare data-debug-new-buffer and
data-debug-insert-thing.
(semanticdb-project-database-global) Move up to avoid compiler warning.
cedet/semantic/db-javascript.el: Fix provide statement.
Require semantic/db-find instead of semantic/db-search.
cedet/semantic/db-mode.el: Declare semantic-lex-spp-set-dynamic-table.
(semanticdb-current-database, semanticdb-current-table): Move into
semantic/db.el
cedet/semantic/db-ref.el: Require eieio, semantic/db, and semantic/util.
Declare data-debug-new-buffer and data-debug-insert-object-slots.
Defvar semantic-case-fold. Require semantic/find when compiling.
cedet/semantic/db-typecache.el: Require semantic/tag-ls,
semantic/analyze/fcn, and semantic/scope. Declare
data-debug-insert-thing and data-debug-new-buffer.
cedet/semantic/db.el (semanticdb-search-results-table): Move class
definition here from semantic/db-search.el.
(semanticdb-current-database, semanticdb-current-table) Move variable
definitions here from semantic/db-mode.el.
2009-08-31 00:45:41 +00:00
|
|
|
|
;;; semantic/db.el --- Semantic tag database manager
|
2009-08-28 15:19:20 +00:00
|
|
|
|
|
2011-01-24 20:08:28 -08:00
|
|
|
|
;; Copyright (C) 2000-2011 Free Software Foundation, Inc.
|
2009-08-28 15:19:20 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
|
|
|
|
;; Keywords: tags
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;
|
|
|
|
|
;; Maintain a database of tags for a group of files and enable
|
|
|
|
|
;; queries into the database.
|
|
|
|
|
;;
|
|
|
|
|
;; By default, assume one database per directory.
|
|
|
|
|
;;
|
|
|
|
|
|
2009-09-28 15:15:00 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(require 'eieio-base)
|
|
|
|
|
(require 'semantic)
|
2009-09-28 15:15:00 +00:00
|
|
|
|
|
|
|
|
|
(declare-function semantic-lex-spp-save-table "semantic/lex-spp")
|
2009-08-28 15:19:20 +00:00
|
|
|
|
|
|
|
|
|
;;; Variables:
|
|
|
|
|
(defgroup semanticdb nil
|
|
|
|
|
"Parser Generator Persistent Database interface."
|
2009-09-28 15:15:00 +00:00
|
|
|
|
:group 'semantic)
|
|
|
|
|
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(defvar semanticdb-database-list nil
|
|
|
|
|
"List of all active databases.")
|
|
|
|
|
|
|
|
|
|
(defvar semanticdb-new-database-class 'semanticdb-project-database-file
|
|
|
|
|
"The default type of database created for new files.
|
|
|
|
|
This can be changed on a per file basis, so that some directories
|
|
|
|
|
are saved using one mechanism, and some directories via a different
|
|
|
|
|
mechanism.")
|
|
|
|
|
(make-variable-buffer-local 'semanticdb-new-database-class)
|
|
|
|
|
|
|
|
|
|
(defvar semanticdb-default-find-index-class 'semanticdb-find-search-index
|
|
|
|
|
"The default type of search index to use for a `semanticdb-table's.
|
2009-10-01 04:54:05 +00:00
|
|
|
|
This can be changed to try out new types of search indices.")
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(make-variable-buffer-local 'semanticdb-default-find=index-class)
|
|
|
|
|
|
2009-09-02 04:37:10 +00:00
|
|
|
|
;;;###autoload
|
cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
semanticdb-current-database and semanticdb-current-table are now in
semantic/db.el.
cedet/semantic/db-ebrowse.el: Don't require semantic/db-mode, since
semanticdb-current-database and semanticdb-current-table are now in
semantic/db.el.
cedet/semantic/db-el.el: Require semantic/lex-spp.
Require semantic/db instead of semantic/db-search.
cedet/semantic/db-file.el: Declare inversion-test and
data-debug-insert-thing.
(semanticdb-load-database): Load inversion only if necessary.
cedet/semantic/db-find.el: Autoload semanticdb-find-default-throttle.
Defvar data-debug-thing-alist, and ede-current-project.
Declare data-debug-insert-stuff-list, data-debug-insert-tag-list,
semantic-scope-reset-cache, and semanticdb-typecache-notify-reset.
Require semantic/tag-file, and semantic/sort.
(semantic-reset): Require semantic/scope.
(semanticdb-partial-synchronize): Require semantic/db-typecache.
(semanticdb-find-table-for-include) Move up to avoid compiler warning.
cedet/semantic/db-global.el: Declare data-debug-new-buffer and
data-debug-insert-thing.
(semanticdb-project-database-global) Move up to avoid compiler warning.
cedet/semantic/db-javascript.el: Fix provide statement.
Require semantic/db-find instead of semantic/db-search.
cedet/semantic/db-mode.el: Declare semantic-lex-spp-set-dynamic-table.
(semanticdb-current-database, semanticdb-current-table): Move into
semantic/db.el
cedet/semantic/db-ref.el: Require eieio, semantic/db, and semantic/util.
Declare data-debug-new-buffer and data-debug-insert-object-slots.
Defvar semantic-case-fold. Require semantic/find when compiling.
cedet/semantic/db-typecache.el: Require semantic/tag-ls,
semantic/analyze/fcn, and semantic/scope. Declare
data-debug-insert-thing and data-debug-new-buffer.
cedet/semantic/db.el (semanticdb-search-results-table): Move class
definition here from semantic/db-search.el.
(semanticdb-current-database, semanticdb-current-table) Move variable
definitions here from semantic/db-mode.el.
2009-08-31 00:45:41 +00:00
|
|
|
|
(defvar semanticdb-current-database nil
|
|
|
|
|
"For a given buffer, this is the currently active database.")
|
|
|
|
|
(make-variable-buffer-local 'semanticdb-current-database)
|
|
|
|
|
|
2009-09-02 04:37:10 +00:00
|
|
|
|
;;;###autoload
|
cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
semanticdb-current-database and semanticdb-current-table are now in
semantic/db.el.
cedet/semantic/db-ebrowse.el: Don't require semantic/db-mode, since
semanticdb-current-database and semanticdb-current-table are now in
semantic/db.el.
cedet/semantic/db-el.el: Require semantic/lex-spp.
Require semantic/db instead of semantic/db-search.
cedet/semantic/db-file.el: Declare inversion-test and
data-debug-insert-thing.
(semanticdb-load-database): Load inversion only if necessary.
cedet/semantic/db-find.el: Autoload semanticdb-find-default-throttle.
Defvar data-debug-thing-alist, and ede-current-project.
Declare data-debug-insert-stuff-list, data-debug-insert-tag-list,
semantic-scope-reset-cache, and semanticdb-typecache-notify-reset.
Require semantic/tag-file, and semantic/sort.
(semantic-reset): Require semantic/scope.
(semanticdb-partial-synchronize): Require semantic/db-typecache.
(semanticdb-find-table-for-include) Move up to avoid compiler warning.
cedet/semantic/db-global.el: Declare data-debug-new-buffer and
data-debug-insert-thing.
(semanticdb-project-database-global) Move up to avoid compiler warning.
cedet/semantic/db-javascript.el: Fix provide statement.
Require semantic/db-find instead of semantic/db-search.
cedet/semantic/db-mode.el: Declare semantic-lex-spp-set-dynamic-table.
(semanticdb-current-database, semanticdb-current-table): Move into
semantic/db.el
cedet/semantic/db-ref.el: Require eieio, semantic/db, and semantic/util.
Declare data-debug-new-buffer and data-debug-insert-object-slots.
Defvar semantic-case-fold. Require semantic/find when compiling.
cedet/semantic/db-typecache.el: Require semantic/tag-ls,
semantic/analyze/fcn, and semantic/scope. Declare
data-debug-insert-thing and data-debug-new-buffer.
cedet/semantic/db.el (semanticdb-search-results-table): Move class
definition here from semantic/db-search.el.
(semanticdb-current-database, semanticdb-current-table) Move variable
definitions here from semantic/db-mode.el.
2009-08-31 00:45:41 +00:00
|
|
|
|
(defvar semanticdb-current-table nil
|
|
|
|
|
"For a given buffer, this is the currently active database table.")
|
|
|
|
|
(make-variable-buffer-local 'semanticdb-current-table)
|
2009-08-28 15:19:20 +00:00
|
|
|
|
|
|
|
|
|
;;; ABSTRACT CLASSES
|
|
|
|
|
;;
|
|
|
|
|
(defclass semanticdb-abstract-table ()
|
|
|
|
|
((parent-db ;; :initarg :parent-db
|
|
|
|
|
;; Do not set an initarg, or you get circular writes to disk.
|
|
|
|
|
:documentation "Database Object containing this table.")
|
|
|
|
|
(major-mode :initarg :major-mode
|
|
|
|
|
:initform nil
|
|
|
|
|
:documentation "Major mode this table belongs to.
|
|
|
|
|
Sometimes it is important for a program to know if a given table has the
|
|
|
|
|
same major mode as the current buffer.")
|
|
|
|
|
(tags :initarg :tags
|
|
|
|
|
:accessor semanticdb-get-tags
|
|
|
|
|
:printer semantic-tag-write-list-slot-value
|
|
|
|
|
:documentation "The tags belonging to this table.")
|
|
|
|
|
(index :type semanticdb-abstract-search-index
|
|
|
|
|
:documentation "The search index.
|
|
|
|
|
Used by semanticdb-find to store additional information about
|
|
|
|
|
this table for searching purposes.
|
|
|
|
|
|
|
|
|
|
Note: This index will not be saved in a persistent file.")
|
|
|
|
|
(cache :type list
|
|
|
|
|
:initform nil
|
|
|
|
|
:documentation "List of cache information for tools.
|
|
|
|
|
Any particular tool can cache data to a database at runtime
|
|
|
|
|
with `semanticdb-cache-get'.
|
|
|
|
|
|
|
|
|
|
Using a semanticdb cache does not save any information to a file,
|
|
|
|
|
so your cache will need to be recalculated at runtime. Caches can be
|
|
|
|
|
referenced even when the file is not in a buffer.
|
|
|
|
|
|
|
|
|
|
Note: This index will not be saved in a persistent file.")
|
|
|
|
|
)
|
|
|
|
|
"A simple table for semantic tags.
|
|
|
|
|
This table is the root of tables, and contains the minimum needed
|
|
|
|
|
for a new table not associated with a buffer."
|
|
|
|
|
:abstract t)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-in-buffer-p ((obj semanticdb-abstract-table))
|
|
|
|
|
"Return a nil, meaning abstract table OBJ is not in a buffer."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-get-buffer ((obj semanticdb-abstract-table))
|
|
|
|
|
"Return a buffer associated with OBJ.
|
|
|
|
|
If the buffer is not in memory, load it with `find-file-noselect'."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-full-filename ((obj semanticdb-abstract-table))
|
|
|
|
|
"Fetch the full filename that OBJ refers to.
|
|
|
|
|
Abstract tables do not have file names associated with them."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-dirty-p ((obj semanticdb-abstract-table))
|
|
|
|
|
"Return non-nil if OBJ is 'dirty'."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-set-dirty ((obj semanticdb-abstract-table))
|
|
|
|
|
"Mark the abstract table OBJ dirty.
|
|
|
|
|
Abstract tables can not be marked dirty, as there is nothing
|
|
|
|
|
for them to synchronize against."
|
|
|
|
|
;; The abstract table can not be dirty.
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-normalize-tags ((obj semanticdb-abstract-table) tags)
|
|
|
|
|
"For the table OBJ, convert a list of TAGS, into standardized form.
|
|
|
|
|
The default is to return TAGS.
|
|
|
|
|
Some databases may default to searching and providing simplified tags
|
|
|
|
|
based on whichever technique used. This method provides a hook for
|
|
|
|
|
them to convert TAG into a more complete form."
|
|
|
|
|
tags)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-normalize-one-tag ((obj semanticdb-abstract-table) tag)
|
|
|
|
|
"For the table OBJ, convert a TAG, into standardized form.
|
|
|
|
|
This method returns a list of the form (DATABASE . NEWTAG).
|
|
|
|
|
|
|
|
|
|
The default is to just return (OBJ TAG).
|
|
|
|
|
|
|
|
|
|
Some databases may default to searching and providing simplified tags
|
|
|
|
|
based on whichever technique used. This method provides a hook for
|
|
|
|
|
them to convert TAG into a more complete form."
|
|
|
|
|
(cons obj tag))
|
|
|
|
|
|
|
|
|
|
(defmethod object-print ((obj semanticdb-abstract-table) &rest strings)
|
|
|
|
|
"Pretty printer extension for `semanticdb-table'.
|
|
|
|
|
Adds the number of tags in this file to the object print name."
|
|
|
|
|
(apply 'call-next-method obj
|
|
|
|
|
(cons (format " (%d tags)"
|
|
|
|
|
(length (semanticdb-get-tags obj))
|
|
|
|
|
)
|
|
|
|
|
strings)))
|
|
|
|
|
|
|
|
|
|
;;; Index Cache
|
|
|
|
|
;;
|
|
|
|
|
(defclass semanticdb-abstract-search-index ()
|
|
|
|
|
((table :initarg :table
|
|
|
|
|
:type semanticdb-abstract-table
|
|
|
|
|
:documentation "XRef to the table this belongs to.")
|
|
|
|
|
)
|
|
|
|
|
"A place where semanticdb-find can store search index information.
|
|
|
|
|
The search index will store data about which other tables might be
|
|
|
|
|
needed, or perhaps create hash or index tables for the current buffer."
|
|
|
|
|
:abstract t)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-get-table-index ((obj semanticdb-abstract-table))
|
|
|
|
|
"Return the search index for the table OBJ.
|
|
|
|
|
If one doesn't exist, create it."
|
|
|
|
|
(if (slot-boundp obj 'index)
|
|
|
|
|
(oref obj index)
|
|
|
|
|
(let ((idx nil))
|
|
|
|
|
(setq idx (funcall semanticdb-default-find-index-class
|
|
|
|
|
(concat (object-name obj) " index")
|
|
|
|
|
;; Fill in the defaults
|
|
|
|
|
:table obj
|
|
|
|
|
))
|
|
|
|
|
(oset obj index idx)
|
|
|
|
|
idx)))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-synchronize ((idx semanticdb-abstract-search-index)
|
|
|
|
|
new-tags)
|
|
|
|
|
"Synchronize the search index IDX with some NEW-TAGS."
|
|
|
|
|
;; The abstract class will do... NOTHING!
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-partial-synchronize ((idx semanticdb-abstract-search-index)
|
|
|
|
|
new-tags)
|
|
|
|
|
"Synchronize the search index IDX with some changed NEW-TAGS."
|
|
|
|
|
;; The abstract class will do... NOTHING!
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2009-08-31 14:51:12 +00:00
|
|
|
|
;;; SEARCH RESULTS TABLE
|
|
|
|
|
;;
|
|
|
|
|
;; Needed for system databases that may not provide
|
|
|
|
|
;; a semanticdb-table associated with a file.
|
|
|
|
|
;;
|
|
|
|
|
(defclass semanticdb-search-results-table (semanticdb-abstract-table)
|
|
|
|
|
(
|
|
|
|
|
)
|
|
|
|
|
"Table used for search results when there is no file or table association.
|
|
|
|
|
Examples include search results from external sources such as from
|
|
|
|
|
Emacs' own symbol table, or from external libraries.")
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-refresh-table ((obj semanticdb-search-results-table) &optional force)
|
|
|
|
|
"If the tag list associated with OBJ is loaded, refresh it.
|
|
|
|
|
This will call `semantic-fetch-tags' if that file is in memory."
|
|
|
|
|
nil)
|
|
|
|
|
|
2009-08-28 15:19:20 +00:00
|
|
|
|
;;; CONCRETE TABLE CLASSES
|
|
|
|
|
;;
|
|
|
|
|
(defclass semanticdb-table (semanticdb-abstract-table)
|
|
|
|
|
((file :initarg :file
|
|
|
|
|
:documentation "File name relative to the parent database.
|
|
|
|
|
This is for the file whose tags are stored in this TABLE object.")
|
|
|
|
|
(buffer :initform nil
|
|
|
|
|
:documentation "The buffer associated with this table.
|
|
|
|
|
If nil, the table's buffer is no in Emacs. If it has a value, then
|
|
|
|
|
it is in Emacs.")
|
|
|
|
|
(dirty :initform nil
|
|
|
|
|
:documentation
|
|
|
|
|
"Non nil if this table needs to be `Saved'.")
|
|
|
|
|
(db-refs :initform nil
|
|
|
|
|
:documentation
|
|
|
|
|
"List of `semanticdb-table' objects refering to this one.
|
|
|
|
|
These aren't saved, but are instead recalculated after load.
|
2011-11-03 21:03:45 +01:00
|
|
|
|
See the file semantic/db-ref.el for how this slot is used.")
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(pointmax :initarg :pointmax
|
|
|
|
|
:initform nil
|
|
|
|
|
:documentation "Size of buffer when written to disk.
|
|
|
|
|
Checked on retrieval to make sure the file is the same.")
|
|
|
|
|
(fsize :initarg :fsize
|
|
|
|
|
:initform nil
|
|
|
|
|
:documentation "Size of the file when it was last referenced.
|
|
|
|
|
Checked when deciding if a loaded table needs updating from changes
|
|
|
|
|
outside of Semantic's control.")
|
|
|
|
|
(lastmodtime :initarg :lastmodtime
|
|
|
|
|
:initform nil
|
|
|
|
|
:documentation "Last modification time of the file referenced.
|
|
|
|
|
Checked when deciding if a loaded table needs updating from changes outside of
|
|
|
|
|
Semantic's control.")
|
|
|
|
|
;; @todo - need to add `last parsed time', so we can also have
|
|
|
|
|
;; refresh checks if spp tables or the parser gets rebuilt.
|
|
|
|
|
(unmatched-syntax :initarg :unmatched-syntax
|
|
|
|
|
:documentation
|
|
|
|
|
"List of vectors specifying unmatched syntax.")
|
|
|
|
|
|
|
|
|
|
(lexical-table :initarg :lexical-table
|
|
|
|
|
:initform nil
|
|
|
|
|
:printer semantic-lex-spp-table-write-slot-value
|
|
|
|
|
:documentation
|
|
|
|
|
"Table that might be needed by the lexical analyzer.
|
|
|
|
|
For C/C++, the C preprocessor macros can be saved here.")
|
|
|
|
|
)
|
|
|
|
|
"A single table of tags derived from file.")
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-in-buffer-p ((obj semanticdb-table))
|
|
|
|
|
"Return a buffer associated with OBJ.
|
|
|
|
|
If the buffer is in memory, return that buffer."
|
|
|
|
|
(let ((buff (oref obj buffer)))
|
|
|
|
|
(if (buffer-live-p buff)
|
|
|
|
|
buff
|
|
|
|
|
(oset obj buffer nil))))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-get-buffer ((obj semanticdb-table))
|
|
|
|
|
"Return a buffer associated with OBJ.
|
|
|
|
|
If the buffer is in memory, return that buffer.
|
|
|
|
|
If the buffer is not in memory, load it with `find-file-noselect'."
|
|
|
|
|
(or (semanticdb-in-buffer-p obj)
|
2009-09-19 17:25:30 +00:00
|
|
|
|
;; Save match data to protect against odd stuff in mode hooks.
|
|
|
|
|
(save-match-data
|
|
|
|
|
(find-file-noselect (semanticdb-full-filename obj) t))))
|
2009-08-28 15:19:20 +00:00
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-set-buffer ((obj semanticdb-table))
|
|
|
|
|
"Set the current buffer to be a buffer owned by OBJ.
|
|
|
|
|
If OBJ's file is not loaded, read it in first."
|
|
|
|
|
(set-buffer (semanticdb-get-buffer obj)))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-full-filename ((obj semanticdb-table))
|
|
|
|
|
"Fetch the full filename that OBJ refers to."
|
|
|
|
|
(expand-file-name (oref obj file)
|
|
|
|
|
(oref (oref obj parent-db) reference-directory)))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-dirty-p ((obj semanticdb-table))
|
|
|
|
|
"Return non-nil if OBJ is 'dirty'."
|
|
|
|
|
(oref obj dirty))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-set-dirty ((obj semanticdb-table))
|
|
|
|
|
"Mark the abstract table OBJ dirty."
|
|
|
|
|
(oset obj dirty t)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defmethod object-print ((obj semanticdb-table) &rest strings)
|
|
|
|
|
"Pretty printer extension for `semanticdb-table'.
|
|
|
|
|
Adds the number of tags in this file to the object print name."
|
|
|
|
|
(apply 'call-next-method obj
|
|
|
|
|
(cons (if (oref obj dirty) ", DIRTY" "") strings)))
|
|
|
|
|
|
|
|
|
|
;;; DATABASE BASE CLASS
|
|
|
|
|
;;
|
|
|
|
|
(defclass semanticdb-project-database (eieio-instance-tracker)
|
|
|
|
|
((tracking-symbol :initform semanticdb-database-list)
|
|
|
|
|
(reference-directory :type string
|
|
|
|
|
:documentation "Directory this database refers to.
|
|
|
|
|
When a cache directory is specified, then this refers to the directory
|
|
|
|
|
this database contains symbols for.")
|
|
|
|
|
(new-table-class :initform semanticdb-table
|
|
|
|
|
:type class
|
|
|
|
|
:documentation
|
|
|
|
|
"New tables created for this database are of this class.")
|
|
|
|
|
(cache :type list
|
|
|
|
|
:initform nil
|
|
|
|
|
:documentation "List of cache information for tools.
|
|
|
|
|
Any particular tool can cache data to a database at runtime
|
|
|
|
|
with `semanticdb-cache-get'.
|
|
|
|
|
|
|
|
|
|
Using a semanticdb cache does not save any information to a file,
|
|
|
|
|
so your cache will need to be recalculated at runtime.
|
|
|
|
|
|
|
|
|
|
Note: This index will not be saved in a persistent file.")
|
|
|
|
|
(tables :initarg :tables
|
|
|
|
|
:type list
|
|
|
|
|
;; Need this protection so apps don't try to access
|
|
|
|
|
;; the tables without using the accessor.
|
|
|
|
|
:accessor semanticdb-get-database-tables
|
|
|
|
|
:protection :protected
|
|
|
|
|
:documentation "List of `semantic-db-table' objects."))
|
|
|
|
|
"Database of file tables.")
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-full-filename ((obj semanticdb-project-database))
|
|
|
|
|
"Fetch the full filename that OBJ refers to.
|
|
|
|
|
Abstract tables do not have file names associated with them."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-dirty-p ((DB semanticdb-project-database))
|
|
|
|
|
"Return non-nil if DB is 'dirty'.
|
|
|
|
|
A database is dirty if the state of the database changed in a way
|
|
|
|
|
where it may need to resynchronize with some persistent storage."
|
|
|
|
|
(let ((dirty nil)
|
|
|
|
|
(tabs (oref DB tables)))
|
|
|
|
|
(while (and (not dirty) tabs)
|
|
|
|
|
(setq dirty (semanticdb-dirty-p (car tabs)))
|
|
|
|
|
(setq tabs (cdr tabs)))
|
|
|
|
|
dirty))
|
|
|
|
|
|
|
|
|
|
(defmethod object-print ((obj semanticdb-project-database) &rest strings)
|
|
|
|
|
"Pretty printer extension for `semanticdb-project-database'.
|
|
|
|
|
Adds the number of tables in this file to the object print name."
|
|
|
|
|
(apply 'call-next-method obj
|
|
|
|
|
(cons (format " (%d tables%s)"
|
|
|
|
|
(length (semanticdb-get-database-tables obj))
|
|
|
|
|
(if (semanticdb-dirty-p obj)
|
|
|
|
|
" DIRTY" "")
|
|
|
|
|
)
|
|
|
|
|
strings)))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-create-database :STATIC ((dbc semanticdb-project-database) directory)
|
|
|
|
|
"Create a new semantic database of class DBC for DIRECTORY and return it.
|
|
|
|
|
If a database for DIRECTORY has already been created, return it.
|
|
|
|
|
If DIRECTORY doesn't exist, create a new one."
|
|
|
|
|
(let ((db (semanticdb-directory-loaded-p directory)))
|
|
|
|
|
(unless db
|
|
|
|
|
(setq db (semanticdb-project-database
|
|
|
|
|
(file-name-nondirectory directory)
|
|
|
|
|
:tables nil))
|
|
|
|
|
;; Set this up here. We can't put it in the constructor because it
|
|
|
|
|
;; would be saved, and we want DB files to be portable.
|
|
|
|
|
(oset db reference-directory (file-truename directory)))
|
|
|
|
|
db))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-flush-database-tables ((db semanticdb-project-database))
|
|
|
|
|
"Reset the tables in DB to be empty."
|
|
|
|
|
(oset db tables nil))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-create-table ((db semanticdb-project-database) file)
|
|
|
|
|
"Create a new table in DB for FILE and return it.
|
|
|
|
|
The class of DB contains the class name for the type of table to create.
|
|
|
|
|
If the table for FILE exists, return it.
|
|
|
|
|
If the table for FILE does not exist, create one."
|
|
|
|
|
(let ((newtab (semanticdb-file-table db file)))
|
|
|
|
|
(unless newtab
|
|
|
|
|
;; This implementation will satisfy autoloaded classes
|
|
|
|
|
;; for tables.
|
|
|
|
|
(setq newtab (funcall (oref db new-table-class)
|
|
|
|
|
(file-name-nondirectory file)
|
|
|
|
|
:file (file-name-nondirectory file)
|
|
|
|
|
))
|
|
|
|
|
(oset newtab parent-db db)
|
|
|
|
|
(object-add-to-list db 'tables newtab t))
|
|
|
|
|
newtab))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-file-table ((obj semanticdb-project-database) filename)
|
|
|
|
|
"From OBJ, return FILENAME's associated table object."
|
|
|
|
|
(object-assoc (file-relative-name (file-truename filename)
|
|
|
|
|
(oref obj reference-directory))
|
|
|
|
|
'file (oref obj tables)))
|
|
|
|
|
|
|
|
|
|
;; DATABASE FUNCTIONS
|
|
|
|
|
(defun semanticdb-get-database (filename)
|
|
|
|
|
"Get a database for FILENAME.
|
|
|
|
|
If one isn't found, create one."
|
|
|
|
|
(semanticdb-create-database semanticdb-new-database-class (file-truename filename)))
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-directory-loaded-p (path)
|
|
|
|
|
"Return the project belonging to PATH if it was already loaded."
|
|
|
|
|
(eieio-instance-tracker-find path 'reference-directory 'semanticdb-database-list))
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-create-table-for-file (filename)
|
|
|
|
|
"Initialize a database table for FILENAME, and return it.
|
|
|
|
|
If FILENAME exists in the database already, return that.
|
|
|
|
|
If there is no database for the table to live in, create one."
|
|
|
|
|
(let ((cdb nil)
|
|
|
|
|
(tbl nil)
|
|
|
|
|
(dd (file-name-directory filename))
|
|
|
|
|
)
|
|
|
|
|
;; Allow a database override function
|
|
|
|
|
(setq cdb (semanticdb-create-database semanticdb-new-database-class
|
|
|
|
|
dd))
|
|
|
|
|
;; Get a table for this file.
|
|
|
|
|
(setq tbl (semanticdb-create-table cdb filename))
|
|
|
|
|
|
|
|
|
|
;; Return the pair.
|
|
|
|
|
(cons cdb tbl)
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
;;; Cache Cache.
|
|
|
|
|
;;
|
|
|
|
|
(defclass semanticdb-abstract-cache ()
|
|
|
|
|
((table :initarg :table
|
|
|
|
|
:type semanticdb-abstract-table
|
|
|
|
|
:documentation
|
|
|
|
|
"Cross reference to the table this belongs to.")
|
|
|
|
|
)
|
|
|
|
|
"Abstract baseclass for tools to use to cache information in semanticdb.
|
|
|
|
|
Tools needing a per-file cache must subclass this, and then get one as
|
|
|
|
|
needed. Cache objects are identified in semanticdb by subclass.
|
|
|
|
|
In order to keep your cache up to date, be sure to implement
|
|
|
|
|
`semanticdb-synchronize', and `semanticdb-partial-synchronize'.
|
2011-11-03 21:03:45 +01:00
|
|
|
|
See the file semantic/scope.el for an example."
|
2009-08-28 15:19:20 +00:00
|
|
|
|
:abstract t)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-cache-get ((table semanticdb-abstract-table)
|
|
|
|
|
desired-class)
|
|
|
|
|
"Get a cache object on TABLE of class DESIRED-CLASS.
|
|
|
|
|
This method will create one if none exists with no init arguments
|
|
|
|
|
other than :table."
|
2009-12-14 04:17:00 +00:00
|
|
|
|
(unless (child-of-class-p desired-class 'semanticdb-abstract-cache)
|
|
|
|
|
(error "Invalid SemanticDB cache"))
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(let ((cache (oref table cache))
|
|
|
|
|
(obj nil))
|
|
|
|
|
(while (and (not obj) cache)
|
|
|
|
|
(if (eq (object-class-fast (car cache)) desired-class)
|
|
|
|
|
(setq obj (car cache)))
|
|
|
|
|
(setq cache (cdr cache)))
|
|
|
|
|
(if obj
|
|
|
|
|
obj ;; Just return it.
|
2011-11-15 18:37:37 +01:00
|
|
|
|
;; No object, let's create a new one and return that.
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(setq obj (funcall desired-class "Cache" :table table))
|
|
|
|
|
(object-add-to-list table 'cache obj)
|
|
|
|
|
obj)))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-cache-remove ((table semanticdb-abstract-table)
|
|
|
|
|
cache)
|
|
|
|
|
"Remove from TABLE the cache object CACHE."
|
|
|
|
|
(object-remove-from-list table 'cache cache))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-synchronize ((cache semanticdb-abstract-cache)
|
|
|
|
|
new-tags)
|
|
|
|
|
"Synchronize a CACHE with some NEW-TAGS."
|
|
|
|
|
;; The abstract class will do... NOTHING!
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-partial-synchronize ((cache semanticdb-abstract-cache)
|
|
|
|
|
new-tags)
|
|
|
|
|
"Synchronize a CACHE with some changed NEW-TAGS."
|
|
|
|
|
;; The abstract class will do... NOTHING!
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defclass semanticdb-abstract-db-cache ()
|
|
|
|
|
((db :initarg :db
|
|
|
|
|
:type semanticdb-project-database
|
|
|
|
|
:documentation
|
|
|
|
|
"Cross reference to the database this belongs to.")
|
|
|
|
|
)
|
|
|
|
|
"Abstract baseclass for tools to use to cache information in semanticdb.
|
|
|
|
|
Tools needing a database cache must subclass this, and then get one as
|
|
|
|
|
needed. Cache objects are identified in semanticdb by subclass.
|
|
|
|
|
In order to keep your cache up to date, be sure to implement
|
|
|
|
|
`semanticdb-synchronize', and `semanticdb-partial-synchronize'.
|
2011-11-03 21:03:45 +01:00
|
|
|
|
See the file semantic/scope.el for an example."
|
2009-08-28 15:19:20 +00:00
|
|
|
|
:abstract t)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-cache-get ((db semanticdb-project-database)
|
|
|
|
|
desired-class)
|
|
|
|
|
"Get a cache object on DB of class DESIRED-CLASS.
|
|
|
|
|
This method will create one if none exists with no init arguments
|
|
|
|
|
other than :table."
|
2009-12-14 04:17:00 +00:00
|
|
|
|
(unless (child-of-class-p desired-class 'semanticdb-abstract-cache)
|
|
|
|
|
(error "Invalid SemanticDB cache"))
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(let ((cache (oref db cache))
|
|
|
|
|
(obj nil))
|
|
|
|
|
(while (and (not obj) cache)
|
|
|
|
|
(if (eq (object-class-fast (car cache)) desired-class)
|
|
|
|
|
(setq obj (car cache)))
|
|
|
|
|
(setq cache (cdr cache)))
|
|
|
|
|
(if obj
|
|
|
|
|
obj ;; Just return it.
|
2011-11-15 18:37:37 +01:00
|
|
|
|
;; No object, let's create a new one and return that.
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(setq obj (funcall desired-class "Cache" :db db))
|
|
|
|
|
(object-add-to-list db 'cache obj)
|
|
|
|
|
obj)))
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-cache-remove ((db semanticdb-project-database)
|
|
|
|
|
cache)
|
|
|
|
|
"Remove from TABLE the cache object CACHE."
|
|
|
|
|
(object-remove-from-list db 'cache cache))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-synchronize ((cache semanticdb-abstract-db-cache)
|
|
|
|
|
new-tags)
|
|
|
|
|
"Synchronize a CACHE with some NEW-TAGS."
|
|
|
|
|
;; The abstract class will do... NOTHING!
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-partial-synchronize ((cache semanticdb-abstract-db-cache)
|
|
|
|
|
new-tags)
|
|
|
|
|
"Synchronize a CACHE with some changed NEW-TAGS."
|
|
|
|
|
;; The abstract class will do... NOTHING!
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
;;; REFRESH
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-refresh-table ((obj semanticdb-table) &optional force)
|
|
|
|
|
"If the tag list associated with OBJ is loaded, refresh it.
|
|
|
|
|
Optional argument FORCE will force a refresh even if the file in question
|
|
|
|
|
is not in a buffer. Avoid using FORCE for most uses, as an old cache
|
|
|
|
|
may be sufficient for the general case. Forced updates can be slow.
|
|
|
|
|
This will call `semantic-fetch-tags' if that file is in memory."
|
Synch Semantic to CEDET 1.0.
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog.
* semantic.el (semantic-version): Update to 2.0.
(semantic-mode-map): Add "," and "m" bindings.
(navigate-menu): Update.
* semantic/symref.el (semantic-symref-calculate-rootdir):
New function.
(semantic-symref-detect-symref-tool): Use it.
* semantic/symref/grep.el (semantic-symref-grep-shell): New var.
(semantic-symref-perform-search): Use it. Calculate root dir with
semantic-symref-calculate-rootdir.
(semantic-symref-derive-find-filepatterns): Improve error message.
* semantic/symref/list.el
(semantic-symref-results-mode-map): New bindings.
(semantic-symref-auto-expand-results): New option.
(semantic-symref-results-dump): Obey auto-expand.
(semantic-symref-list-expand-all, semantic-symref-regexp)
(semantic-symref-list-contract-all)
(semantic-symref-list-map-open-hits)
(semantic-symref-list-update-open-hits)
(semantic-symref-list-create-macro-on-open-hit)
(semantic-symref-list-call-macro-on-open-hits): New functions.
(semantic-symref-list-menu-entries)
(semantic-symref-list-menu): New vars.
(semantic-symref-list-map-open-hits): Move cursor to beginning of
match before calling the mapped function.
* semantic/doc.el
(semantic-documentation-comment-preceeding-tag): Do nothing if the
mode doesn't provide comment-start-skip.
* semantic/scope.el
(semantic-analyze-scope-nested-tags-default): Strip duplicates.
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
(semantic-decoration-on-includes-highlight-default): Check that
the include tag has a postion.
* semantic/complete.el (semantic-collector-local-members):
(semantic-complete-read-tag-local-members)
(semantic-complete-jump-local-members): New class and functions.
(semantic-complete-self-insert): Save excursion before completing.
* semantic/analyze/complete.el
(semantic-analyze-possible-completions-default): If no completions
are found, return the raw by-name-only completion list. Add FLAGS
arguments. Add support for 'no-tc (type constraint) and
'no-unique, or no stripping duplicates.
(semantic-analyze-possible-completions-default): Add FLAGS arg.
* semantic/util-modes.el
(semantic-stickyfunc-show-only-functions-p): New option.
(semantic-stickyfunc-fetch-stickyline): Don't show stickytext for
the very first line in a buffer.
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
* semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the
:filename property and the tag position.
* semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Add recursion limit.
* semantic/imenu.el (semantic-imenu-bucketize-type-members):
Make this buffer local, not the obsoleted variable.
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
(semantic-idle-symbol-maybe-highlight): Rename from *-summary-*.
Callers changed.
(semantic-idle-work-parse-neighboring-files-flag): Default to nil.
(semantic-idle-work-update-headers-flag): New var.
(semantic-idle-work-for-one-buffer): Use it.
(semantic-idle-local-symbol-highlight): Rename from
semantic-idle-tag-highlight.
(semantic-idle-truncate-long-summaries): New option.
* semantic/ia.el (semantic-ia-cache)
(semantic-ia-get-completions): Deleted. Callers changed.
(semantic-ia-show-variants): New command.
(semantic-ia-show-doc): If doc is empty, don't make a temp buffer.
(semantic-ia-show-summary): If there isn't anything to show, say so.
* semantic/grammar.el (semantic-grammar-create-package):
Save the buffer even in batch mode.
* semantic/fw.el
(semanticdb-without-unloaded-file-searches): New macro.
* semantic/dep.el (semantic-dependency-find-file-on-path):
Fix case dereferencing ede-object when it is a list.
* semantic/db-typecache.el (semanticdb-expand-nested-tag)
(semanticdb-typecache-faux-namespace): New functions.
(semanticdb-typecache-file-tags)
(semanticdb-typecache-merge-streams): Use them.
(semanticdb-typecache-file-tags): When deriving tags from a file,
give the mode a chance to monkey with the tag copy.
(semanticdb-typecache-find-default): Wrap find in save-excursion.
(semanticdb-typecache-find-by-name-helper): Merge found names down.
* semantic/db-global.el
(semanticdb-enable-gnu-global-in-buffer): Don't show messages if
GNU Global is not available and we don't want to throw an error.
* semantic/db-find.el (semanticdb-find-result-nth-in-buffer):
When trying to normalize the tag to a buffer, don't error if
set-buffer method doesn't exist.
* semantic/db-file.el (semanticdb-save-db): Simplify msg.
* semantic/db.el (semanticdb-refresh-table): If forcing a
refresh on a file not in a buffer, use semantic-find-file-noselect
and delete the buffer after use.
(semanticdb-current-database-list): When calculating root via
hooks, force it through true-filename and skip the list of
possible roots.
* semantic/ctxt.el (semantic-ctxt-imported-packages): New.
* semantic/analyze/debug.el
(semantic-analyzer-debug-insert-tag): Reset standard output to
current buffer.
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype): Change "prefix" to
"symbol" in messages.
* semantic/analyze/refs.el: (semantic-analyze-refs-impl)
(semantic-analyze-refs-proto): When calculating value, make sure
the found tag is 'similar' to the originating tag.
(semantic--analyze-refs-find-tags-with-parent): Attempt to
identify matches via imported symbols of parents.
(semantic--analyze-refs-full-lookup-with-parents): Do a deep
search during the brute search.
* semantic/analyze.el
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
(semantic-expand-c-tag-namelist): Split a full type from a typedef
out to its own tag.
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
* semantic/wisent/python-wy.el: Regenerate.
2010-09-18 22:49:54 -04:00
|
|
|
|
(cond
|
|
|
|
|
;;
|
|
|
|
|
;; Already in a buffer, just do it.
|
|
|
|
|
((semanticdb-in-buffer-p obj)
|
|
|
|
|
(semanticdb-set-buffer obj)
|
|
|
|
|
(semantic-fetch-tags))
|
|
|
|
|
;;
|
|
|
|
|
;; Not in a buffer. Forcing a load.
|
|
|
|
|
(force
|
|
|
|
|
;; Patch from Iain Nicol. --
|
|
|
|
|
;; @TODO: I wonder if there is a way to recycle
|
|
|
|
|
;; semanticdb-create-table-for-file-not-in-buffer
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(save-excursion
|
Synch Semantic to CEDET 1.0.
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog.
* semantic.el (semantic-version): Update to 2.0.
(semantic-mode-map): Add "," and "m" bindings.
(navigate-menu): Update.
* semantic/symref.el (semantic-symref-calculate-rootdir):
New function.
(semantic-symref-detect-symref-tool): Use it.
* semantic/symref/grep.el (semantic-symref-grep-shell): New var.
(semantic-symref-perform-search): Use it. Calculate root dir with
semantic-symref-calculate-rootdir.
(semantic-symref-derive-find-filepatterns): Improve error message.
* semantic/symref/list.el
(semantic-symref-results-mode-map): New bindings.
(semantic-symref-auto-expand-results): New option.
(semantic-symref-results-dump): Obey auto-expand.
(semantic-symref-list-expand-all, semantic-symref-regexp)
(semantic-symref-list-contract-all)
(semantic-symref-list-map-open-hits)
(semantic-symref-list-update-open-hits)
(semantic-symref-list-create-macro-on-open-hit)
(semantic-symref-list-call-macro-on-open-hits): New functions.
(semantic-symref-list-menu-entries)
(semantic-symref-list-menu): New vars.
(semantic-symref-list-map-open-hits): Move cursor to beginning of
match before calling the mapped function.
* semantic/doc.el
(semantic-documentation-comment-preceeding-tag): Do nothing if the
mode doesn't provide comment-start-skip.
* semantic/scope.el
(semantic-analyze-scope-nested-tags-default): Strip duplicates.
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
(semantic-decoration-on-includes-highlight-default): Check that
the include tag has a postion.
* semantic/complete.el (semantic-collector-local-members):
(semantic-complete-read-tag-local-members)
(semantic-complete-jump-local-members): New class and functions.
(semantic-complete-self-insert): Save excursion before completing.
* semantic/analyze/complete.el
(semantic-analyze-possible-completions-default): If no completions
are found, return the raw by-name-only completion list. Add FLAGS
arguments. Add support for 'no-tc (type constraint) and
'no-unique, or no stripping duplicates.
(semantic-analyze-possible-completions-default): Add FLAGS arg.
* semantic/util-modes.el
(semantic-stickyfunc-show-only-functions-p): New option.
(semantic-stickyfunc-fetch-stickyline): Don't show stickytext for
the very first line in a buffer.
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
* semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the
:filename property and the tag position.
* semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Add recursion limit.
* semantic/imenu.el (semantic-imenu-bucketize-type-members):
Make this buffer local, not the obsoleted variable.
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
(semantic-idle-symbol-maybe-highlight): Rename from *-summary-*.
Callers changed.
(semantic-idle-work-parse-neighboring-files-flag): Default to nil.
(semantic-idle-work-update-headers-flag): New var.
(semantic-idle-work-for-one-buffer): Use it.
(semantic-idle-local-symbol-highlight): Rename from
semantic-idle-tag-highlight.
(semantic-idle-truncate-long-summaries): New option.
* semantic/ia.el (semantic-ia-cache)
(semantic-ia-get-completions): Deleted. Callers changed.
(semantic-ia-show-variants): New command.
(semantic-ia-show-doc): If doc is empty, don't make a temp buffer.
(semantic-ia-show-summary): If there isn't anything to show, say so.
* semantic/grammar.el (semantic-grammar-create-package):
Save the buffer even in batch mode.
* semantic/fw.el
(semanticdb-without-unloaded-file-searches): New macro.
* semantic/dep.el (semantic-dependency-find-file-on-path):
Fix case dereferencing ede-object when it is a list.
* semantic/db-typecache.el (semanticdb-expand-nested-tag)
(semanticdb-typecache-faux-namespace): New functions.
(semanticdb-typecache-file-tags)
(semanticdb-typecache-merge-streams): Use them.
(semanticdb-typecache-file-tags): When deriving tags from a file,
give the mode a chance to monkey with the tag copy.
(semanticdb-typecache-find-default): Wrap find in save-excursion.
(semanticdb-typecache-find-by-name-helper): Merge found names down.
* semantic/db-global.el
(semanticdb-enable-gnu-global-in-buffer): Don't show messages if
GNU Global is not available and we don't want to throw an error.
* semantic/db-find.el (semanticdb-find-result-nth-in-buffer):
When trying to normalize the tag to a buffer, don't error if
set-buffer method doesn't exist.
* semantic/db-file.el (semanticdb-save-db): Simplify msg.
* semantic/db.el (semanticdb-refresh-table): If forcing a
refresh on a file not in a buffer, use semantic-find-file-noselect
and delete the buffer after use.
(semanticdb-current-database-list): When calculating root via
hooks, force it through true-filename and skip the list of
possible roots.
* semantic/ctxt.el (semantic-ctxt-imported-packages): New.
* semantic/analyze/debug.el
(semantic-analyzer-debug-insert-tag): Reset standard output to
current buffer.
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype): Change "prefix" to
"symbol" in messages.
* semantic/analyze/refs.el: (semantic-analyze-refs-impl)
(semantic-analyze-refs-proto): When calculating value, make sure
the found tag is 'similar' to the originating tag.
(semantic--analyze-refs-find-tags-with-parent): Attempt to
identify matches via imported symbols of parents.
(semantic--analyze-refs-full-lookup-with-parents): Do a deep
search during the brute search.
* semantic/analyze.el
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
(semantic-expand-c-tag-namelist): Split a full type from a typedef
out to its own tag.
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
* semantic/wisent/python-wy.el: Regenerate.
2010-09-18 22:49:54 -04:00
|
|
|
|
(let ((buff (semantic-find-file-noselect
|
|
|
|
|
(semanticdb-full-filename obj))))
|
|
|
|
|
(set-buffer buff)
|
|
|
|
|
(semantic-fetch-tags)
|
|
|
|
|
;; Kill off the buffer if it didn't exist when we were called.
|
|
|
|
|
(kill-buffer buff))))))
|
2009-08-28 15:19:20 +00:00
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-needs-refresh-p ((obj semanticdb-table))
|
|
|
|
|
"Return non-nil of OBJ's tag list is out of date.
|
|
|
|
|
The file associated with OBJ does not need to be in a buffer."
|
|
|
|
|
(let* ((ff (semanticdb-full-filename obj))
|
|
|
|
|
(buff (semanticdb-in-buffer-p obj))
|
|
|
|
|
)
|
|
|
|
|
(if buff
|
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
* cedet/semantic/symref/list.el (semantic-symref-rb-toggle-expand-tag):
* cedet/semantic/symref/grep.el (semantic-symref-perform-search):
* cedet/semantic/bovine/gcc.el (semantic-gcc-query):
* cedet/semantic/bovine/c.el (semantic-c-parse-lexical-token):
* cedet/semantic/analyze/debug.el (semantic-analyzer-debug-add-buttons)
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype)
(semantic-analyzer-debug-insert-include-summary):
* cedet/semantic/util.el (semantic-file-tag-table):
(semantic-describe-buffer-var-helper, semantic-something-to-tag-table)
(semantic-recursive-find-nonterminal-by-name):
* cedet/semantic/tag-ls.el (semantic-tag-calculate-parent-default):
* cedet/semantic/tag-file.el (semantic-prototype-file):
* cedet/semantic/symref.el (semantic-symref-parse-tool-output):
* cedet/semantic/sb.el (semantic-sb-fetch-tag-table):
* cedet/semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
* cedet/semantic/idle.el (semantic-idle-work-for-one-buffer):
(semantic-idle-summary-maybe-highlight):
* cedet/semantic/ia-sb.el (semantic-ia-speedbar)
(semantic-ia-sb-tag-info):
* cedet/semantic/grammar.el (semantic-analyze-possible-completions):
* cedet/semantic/find.el (semantic-brute-find-tag-by-position):
* cedet/semantic/ede-grammar.el (project-compile-target):
(ede-proj-makefile-insert-variables):
* cedet/semantic/debug.el (semantic-debug-set-parser-location):
(semantic-debug-set-source-location, semantic-debug-interface-layout)
(semantic-debug-mode, semantic-debug):
* cedet/semantic/db.el (semanticdb-needs-refresh-p):
* cedet/semantic/db-typecache.el (semanticdb-typecache-refresh-for-buffer):
* cedet/semantic/db-javascript.el (semanticdb-equivalent-mode):
* cedet/semantic/db-find.el (semanticdb-find-log-new-search)
(semanticdb-find-translate-path-includes--internal)
(semanticdb-reset-log, semanticdb-find-log-activity):
* cedet/semantic/db-file.el (object-write):
* cedet/semantic/db-el.el (semanticdb-equivalent-mode):
* cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-C-file-p)
(semanticdb-create-ebrowse-database):
* cedet/semantic/db-debug.el (semanticdb-table-sanity-check):
* cedet/semantic/complete.el (semantic-displayor-focus-request)
(semantic-collector-calculate-completions-raw)
(semantic-complete-read-tag-analyzer):
* cedet/semantic/analyze.el (semantic-analyze-pulse):
* cedet/ede/util.el (ede-update-version-in-source):
* cedet/ede/proj.el (project-delete-target):
* cedet/ede/proj-elisp.el (ede-update-version-in-source)
(ede-proj-flush-autoconf):
* cedet/ede/pconf.el (ede-proj-configure-synchronize)
(ede-proj-configure-synchronize):
* cedet/ede/locate.el (ede-locate-file-in-project-impl):
* cedet/ede/linux.el (ede-linux-version):
* cedet/ede/emacs.el (ede-emacs-version):
* cedet/ede/dired.el (ede-dired-add-to-target):
* cedet/ede.el (ede-buffer-header-file, ede-find-target)
(ede-buffer-documentation-files, ede-project-buffers, ede-set)
(ede-target-buffers, ede-buffers, ede-make-project-local-variable):
* cedet/cedet-idutils.el (cedet-idutils-fnid-call):
(cedet-idutils-lid-call, cedet-idutils-expand-filename)
(cedet-idutils-version-check):
* cedet/cedet-global.el (cedet-gnu-global-call):
(cedet-gnu-global-expand-filename, cedet-gnu-global-root)
(cedet-gnu-global-version-check, cedet-gnu-global-scan-hits):
* cedet/cedet-cscope.el (cedet-cscope-call)
(cedet-cscope-expand-filename, cedet-cscope-version-check):
Use with-current-buffer.
* cedet/ede.el (ede-make-project-local-variable)
(ede-set-project-variables, ede-set): Use dolist.
2009-10-30 02:16:41 +00:00
|
|
|
|
(with-current-buffer buff
|
2009-08-28 15:19:20 +00:00
|
|
|
|
;; Use semantic's magic tracker to determine of the buffer is up
|
|
|
|
|
;; to date or not.
|
|
|
|
|
(not (semantic-parse-tree-up-to-date-p))
|
|
|
|
|
;; We assume that semanticdb is keeping itself up to date.
|
|
|
|
|
;; via all the clever hooks
|
|
|
|
|
)
|
|
|
|
|
;; Buffer isn't loaded. The only clue we have is if the file
|
|
|
|
|
;; is somehow different from our mark in the semanticdb table.
|
|
|
|
|
(let* ((stats (file-attributes ff))
|
|
|
|
|
(actualsize (nth 7 stats))
|
|
|
|
|
(actualmod (nth 5 stats))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(or (not (slot-boundp obj 'tags))
|
|
|
|
|
;; (not (oref obj tags)) --> not needed anymore?
|
|
|
|
|
(/= (or (oref obj fsize) 0) actualsize)
|
|
|
|
|
(not (equal (oref obj lastmodtime) actualmod))
|
|
|
|
|
)
|
|
|
|
|
))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Synchronization
|
|
|
|
|
;;
|
|
|
|
|
(defmethod semanticdb-synchronize ((table semanticdb-abstract-table)
|
|
|
|
|
new-tags)
|
|
|
|
|
"Synchronize the table TABLE with some NEW-TAGS."
|
|
|
|
|
(oset table tags new-tags)
|
|
|
|
|
(oset table pointmax (point-max))
|
|
|
|
|
(let ((fattr (file-attributes (semanticdb-full-filename table))))
|
|
|
|
|
(oset table fsize (nth 7 fattr))
|
|
|
|
|
(oset table lastmodtime (nth 5 fattr))
|
|
|
|
|
)
|
|
|
|
|
;; Assume it is now up to date.
|
|
|
|
|
(oset table unmatched-syntax semantic-unmatched-syntax-cache)
|
|
|
|
|
;; The lexical table should be good too.
|
2009-09-06 21:22:05 +00:00
|
|
|
|
(when (featurep 'semantic/lex-spp)
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(oset table lexical-table (semantic-lex-spp-save-table)))
|
|
|
|
|
;; this implies dirtyness
|
|
|
|
|
(semanticdb-set-dirty table)
|
|
|
|
|
|
|
|
|
|
;; Synchronize the index
|
|
|
|
|
(when (slot-boundp table 'index)
|
|
|
|
|
(let ((idx (oref table index)))
|
|
|
|
|
(when idx (semanticdb-synchronize idx new-tags))))
|
|
|
|
|
|
|
|
|
|
;; Synchronize application caches.
|
|
|
|
|
(dolist (C (oref table cache))
|
|
|
|
|
(semanticdb-synchronize C new-tags)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
;; Update cross references
|
|
|
|
|
;; (semanticdb-refresh-references table)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-partial-synchronize ((table semanticdb-abstract-table)
|
|
|
|
|
new-tags)
|
|
|
|
|
"Synchronize the table TABLE where some NEW-TAGS changed."
|
|
|
|
|
;; You might think we need to reset the tags, but since the partial
|
|
|
|
|
;; parser splices the lists, we don't need to do anything
|
|
|
|
|
;;(oset table tags new-tags)
|
|
|
|
|
;; We do need to mark ourselves dirty.
|
|
|
|
|
(semanticdb-set-dirty table)
|
|
|
|
|
|
|
|
|
|
;; The lexical table may be modified.
|
2009-09-06 21:22:05 +00:00
|
|
|
|
(when (featurep 'semantic/lex-spp)
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(oset table lexical-table (semantic-lex-spp-save-table)))
|
|
|
|
|
|
|
|
|
|
;; Incremental parser doesn't mokey around with this.
|
|
|
|
|
(oset table unmatched-syntax semantic-unmatched-syntax-cache)
|
|
|
|
|
|
|
|
|
|
;; Synchronize the index
|
|
|
|
|
(when (slot-boundp table 'index)
|
|
|
|
|
(let ((idx (oref table index)))
|
|
|
|
|
(when idx (semanticdb-partial-synchronize idx new-tags))))
|
|
|
|
|
|
|
|
|
|
;; Synchronize application caches.
|
|
|
|
|
(dolist (C (oref table cache))
|
|
|
|
|
(semanticdb-synchronize C new-tags)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
;; Update cross references
|
|
|
|
|
;;(when (semantic-find-tags-by-class 'include new-tags)
|
|
|
|
|
;; (semanticdb-refresh-references table))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
;;; SAVE/LOAD
|
|
|
|
|
;;
|
|
|
|
|
(defmethod semanticdb-save-db ((DB semanticdb-project-database)
|
|
|
|
|
&optional supress-questions)
|
|
|
|
|
"Cause a database to save itself.
|
|
|
|
|
The database base class does not save itself persistently.
|
|
|
|
|
Subclasses could save themselves to a file, or to a database, or other
|
|
|
|
|
form."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-save-current-db ()
|
|
|
|
|
"Save the current tag database."
|
|
|
|
|
(interactive)
|
|
|
|
|
(message "Saving current tag summaries...")
|
|
|
|
|
(semanticdb-save-db semanticdb-current-database)
|
|
|
|
|
(message "Saving current tag summaries...done"))
|
|
|
|
|
|
2009-09-21 18:20:50 +00:00
|
|
|
|
;; This prevents Semanticdb from querying multiple times if the users
|
|
|
|
|
;; answers "no" to creating the Semanticdb directory.
|
|
|
|
|
(defvar semanticdb--inhibit-create-file-directory)
|
|
|
|
|
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(defun semanticdb-save-all-db ()
|
|
|
|
|
"Save all semantic tag databases."
|
|
|
|
|
(interactive)
|
|
|
|
|
(message "Saving tag summaries...")
|
2009-09-21 18:20:50 +00:00
|
|
|
|
(let ((semanticdb--inhibit-make-directory nil))
|
|
|
|
|
(mapc 'semanticdb-save-db semanticdb-database-list))
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(message "Saving tag summaries...done"))
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-save-all-db-idle ()
|
|
|
|
|
"Save all semantic tag databases from idle time.
|
|
|
|
|
Exit the save between databases if there is user input."
|
|
|
|
|
(semantic-safe "Auto-DB Save: %S"
|
|
|
|
|
(semantic-exit-on-input 'semanticdb-idle-save
|
|
|
|
|
(mapc (lambda (db)
|
|
|
|
|
(semantic-throw-on-input 'semanticdb-idle-save)
|
|
|
|
|
(semanticdb-save-db db t))
|
|
|
|
|
semanticdb-database-list))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
;;; Directory Project support
|
|
|
|
|
;;
|
|
|
|
|
(defvar semanticdb-project-predicate-functions nil
|
|
|
|
|
"List of predicates to try that indicate a directory belongs to a project.
|
|
|
|
|
This list is used when `semanticdb-persistent-path' contains the value
|
|
|
|
|
'project. If the predicate list is nil, then presume all paths are valid.
|
|
|
|
|
|
|
|
|
|
Project Management software (such as EDE and JDE) should add their own
|
|
|
|
|
predicates with `add-hook' to this variable, and semanticdb will save tag
|
|
|
|
|
caches in directories controlled by them.")
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-write-directory-p ((obj semanticdb-project-database))
|
|
|
|
|
"Return non-nil if OBJ should be written to disk.
|
|
|
|
|
Uses `semanticdb-persistent-path' to determine the return value."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
;;; Utilities
|
|
|
|
|
;;
|
|
|
|
|
;; What is the current database, are two tables of an equivalent mode,
|
|
|
|
|
;; and what databases are a part of the same project.
|
|
|
|
|
(defun semanticdb-current-database ()
|
|
|
|
|
"Return the currently active database."
|
|
|
|
|
(or semanticdb-current-database
|
|
|
|
|
(and default-directory
|
|
|
|
|
(semanticdb-create-database semanticdb-new-database-class
|
|
|
|
|
default-directory)
|
|
|
|
|
)
|
|
|
|
|
nil))
|
|
|
|
|
|
|
|
|
|
(defvar semanticdb-match-any-mode nil
|
2009-10-01 04:54:05 +00:00
|
|
|
|
"Non-nil to temporarily search any major mode for a tag.
|
2009-08-28 15:19:20 +00:00
|
|
|
|
If a particular major mode wants to search any mode, put the
|
|
|
|
|
`semantic-match-any-mode' symbol onto the symbol of that major mode.
|
|
|
|
|
Do not set the value of this variable permanently.")
|
|
|
|
|
|
|
|
|
|
(defmacro semanticdb-with-match-any-mode (&rest body)
|
2009-10-01 04:54:05 +00:00
|
|
|
|
"A Semanticdb search occurring withing BODY will search tags in all modes.
|
|
|
|
|
This temporarily sets `semanticdb-match-any-mode' while executing BODY."
|
2009-08-28 15:19:20 +00:00
|
|
|
|
`(let ((semanticdb-match-any-mode t))
|
|
|
|
|
,@body))
|
|
|
|
|
(put 'semanticdb-with-match-any-mode 'lisp-indent-function 0)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-equivalent-mode-for-search (table &optional buffer)
|
|
|
|
|
"Return non-nil if TABLE's mode is equivalent to BUFFER.
|
|
|
|
|
See `semanticdb-equivalent-mode' for details.
|
|
|
|
|
This version is used during searches. Major-modes that opt
|
|
|
|
|
to set the `semantic-match-any-mode' property will be able to search
|
|
|
|
|
all files of any type."
|
|
|
|
|
(or (get major-mode 'semantic-match-any-mode)
|
|
|
|
|
semanticdb-match-any-mode
|
|
|
|
|
(semanticdb-equivalent-mode table buffer))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-equivalent-mode ((table semanticdb-abstract-table) &optional buffer)
|
|
|
|
|
"Return non-nil if TABLE's mode is equivalent to BUFFER.
|
2010-01-15 18:51:50 -08:00
|
|
|
|
Equivalent modes are specified by the `semantic-equivalent-major-modes'
|
2009-08-28 15:19:20 +00:00
|
|
|
|
local variable."
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
(defmethod semanticdb-equivalent-mode ((table semanticdb-table) &optional buffer)
|
|
|
|
|
"Return non-nil if TABLE's mode is equivalent to BUFFER.
|
2010-01-15 18:51:50 -08:00
|
|
|
|
Equivalent modes are specified by the `semantic-equivalent-major-modes'
|
2009-08-28 15:19:20 +00:00
|
|
|
|
local variable."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if buffer (set-buffer buffer))
|
|
|
|
|
(or
|
|
|
|
|
;; nil major mode in table means we don't know yet. Assume yes for now?
|
|
|
|
|
(null (oref table major-mode))
|
|
|
|
|
;; nil means the same as major-mode
|
|
|
|
|
(and (not semantic-equivalent-major-modes)
|
|
|
|
|
(mode-local-use-bindings-p major-mode (oref table major-mode)))
|
|
|
|
|
(and semantic-equivalent-major-modes
|
|
|
|
|
(member (oref table major-mode) semantic-equivalent-major-modes))
|
|
|
|
|
)
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Associations
|
|
|
|
|
;;
|
|
|
|
|
;; These routines determine associations between a file, and multiple
|
|
|
|
|
;; associated databases.
|
|
|
|
|
|
|
|
|
|
(defcustom semanticdb-project-roots nil
|
|
|
|
|
"*List of directories, where each directory is the root of some project.
|
|
|
|
|
All subdirectories of a root project are considered a part of one project.
|
2009-10-01 04:54:05 +00:00
|
|
|
|
Values in this string can be overridden by project management programs
|
2009-08-28 15:19:20 +00:00
|
|
|
|
via the `semanticdb-project-root-functions' variable."
|
|
|
|
|
:group 'semanticdb
|
|
|
|
|
:type '(repeat string))
|
|
|
|
|
|
|
|
|
|
(defvar semanticdb-project-root-functions nil
|
|
|
|
|
"List of functions used to determine a given directories project root.
|
|
|
|
|
Functions in this variable can override `semanticdb-project-roots'.
|
|
|
|
|
Functions set in the variable are given one argument (a directory) and
|
|
|
|
|
must return a string, (the root directory) or a list of strings (multiple
|
|
|
|
|
root directories in a more complex system). This variable should be used
|
|
|
|
|
by project management programs like EDE or JDE.")
|
|
|
|
|
|
|
|
|
|
(defvar semanticdb-project-system-databases nil
|
|
|
|
|
"List of databases containing system library information.
|
|
|
|
|
Mode authors can create their own system databases which know
|
|
|
|
|
detailed information about the system libraries for querying purposes.
|
|
|
|
|
Put those into this variable as a buffer-local, or mode-local
|
|
|
|
|
value.")
|
|
|
|
|
(make-variable-buffer-local 'semanticdb-project-system-databases)
|
|
|
|
|
|
|
|
|
|
(defvar semanticdb-search-system-databases t
|
|
|
|
|
"Non nil if search routines are to include a system database.")
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-current-database-list (&optional dir)
|
|
|
|
|
"Return a list of databases associated with the current buffer.
|
|
|
|
|
If optional argument DIR is non-nil, then use DIR as the starting directory.
|
|
|
|
|
If this buffer has a database, but doesn't have a project associated
|
|
|
|
|
with it, return nil.
|
|
|
|
|
First, it checks `semanticdb-project-root-functions', and if that
|
|
|
|
|
has no results, it checks `semanticdb-project-roots'. If that fails,
|
|
|
|
|
it returns the results of function `semanticdb-current-database'.
|
|
|
|
|
Always append `semanticdb-project-system-databases' if
|
|
|
|
|
`semanticdb-search-system' is non-nil."
|
|
|
|
|
(let ((root nil) ; found root directory
|
|
|
|
|
(dbs nil) ; collected databases
|
|
|
|
|
(roots semanticdb-project-roots) ;all user roots
|
|
|
|
|
(dir (file-truename (or dir default-directory)))
|
|
|
|
|
)
|
|
|
|
|
;; Find the root based on project functions.
|
|
|
|
|
(setq root (run-hook-with-args-until-success
|
|
|
|
|
'semanticdb-project-root-functions
|
|
|
|
|
dir))
|
Synch Semantic to CEDET 1.0.
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog.
* semantic.el (semantic-version): Update to 2.0.
(semantic-mode-map): Add "," and "m" bindings.
(navigate-menu): Update.
* semantic/symref.el (semantic-symref-calculate-rootdir):
New function.
(semantic-symref-detect-symref-tool): Use it.
* semantic/symref/grep.el (semantic-symref-grep-shell): New var.
(semantic-symref-perform-search): Use it. Calculate root dir with
semantic-symref-calculate-rootdir.
(semantic-symref-derive-find-filepatterns): Improve error message.
* semantic/symref/list.el
(semantic-symref-results-mode-map): New bindings.
(semantic-symref-auto-expand-results): New option.
(semantic-symref-results-dump): Obey auto-expand.
(semantic-symref-list-expand-all, semantic-symref-regexp)
(semantic-symref-list-contract-all)
(semantic-symref-list-map-open-hits)
(semantic-symref-list-update-open-hits)
(semantic-symref-list-create-macro-on-open-hit)
(semantic-symref-list-call-macro-on-open-hits): New functions.
(semantic-symref-list-menu-entries)
(semantic-symref-list-menu): New vars.
(semantic-symref-list-map-open-hits): Move cursor to beginning of
match before calling the mapped function.
* semantic/doc.el
(semantic-documentation-comment-preceeding-tag): Do nothing if the
mode doesn't provide comment-start-skip.
* semantic/scope.el
(semantic-analyze-scope-nested-tags-default): Strip duplicates.
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
(semantic-decoration-on-includes-highlight-default): Check that
the include tag has a postion.
* semantic/complete.el (semantic-collector-local-members):
(semantic-complete-read-tag-local-members)
(semantic-complete-jump-local-members): New class and functions.
(semantic-complete-self-insert): Save excursion before completing.
* semantic/analyze/complete.el
(semantic-analyze-possible-completions-default): If no completions
are found, return the raw by-name-only completion list. Add FLAGS
arguments. Add support for 'no-tc (type constraint) and
'no-unique, or no stripping duplicates.
(semantic-analyze-possible-completions-default): Add FLAGS arg.
* semantic/util-modes.el
(semantic-stickyfunc-show-only-functions-p): New option.
(semantic-stickyfunc-fetch-stickyline): Don't show stickytext for
the very first line in a buffer.
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
* semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the
:filename property and the tag position.
* semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Add recursion limit.
* semantic/imenu.el (semantic-imenu-bucketize-type-members):
Make this buffer local, not the obsoleted variable.
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
(semantic-idle-symbol-maybe-highlight): Rename from *-summary-*.
Callers changed.
(semantic-idle-work-parse-neighboring-files-flag): Default to nil.
(semantic-idle-work-update-headers-flag): New var.
(semantic-idle-work-for-one-buffer): Use it.
(semantic-idle-local-symbol-highlight): Rename from
semantic-idle-tag-highlight.
(semantic-idle-truncate-long-summaries): New option.
* semantic/ia.el (semantic-ia-cache)
(semantic-ia-get-completions): Deleted. Callers changed.
(semantic-ia-show-variants): New command.
(semantic-ia-show-doc): If doc is empty, don't make a temp buffer.
(semantic-ia-show-summary): If there isn't anything to show, say so.
* semantic/grammar.el (semantic-grammar-create-package):
Save the buffer even in batch mode.
* semantic/fw.el
(semanticdb-without-unloaded-file-searches): New macro.
* semantic/dep.el (semantic-dependency-find-file-on-path):
Fix case dereferencing ede-object when it is a list.
* semantic/db-typecache.el (semanticdb-expand-nested-tag)
(semanticdb-typecache-faux-namespace): New functions.
(semanticdb-typecache-file-tags)
(semanticdb-typecache-merge-streams): Use them.
(semanticdb-typecache-file-tags): When deriving tags from a file,
give the mode a chance to monkey with the tag copy.
(semanticdb-typecache-find-default): Wrap find in save-excursion.
(semanticdb-typecache-find-by-name-helper): Merge found names down.
* semantic/db-global.el
(semanticdb-enable-gnu-global-in-buffer): Don't show messages if
GNU Global is not available and we don't want to throw an error.
* semantic/db-find.el (semanticdb-find-result-nth-in-buffer):
When trying to normalize the tag to a buffer, don't error if
set-buffer method doesn't exist.
* semantic/db-file.el (semanticdb-save-db): Simplify msg.
* semantic/db.el (semanticdb-refresh-table): If forcing a
refresh on a file not in a buffer, use semantic-find-file-noselect
and delete the buffer after use.
(semanticdb-current-database-list): When calculating root via
hooks, force it through true-filename and skip the list of
possible roots.
* semantic/ctxt.el (semantic-ctxt-imported-packages): New.
* semantic/analyze/debug.el
(semantic-analyzer-debug-insert-tag): Reset standard output to
current buffer.
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype): Change "prefix" to
"symbol" in messages.
* semantic/analyze/refs.el: (semantic-analyze-refs-impl)
(semantic-analyze-refs-proto): When calculating value, make sure
the found tag is 'similar' to the originating tag.
(semantic--analyze-refs-find-tags-with-parent): Attempt to
identify matches via imported symbols of parents.
(semantic--analyze-refs-full-lookup-with-parents): Do a deep
search during the brute search.
* semantic/analyze.el
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
(semantic-expand-c-tag-namelist): Split a full type from a typedef
out to its own tag.
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
* semantic/wisent/python-wy.el: Regenerate.
2010-09-18 22:49:54 -04:00
|
|
|
|
(if root
|
|
|
|
|
(setq root (file-truename root))
|
|
|
|
|
;; Else, Find roots based on strings
|
|
|
|
|
(while roots
|
|
|
|
|
(let ((r (file-truename (car roots))))
|
|
|
|
|
(if (string-match (concat "^" (regexp-quote r)) dir)
|
|
|
|
|
(setq root r)))
|
|
|
|
|
(setq roots (cdr roots))))
|
2009-08-28 15:19:20 +00:00
|
|
|
|
|
|
|
|
|
;; If no roots are found, use this directory.
|
|
|
|
|
(unless root (setq root dir))
|
|
|
|
|
|
|
|
|
|
;; Find databases based on the root directory.
|
|
|
|
|
(when root
|
|
|
|
|
;; The rootlist allows the root functions to possibly
|
|
|
|
|
;; return several roots which are in different areas but
|
|
|
|
|
;; all apart of the same system.
|
|
|
|
|
(let ((regexp (concat "^" (regexp-quote root)))
|
|
|
|
|
(adb semanticdb-database-list) ; all databases
|
|
|
|
|
)
|
|
|
|
|
(while adb
|
|
|
|
|
;; I don't like this part, but close enough.
|
|
|
|
|
(if (and (slot-boundp (car adb) 'reference-directory)
|
|
|
|
|
(string-match regexp (oref (car adb) reference-directory)))
|
|
|
|
|
(setq dbs (cons (car adb) dbs)))
|
|
|
|
|
(setq adb (cdr adb))))
|
|
|
|
|
)
|
|
|
|
|
;; Add in system databases
|
|
|
|
|
(when semanticdb-search-system-databases
|
|
|
|
|
(setq dbs (nconc dbs semanticdb-project-system-databases)))
|
|
|
|
|
;; Return
|
|
|
|
|
dbs))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Generic Accessor Routines
|
|
|
|
|
;;
|
|
|
|
|
;; These routines can be used to get at tags in files w/out
|
|
|
|
|
;; having to know a lot about semanticDB.
|
|
|
|
|
(defvar semanticdb-file-table-hash (make-hash-table :test 'equal)
|
|
|
|
|
"Hash table mapping file names to database tables.")
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-file-table-object-from-hash (file)
|
|
|
|
|
"Retrieve a DB table from the hash for FILE.
|
|
|
|
|
Does not use `file-truename'."
|
|
|
|
|
(gethash file semanticdb-file-table-hash 'no-hit))
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-file-table-object-put-hash (file dbtable)
|
|
|
|
|
"For FILE, associate DBTABLE in the hash table."
|
|
|
|
|
(puthash file dbtable semanticdb-file-table-hash))
|
|
|
|
|
|
2009-09-02 04:37:10 +00:00
|
|
|
|
;;;###autoload
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(defun semanticdb-file-table-object (file &optional dontload)
|
|
|
|
|
"Return a semanticdb table belonging to FILE, make it up to date.
|
|
|
|
|
If file has database tags available in the database, return it.
|
|
|
|
|
If file does not have tags available, and DONTLOAD is nil,
|
|
|
|
|
then load the tags for FILE, and create a new table object for it.
|
|
|
|
|
DONTLOAD does not affect the creation of new database objects."
|
|
|
|
|
;; (message "Object Translate: %s" file)
|
2011-07-04 17:36:38 +02:00
|
|
|
|
(when (and file (file-exists-p file))
|
2009-08-28 15:19:20 +00:00
|
|
|
|
(let* ((default-directory (file-name-directory file))
|
|
|
|
|
(tab (semanticdb-file-table-object-from-hash file))
|
|
|
|
|
(fullfile nil))
|
|
|
|
|
|
|
|
|
|
;; If it is not in the cache, then extract the more traditional
|
|
|
|
|
;; way by getting the database, and finding a table in that database.
|
|
|
|
|
;; Once we have a table, add it to the hash.
|
|
|
|
|
(when (eq tab 'no-hit)
|
|
|
|
|
(setq fullfile (file-truename file))
|
|
|
|
|
(let ((db (or ;; This line will pick up system databases.
|
|
|
|
|
(semanticdb-directory-loaded-p default-directory)
|
|
|
|
|
;; this line will make a new one if needed.
|
|
|
|
|
(semanticdb-get-database default-directory))))
|
|
|
|
|
(setq tab (semanticdb-file-table db fullfile))
|
|
|
|
|
(when tab
|
|
|
|
|
(semanticdb-file-table-object-put-hash file tab)
|
|
|
|
|
(when (not (string= fullfile file))
|
|
|
|
|
(semanticdb-file-table-object-put-hash fullfile tab)
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
((and tab
|
|
|
|
|
;; Is this in a buffer?
|
|
|
|
|
;;(find-buffer-visiting (semanticdb-full-filename tab))
|
|
|
|
|
(semanticdb-in-buffer-p tab)
|
|
|
|
|
)
|
|
|
|
|
(save-excursion
|
|
|
|
|
;;(set-buffer (find-buffer-visiting (semanticdb-full-filename tab)))
|
|
|
|
|
(semanticdb-set-buffer tab)
|
|
|
|
|
(semantic-fetch-tags)
|
|
|
|
|
;; Return the table.
|
|
|
|
|
tab))
|
|
|
|
|
((and tab dontload)
|
|
|
|
|
;; If we have table, and we don't want to load it, just return it.
|
|
|
|
|
tab)
|
|
|
|
|
((and tab
|
|
|
|
|
;; Is table fully loaded, or just a proxy?
|
|
|
|
|
(number-or-marker-p (oref tab pointmax))
|
|
|
|
|
;; Is this table up to date with the file?
|
|
|
|
|
(not (semanticdb-needs-refresh-p tab)))
|
|
|
|
|
;; A-ok!
|
|
|
|
|
tab)
|
|
|
|
|
((or (and fullfile (get-file-buffer fullfile))
|
|
|
|
|
(get-file-buffer file))
|
|
|
|
|
;; are these two calls this faster than `find-buffer-visiting'?
|
|
|
|
|
|
|
|
|
|
;; If FILE is being visited, but none of the above state is
|
|
|
|
|
;; true (meaning, there is no table object associated with it)
|
|
|
|
|
;; then it is a file not supported by Semantic, and can be safely
|
|
|
|
|
;; ignored.
|
|
|
|
|
nil)
|
|
|
|
|
((not dontload) ;; We must load the file.
|
|
|
|
|
;; Full file should have been set by now. Debug why not?
|
|
|
|
|
(when (and (not tab) (not fullfile))
|
|
|
|
|
;; This case is if a 'nil is erroneously put into the hash table. This
|
|
|
|
|
;; would need fixing
|
|
|
|
|
(setq fullfile (file-truename file))
|
|
|
|
|
)
|
|
|
|
|
|
2011-11-15 18:37:37 +01:00
|
|
|
|
;; If we have a table, but no fullfile, that's ok. Let's get the filename
|
2009-08-28 15:19:20 +00:00
|
|
|
|
;; from the table which is pre-truenamed.
|
|
|
|
|
(when (and (not fullfile) tab)
|
|
|
|
|
(setq fullfile (semanticdb-full-filename tab)))
|
|
|
|
|
|
|
|
|
|
(setq tab (semanticdb-create-table-for-file-not-in-buffer fullfile))
|
|
|
|
|
|
|
|
|
|
;; Save the new table.
|
|
|
|
|
(semanticdb-file-table-object-put-hash file tab)
|
|
|
|
|
(when (not (string= fullfile file))
|
|
|
|
|
(semanticdb-file-table-object-put-hash fullfile tab)
|
|
|
|
|
)
|
|
|
|
|
;; Done!
|
|
|
|
|
tab)
|
|
|
|
|
(t
|
|
|
|
|
;; Full file should have been set by now. Debug why not?
|
|
|
|
|
;; One person found this. Is it a file that failed to parse
|
|
|
|
|
;; in the past?
|
|
|
|
|
(when (not fullfile)
|
|
|
|
|
(setq fullfile (file-truename file)))
|
|
|
|
|
|
|
|
|
|
;; We were asked not to load the file in and parse it.
|
|
|
|
|
;; Instead just create a database table with no tags
|
|
|
|
|
;; and a claim of being empty.
|
|
|
|
|
;;
|
|
|
|
|
;; This will give us a starting point for storing
|
|
|
|
|
;; database cross-references so when it is loaded,
|
|
|
|
|
;; the cross-references will fire and caches will
|
|
|
|
|
;; be cleaned.
|
|
|
|
|
(let ((ans (semanticdb-create-table-for-file file)))
|
|
|
|
|
(setq tab (cdr ans))
|
|
|
|
|
|
|
|
|
|
;; Save the new table.
|
|
|
|
|
(semanticdb-file-table-object-put-hash file tab)
|
|
|
|
|
(when (not (string= fullfile file))
|
|
|
|
|
(semanticdb-file-table-object-put-hash fullfile tab)
|
|
|
|
|
)
|
|
|
|
|
;; Done!
|
|
|
|
|
tab))
|
|
|
|
|
)
|
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
(defvar semanticdb-out-of-buffer-create-table-fcn nil
|
|
|
|
|
"When non-nil, a function for creating a semanticdb table.
|
|
|
|
|
This should take a filename to be parsed.")
|
|
|
|
|
(make-variable-buffer-local 'semanticdb-out-of-buffer-create-table-fcn)
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-create-table-for-file-not-in-buffer (filename)
|
|
|
|
|
"Create a table for the file FILENAME.
|
|
|
|
|
If there are no language specific configurations, this
|
|
|
|
|
function will read in the buffer, parse it, and kill the buffer."
|
|
|
|
|
(if (and semanticdb-out-of-buffer-create-table-fcn
|
|
|
|
|
(not (file-remote-p filename)))
|
|
|
|
|
;; Use external parser only of the file is accessible to the
|
|
|
|
|
;; local file system.
|
|
|
|
|
(funcall semanticdb-out-of-buffer-create-table-fcn filename)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ( ;; Remember the buffer to kill
|
|
|
|
|
(kill-buffer-flag (find-buffer-visiting filename))
|
|
|
|
|
(buffer-to-kill (or kill-buffer-flag
|
|
|
|
|
(semantic-find-file-noselect filename t))))
|
|
|
|
|
|
|
|
|
|
;; This shouldn't ever be set. Debug some issue here?
|
|
|
|
|
;; (when kill-buffer-flag (debug))
|
|
|
|
|
|
|
|
|
|
(set-buffer buffer-to-kill)
|
|
|
|
|
;; Find file should automatically do this for us.
|
|
|
|
|
;; Sometimes the DB table doesn't contains tags and needs
|
|
|
|
|
;; a refresh. For example, when the file is loaded for
|
|
|
|
|
;; the first time, and the idle scheduler didn't get a
|
|
|
|
|
;; chance to trigger a parse before the file buffer is
|
|
|
|
|
;; killed.
|
|
|
|
|
(when semanticdb-current-table
|
|
|
|
|
(semantic-fetch-tags))
|
|
|
|
|
(prog1
|
|
|
|
|
semanticdb-current-table
|
|
|
|
|
(when (not kill-buffer-flag)
|
|
|
|
|
;; If we had to find the file, then we should kill it
|
|
|
|
|
;; to keep the master buffer list clean.
|
|
|
|
|
(kill-buffer buffer-to-kill)
|
|
|
|
|
)))))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defun semanticdb-file-stream (file)
|
|
|
|
|
"Return a list of tags belonging to FILE.
|
|
|
|
|
If file has database tags available in the database, return them.
|
|
|
|
|
If file does not have tags available, then load the file, and create them."
|
|
|
|
|
(let ((table (semanticdb-file-table-object file)))
|
|
|
|
|
(when table
|
|
|
|
|
(semanticdb-get-tags table))))
|
|
|
|
|
|
|
|
|
|
(provide 'semantic/db)
|
|
|
|
|
|
2009-09-02 04:37:10 +00:00
|
|
|
|
;; Local variables:
|
|
|
|
|
;; generated-autoload-file: "loaddefs.el"
|
2009-09-05 01:00:36 +00:00
|
|
|
|
;; generated-autoload-load-name: "semantic/db"
|
2009-09-02 04:37:10 +00:00
|
|
|
|
;; End:
|
|
|
|
|
|
cedet/semantic/db-debug.el: Don't require semantic/db-mode, since
semanticdb-current-database and semanticdb-current-table are now in
semantic/db.el.
cedet/semantic/db-ebrowse.el: Don't require semantic/db-mode, since
semanticdb-current-database and semanticdb-current-table are now in
semantic/db.el.
cedet/semantic/db-el.el: Require semantic/lex-spp.
Require semantic/db instead of semantic/db-search.
cedet/semantic/db-file.el: Declare inversion-test and
data-debug-insert-thing.
(semanticdb-load-database): Load inversion only if necessary.
cedet/semantic/db-find.el: Autoload semanticdb-find-default-throttle.
Defvar data-debug-thing-alist, and ede-current-project.
Declare data-debug-insert-stuff-list, data-debug-insert-tag-list,
semantic-scope-reset-cache, and semanticdb-typecache-notify-reset.
Require semantic/tag-file, and semantic/sort.
(semantic-reset): Require semantic/scope.
(semanticdb-partial-synchronize): Require semantic/db-typecache.
(semanticdb-find-table-for-include) Move up to avoid compiler warning.
cedet/semantic/db-global.el: Declare data-debug-new-buffer and
data-debug-insert-thing.
(semanticdb-project-database-global) Move up to avoid compiler warning.
cedet/semantic/db-javascript.el: Fix provide statement.
Require semantic/db-find instead of semantic/db-search.
cedet/semantic/db-mode.el: Declare semantic-lex-spp-set-dynamic-table.
(semanticdb-current-database, semanticdb-current-table): Move into
semantic/db.el
cedet/semantic/db-ref.el: Require eieio, semantic/db, and semantic/util.
Declare data-debug-new-buffer and data-debug-insert-object-slots.
Defvar semantic-case-fold. Require semantic/find when compiling.
cedet/semantic/db-typecache.el: Require semantic/tag-ls,
semantic/analyze/fcn, and semantic/scope. Declare
data-debug-insert-thing and data-debug-new-buffer.
cedet/semantic/db.el (semanticdb-search-results-table): Move class
definition here from semantic/db-search.el.
(semanticdb-current-database, semanticdb-current-table) Move variable
definitions here from semantic/db-mode.el.
2009-08-31 00:45:41 +00:00
|
|
|
|
;;; semantic/db.el ends here
|