annotate lisp/oobr/eif-calls.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 4103f0995bd7
children 4be1180a9e89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: eif-calls.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Produce first level static call tree for Eiffel class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: oop, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
9 ;; ORG: Motorola Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 7-Dec-89 at 19:32:47
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
12 ;; LAST-MOD: 30-Aug-95 at 15:22:33 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
14 ;; Copyright (C) 1989-1995 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; See the file BR-COPY for license information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; This file is part of the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; The default commands, 'eif-store-class-info' and 'eif-insert-class-info'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; work in tandem to display the parents, attributes and routines with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; routine call summaries for a class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; The command {M-x eif-info-use-short}, will instead cause the above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; commands to run the Eiffel 'short' command on a class, thereby
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; displaying its specification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; The command {M-x eif-info-use-flat}, will instead cause the above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; commands to run the Eiffel 'flat' command on a class, thereby
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; displaying its complete feature set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; Call {M-x eif-info-use-calls} to reset these commands to their default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (require 'br-eif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defun eif-info-use-calls ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "Setup to display call trees and other class summary info."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (fset 'eif-store-class-info 'eif-store-class-info-calls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (fset 'eif-insert-class-info 'eif-insert-class-info-calls))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (eif-info-use-calls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defun eif-info-use-flat ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "Setup to display the Eiffel 'flat' output for classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (fset 'eif-store-class-info 'eif-store-class-info-flat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (fset 'eif-insert-class-info 'eif-insert-class-info-flat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defun eif-info-use-short ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 "Setup to display the Eiffel 'short' output for classes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (fset 'eif-store-class-info 'eif-store-class-info-short)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (fset 'eif-insert-class-info 'eif-insert-class-info-short))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defun eif-show-class-info (&optional class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "Displays class specific information summary in other window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 This summary includes listings of textually included attributes, routines,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 and routine calls from an Eiffel class. Use optional CLASS-NAME for class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 text or extract from the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (interactive (list (br-complete-class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (let ((cn (car (eif-get-class-name-from-source))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (if cn (concat "Class name: (default " cn ") "))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (let ((class-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (if (not (br-class-in-table-p class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (if (setq class-file-name buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (setq class-name (car (eif-get-class-name-from-source)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (error "No class specified.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if (null class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (error "No class specified.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (message "Building '%s' class info..." class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (eif-store-class-info class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (message "Building '%s' class info...Done" class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (br-eval-in-other-window "*Class Info*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 '(eif-insert-class-info class-file-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; Internal functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defun eif-get-class-name-from-source ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 "Return indication of closest class definition preceding point or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 If non-nil, value is a cons cell of (class-name . deferred-class-p)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (or (re-search-backward eif-class-def-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (re-search-forward eif-class-def-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (cons (eif-set-case (buffer-substring (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (match-end 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun eif-insert-class-info-calls (&optional src-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "Inserts textually included attributes, routines, and routine calls from 'eif-last-class-name'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 Uses optional SRC-FILE-NAME for lookups or class name from 'eif-last-class-name'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (if (and eif-last-class-name eif-attributes-and-routines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (error (concat "Call 'eif-store-class-info' first."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (let ((key (car (where-is-internal 'eif-store-class-info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (and key (concat " It is bound to {" key "}."))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (let ((in-lookup-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (if src-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (br-class-in-table-p eif-last-class-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (if (not (or in-lookup-table src-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (insert eif-last-class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (center-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (insert "Parents:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (let ((parents (if in-lookup-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (br-get-parents eif-last-class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (eif-get-parents-from-source src-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (if parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (mapcar (function (lambda (par) (insert " " par "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 parents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (insert " <None>\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (let ((attribs (car eif-attributes-and-routines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (routines (cdr eif-attributes-and-routines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (if parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (insert "\nNon-Inherited Attributes:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (insert "\nAttributes:\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (if attribs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (mapcar (function (lambda(attr) (insert " " attr "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 attribs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (insert " <None>\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (if parents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "\nNon-Inherited Routines with Apparent Routine Calls:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (insert "\nRoutines with Apparent Routine Calls:\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (if routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (lambda(cns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (insert " " (car cns) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (lambda (call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (insert " " call "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (cdr cns))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 routines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (insert " <None>\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (set-buffer-modified-p nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defun eif-store-class-info-calls (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "Generates cons of textually included attributes and routines (including routine calls) from CLASS-NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 It stores this cons in the global 'eif-attributes-and-routines'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (interactive (list (br-complete-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (setq eif-last-class-name (downcase class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (let ((in-lookup-table (br-class-path eif-last-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (if (not (or in-lookup-table buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (setq eif-attributes-and-routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (eif-get-features-from-source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (if in-lookup-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (br-class-path eif-last-class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 buffer-file-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (defun eif-insert-class-info-short ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (insert-file-contents eif-tmp-info-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (shell-command (concat "rm -f " eif-tmp-info-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (message ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun eif-store-class-info-short (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (interactive (list (br-complete-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (shell-command (concat "short -b 3 -p "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (br-class-path (br-find-class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "> " eif-tmp-info-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defun eif-insert-class-info-flat ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (insert-file-contents eif-tmp-info-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (shell-command (concat "rm -f " eif-tmp-info-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (message ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (defun eif-store-class-info-flat (class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (interactive (list (br-complete-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (shell-command (concat "flat -b 3 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (br-class-path (br-find-class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "> " eif-tmp-info-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (defun eif-class-name-from-file-name (file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (string-match "^.*/\\([a-z0-9_]+\\)\\.e$" file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (if (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (substring file-name (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun eif-eval-in-other-window (buffer form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Clear out BUFFER and display result of FORM evaluation in viewer window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 Then return to previous window. BUFFER may be a buffer name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (let ((wind (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (pop-to-buffer (get-buffer-create buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (eval form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (select-window wind)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (defun eif-get-attribute-definition-regexp (identifier-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 "Return regexp to match to IDENTIFIER-REGEXP definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 Matching attribute name is grouping 'eif-feature-name-grpn'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (concat eif-modifier-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "\\(" identifier-regexp "\\)[ \t]*:[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 eif-type "\\([ \t]+is[ \t]+.+\\)?[ \t]*;?[ \t]*\\(--.*\\)?$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defun eif-get-features-from-source (filename &optional form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Returns cons of attribute def list and routine def list from Eiffel class FILENAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 Optional FORM is a Lisp form to be evaluated instead of the default feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 extraction. Assumes file existence has already been checked. The cdr of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 each element of each item in routine def list is a best guess list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 subroutines invoked by the routine."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (let* ((no-kill (get-file-buffer filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (tmp-buf (set-buffer (get-buffer-create "*tmp*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 features orig-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if no-kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (set-buffer no-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (setq orig-buf (funcall br-find-file-noselect-function filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (set-buffer orig-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (copy-to-buffer tmp-buf (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (set-buffer tmp-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (while (re-search-forward "^\\([^\"\n]*\\)--.*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (replace-match "\\1" t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (if (not (re-search-forward "^feature[ \t]*$" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq features
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (eval form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (eif-parse-features)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (erase-buffer) ; tmp-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (or no-kill (kill-buffer orig-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 features))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defun eif-in-comment-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "Return nil unless point is within an Eiffel comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (let ((end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (search-forward "--" end t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun eif-to-attribute (&optional identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "Move point to attribute matching optional IDENTIFIER or next attribute def in buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 Leave point at beginning of line where feature is defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 Return name of attribute matched or nil. Ignore obsolete attributes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (let ((pat (if identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (eif-attribute-to-regexp identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 eif-attribute-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (non-attrib-keyword "local\\|require\\|ensure\\|invariant"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (while (and (re-search-forward pat nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (setq found (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (match-beginning eif-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (match-end eif-feature-name-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 start (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; Continue loop if in a comment or a local declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (or (if (eif-in-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (progn (setq found nil) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (while (and (setq keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 "\\(^\\|[ \t]+\\)\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 "end\\|feature\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 non-attrib-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "\\)[\; \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (eif-in-comment-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (if (and keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (equal 0 (string-match non-attrib-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 keyword)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (progn (setq found nil) t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (if start (goto-char start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (defun eif-parse-attributes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 "Returns list of attributes defined in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 Assumes point is at the start of buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (let (attribs attrib lattrib reserved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; For each attribute definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (while (and (eif-to-attribute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (looking-at eif-attribute-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (setq attrib (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (match-beginning eif-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (match-end eif-feature-name-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 lattrib (downcase attrib))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (if (or (> (length lattrib) 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (< (length lattrib) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq reserved eif-reserved-words)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; Ensure that each attrib is not a reserved word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (while (if (string-equal lattrib (car reserved))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (setq attrib nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (string-lessp (car reserved) lattrib))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (setq reserved (cdr reserved))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (if attrib (br-set-cons attribs attrib)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (setq attribs (nreverse attribs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (defun eif-parse-features (&optional skip-calls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 "Returns cons of attribute def list and routine def list from current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 The cdr of each item in routine def list is a best guess list of routine calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 invoked by the routine, unless optional SKIP-CALLS is non-nil, in which case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 each item is just the routine name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (let ((routines) attribs external routine calls non-ids reserved type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;; Get attribute definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; and add attributes to list of names not to consider routine invocations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (setq attribs (eif-parse-attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 non-ids (append attribs eif-reserved-words)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 attribs (mapcar (function (lambda (attribute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (concat "= " attribute)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 attribs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; For each routine definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (while (re-search-forward eif-routine-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (setq routine (buffer-substring (match-beginning eif-feature-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (match-end eif-feature-name-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 external (if (match-beginning eif-modifier-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (string-match "external"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (match-beginning eif-modifier-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (match-end eif-modifier-grpn))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 reserved non-ids)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if (match-beginning eif-feature-args-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;; Routine takes a list of arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;; Add ids matched to list of names not to consider routine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; invocations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (setq reserved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (append (eif-parse-params
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (match-beginning eif-feature-args-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (match-end eif-feature-args-grpn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 reserved)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (cond (external
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq routine (concat "/ " routine)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ((re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "^[ \t]*\\(do\\|once\\|deferred\\)[ \t\n]+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (setq type (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (cond ((string-equal type "do")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq routine (concat "- " routine)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ((string-equal type "once")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (setq routine (concat "1 " routine)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (t ;; deferred type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (setq routine (concat "> " routine))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (if skip-calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (setq routines (cons routine routines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (setq calls (nreverse (eif-parse-ids reserved))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 routines (cons (cons routine calls) routines))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (setq routines (nreverse routines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (cons attribs routines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (defun eif-parse-ids (&optional non-ids)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 "Ignores list of NON-IDS and returns list of Eiffel identifiers through the end of the current routine definition."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (let (call calls lcall call-list non-id-list same start valid-call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (while (and (setq start (eif-try-for-routine-call))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;; Ignore assignable entities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (cond ((stringp start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq non-ids (cons (downcase start) non-ids)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; Ignore reserved word expressions that look like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;; routine calls with arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ((and (setq call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (downcase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (buffer-substring start (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (looking-at "[ \t]*\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (br-member call non-ids)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;; Skip past rest of this routine invocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (while (or (progn (setq valid-call t same (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (and (setq call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (eif-skip-past-arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 valid-call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (or (null call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (= call 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (looking-at "\\.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (skip-chars-forward ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (if (setq valid-call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 eif-identifier))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (goto-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (> (point) same))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (if (and valid-call (looking-at "\\."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (progn (skip-chars-forward ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (if (setq valid-call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 eif-identifier))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (goto-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (match-end 0)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (if (and valid-call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (/= start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (progn (setq call (buffer-substring start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 lcall (downcase call))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;; If at end of 'do' part of routine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; definition...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (if (or (string-equal lcall "ensure")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (and (string-equal lcall "end")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 "[ \t]*[;]?[ \t]*[\n][ \t]*[\n]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (setq valid-call nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if call (br-set-cons calls call))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 valid-call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (while calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (setq call (car calls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 calls (cdr calls)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 lcall (downcase call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 non-id-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (or non-ids eif-reserved-words))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (if (br-member lcall non-id-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (setq call nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (if call (setq call-list (append call-list (list call)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 call-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (defun eif-parse-params (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 "Returns list of Eiffel formal parameters between START and END, in reverse order."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (let (params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (while (re-search-forward eif-identifier nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq params (cons (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (match-beginning 0) (match-end 0)) params))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if (looking-at "[ \t]*:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (progn (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (re-search-forward eif-type nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 params))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defun eif-skip-past-arg-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 "Skips path arg list delimited by parenthesis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 Leaves point after closing parenthesis. Returns number of unclosed parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 iff point moves, otherwise nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (let ((depth 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if (not (looking-at "[ \t]*\("))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (setq depth (1+ depth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (while (> depth 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (skip-chars-forward "^()\"'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (cond ((= ?\" (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (progn (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (skip-chars-forward "^\"")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ((= ?' (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (progn (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (skip-chars-forward "^'")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ((setq depth (if (= ?\( (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (1+ depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (1- depth)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (and (not (eobp)) (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 depth)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (defun eif-try-for-routine-call ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 "Matches to best guess of next routine call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 Returns character position of start of valid match, nil when no match,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 identifier string when an assignable entity, i.e. matches to a non-routine."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (if (re-search-forward (concat eif-identifier "\\([ \t\n]*:=\\)?") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (if (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (buffer-substring (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;;; Internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (defvar eif-reserved-words
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 '("!!" "alias" "and" "as" "bits" "boolean" "character" "check" "class" "clone" "create"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 "creation"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 "current" "debug" "deferred" "define" "div" "do" "double" "else" "elseif"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "end" "ensure" "expanded" "export" "external" "false" "feature" "forget"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 "from" "if" "implies" "indexing" "infix" "inherit" "inspect" "integer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 "invariant" "is" "language" "like" "local" "loop" "mod" "name" "nochange"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 "not" "obsolete" "old" "once" "or" "prefix" "real" "redefine" "rename"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 "repeat" "require" "rescue" "result" "retry" "select" "then" "true"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 "undefine" "unique" "until" "variant" "void" "when" "xor")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 "Lexicographically ordered list of reserved words in Eiffel version 2.2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 Longest one is 9 characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 Minor support for Eiffel 3 has now been added.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; Must handle types of these forms:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; like LIST [INTEGER]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; VECTOR [INTEGER , INTEGER]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;; LIST [ LIST[INTEGER]]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;; yet must ignore the 'is' in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ;; var: INTEGER is 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (defconst eif-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 "\\(like[ \t]+\\)?[a-zA-Z][a-zA-Z_0-9]*\\([ \t]*\\[.+\\]\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 "Regexp to match Eiffel entity and return value type expressions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (defconst eif-modifier-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 "^[ \t]*\\(frozen[ \t\n]+\\|external[ \t]+\"[^\" ]+\"[ \t\n]+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 "Special prefix modifiers that can precede a feature definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; Handles attributes of these forms:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;; attr: TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; char: CHARACTER is 'a'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;; message: STRING is "Hello, what is your name?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;; flag: BOOLEAN is true ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defconst eif-attribute-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (eif-get-attribute-definition-regexp eif-identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 "Regexp to match to an attribute definition line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defconst eif-routine-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (concat eif-modifier-regexp "\\(" eif-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 "\\|prefix[ \t]+\"[^\" ]+\"\\|infix[ \t]+\"[^\" ]+\"\\)[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 "\\(([^\)]+)[ \t]*\\)?\\(:[ \t\n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 eif-type "[ \t\n]+\\)?is[ \t]*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 "Regexp to match to routine definition line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 Ignores obsolete routines and multiple routine definition lists.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;;; Should match a multiple feature definition list on a single line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;;; (routine-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;;; (concat "^[ \t]*\\(\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ;;; eif-identifier "[ \t]*[,]?[ \t]*\\)+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;;; "\\(([^\)]+)[ \t]*\\)?\\(:[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 ;;; eif-type "[ \t]+\\)?is[ \t]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (defun eif-attribute-to-regexp (identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 "Return regexp to match to IDENTIFER attribute definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 Attribute name is grouping 'eif-feature-name-grpn'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (eif-get-attribute-definition-regexp (regexp-quote identifier)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (defun eif-routine-to-regexp (identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 "Return regexp to match to IDENTIFIER's routine definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 Routine name is grouping 'eif-feature-name-grpn'. Ignore obsolete routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 and multiple routine definition lists."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (concat eif-modifier-regexp "\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (regexp-quote identifier) "\\)[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 "\\(([^\)]+)[ \t\n]*\\)?\\(:[ \t\n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 eif-type "[ \t\n]+\\)?is[ \t]*\\(--.*\\)?$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (defconst eif-modifier-grpn 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 "Regexp grouping for leading feature modifies, 'frozen' or 'external'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (defconst eif-feature-name-grpn 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 "Regexp grouping for feature name from (eif-attribute-to-regexp) or (eif-routine-to-regexp).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (defconst eif-feature-args-grpn 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 "Regexp grouping for feature arg list for (eif-routine-to-regexp).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (defvar eif-last-class-name nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 "Last class name used as parameter to 'eif-store-class-info'. Value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 used by 'eif-insert-class-info'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (defvar eif-attributes-and-routines nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 "Class data stored by 'eif-store-class-info' for use by 'eif-insert-class-info'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defconst eif-tmp-info-file "/tmp/eif-short"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 "Temporary file used to hold Eiffel class info.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (provide 'eif-calls)