annotate lisp/oobr/br-objc-ft.el @ 215:1f0dabaa0855 r20-4b6

Import from CVS: tag r20-4b6
author cvs
date Mon, 13 Aug 2007 10:07:35 +0200
parents 4be1180a9e89
children
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
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 03-Oct-90
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
12 ;; LAST-MOD: 31-Oct-96 at 17:03:48 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
14 ;; Copyright (C) 1990-1996 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; See the file BR-COPY for license information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; This file is part of the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; 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."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
107 (objc-feature-matches (regexp-quote ftr-name)))
0
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
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
152 (defun objc-feature-map-class-tags (function class)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
153 "Apply FUNCTION to all feature tags from CLASS and return a list of the results.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
154 Feature tags come from the file named by br-feature-tags-file."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
155 (let ((obuf (current-buffer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
156 (class-tag (concat "\n" class objc-type-tag-separator))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
157 (results)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
158 search-function)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
159 (if (= (aref class 0) ?\[)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
160 ;; Default class of protocols or categories. Use a string match
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
161 ;; for speed.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
162 (setq search-function 'search-forward
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
163 class-tag (concat "\n" class objc-type-tag-separator))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
164 (setq search-function 're-search-forward
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
165 class-tag
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
166 ;; Include methods defined in any of the class' categories.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
167 (concat "^" class "\\(([^\)]*)\\)?" objc-type-tag-separator)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
168 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
169 (goto-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
170 (while (funcall search-function class-tag nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
171 (setq results (cons (funcall function) results))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
172 ;; Might have deleted current tag and would miss next tag unless point
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
173 ;; is moved backwards.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
174 (backward-char))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
175 (set-buffer obuf)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
176 results))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
177
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defun objc-feature-name-to-regexp (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "Converts feature NAME into a regular expression matching the feature's name tag."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; protocol name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ((= (aref name 0) ?\<) (regexp-quote name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; category name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ((= (aref name 0) ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; Drop any class name following the category.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (substring name 0 (1+ (string-match "\)" name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; feature tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ((string-match objc-tag-fields-regexp name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "^" (regexp-quote (substring name (match-beginning 0) (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; unrecognized name format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (t (error "(objc-feature-name-to-regexp): Invalid name, '%s'" name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (defun objc-feature-signature-to-name (signature &optional with-class for-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 "Extracts the feature name from SIGNATURE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 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
202 The feature's class name is dropped from signature unless optional WITH-CLASS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 is non-nil. The feature's type (class feature = +, instance feature = -)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 is dropped unless FOR-DISPLAY is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; feature tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (if (string-match objc-tag-fields-regexp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (cond ((and with-class for-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (substring signature (match-beginning 1) (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (for-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (substring signature (match-beginning 2) (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (with-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (substring signature (match-beginning 1) (1+ (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (substring signature (match-beginning 3) (match-end 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (t (substring signature (match-beginning 3) (match-end 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; source code signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (let ((loop-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (name-part (concat "\\`" objc-name-part objc-name-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (name-type (concat "\\`" objc-name-part objc-type-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (cond ((or (= (aref signature 0) ?\<) (= (aref signature 0) ?\())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; protocol or category tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if for-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (concat "@ " signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ((string-match (concat "\\`" br-feature-type-regexp) signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; regular feature signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (if for-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (setq name (concat (substring signature (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq signature (concat (substring signature (match-end 0)) ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (while (and loop-p (string-match name-part signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; Handles named or unnamed parameters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (if (match-beginning objc-name-part-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (setq name (concat name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (match-beginning objc-name-part-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (match-end objc-name-part-id)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (/= (aref signature (1- (match-end 0))) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (setq loop-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 signature (substring signature (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq name (concat name ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 signature (substring signature (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if (string-match name-type signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (setq signature (substring signature (match-end 0)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (t (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "(objc-feature-signature-to-name): Invalid signature, '%s'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (defun objc-feature-signature-to-regexp (signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 "Return regexp to match the definition of an Objective-C element SIGNATURE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 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
259 (cond ((string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "^\\([^*& \n]+\\)%s%s [^%s\n]+%s\\([\<\(][^\>\)\n]+[\>\)]\\(%s\\)?\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 objc-type-tag-separator br-feature-type-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 objc-type-tag-separator objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 objc-identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; protocol or category signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (let ((class (substring signature (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (element (substring signature (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (if (= (aref element 0) ?\<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (if (string-equal class objc-default-protocol-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; find def of protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (concat objc-protocol-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (objc-class-definition-name element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 "[\< \t\n\r]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; find def of class which conforms to protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (concat objc-interface-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (objc-class-definition-name class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 objc-class-name-after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "[^\>\{]*[\<,][ \t\n\r]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (objc-class-definition-name element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "[ \t\n\r]*[\>,]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (if (string-equal class objc-default-category-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;; find def of '[category]@(category-name)class-name'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (concat objc-interface-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (objc-class-definition-name element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; find def of 'class-name@(category-name)'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (concat objc-interface-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (objc-class-definition-name (concat class element)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; regulare feature tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (setq signature (regexp-quote signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (string-match objc-tag-fields-regexp signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;; We must leave the class name as an optional component at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; start of the signature so that functions that lookup feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; definitions can use it to ensure that the definition is found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; within the right class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (setq signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 "\\(" (substring signature (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 objc-type-tag-separator "\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (substring signature (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (let ((pat) (i 0) (c) (len (length signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (setq c (aref signature i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 pat (cond ((= c ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (concat pat "[ \t\n\^M]*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (concat pat (char-to-string c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (if (= ?{ (aref pat (1- (length pat))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (setq pat (concat (substring pat 0 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 "\\([ \t\n]*//.*[\n]\\)*[ \t\n]*{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 pat)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
319 (defun objc-feature-tag-regexp (class feature-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
320 "Return a regexp that matches to the feature tag entry for CLASS' FEATURE-NAME."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
321 (concat "^" (regexp-quote class) objc-type-tag-separator
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
322 br-feature-type-regexp " "
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
323 (regexp-quote feature-name) "\\(" objc-type-tag-separator "\\|\\'\\)"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
324
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun objc-feature-tree-command-p (class-or-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 "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
327 (if (br-in-browser) (br-to-view-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (br-feature-found-p (br-feature-file class-or-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 class-or-signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (defun objc-list-categories (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 "Return sorted list of Objective-C CLASS categories."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (let ((obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (categories)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 class-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (cond ((string-equal class objc-default-category-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (objc-list-features class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ((= (aref class 0) ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;; Any other default classes belong to no categories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (setq class-tag (concat "\n" class objc-type-tag-separator "\("))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; Use a string match for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (while (search-forward class-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (setq categories (cons (br-feature-current) categories)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (set-buffer obuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (objc-sort-features (nreverse categories))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun objc-list-features (class &optional indent)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
353 "Return sorted list of Objective-C feature tags lexically defined in CLASS.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
354 Optional INDENT is unused but is required for multi-language OO-Browser conformance."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
355 (objc-sort-features
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
356 (nreverse (objc-feature-map-class-tags 'br-feature-current class))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defun objc-list-protocols (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "Return sorted list of Objective-C CLASS protocols."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (let ((obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (protocols)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 class-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (cond ((string-equal class objc-default-protocol-class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (objc-list-features class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ((= (aref class 0) ?\[)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; Any other default classes conform to no formal protocols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq class-tag (concat "\n" class objc-type-tag-separator "\<"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;; Use a string match for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (while (search-forward class-tag nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq protocols (cons (br-feature-current) protocols)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (set-buffer obuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (objc-sort-features (nreverse protocols))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defun objc-routine-at-point-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "Returns name of Objective-C routine signature at point or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 If called interactively, it prints the name in the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (if (and (re-search-backward "[-+\n\^M]\\|\\`" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (looking-at "[ \t\n\^M]*[-+]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (let ((name "") (loop-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (name-part (concat objc-name-part objc-name-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (name-type (concat objc-name-part objc-type-sep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (while (and loop-p (looking-at name-part))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;; Handles named or unamed parameters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (if (match-beginning objc-name-part-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (setq name (concat name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (match-beginning objc-name-part-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (match-end objc-name-part-id)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (if (/= (preceding-char) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (setq loop-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq name (concat name ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (if (looking-at name-type) (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (message name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (defun objc-scan-features ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 "Return reverse ordered list of Objective-C routine definitions in current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 Assume point is at beginning of widened buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (let ((routines) (rout) (class-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 class category)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (concat "^@implementation[ \t\n\r]+" objc-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 "\\([ \t\n\r]*([ \t\n\r]*" objc-identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 "[ \t\n\r]*)\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (setq category (if (match-beginning 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (buffer-substring (match-beginning 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 class (buffer-substring (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 class (if category (format "%s(%s)" class category) class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if (search-forward "\n@end" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (setq class-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (error "(objc-scan-features): %s, at char %d, @implementation without @end.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (while (re-search-forward objc-routine-def class-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (setq rout (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (if (c-within-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (search-forward "*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (backward-char) ;; Move point to precede feature opening brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; Move to end of feature but ignore any error if braces are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; unbalanced. Let the compiler tell the user about this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq rout (objc-feature-normalize rout class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 routines (cons rout routines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 routines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defun objc-scan-protocol-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 "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
444 Point may be immediately before or after the '<' which begins the protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 list. Leaves point afer the closing delimiter of the protocol list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (cond ((= (preceding-char) ?\<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ((= (following-char) ?\<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (error "(objc-scan-protocol-list): Point must precede or follow a '<' delimiter.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (let ((end (save-excursion (search-forward "\>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (protocols))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (while (re-search-forward objc-identifier end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (setq protocols (cons (concat "<"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 protocols)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (nreverse protocols)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defun objc-sort-features (routine-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (sort routine-list 'objc-feature-lessp))
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-to-definition (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 "If point is within a declaration, try to move to its definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 With OTHER-WIN non-nil, show it in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ((objc-include-file other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ((br-check-for-class (objc-class-decl-p) other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ((objc-feature other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ((and (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (br-check-for-class (objc-find-class-name) other-win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (t (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 "(OO-Browser): Select an Objective-C declaration to move to its definition.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (defun objc-view-protocol (protocol-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 "Display definition of PROTOCOL-NAME for viewing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 PROTOCOL-NAME must be a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (or (string-match "<.*>" protocol-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (setq protocol-name (concat "<" protocol-name ">")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (let* ((sig (concat objc-default-protocol-class objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 protocol-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (feature-path (br-feature-file sig)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (br-to-view-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (if (br-feature-found-p feature-path sig)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (progn (br-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; Force mode-line redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (set-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (br-to-from-viewer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;; Protocol not found. Return to original window and signal an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (br-to-from-viewer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (error "(OO-Browser): No '%s' protocol defined in Environment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 protocol-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ;;; ************************************************************************
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-class-decl-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 "Return nil unless point is within a class declaration, referenced by another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 class. Commented declarations also return nil. When value is non-nil, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 the class name from the declaration. Leave point at start of statement for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 visual clarity."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (objc-skip-to-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (let ((class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (and (looking-at objc-class-decl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (setq class (buffer-substring (match-beginning objc-class-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (match-end objc-class-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (not (c-within-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (not (looking-at "[ \t]*//")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 class))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defun objc-feature (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 "Move point to definition of the element given by declaration at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 Return nil if point is not within an element declaration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;; If '{' follows the feature declaration, then feature is defined right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;; here, within the class definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (cond ((objc-feature-def-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (recenter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; Now look for feature definition in code (non-header) files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ((objc-feature-decl-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (let ((class) feature-name signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (setq signature (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (match-end 1)))
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 (if (re-search-backward objc-class-def-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (setq class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (match-beginning objc-class-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (match-end objc-class-name-grpn)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (setq signature (objc-feature-normalize signature class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 feature-name (objc-feature-signature-to-name signature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (if (objc-locate-feature feature-name class signature other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (message "(OO-Browser): No definition for '%s' in '%s'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 feature-name (or class "UNKNOWN-CLASS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (defun objc-feature-decl-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 "Return t if point is within an Objective-C feature declaration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (looking-at objc-feature-declaration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (defun objc-feature-def-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 "Return nil unless point is within an element definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 Commented element definitions also return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (objc-skip-to-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (and (not (c-within-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (save-excursion (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (not (looking-at "[ \t]*//")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (not (looking-at objc-class-decl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (looking-at (concat objc-feature-decl-or-def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 objc-comment-regexp "[{;,]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (= ?\{ (save-excursion (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (preceding-char))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
569 (defun objc-feature-display (class-list signature ftr-regexp &optional other-win)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
570 "Display routine definition derived from CLASS-LIST, matching SIGNATURE (string) and FTR-REGEXP (regexp matching SIGNATURE).
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
571 Use routine tags table to locate a match. Caller must use 'set-buffer'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
572 to restore prior buffer when a match is not found."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
573 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
574 (let ((classes class-list)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
575 (found-ftr)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
576 (class))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
577 (if (null class-list)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
578 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
579 (while (and (not found-ftr) classes)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
580 (setq class (car classes)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
581 found-ftr (br-feature-found-p
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
582 (br-feature-file signature)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
583 ftr-regexp nil other-win t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
584 classes (if found-ftr nil (cdr classes))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
585 (if found-ftr
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
586 (or class t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
587 (objc-feature-display
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
588 (apply 'append (mapcar (function (lambda (cl) (br-get-parents cl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
589 class-list))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
590 signature
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
591 ftr-regexp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
592 other-win)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (defun objc-feature-lessp (tag1 tag2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (string-lessp (objc-feature-partial-name tag1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (objc-feature-partial-name tag2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
598 (defun objc-feature-map-tags (function regexp)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
599 "Apply FUNCTION to all current feature tags that match REGEXP and return a list of the results.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
600 Feature tags come from the file named by br-feature-tags-file."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
601 (let ((identifier-chars (concat "[" objc-identifier-chars "]*"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
602 (results))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
603 (setq regexp (format "^[^%s \n]+%s%s %s%s" objc-type-tag-separator
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
604 objc-type-tag-separator br-feature-type-regexp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
605 regexp objc-type-tag-separator))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
606 ;; Ensure match to feature names only; also handle "^" and "$" meta-chars
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (save-excursion
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
608 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (while (re-search-forward regexp nil t)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
611 (setq results (cons (funcall function) results))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
612 results))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
613
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
614 (defun objc-feature-matches (regexp)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
615 "Return an unsorted list of feature tags whose names match in part or whole to REGEXP.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
616 ^ and $ characters may be used to match to the beginning and end of a feature name,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
617 respectively."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
618 (objc-feature-map-tags 'br-feature-current regexp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (defun objc-feature-normalize (routine class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (let* ((len (length routine))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (normal-feature (make-string len ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (n 0) (i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (space-list '(?\ ?\t ?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (space-regexp "[ \t\n\^M]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 chr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (setq chr (aref routine i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; Convert sequences of space characters to a single space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ((memq chr space-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (aset normal-feature n ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (if (string-match space-regexp routine i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (setq i (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (setq i (1+ i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 n (1+ n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; Remove // style comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 ((and (= chr ?/)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (< (1+ i) len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (= (aref routine (1+ i)) ?/))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (setq i (+ i 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (while (and (< i len) (/= (aref routine i) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (t ;; Normal character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (aset normal-feature n chr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (setq i (1+ i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 n (1+ n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (setq normal-feature (substring normal-feature 0 n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (concat class objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (objc-feature-signature-to-name normal-feature nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 objc-type-tag-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 normal-feature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
656 (defun objc-feature-partial-name (feature-tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
657 "Extract the feature name without its class name from FEATURE-TAG."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
658 (objc-feature-signature-to-name feature-tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
659
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (defun objc-feature-tag-class (feature-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 "Extract the class name from FEATURE-SIGNATURE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (if (string-match objc-type-tag-separator feature-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (substring feature-signature 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (defun objc-files-with-source (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 "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
668 Return as a list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (let ((file (if class (br-class-path class) buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (and file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (let* ((src-file-regexp (concat "^" (br-filename-head file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 objc-code-file-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (dir (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (files (directory-files dir nil src-file-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (mapcar (function (lambda (f) (concat dir f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 files)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (defun objc-find-ancestors-feature (class-list signature &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 "Scan ancestors of CLASS-LIST and show routine definition matching SIGNATURE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ;; If no class, search for non-element function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (or class-list (setq class-list '(nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (let ((obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (ftr-regexp (objc-feature-signature-to-regexp signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (if (and br-feature-tags-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (file-exists-p br-feature-tags-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (file-readable-p br-feature-tags-file))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
688 (objc-feature-display
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 class-list signature ftr-regexp other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ;; Only works if features are in same directory as class def.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (objc-scan-ancestors-feature class-list ftr-regexp other-win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (set-buffer obuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (defun objc-find-class-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 "Return current word as a potential class name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (let* ((start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (ignore "-+ \t\n;,.<>{}*&\(\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (pat (concat "^" ignore)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (skip-chars-backward ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (skip-chars-backward pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (skip-chars-forward (concat pat ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (buffer-substring start (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (defun objc-get-class-name-from-source ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 "Return class name from closest class definition preceding point or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (let ((opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (if (re-search-backward objc-class-def-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (progn (setq class (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (match-beginning objc-class-name-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (match-end objc-class-name-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 ;; Ensure that declaration occurs within class definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (forward-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (and (> (point) opoint) class))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (defun objc-get-feature-tags (routine-file &optional routine-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 "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
722 Assume ROUTINE-FILE has already been read into a buffer and that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 'br-feature-tags-init' has been called. Optional ROUTINE-LIST can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 provided so that a non-standard scan function can be used before calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 this function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (let ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (setq routine-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (objc-sort-features
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (or routine-list (objc-scan-features))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 ;; Delete any prior routine tags associated with routine-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (if (search-forward routine-file nil 'end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (progn (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (search-forward "\^L" nil 'end 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (delete-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (if routine-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (progn (insert "\^L\n" routine-file "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (mapcar (function (lambda (tag) (insert tag "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 routine-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (set-buffer obuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (defun objc-include-file (&optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 "If point is on an include file line, try to display file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 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
750 Look for include file in 'objc-cpp-include-dirs' and in directory list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 'objc-include-dirs'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (if (looking-at objc-include-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (let ((incl-type (string-to-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (match-beginning objc-include-type-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (1+ (match-beginning objc-include-type-grpn)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (file (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (match-beginning objc-include-file-grpn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (match-end objc-include-file-grpn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (dir-list objc-include-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (setq dir-list (if (= incl-type ?\<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (append dir-list objc-cpp-include-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (cons (file-name-directory buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 dir-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (while dir-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (setq path (concat (car dir-list) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 dir-list (if (setq found (file-exists-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (cdr dir-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ;; If not found in normal include dirs, check all Env paths also.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (if (not found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (let ((paths (delq nil (hash-map 'cdr br-paths-htable))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (while paths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (setq path (car paths))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if (string-equal (file-name-nondirectory path) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (setq found t paths nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (setq paths (cdr paths))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 ;; If found, display file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (if (file-readable-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (funcall br-edit-file-function path other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (if (not (fboundp 'br-lang-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (objc-mode-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (br-major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (message "(OO-Browser): Include file '%s' unreadable." path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (message "(OO-Browser): Include file '%s' not found." file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (defun objc-locate-feature (ftr class signature &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;; 'class' may = nil, implying non-element function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (let ((def-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (if (and signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (setq def-class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (objc-find-ancestors-feature (list class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 signature other-win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (progn (if (and class (not (equal class def-class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 "Element `%s` of class '%s' inherited from class '%s'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ftr class def-class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (defun objc-scan-ancestors-feature (class-list ftr-regexp &optional other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 "Display routine definition derived from CLASS-LIST, matching FTR-REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 Scan files with same base name as class file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (let ((classes class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (found-ftr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (code-def-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (if (null class-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (while (and (not found-ftr) classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (setq class (car classes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 code-def-files (objc-files-with-source class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (while (and (setq file (car code-def-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (not (setq found-ftr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (br-feature-found-p file ftr-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 nil other-win t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (setq code-def-files (cdr code-def-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (setq classes (if found-ftr nil (cdr classes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (if found-ftr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (or class t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (objc-scan-ancestors-feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (apply 'append (mapcar (function (lambda (cl) (br-get-parents cl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 class-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 ftr-regexp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (defun objc-skip-past-comments ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 "Skip over comments immediately following point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (cond ((looking-at "//")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (equal (forward-line 1) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ((looking-at "/\\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (re-search-forward "\\*/" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (defun objc-skip-to-statement ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (if (re-search-backward "\\(^\\|[;{}]\\)[ \t]*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (progn (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (defconst objc-code-file-regexp ".\\.[cmCM]$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 "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
864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (defconst objc-include-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 "[ \t/*]*#[ \t]*\\(import\\|include\\)[ \t]+\\([\"<]\\)\\([^\">]+\\)[\">]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 "Regexp to match to Objective-C include file lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 File name is grouping 'objc-include-file-grpn'. Type of include,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 user-specified via double quote, or system-related starting with `<' is given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 by grouping 'objc-include-type-grpn'.")
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-include-type-grpn 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (defconst objc-include-file-grpn 3)
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-type-def-modifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 "\\(auto\\|const\\|inline\\|register\\|static\\|typedef\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (defconst objc-func-identifier (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 "[_a-zA-Z][^][ \t:;.,~{}()]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 "Regular expression matching an Objective-C function name.")
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-feature-decl-or-def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 "[-+]\\([^\]\[{};`'\"/|?,!.#$%^=+-]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 "Regexp matching an Objective-C feature declaration or definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 Feature name is group 1.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (defconst objc-feature-name-grpn 1)
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-comment-regexp "\\([ \t\n]*//.*[\n]\\)*[ \t\n]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (defconst objc-routine-def (concat "^" objc-feature-decl-or-def
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 objc-comment-regexp "{"))
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-feature-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (concat "^[ \t]*\\(" objc-feature-decl-or-def "\\)" objc-comment-regexp ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (defconst objc-class-decl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (concat objc-class-name-before objc-identifier "[ \t]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 "Regexp matching an Objective-C class declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 Class name is grouping 'objc-class-name-grpn'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (defconst objc-class-name-grpn 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (defconst objc-arg-identifier (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 "[_a-zA-Z][" objc-identifier-chars "]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 "Regular expression matching an Objective-C function argument identifier.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (defconst objc-name-part-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 "[ \t\n]*\\(([^\)]+)[ \t\n]*\\)?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (defconst objc-name-part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (concat objc-name-part-prefix objc-identifier "?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (defconst objc-name-sep "[ \t\n]*\\([:;{]\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (defconst objc-type-sep "\\([ \t\n;{]\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (defconst objc-name-part-type 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (defconst objc-name-part-id 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (defconst objc-name-part-sep 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (provide 'br-objc-ft)