Skip to content

Commit 7122edc

Browse files
committed
Make php-create-regexp-for-classlike defined in compile time
1 parent 54d7c6f commit 7122edc

File tree

1 file changed

+13
-36
lines changed

1 file changed

+13
-36
lines changed

php.el

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -192,45 +192,22 @@ which will be the name of the method."
192192
(group (+ (or (syntax word) (syntax symbol))))
193193
(* (syntax whitespace))
194194
"(")))
195-
)
196195

197-
(defun php-create-regexp-for-classlike (type)
198-
"Accepts a `TYPE' of a 'classlike' object as a string, such as
196+
(defun php-create-regexp-for-classlike (type)
197+
"Accepts a `TYPE' of a 'classlike' object as a string, such as
199198
'class' or 'interface', and returns a regexp as a string which
200199
can be used to match against definitions for that classlike."
201-
(concat
202-
;; First see if 'abstract' or 'final' appear, although really these
203-
;; are not valid for all values of `type' that the function
204-
;; accepts.
205-
"^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?"
206-
;; The classlike type
207-
type
208-
;; Its name, which is the first captured group in the regexp. We
209-
;; allow backslashes in the name to handle namespaces, but again
210-
;; this is not necessarily correct for all values of `type'.
211-
"\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)"))
212-
213-
(defvar php-imenu-generic-expression
214-
`(("Namespaces"
215-
,(php-create-regexp-for-classlike "namespace") 1)
216-
("Classes"
217-
,(php-create-regexp-for-classlike "class") 1)
218-
("Interfaces"
219-
,(php-create-regexp-for-classlike "interface") 1)
220-
("Traits"
221-
,(php-create-regexp-for-classlike "trait") 1)
222-
("All Methods"
223-
,(php-create-regexp-for-method "\\(?:\\sw\\|\\s_\\)+") 1)
224-
("Private Methods"
225-
,(php-create-regexp-for-method "private") 1)
226-
("Protected Methods"
227-
,(php-create-regexp-for-method "protected") 1)
228-
("Public Methods"
229-
,(php-create-regexp-for-method "public") 1)
230-
("Anonymous Functions"
231-
"\\<\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*=\\s-*function\\s-*(" 1)
232-
("Named Functions"
233-
"^\\s-*function\\s-+\\(\\(?:\\sw\\|\\s_\\)+\\)\\s-*(" 1))
200+
(concat
201+
;; First see if 'abstract' or 'final' appear, although really these
202+
;; are not valid for all values of `type' that the function
203+
;; accepts.
204+
"^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?"
205+
;; The classlike type
206+
type
207+
;; Its name, which is the first captured group in the regexp. We
208+
;; allow backslashes in the name to handle namespaces, but again
209+
;; this is not necessarily correct for all values of `type'.
210+
"\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)")))
234211
"Imenu generic expression for PHP Mode. See `imenu-generic-expression'.")
235212

236213
(defvar php--re-namespace-pattern

0 commit comments

Comments
 (0)