annotate lisp/oobr/br-objc-ft.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 4103f0995bd7
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: br-objc-ft.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Objective-C OO-Browser class and feature functions.
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: c, 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; ORG: Motorola Inc.
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: 03-Oct-90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; LAST-MOD: 5-May-95 at 15:57:14 by Bob Weiner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; Copyright (C) 1990-1995 Free Software Foundation, Inc.
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 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (require 'br-objc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defconst objc-default-category-class "[category]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 "Name of the default class whose instances are Objective-C categories.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defconst objc-default-protocol-class "[protocol]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "Name of the default class whose instances are Objective-C protocols.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defconst objc-type-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (concat "[a-zA-Z][" objc-identifier-chars "]*[ \t\n]*[*&]*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defconst objc-type-tag-separator "@"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "String that separates a tag's type from its normalized definition form.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defconst objc-tag-fields-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; The \\\\? below is necessary because we sometimes use this expression to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; test against a string that has ben regexp-quoted and some of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; characters in br-feature-type-regexp will then be preceded by \\.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (format "\\`\\([^*& \n]+\\)%s\\\\?\\(%s \\)\\([^%s\n]+\\)\\(%s\\|\\'\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 objc-type-tag-separator br-feature-type-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 objc-type-tag-separator objc-type-tag-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "Regexp matching the fields of an Objective-C feature tag line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Group 1 is the class of the feature. Group 2 is the prefix preceding the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 feature when displayed within a listing buffer. Group 3 is the feature name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 The feature definition signature begins at the end of the regexp match,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 i.e. (match-end 0), and goes to the end of the string or line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defvar objc-cpp-include-dirs '("/usr/include/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 "*Ordered list of include directories by default searched by C preprocessor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Each directory must end with a directory separator. See also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 'objc-include-dirs'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvar objc-include-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "*Ordered list of directories to search for Objective-C include files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Each directory must end with a directory separator. Directories normally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 searched by the Objective-C pre-processor should be set instead in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 'objc-cpp-include-dirs'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defun objc-add-default-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; Add to 'system' class table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (mapcar (function (lambda (class) (br-add-class class br-null-path nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (list objc-default-category-class objc-default-protocol-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (if br-c-tags-flag (c-add-default-classes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defun objc-class-definition-name (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 "Convert CLASS name to the way it appears in its source code definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 Returns a regular expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (cond ((string-match "^<.+>$" class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; Remove <> delimiters from protocol class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (regexp-quote (substring class 1 -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ((string-match "^\\([^ \(]+\\) *(\\([^\)]*\\)) *$" class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; Allow for whitespace within class(category)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (format "%s[ \t\n\r]*([ \t\n\r]*%s[ \t\n\r]*)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (substring class (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (substring class (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ((string-match "^(\\([^\)]*\\)) *\\([^ ]+\\) *$" class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; Allow for whitespace within (category)class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (format "%s[ \t\n\r]*([ \t\n\r]*%s[ \t\n\r]*)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (substring class (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (substring class (match-beginning 1) (match-end 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (t (regexp-quote class))))
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 objc-class-definition-regexp (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "Return regexp to uniquely match the definition of CLASS name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (concat objc-class-name-before (objc-class-definition-name class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 objc-class-name-after))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defun objc-feature-implementors (ftr-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "Return unsorted list of Objective-C feature tags which implement FTR-NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (objc-feature-matches ftr-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (defun objc-feature-locate-p (feature-tag &optional regexp-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 "Leaves point at the start of FEATURE-TAG's definition in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 Assumes caller has moved point to the beginning of the buffer or to the point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 of desired search start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 Optional REGEXP-FLAG means FEATURE-TAG is a regular expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; Match to function definitions, not declarations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (let ((found) (start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; First move to the proper class implementation if this is not a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; [default-class], so that if two classes in the same file have the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; feature signature, we still end up at the right one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (if (and (not (string-match (if regexp-flag "\\`\\\\\\[" "\\`\\[")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 feature-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (string-match objc-tag-fields-regexp feature-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (let ((class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (substring feature-tag (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; Protocols don't define methods, they only declare them, so we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; know we can't be searching for a protocol method definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; here, and so there is no special case handling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (re-search-forward (concat objc-implementation-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; Assume regexp-quoted class is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; same as non-regexp-quoted version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; since this call will regexp-quote it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; again; we have no way of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; un-regexp-quoting it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (objc-class-definition-name class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; Now search for feature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (or regexp-flag (setq feature-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (objc-feature-signature-to-regexp feature-tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (while (and (re-search-forward feature-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (setq start (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (not (setq found (not (if (c-within-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (progn (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 t)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (progn (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (objc-to-comments-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (recenter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 t))))
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 objc-feature-name-to-regexp (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "Converts feature NAME into a regular expression matching the feature's name tag."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; protocol name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ((= (aref name 0) ?\<) (regexp-quote name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; category name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ((= (aref name 0) ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; Drop any class name following the category.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (substring name 0 (1+ (string-match "\)" name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; feature tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ((string-match objc-tag-fields-regexp name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 "^" (regexp-quote (substring name (match-beginning 0) (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; unrecognized name format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (t (error "(objc-feature-name-to-regexp): Invalid name, '%s'" name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defun objc-feature-signature-to-name (signature &optional with-class for-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Extracts the feature name from SIGNATURE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 SIGNATURE may be a feature tag line or a signature extracted from source code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 The feature's class name is dropped from signature unless optional WITH-CLASS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 is non-nil. The feature's type (class feature = +, instance feature = -)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 is dropped unless FOR-DISPLAY is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; feature tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (if (string-match objc-tag-fields-regexp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (cond ((and with-class for-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (substring signature (match-beginning 1) (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (for-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (substring signature (match-beginning 2) (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (with-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (substring signature (match-beginning 1) (1+ (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (substring signature (match-beginning 3) (match-end 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (t (substring signature (match-beginning 3) (match-end 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; source code signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (let ((loop-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (name-part (concat "\\`" objc-name-part objc-name-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (name-type (concat "\\`" objc-name-part objc-type-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (cond ((or (= (aref signature 0) ?\<) (= (aref signature 0) ?\())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;; protocol or category tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (setq name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (if for-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (concat "@ " signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ((string-match (concat "\\`" br-feature-type-regexp) signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; regular feature signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (if for-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (setq name (concat (substring signature (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (setq signature (concat (substring signature (match-end 0)) ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (while (and loop-p (string-match name-part signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; Handles named or unnamed parameters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (if (match-beginning objc-name-part-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (setq name (concat name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (match-beginning objc-name-part-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (match-end objc-name-part-id)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (if (/= (aref signature (1- (match-end 0))) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (setq loop-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 signature (substring signature (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (setq name (concat name ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 signature (substring signature (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (if (string-match name-type signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (setq signature (substring signature (match-end 0)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (t (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 "(objc-feature-signature-to-name): Invalid signature, '%s'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun objc-feature-signature-to-regexp (signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 "Return regexp to match the definition of an Objective-C element SIGNATURE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 SIGNATURE may be a feature tag line or a signature extracted from source code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (cond ((string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 "^\\([^*& \n]+\\)%s%s [^%s\n]+%s\\([\<\(][^\>\)\n]+[\>\)]\\(%s\\)?\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 objc-type-tag-separator br-feature-type-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 objc-type-tag-separator objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 objc-identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; protocol or category signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (let ((class (substring signature (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (element (substring signature (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (= (aref element 0) ?\<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if (string-equal class objc-default-protocol-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; find def of protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (concat objc-protocol-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (objc-class-definition-name element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "[\< \t\n\r]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; find def of class which conforms to protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (concat objc-interface-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (objc-class-definition-name class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 objc-class-name-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "[^\>\{]*[\<,][ \t\n\r]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (objc-class-definition-name element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "[ \t\n\r]*[\>,]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if (string-equal class objc-default-category-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; find def of '[category]@(category-name)class-name'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (concat objc-interface-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (objc-class-definition-name element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; find def of 'class-name@(category-name)'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (concat objc-interface-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (objc-class-definition-name (concat class element)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; regulare feature tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq signature (regexp-quote signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (if (string-match objc-tag-fields-regexp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; We must leave the class name as an optional component at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; start of the signature so that functions that lookup feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; definitions can use it to ensure that the definition is found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; within the right class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "\\(" (substring signature (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 objc-type-tag-separator "\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (substring signature (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (let ((pat) (i 0) (c) (len (length signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (setq c (aref signature i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 pat (cond ((= c ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (concat pat "[ \t\n\^M]*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (concat pat (char-to-string c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (= ?{ (aref pat (1- (length pat))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (setq pat (concat (substring pat 0 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 "\\([ \t\n]*//.*[\n]\\)*[ \t\n]*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 pat)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defun objc-feature-tree-command-p (class-or-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "Display definition of CLASS-OR-SIGNATURE if a signature and return t, else return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (if (br-in-browser) (br-to-view-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (br-feature-found-p (br-feature-file class-or-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 class-or-signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defun objc-list-categories (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 "Return sorted list of Objective-C CLASS categories."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (let ((obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (categories)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 class-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (cond ((string-equal class objc-default-category-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (objc-list-features class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ((= (aref class 0) ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; Any other default classes belong to no categories.
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 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq class-tag (concat "\n" class objc-type-tag-separator "\("))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;; Use a string match for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (while (search-forward class-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (setq categories (cons (br-feature-current) categories)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (set-buffer obuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (objc-sort-features (nreverse categories))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (defun objc-list-features (class &optional indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 "Return sorted list of Objective-C features lexically defined in CLASS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (let ((obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (features)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 class-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 search-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (if (= (aref class 0) ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; Default class of protocols or categories. Use a string match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (setq search-function 'search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 class-tag (concat "\n" class objc-type-tag-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq search-function 're-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 class-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; Include methods defined in any of the class' categories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (concat "^" class "\\(([^\)]*)\\)?" objc-type-tag-separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (while (funcall search-function class-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (setq features (cons (br-feature-current) features)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (set-buffer obuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (objc-sort-features (nreverse features))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defun objc-list-protocols (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 "Return sorted list of Objective-C CLASS protocols."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (let ((obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (protocols)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 class-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (cond ((string-equal class objc-default-protocol-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (objc-list-features class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ((= (aref class 0) ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;; Any other default classes conform to no formal protocols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (setq class-tag (concat "\n" class objc-type-tag-separator "\<"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; Use a string match for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (while (search-forward class-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (setq protocols (cons (br-feature-current) protocols)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (set-buffer obuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (objc-sort-features (nreverse protocols))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defun objc-routine-at-point-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Returns name of Objective-C routine signature at point or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 If called interactively, it prints the name in the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (if (and (re-search-backward "[-+\n\^M]\\|\\`" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (looking-at "[ \t\n\^M]*[-+]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (let ((name "") (loop-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (name-part (concat objc-name-part objc-name-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (name-type (concat objc-name-part objc-type-sep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (while (and loop-p (looking-at name-part))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;; Handles named or unamed parameters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (if (match-beginning objc-name-part-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (setq name (concat name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (match-beginning objc-name-part-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (match-end objc-name-part-id)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if (/= (preceding-char) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (setq loop-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (setq name (concat name ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if (looking-at name-type) (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (message name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defun objc-scan-features ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "Return reverse ordered list of Objective-C routine definitions in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 Assume point is at beginning of widened buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (let ((routines) (rout) (class-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 class category)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (concat "^@implementation[ \t\n\r]+" objc-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 "\\([ \t\n\r]*([ \t\n\r]*" objc-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "[ \t\n\r]*)\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (setq category (if (match-beginning 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (buffer-substring (match-beginning 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 class (buffer-substring (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 class (if category (format "%s(%s)" class category) class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if (search-forward "\n@end" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (setq class-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (error "(objc-scan-features): %s, at char %d, @implementation without @end.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (while (re-search-forward objc-routine-def class-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq rout (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (if (c-within-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (backward-char) ;; Move point to precede feature opening brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;; Move to end of feature but ignore any error if braces are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ;; unbalanced. Let the compiler tell the user about this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (setq rout (objc-feature-normalize rout class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 routines (cons rout routines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 routines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (defun objc-scan-protocol-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 "Return a list of protocol names following point, delimited by <> and separated by commas.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 Point may be immediately before or after the '<' which begins the protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 list. Leaves point afer the closing delimiter of the protocol list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (cond ((= (preceding-char) ?\<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ((= (following-char) ?\<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (error "(objc-scan-protocol-list): Point must precede or follow a '<' delimiter.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (let ((end (save-excursion (search-forward "\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (protocols))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (while (re-search-forward objc-identifier end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq protocols (cons (concat "<"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 protocols)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (nreverse protocols)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (defun objc-sort-features (routine-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (sort routine-list 'objc-feature-lessp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun objc-to-definition (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "If point is within a declaration, try to move to its definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 With OTHER-WIN non-nil, show it in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ((objc-include-file other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ((br-check-for-class (objc-class-decl-p) other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ((objc-feature other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ((and (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (br-check-for-class (objc-find-class-name) other-win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (t (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "(OO-Browser): Select an Objective-C declaration to move to its definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (defun objc-view-protocol (protocol-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 "Display definition of PROTOCOL-NAME for viewing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 PROTOCOL-NAME must be a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (or (string-match "<.*>" protocol-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (setq protocol-name (concat "<" protocol-name ">")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (let* ((sig (concat objc-default-protocol-class objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 protocol-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (feature-path (br-feature-file sig)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (br-to-view-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (if (br-feature-found-p feature-path sig)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (progn (br-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; Force mode-line redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (set-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (br-to-from-viewer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; Protocol not found. Return to original window and signal an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (br-to-from-viewer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (error "(OO-Browser): No '%s' protocol defined in Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 protocol-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (defun objc-class-decl-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 "Return nil unless point is within a class declaration, referenced by another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 class. Commented declarations also return nil. When value is non-nil, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 the class name from the declaration. Leave point at start of statement for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 visual clarity."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (objc-skip-to-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (let ((class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (and (looking-at objc-class-decl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (setq class (buffer-substring (match-beginning objc-class-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (match-end objc-class-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (not (c-within-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (not (looking-at "[ \t]*//")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (defun objc-feature (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 "Move point to definition of the element given by declaration at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 Return nil if point is not within an element declaration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ;; If '{' follows the feature declaration, then feature is defined right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;; here, within the class definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (cond ((objc-feature-def-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (recenter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; Now look for feature definition in code (non-header) files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ((objc-feature-decl-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (let ((class) feature-name signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (setq signature (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (if (re-search-backward objc-class-def-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (setq class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (match-beginning objc-class-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (match-end objc-class-name-grpn)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (setq signature (objc-feature-normalize signature class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 feature-name (objc-feature-signature-to-name signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (if (objc-locate-feature feature-name class signature other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (message "(OO-Browser): No definition for '%s' in '%s'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 feature-name (or class "UNKNOWN-CLASS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (defun objc-feature-decl-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 "Return t if point is within an Objective-C feature declaration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (looking-at objc-feature-declaration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (defun objc-feature-def-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 "Return nil unless point is within an element definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 Commented element definitions also return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (objc-skip-to-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (and (not (c-within-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (save-excursion (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (not (looking-at "[ \t]*//")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (not (looking-at objc-class-decl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (looking-at (concat objc-feature-decl-or-def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 objc-comment-regexp "[{;,]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (= ?\{ (save-excursion (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (preceding-char))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (defun objc-feature-partial-name (feature-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 "Extract the feature name without its class name from FEATURE-TAG."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (objc-feature-signature-to-name feature-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (defun objc-feature-lessp (tag1 tag2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (string-lessp (objc-feature-partial-name tag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (objc-feature-partial-name tag2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (defun objc-feature-matches (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 "Return an unsorted list of feature tags whose names match in whole to NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ;; Ensure match to feature names only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (let ((regexp (format "^[^%s \n]+%s%s %s%s" objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 objc-type-tag-separator br-feature-type-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (regexp-quote name) objc-type-tag-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (features))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (while (re-search-forward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (setq features (cons (br-feature-current) features))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 features)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (defun objc-feature-normalize (routine class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (let* ((len (length routine))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (normal-feature (make-string len ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (n 0) (i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (space-list '(?\ ?\t ?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (space-regexp "[ \t\n\^M]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 chr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (setq chr (aref routine i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; Convert sequences of space characters to a single space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ((memq chr space-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (aset normal-feature n ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (if (string-match space-regexp routine i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (setq i (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (setq i (1+ i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 n (1+ n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; Remove // style comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ((and (= chr ?/)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (< (1+ i) len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (= (aref routine (1+ i)) ?/))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (setq i (+ i 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (while (and (< i len) (/= (aref routine i) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (t ;; Normal character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (aset normal-feature n chr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (setq i (1+ i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 n (1+ n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (setq normal-feature (substring normal-feature 0 n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (concat class objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (objc-feature-signature-to-name normal-feature nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 normal-feature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (defun objc-feature-tag-class (feature-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 "Extract the class name from FEATURE-SIGNATURE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (if (string-match objc-type-tag-separator feature-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (substring feature-signature 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (defun objc-feature-tags-lookup (class-list signature ftr-regexp &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 "Display routine definition derived from CLASS-LIST, matching SIGNATURE (string) and FTR-REGEXP (regexp matching SIGNATURE).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 Use routine tags table to locate a match. Caller must use 'set-buffer'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 to restore prior buffer when a match is not found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (let ((classes class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (found-ftr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (if (null class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (while (and (not found-ftr) classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (setq class (car classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 found-ftr (br-feature-found-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (br-feature-file signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ftr-regexp nil other-win t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 classes (if found-ftr nil (cdr classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (if found-ftr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (or class t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (objc-feature-tags-lookup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (apply 'append (mapcar (function (lambda (cl) (br-get-parents cl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 class-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ftr-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 other-win)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (defun objc-files-with-source (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 "Use CLASS to compute set of files that match to an Objective-C source file regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 Return as a list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (let ((file (if class (br-class-path class) buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (and file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (let* ((src-file-regexp (concat "^" (br-filename-head file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 objc-code-file-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (dir (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (files (directory-files dir nil src-file-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (mapcar (function (lambda (f) (concat dir f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 files)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defun objc-find-ancestors-feature (class-list signature &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 "Scan ancestors of CLASS-LIST and show routine definition matching SIGNATURE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;; If no class, search for non-element function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (or class-list (setq class-list '(nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (let ((obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (ftr-regexp (objc-feature-signature-to-regexp signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (if (and br-feature-tags-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (file-exists-p br-feature-tags-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (file-readable-p br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (objc-feature-tags-lookup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 class-list signature ftr-regexp other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;; Only works if features are in same directory as class def.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (objc-scan-ancestors-feature class-list ftr-regexp other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (set-buffer obuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (defun objc-find-class-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 "Return current word as a potential class name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (let* ((start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (ignore "-+ \t\n;,.<>{}*&\(\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (pat (concat "^" ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (skip-chars-backward ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (skip-chars-backward pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (skip-chars-forward (concat pat ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (buffer-substring start (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (defun objc-get-class-name-from-source ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 "Return class name from closest class definition preceding point or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (let ((opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (if (re-search-backward objc-class-def-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (progn (setq class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (match-beginning objc-class-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (match-end objc-class-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;; Ensure that declaration occurs within class definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (forward-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (and (> (point) opoint) class))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (defun objc-get-feature-tags (routine-file &optional routine-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 "Scan Objective-C ROUTINE-FILE and hold routine tags in 'br-feature-tags-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 Assume ROUTINE-FILE has already been read into a buffer and that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 'br-feature-tags-init' has been called. Optional ROUTINE-LIST can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 provided so that a non-standard scan function can be used before calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 this function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (let ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (setq routine-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (objc-sort-features
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (or routine-list (objc-scan-features))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;; Delete any prior routine tags associated with routine-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (if (search-forward routine-file nil 'end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (progn (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (search-forward "\^L" nil 'end 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (delete-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (if routine-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (progn (insert "\^L\n" routine-file "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (mapcar (function (lambda (tag) (insert tag "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 routine-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (set-buffer obuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (defun objc-include-file (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 "If point is on an include file line, try to display file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 Return non-nil iff an include file line, even if file is not found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 Look for include file in 'objc-cpp-include-dirs' and in directory list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 'objc-include-dirs'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (if (looking-at objc-include-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (let ((incl-type (string-to-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (match-beginning objc-include-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (1+ (match-beginning objc-include-type-grpn)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (file (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (match-beginning objc-include-file-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (match-end objc-include-file-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (dir-list objc-include-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (setq dir-list (if (= incl-type ?\<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (append dir-list objc-cpp-include-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (cons (file-name-directory buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 dir-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (while dir-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (setq path (concat (car dir-list) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 dir-list (if (setq found (file-exists-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (cdr dir-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 ;; If not found in normal include dirs, check all Env paths also.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (if (not found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (let ((paths (delq nil (hash-map 'cdr br-paths-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (while paths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (setq path (car paths))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (if (string-equal (file-name-nondirectory path) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (setq found t paths nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (setq paths (cdr paths))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 ;; If found, display file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (if (file-readable-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (funcall br-edit-file-function path other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (if (not (fboundp 'br-lang-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (objc-mode-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (br-major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (message "(OO-Browser): Include file '%s' unreadable." path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (message "(OO-Browser): Include file '%s' not found." file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (defun objc-locate-feature (ftr class signature &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 ;; 'class' may = nil, implying non-element function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (let ((def-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (if (and signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (setq def-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (objc-find-ancestors-feature (list class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 signature other-win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (progn (if (and class (not (equal class def-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 "Element `%s` of class '%s' inherited from class '%s'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ftr class def-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defun objc-scan-ancestors-feature (class-list ftr-regexp &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 "Display routine definition derived from CLASS-LIST, matching FTR-REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 Scan files with same base name as class file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (let ((classes class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (found-ftr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (code-def-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (if (null class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (while (and (not found-ftr) classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (setq class (car classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 code-def-files (objc-files-with-source class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (while (and (setq file (car code-def-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (not (setq found-ftr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (br-feature-found-p file ftr-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 nil other-win t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (setq code-def-files (cdr code-def-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (setq classes (if found-ftr nil (cdr classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (if found-ftr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (or class t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (objc-scan-ancestors-feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (apply 'append (mapcar (function (lambda (cl) (br-get-parents cl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 class-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 ftr-regexp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (defun objc-skip-past-comments ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 "Skip over comments immediately following point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (cond ((looking-at "//")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (equal (forward-line 1) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ((looking-at "/\\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (re-search-forward "\\*/" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (defun objc-skip-to-statement ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (if (re-search-backward "\\(^\\|[;{}]\\)[ \t]*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (progn (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (defconst objc-code-file-regexp ".\\.[cmCM]$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 "Regular expression matching a unique part of Objective-C source (non-header) file name and no others.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (defconst objc-include-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 "[ \t/*]*#[ \t]*\\(import\\|include\\)[ \t]+\\([\"<]\\)\\([^\">]+\\)[\">]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 "Regexp to match to Objective-C include file lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 File name is grouping 'objc-include-file-grpn'. Type of include,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 user-specified via double quote, or system-related starting with `<' is given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 by grouping 'objc-include-type-grpn'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (defconst objc-include-type-grpn 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (defconst objc-include-file-grpn 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (defconst objc-type-def-modifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 "\\(auto\\|const\\|inline\\|register\\|static\\|typedef\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (defconst objc-func-identifier (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 "[_a-zA-Z][^][ \t:;.,~{}()]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 "Regular expression matching an Objective-C function name.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (defconst objc-feature-decl-or-def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 "[-+]\\([^\]\[{};`'\"/|?,!.#$%^=+-]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 "Regexp matching an Objective-C feature declaration or definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 Feature name is group 1.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (defconst objc-feature-name-grpn 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (defconst objc-comment-regexp "\\([ \t\n]*//.*[\n]\\)*[ \t\n]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (defconst objc-routine-def (concat "^" objc-feature-decl-or-def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 objc-comment-regexp "{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (defconst objc-feature-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (concat "^[ \t]*\\(" objc-feature-decl-or-def "\\)" objc-comment-regexp ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (defconst objc-class-decl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (concat objc-class-name-before objc-identifier "[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 "Regexp matching an Objective-C class declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 Class name is grouping 'objc-class-name-grpn'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (defconst objc-class-name-grpn 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (defconst objc-arg-identifier (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 "[_a-zA-Z][" objc-identifier-chars "]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 "Regular expression matching an Objective-C function argument identifier.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (defconst objc-name-part-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 "[ \t\n]*\\(([^\)]+)[ \t\n]*\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (defconst objc-name-part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (concat objc-name-part-prefix objc-identifier "?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (defconst objc-name-sep "[ \t\n]*\\([:;{]\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (defconst objc-type-sep "\\([ \t\n;{]\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (defconst objc-name-part-type 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (defconst objc-name-part-id 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (defconst objc-name-part-sep 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (provide 'br-objc-ft)