db-typecache.el 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. ;;; semantic/db-typecache.el --- Manage Datatypes
  2. ;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
  3. ;; Author: Eric M. Ludlam <eric@siege-engine.com>
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;
  17. ;; Manage a datatype cache.
  18. ;;
  19. ;; For typed languages like C++ collect all known types from various
  20. ;; headers, merge namespaces, and expunge duplicates.
  21. ;;
  22. ;; It is likely this feature will only be needed for C/C++.
  23. (require 'semantic)
  24. (require 'semantic/db)
  25. (require 'semantic/db-find)
  26. (require 'semantic/analyze/fcn)
  27. ;; For semantic-find-tags-by-* macros
  28. (eval-when-compile (require 'semantic/find))
  29. (declare-function data-debug-insert-thing "data-debug")
  30. (declare-function data-debug-new-buffer "data-debug")
  31. (declare-function semantic-sort-tags-by-name-then-type-increasing "semantic/sort")
  32. (declare-function semantic-scope-tag-clone-with-scope "semantic/scope")
  33. ;;; Code:
  34. ;;; TABLE TYPECACHE
  35. ;;;###autoload
  36. (defclass semanticdb-typecache ()
  37. ((filestream :initform nil
  38. :documentation
  39. "Fully sorted/merged list of tags within this buffer.")
  40. (includestream :initform nil
  41. :documentation
  42. "Fully sorted/merged list of tags from this file's includes list.")
  43. (stream :initform nil
  44. :documentation
  45. "The searchable tag stream for this cache.
  46. NOTE: Can I get rid of this? Use a hashtable instead?")
  47. (dependants :initform nil
  48. :documentation
  49. "Any other object that is dependent on typecache results.
  50. Said object must support `semantic-reset' methods.")
  51. ;; @todo - add some sort of fast-hash.
  52. ;; @note - Rebuilds in large projects already take a while, and the
  53. ;; actual searches are pretty fast. Really needed?
  54. )
  55. "Structure for maintaining a typecache.")
  56. (defmethod semantic-reset ((tc semanticdb-typecache))
  57. "Reset the object IDX."
  58. (oset tc filestream nil)
  59. (oset tc includestream nil)
  60. (oset tc stream nil)
  61. (mapc 'semantic-reset (oref tc dependants))
  62. (oset tc dependants nil)
  63. )
  64. (defmethod semanticdb-typecache-notify-reset ((tc semanticdb-typecache))
  65. "Do a reset from a notify from a table we depend on."
  66. (oset tc includestream nil)
  67. (mapc 'semantic-reset (oref tc dependants))
  68. (oset tc dependants nil)
  69. )
  70. (defmethod semanticdb-partial-synchronize ((tc semanticdb-typecache)
  71. new-tags)
  72. "Reset the typecache based on a partial reparse."
  73. (when (semantic-find-tags-by-class 'include new-tags)
  74. (oset tc includestream nil)
  75. (mapc 'semantic-reset (oref tc dependants))
  76. (oset tc dependants nil)
  77. )
  78. (when (semantic-find-tags-by-class 'type new-tags)
  79. ;; Reset our index
  80. (oset tc filestream nil)
  81. t ;; Return true, our core file tags have changed in a relevant way.
  82. )
  83. ;; NO CODE HERE
  84. )
  85. (defun semanticdb-typecache-add-dependant (dep)
  86. "Add into the local typecache a dependant DEP."
  87. (let* ((table semanticdb-current-table)
  88. ;;(idx (semanticdb-get-table-index table))
  89. (cache (semanticdb-get-typecache table))
  90. )
  91. (object-add-to-list cache 'dependants dep)))
  92. (defun semanticdb-typecache-length (thing)
  93. "How long is THING?
  94. Debugging function."
  95. (cond ((semanticdb-typecache-child-p thing)
  96. (length (oref thing stream)))
  97. ((semantic-tag-p thing)
  98. (length (semantic-tag-type-members thing)))
  99. ((and (listp thing) (semantic-tag-p (car thing)))
  100. (length thing))
  101. ((null thing)
  102. 0)
  103. (t -1) ))
  104. (defmethod semanticdb-get-typecache ((table semanticdb-abstract-table))
  105. "Retrieve the typecache from the semanticdb TABLE.
  106. If there is no table, create one, and fill it in."
  107. (semanticdb-refresh-table table)
  108. (let* ((idx (semanticdb-get-table-index table))
  109. (cache (oref idx type-cache))
  110. )
  111. ;; Make sure we have a cache object in the DB index.
  112. (when (not cache)
  113. ;; The object won't change as we fill it with stuff.
  114. (setq cache (semanticdb-typecache (semanticdb-full-filename table)))
  115. (oset idx type-cache cache))
  116. cache))
  117. (defmethod semanticdb-have-typecache-p ((table semanticdb-abstract-table))
  118. "Return non-nil (the typecache) if TABLE has a pre-calculated typecache."
  119. (let* ((idx (semanticdb-get-table-index table)))
  120. (oref idx type-cache)))
  121. ;;; DATABASE TYPECACHE
  122. ;;
  123. ;; A full database can cache the types across its files.
  124. ;;
  125. ;; Unlike file based caches, this one is a bit simpler, and just needs
  126. ;; to get reset when a table gets updated.
  127. ;;;###autoload
  128. (defclass semanticdb-database-typecache (semanticdb-abstract-db-cache)
  129. ((stream :initform nil
  130. :documentation
  131. "The searchable tag stream for this cache.")
  132. )
  133. "Structure for maintaining a typecache.")
  134. (defmethod semantic-reset ((tc semanticdb-database-typecache))
  135. "Reset the object IDX."
  136. (oset tc stream nil)
  137. )
  138. (defmethod semanticdb-synchronize ((cache semanticdb-database-typecache)
  139. new-tags)
  140. "Synchronize a CACHE with some NEW-TAGS."
  141. )
  142. (defmethod semanticdb-partial-synchronize ((cache semanticdb-database-typecache)
  143. new-tags)
  144. "Synchronize a CACHE with some changed NEW-TAGS."
  145. )
  146. (defmethod semanticdb-get-typecache ((db semanticdb-project-database))
  147. "Retrieve the typecache from the semantic database DB.
  148. If there is no table, create one, and fill it in."
  149. (semanticdb-cache-get db semanticdb-database-typecache)
  150. )
  151. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  152. ;;; MERGING
  153. ;;
  154. ;; Managing long streams of tags representing data types.
  155. ;;
  156. (defun semanticdb-typecache-apply-filename (file stream)
  157. "Apply the filename FILE to all tags in STREAM."
  158. (let ((new nil))
  159. (while stream
  160. (setq new (cons (semantic-tag-copy (car stream) nil file)
  161. new))
  162. ;The below is handled by the tag-copy fcn.
  163. ;(semantic--tag-put-property (car new) :filename file)
  164. (setq stream (cdr stream)))
  165. (nreverse new)))
  166. (defsubst semanticdb-typecache-safe-tag-members (tag)
  167. "Return a list of members for TAG that are safe to permute."
  168. (let ((mem (semantic-tag-type-members tag))
  169. (fname (semantic-tag-file-name tag)))
  170. (if fname
  171. (setq mem (semanticdb-typecache-apply-filename fname mem))
  172. (copy-sequence mem))))
  173. (defsubst semanticdb-typecache-safe-tag-list (tags table)
  174. "Make the tag list TAGS found in TABLE safe for the typecache.
  175. Adds a filename and copies the tags."
  176. (semanticdb-typecache-apply-filename
  177. (semanticdb-full-filename table)
  178. tags))
  179. (defun semanticdb-typecache-faux-namespace (name members)
  180. "Create a new namespace tag with NAME and a set of MEMBERS.
  181. The new tag will be a faux tag, used as a placeholder in a typecache."
  182. (let ((tag (semantic-tag-new-type name "namespace" members nil)))
  183. ;; Make sure we mark this as a fake tag.
  184. (semantic-tag-set-faux tag)
  185. tag))
  186. (defun semanticdb-typecache-merge-streams (cache1 cache2)
  187. "Merge into CACHE1 and CACHE2 together. The Caches will be merged in place."
  188. (if (or (and (not cache1) (not cache2))
  189. (and (not (cdr cache1)) (not cache2))
  190. (and (not cache1) (not (cdr cache2))))
  191. ;; If all caches are empty OR
  192. ;; cache1 is length 1 and no cache2 OR
  193. ;; no cache1 and length 1 cache2
  194. ;;
  195. ;; then just return the cache, and skip all this merging stuff.
  196. (or cache1 cache2)
  197. ;; Assume we always have datatypes, as this typecache isn't really
  198. ;; useful without a typed language.
  199. (require 'semantic/sort)
  200. (let ((S (semantic-sort-tags-by-name-then-type-increasing
  201. ;; I used to use append, but it copied cache1 but not cache2.
  202. ;; Since sort was permuting cache2, I already had to make sure
  203. ;; the caches were permute-safe. Might as well use nconc here.
  204. (nconc cache1 cache2)))
  205. (ans nil)
  206. (next nil)
  207. (prev nil)
  208. (type nil))
  209. ;; With all the tags in order, we can loop over them, and when
  210. ;; two have the same name, we can either throw one away, or construct
  211. ;; a fresh new tag merging the items together.
  212. (while S
  213. (setq prev (car ans))
  214. (setq next (car S))
  215. (if (or
  216. ;; CASE 1 - First item
  217. (null prev)
  218. ;; CASE 2 - New name
  219. (not (string= (semantic-tag-name next)
  220. (semantic-tag-name prev))))
  221. (setq ans (cons next ans))
  222. ;; ELSE - We have a NAME match.
  223. (setq type (semantic-tag-type next))
  224. (if (or (semantic-tag-of-type-p prev type) ; Are they the same datatype
  225. (semantic-tag-faux-p prev)
  226. (semantic-tag-faux-p next) ; or either a faux tag?
  227. )
  228. ;; Same Class, we can do a merge.
  229. (cond
  230. ((and (semantic-tag-of-class-p next 'type)
  231. (string= type "namespace"))
  232. ;; Namespaces - merge the children together.
  233. (setcar ans
  234. (semanticdb-typecache-faux-namespace
  235. (semantic-tag-name prev) ; - they are the same
  236. (semanticdb-typecache-merge-streams
  237. (semanticdb-typecache-safe-tag-members prev)
  238. (semanticdb-typecache-safe-tag-members next))
  239. ))
  240. )
  241. ((semantic-tag-prototype-p next)
  242. ;; NEXT is a prototype... so keep previous.
  243. nil ; - keep prev, do nothing
  244. )
  245. ((semantic-tag-prototype-p prev)
  246. ;; PREV is a prototype, but not next.. so keep NEXT.
  247. ;; setcar - set by side-effect on top of prev
  248. (setcar ans next)
  249. )
  250. (t
  251. ;;(message "Don't know how to merge %s. Keeping first entry." (semantic-tag-name next))
  252. ))
  253. ;; Not same class... but same name
  254. ;(message "Same name, different type: %s, %s!=%s"
  255. ; (semantic-tag-name next)
  256. ; (semantic-tag-type next)
  257. ; (semantic-tag-type prev))
  258. (setq ans (cons next ans))
  259. ))
  260. (setq S (cdr S)))
  261. (nreverse ans))))
  262. ;;; Refresh / Query API
  263. ;;
  264. ;; Queries that can be made for the typecache.
  265. (define-overloadable-function semanticdb-expand-nested-tag (tag)
  266. "Expand TAG from fully qualified names.
  267. If TAG has fully qualified names, expand it to a series of nested
  268. namespaces instead."
  269. tag)
  270. (defmethod semanticdb-typecache-file-tags ((table semanticdb-abstract-table))
  271. "No tags available from non-file based tables."
  272. nil)
  273. (defmethod semanticdb-typecache-file-tags ((table semanticdb-table))
  274. "Update the typecache for TABLE, and return the file-tags.
  275. File-tags are those that belong to this file only, and excludes
  276. all included files."
  277. (let* (;(idx (semanticdb-get-table-index table))
  278. (cache (semanticdb-get-typecache table))
  279. )
  280. ;; Make sure our file-tags list is up to date.
  281. (when (not (oref cache filestream))
  282. (let ((tags (semantic-find-tags-by-class 'type table))
  283. (exptags nil))
  284. (when tags
  285. (setq tags (semanticdb-typecache-safe-tag-list tags table))
  286. (dolist (T tags)
  287. (push (semanticdb-expand-nested-tag T) exptags))
  288. (oset cache filestream (semanticdb-typecache-merge-streams exptags nil)))))
  289. ;; Return our cache.
  290. (oref cache filestream)
  291. ))
  292. (defmethod semanticdb-typecache-include-tags ((table semanticdb-abstract-table))
  293. "No tags available from non-file based tables."
  294. nil)
  295. (defmethod semanticdb-typecache-include-tags ((table semanticdb-table))
  296. "Update the typecache for TABLE, and return the merged types from the include tags.
  297. Include-tags are the tags brought in via includes, all merged together into
  298. a master list."
  299. (let* ((cache (semanticdb-get-typecache table))
  300. )
  301. ;; Make sure our file-tags list is up to date.
  302. (when (not (oref cache includestream))
  303. (let (;; Calc the path first. This will have a nice side -effect of
  304. ;; getting the cache refreshed if a refresh is needed. Most of the
  305. ;; time this value is itself cached, so the query is fast.
  306. (incpath (semanticdb-find-translate-path table nil))
  307. (incstream nil))
  308. ;; Get the translated path, and extract all the type tags, then merge
  309. ;; them all together.
  310. (dolist (i incpath)
  311. ;; don't include ourselves in this crazy list.
  312. (when (and i (not (eq i table))
  313. ;; @todo - This eieio fcn can be slow! Do I need it?
  314. ;; (semanticdb-table-child-p i)
  315. )
  316. (setq incstream
  317. (semanticdb-typecache-merge-streams
  318. incstream
  319. ;; Getting the cache from this table will also cause this
  320. ;; file to update its cache from its descendants.
  321. ;;
  322. ;; In theory, caches are only built for most includes
  323. ;; only once (in the loop before this one), so this ends
  324. ;; up being super fast as we edit our file.
  325. (copy-sequence
  326. (semanticdb-typecache-file-tags i))))
  327. ))
  328. ;; Save...
  329. (oset cache includestream incstream)))
  330. ;; Return our cache.
  331. (oref cache includestream)
  332. ))
  333. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  334. ;;; Search Routines
  335. ;;
  336. ;;;###autoload
  337. (define-overloadable-function semanticdb-typecache-find (type &optional path find-file-match)
  338. "Search the typecache for TYPE in PATH.
  339. If type is a string, split the string, and search for the parts.
  340. If type is a list, treat the type as a pre-split string.
  341. PATH can be nil for the current buffer, or a semanticdb table.
  342. FIND-FILE-MATCH is non-nil to force all found tags to be loaded into a buffer.")
  343. (defun semanticdb-typecache-find-default (type &optional path find-file-match)
  344. "Default implementation of `semanticdb-typecache-find'.
  345. TYPE is the datatype to find.
  346. PATH is the search path, which should be one table object.
  347. If FIND-FILE-MATCH is non-nil, then force the file belonging to the
  348. found tag to be loaded."
  349. (if (not (and (featurep 'semantic/db) semanticdb-current-database))
  350. nil ;; No DB, no search
  351. (save-excursion
  352. (semanticdb-typecache-find-method (or path semanticdb-current-table)
  353. type find-file-match))))
  354. (defun semanticdb-typecache-find-by-name-helper (name table)
  355. "Find the tag with NAME in TABLE, which is from a typecache.
  356. If more than one tag has NAME in TABLE, we will prefer the tag that
  357. is of class 'type."
  358. (let* ((names (semantic-find-tags-by-name name table))
  359. (nmerge (semanticdb-typecache-merge-streams names nil))
  360. (types (semantic-find-tags-by-class 'type nmerge)))
  361. (or (car-safe types) (car-safe nmerge))))
  362. (defmethod semanticdb-typecache-find-method ((table semanticdb-abstract-table)
  363. type find-file-match)
  364. "Search the typecache in TABLE for the datatype TYPE.
  365. If type is a string, split the string, and search for the parts.
  366. If type is a list, treat the type as a pre-split string.
  367. If FIND-FILE-MATCH is non-nil, then force the file belonging to the
  368. found tag to be loaded."
  369. ;; convert string to a list.
  370. (when (stringp type) (setq type (semantic-analyze-split-name type)))
  371. (when (stringp type) (setq type (list type)))
  372. ;; Search for the list in our typecache.
  373. (let* ((file (semanticdb-typecache-file-tags table))
  374. (inc (semanticdb-typecache-include-tags table))
  375. (stream nil)
  376. (f-ans nil)
  377. (i-ans nil)
  378. (ans nil)
  379. (notdone t)
  380. (lastfile nil)
  381. (thisfile nil)
  382. (lastans nil)
  383. (calculated-scope nil)
  384. )
  385. ;; 1) Find first symbol in the two master lists and then merge
  386. ;; the found streams.
  387. ;; We stripped duplicates, so these will be super-fast!
  388. (setq f-ans (semantic-find-first-tag-by-name (car type) file))
  389. (setq i-ans (semantic-find-first-tag-by-name (car type) inc))
  390. (if (and f-ans i-ans)
  391. (progn
  392. ;; This trick merges the two identified tags, making sure our lists are
  393. ;; complete. The second find then gets the new 'master' from the list of 2.
  394. (setq ans (semanticdb-typecache-merge-streams (list f-ans) (list i-ans)))
  395. (setq ans (semantic-find-first-tag-by-name (car type) ans))
  396. )
  397. ;; The answers are already sorted and merged, so if one misses,
  398. ;; no need to do any special work.
  399. (setq ans (or f-ans i-ans)))
  400. ;; 2) Loop over the remaining parts.
  401. (while (and type notdone)
  402. ;; For pass > 1, stream will be non-nil, so do a search, otherwise
  403. ;; ans is from outside the loop.
  404. (when stream
  405. (setq ans (semanticdb-typecache-find-by-name-helper (car type) stream))
  406. ;; NOTE: The below test to make sure we get a type is only relevant
  407. ;; for the SECOND pass or later. The first pass can only ever
  408. ;; find a type/namespace because everything else is excluded.
  409. ;; If this is not the last entry from the list, then it
  410. ;; must be a type or a namespace. Let's double check.
  411. (when (cdr type)
  412. ;; From above, there is only one tag in ans, and we prefer
  413. ;; types.
  414. (when (not (semantic-tag-of-class-p ans 'type))
  415. (setq ans nil)))
  416. )
  417. (push ans calculated-scope)
  418. ;; Track most recent file.
  419. (setq thisfile (semantic-tag-file-name ans))
  420. (when (and thisfile (stringp thisfile))
  421. (setq lastfile thisfile))
  422. ;; If we have a miss, exit, otherwise, update the stream to
  423. ;; the next set of members.
  424. (if (not ans)
  425. (setq notdone nil)
  426. (setq stream (semantic-tag-type-members ans)))
  427. (setq lastans ans
  428. ans nil
  429. type (cdr type)))
  430. (if (or type (not notdone))
  431. ;; If there is stuff left over, then we failed. Just return
  432. ;; nothing.
  433. nil
  434. ;; We finished, so return everything.
  435. (if (and find-file-match lastfile)
  436. ;; This won't liven up the tag since we have a copy, but
  437. ;; we ought to be able to get there and go to the right line.
  438. (find-file-noselect lastfile)
  439. ;; We don't want to find-file match, so instead let's
  440. ;; push the filename onto the return tag.
  441. (when lastans
  442. (setq lastans (semantic-tag-copy lastans nil lastfile))
  443. ;; We used to do the below, but we would erroneously be putting
  444. ;; attributes on tags being shred with other lists.
  445. ;;(semantic--tag-put-property lastans :filename lastfile)
  446. )
  447. )
  448. (if (and lastans calculated-scope)
  449. ;; Put our discovered scope into the tag if we have a tag
  450. (progn
  451. (require 'semantic/scope)
  452. (semantic-scope-tag-clone-with-scope
  453. lastans (reverse (cdr calculated-scope))))
  454. ;; Else, just return
  455. lastans
  456. ))))
  457. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  458. ;;; BRUTISH Typecache
  459. ;;
  460. ;; Routines for a typecache that crosses all tables in a given database
  461. ;; for a matching major-mode.
  462. (defmethod semanticdb-typecache-for-database ((db semanticdb-project-database)
  463. &optional mode)
  464. "Return the typecache for the project database DB.
  465. If there isn't one, create it.
  466. "
  467. (let ((lmode (or mode major-mode))
  468. (cache (semanticdb-get-typecache db))
  469. (stream nil)
  470. )
  471. (dolist (table (semanticdb-get-database-tables db))
  472. (when (eq lmode (oref table :major-mode))
  473. (setq stream
  474. (semanticdb-typecache-merge-streams
  475. stream
  476. (copy-sequence
  477. (semanticdb-typecache-file-tags table))))
  478. ))
  479. (oset cache stream stream)
  480. cache))
  481. (defun semanticdb-typecache-refresh-for-buffer (buffer)
  482. "Refresh the typecache for BUFFER."
  483. (with-current-buffer buffer
  484. (let* ((tab semanticdb-current-table)
  485. ;(idx (semanticdb-get-table-index tab))
  486. (tc (semanticdb-get-typecache tab)))
  487. (semanticdb-typecache-file-tags tab)
  488. (semanticdb-typecache-include-tags tab)
  489. tc)))
  490. ;;; DEBUG
  491. ;;
  492. (defun semanticdb-typecache-complete-flush ()
  493. "Flush all typecaches referenced by the current buffer."
  494. (interactive)
  495. (let* ((path (semanticdb-find-translate-path nil nil)))
  496. (dolist (P path)
  497. (oset P pointmax nil)
  498. (semantic-reset (semanticdb-get-typecache P)))))
  499. (defun semanticdb-typecache-dump ()
  500. "Dump the typecache for the current buffer."
  501. (interactive)
  502. (require 'data-debug)
  503. (let* ((start (current-time))
  504. (tc (semanticdb-typecache-refresh-for-buffer (current-buffer)))
  505. (end (current-time))
  506. )
  507. (data-debug-new-buffer "*TypeCache ADEBUG*")
  508. (message "Calculating Cache took %.2f seconds."
  509. (semantic-elapsed-time start end))
  510. (data-debug-insert-thing tc "]" "")
  511. ))
  512. (defun semanticdb-db-typecache-dump ()
  513. "Dump the typecache for the current buffer's database."
  514. (interactive)
  515. (require 'data-debug)
  516. (let* ((tab semanticdb-current-table)
  517. (idx (semanticdb-get-table-index tab))
  518. (junk (oset idx type-cache nil)) ;; flush!
  519. (start (current-time))
  520. (tc (semanticdb-typecache-for-database (oref tab parent-db)))
  521. (end (current-time))
  522. )
  523. (data-debug-new-buffer "*TypeCache ADEBUG*")
  524. (message "Calculating Cache took %.2f seconds."
  525. (semantic-elapsed-time start end))
  526. (data-debug-insert-thing tc "]" "")
  527. ))
  528. (provide 'semantic/db-typecache)
  529. ;; Local variables:
  530. ;; generated-autoload-file: "loaddefs.el"
  531. ;; generated-autoload-load-name: "semantic/db-typecache"
  532. ;; End:
  533. ;;; semantic/db-typecache.el ends here