Mercurial > emacs
annotate lisp/cedet/srecode/expandproto.el @ 105842:83dde921cc1b
* emacs-lisp/autoload.el (generated-autoload-feature): Remove.
(autoload-rubric): Don't use any more.
* cedet/semantic/fw.el (semantic/loaddefs):
* cedet/srecode.el (srecode/loaddefs):
* cedet/ede.el (ede/loaddefs): Load rather than require.
* lisp/cedet/ede/cpp-root.el:
* lisp/cedet/ede/emacs.el:
* lisp/cedet/ede/files.el:
* lisp/cedet/ede/linux.el:
* lisp/cedet/ede/locate.el:
* lisp/cedet/ede/make.el:
* lisp/cedet/ede/shell.el:
* lisp/cedet/ede/speedbar.el:
* lisp/cedet/ede/system.el:
* lisp/cedet/ede/util.el:
* lisp/cedet/semantic/analyze.el:
* lisp/cedet/semantic/bovine.el:
* lisp/cedet/semantic/complete.el:
* lisp/cedet/semantic/ctxt.el:
* lisp/cedet/semantic/db-file.el:
* lisp/cedet/semantic/db-find.el:
* lisp/cedet/semantic/db-global.el:
* lisp/cedet/semantic/db-mode.el:
* lisp/cedet/semantic/db-typecache.el:
* lisp/cedet/semantic/db.el:
* lisp/cedet/semantic/debug.el:
* lisp/cedet/semantic/dep.el:
* lisp/cedet/semantic/doc.el:
* lisp/cedet/semantic/edit.el:
* lisp/cedet/semantic/find.el:
* lisp/cedet/semantic/format.el:
* lisp/cedet/semantic/html.el:
* lisp/cedet/semantic/ia-sb.el:
* lisp/cedet/semantic/ia.el:
* lisp/cedet/semantic/idle.el:
* lisp/cedet/semantic/lex-spp.el:
* lisp/cedet/semantic/lex.el:
* lisp/cedet/semantic/mru-bookmark.el:
* lisp/cedet/semantic/scope.el:
* lisp/cedet/semantic/senator.el:
* lisp/cedet/semantic/sort.el:
* lisp/cedet/semantic/symref.el:
* lisp/cedet/semantic/tag-file.el:
* lisp/cedet/semantic/tag-ls.el:
* lisp/cedet/semantic/tag-write.el:
* lisp/cedet/semantic/tag.el:
* lisp/cedet/semantic/util-modes.el:
* lisp/cedet/semantic/analyze/complete.el:
* lisp/cedet/semantic/analyze/refs.el:
* lisp/cedet/semantic/bovine/c.el:
* lisp/cedet/semantic/bovine/gcc.el:
* lisp/cedet/semantic/bovine/make.el:
* lisp/cedet/semantic/bovine/scm.el:
* lisp/cedet/semantic/decorate/include.el:
* lisp/cedet/semantic/decorate/mode.el:
* lisp/cedet/semantic/symref/cscope.el:
* lisp/cedet/semantic/symref/global.el:
* lisp/cedet/semantic/symref/grep.el:
* lisp/cedet/semantic/symref/idutils.el:
* lisp/cedet/semantic/symref/list.el:
* lisp/cedet/semantic/wisent/java-tags.el:
* lisp/cedet/semantic/wisent/javascript.el:
* lisp/cedet/srecode/compile.el:
* lisp/cedet/srecode/cpp.el:
* lisp/cedet/srecode/document.el:
* lisp/cedet/srecode/el.el:
* lisp/cedet/srecode/expandproto.el:
* lisp/cedet/srecode/getset.el:
* lisp/cedet/srecode/insert.el:
* lisp/cedet/srecode/java.el:
* lisp/cedet/srecode/map.el:
* lisp/cedet/srecode/mode.el:
* lisp/cedet/srecode/template.el:
* lisp/cedet/srecode/texi.el: Remove the file-local setting of
generated-autoload-feature.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 03 Nov 2009 21:45:31 +0000 |
parents | 7f4c7f5c0eba |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
104498 | 1 ;;; srecode/expandproto.el --- Expanding prototypes. |
2 | |
105284 | 3 ;; Copyright (C) 2007, 2009 Free Software Foundation, Inc. |
104498 | 4 |
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com> | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software: you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation, either version 3 of the License, or | |
12 ;; (at your option) any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
21 | |
22 ;;; Commentary: | |
23 ;; | |
24 ;; Methods for expanding a prototype into an implementation. | |
25 | |
26 (require 'ring) | |
27 (require 'semantic) | |
28 (require 'semantic/analyze) | |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104498
diff
changeset
|
29 (require 'semantic/senator) |
104498 | 30 (require 'srecode/insert) |
31 (require 'srecode/dictionary) | |
32 | |
33 (declare-function semantic-brute-find-tag-by-attribute-value "semantic/find") | |
34 | |
35 ;;; Code: | |
36 (defcustom srecode-expandproto-template-file-alist | |
37 '( ( c++-mode . "srecode-expandproto-cpp.srt" ) | |
38 ) | |
39 ;; @todo - Make this variable auto-generated from the Makefile. | |
40 "Associate template files for expanding prototypes to a major mode." | |
41 :group 'srecode | |
42 :type '(repeat (cons (sexp :tag "Mode") | |
43 (sexp :tag "Filename")) | |
44 )) | |
45 | |
46 ;;;###autoload | |
47 (defun srecode-insert-prototype-expansion () | |
48 "Insert get/set methods for the current class." | |
49 (interactive) | |
50 | |
51 (srecode-load-tables-for-mode major-mode) | |
52 (srecode-load-tables-for-mode major-mode | |
53 srecode-expandproto-template-file-alist) | |
54 | |
55 (if (not (srecode-table)) | |
56 (error "No template table found for mode %s" major-mode)) | |
57 | |
58 (let ((proto | |
59 ;; Step 1: Find the prototype, or prototype list to expand. | |
60 (srecode-find-prototype-for-expansion))) | |
61 | |
62 (if (not proto) | |
63 (error "Could not find prototype to expand")) | |
64 | |
65 ;; Step 2: Insert implementations of the prototypes. | |
66 | |
67 | |
68 )) | |
69 | |
70 (defun srecode-find-prototype-for-expansion () | |
71 "Find a prototype to use for expanding into an implementation." | |
72 ;; We may find a prototype tag in one of several places. | |
73 ;; Search in order of logical priority. | |
74 (let ((proto nil) | |
75 ) | |
76 | |
77 ;; 1) A class full of prototypes under point. | |
78 (let ((tag (semantic-current-tag))) | |
79 (when tag | |
80 (when (not (semantic-tag-of-class-p tag 'type)) | |
81 (setq tag (semantic-current-tag-parent)))) | |
82 (when (and tag (semantic-tag-of-class-p tag 'type)) | |
83 ;; If the current class has prototype members, then | |
84 ;; we will do the whole class! | |
85 (require 'semantic/find) | |
86 (if (semantic-brute-find-tag-by-attribute-value | |
87 :prototype t | |
88 (semantic-tag-type-members tag)) | |
89 (setq proto tag))) | |
90 ) | |
91 | |
92 ;; 2) A prototype under point. | |
93 (when (not proto) | |
94 (let ((tag (semantic-current-tag))) | |
95 (when (and tag | |
96 (and | |
97 (semantic-tag-of-class-p tag 'function) | |
98 (semantic-tag-get-attribute tag :prototype))) | |
99 (setq proto tag)))) | |
100 | |
101 ;; 3) A tag in the kill ring that is a prototype | |
102 (when (not proto) | |
103 (if (ring-empty-p senator-tag-ring) | |
104 nil ;; Not for us. | |
105 (let ((tag (ring-ref senator-tag-ring 0)) | |
106 ) | |
107 (when | |
108 (and tag | |
109 (or | |
110 (and | |
111 (semantic-tag-of-class-p tag 'function) | |
112 (semantic-tag-get-attribute tag :prototype)) | |
113 (and | |
114 (semantic-tag-of-class-p tag 'type) | |
115 (require 'semantic/find) | |
116 (semantic-brute-find-tag-by-attribute-value | |
117 :prototype t | |
118 (semantic-tag-type-members tag)))) | |
119 ) | |
120 (setq proto tag)) | |
121 ))) | |
122 | |
123 proto)) | |
124 | |
105313
068b13ebb340
* cedet/srecode/expandproto.el: Fix provide statement.
Juanma Barranquero <lekktu@gmail.com>
parents:
105284
diff
changeset
|
125 (provide 'srecode/expandproto) |
104498 | 126 |
127 ;; Local variables: | |
128 ;; generated-autoload-file: "loaddefs.el" | |
129 ;; generated-autoload-load-name: "srecode/expandproto" | |
130 ;; End: | |
131 | |
105377 | 132 ;; arch-tag: f0371b5f-9bec-46a1-9b5d-8dff0e897426 |
104498 | 133 ;;; srecode/expandproto.el ends here |