2 new commits in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/141dc5e3316f/
Changeset: 141dc5e3316f
User: acm
Date: 2013-04-15 12:12:26
Summary: Reformulate java imenu-generic-expression. Contributed by Filipp Gunbin.
The old expression contained ill formed regexps.
cc-menus.el (cc-imenu-java-ellipsis-regexp)
(cc-imenu-java-type-spec-regexp, cc-imenu-java-comment-regexp)
(cc-imenu-java-method-arg-regexp): New defconsts.
(cc-imenu-java-build-type-args-regex): New defun.
(cc-imenu-java-generic-expression): Fixed, to remove "ambiguous" handling
of spaces in the regexp.
Affected #: 1 file
diff -r 69c1bab677d6c446cab32df89acb21e6d6aa5727 -r
141dc5e3316f5510b4f8cc03bef0ba782722ed98 cc-menus.el
--- a/cc-menus.el
+++ b/cc-menus.el
@@ -162,47 +162,131 @@
cc-imenu-c++-generic-expression
"Imenu generic expression for C mode. See `imenu-generic-expression'.")
-(defvar cc-imenu-java-generic-expression
+
+;; Auxiliary regexps for Java try to match their trailing whitespace where
+;; appropriate, but _not_ starting whitespace.
+
+(defconst cc-imenu-java-ellipsis-regexp
+ (concat
+ "\\.\\{3\\}"
+ "[ \t\n\r]*"))
+
+(defun cc-imenu-java-build-type-args-regex (depth)
+ "Builds regexp for type arguments list with DEPTH allowed
+nested angle brackets constructs."
+ (if (> depth 0)
+ (concat "<"
+ "[][.," c-alnum "_? \t\n\r]+"
+ (if (> depth 1)
+ "\\(")
+ (cc-imenu-java-build-type-args-regex (1- depth))
+ (if (> depth 1)
+ (concat "[][.," c-alnum "_? \t\n\r]*"
+ "\\)*"))
+ ">")))
+
+(defconst cc-imenu-java-type-spec-regexp
+ (concat
+ ;; zero or more identifiers followed by a dot
+ "\\("
+ "[" c-alpha "_][" c-alnum "_]*\\."
+ "\\)*"
+ ;; a single mandatory identifier without a dot
+ "[" c-alpha "_][" c-alnum "_]*"
+ ;; then choice:
+ "\\("
+ ;; (option 1) type arguments list which _may_ be followed with brackets
+ ;; and/or spaces, then optional variable arity
+ "[ \t\n\r]*"
+ (cc-imenu-java-build-type-args-regex 3)
+ "[][ \t\n\r]*"
+ "\\(" cc-imenu-java-ellipsis-regexp "\\)?"
+ "\\|"
+ ;; (option 2) just brackets and/or spaces (there should be at least one),
+ ;; then optional variable arity
+ "[][ \t\n\r]+"
+ "\\(" cc-imenu-java-ellipsis-regexp "\\)?"
+ "\\|"
+ ;; (option 3) just variable arity
+ cc-imenu-java-ellipsis-regexp
+ "\\)"))
+
+(defconst cc-imenu-java-comment-regexp
+ (concat
+ "/"
+ "\\("
+ ;; a traditional comment
+ "\\*"
+ "\\("
+ "[^*]"
+ "\\|"
+ "\\*+[^/*]"
+ "\\)*"
+ "\\*+/"
+ "\\|"
+ ;; an end-of-line comment
+ "/[^\n\r]*[\n\r]"
+ "\\)"
+ "[ \t\n\r]*"
+ ))
+
+;; Comments are allowed before the argument, after any of the
+;; modifiers and after the identifier.
+(defconst cc-imenu-java-method-arg-regexp
+ (concat
+ "\\(" cc-imenu-java-comment-regexp "\\)*"
+ ;; optional modifiers
+ "\\("
+ ;; a modifier is either an annotation or "final"
+ "\\("
+ "@[" c-alpha "_]"
+ "[" c-alnum "._]*"
+ ;; TODO support element-value pairs!
+ "\\|"
+ "final"
+ "\\)"
+ ;; a modifier ends with comments and/or ws
+ "\\("
+ "\\(" cc-imenu-java-comment-regexp "\\)+"
+ "\\|"
+ "[ \t\n\r]+"
+ "\\(" cc-imenu-java-comment-regexp "\\)*"
+ "\\)"
+ "\\)*"
+ ;; type spec
+ cc-imenu-java-type-spec-regexp
+ ;; identifier
+ "[" c-alpha "_]"
+ "[" c-alnum "_]*"
+ ;; optional comments and/or ws
+ "[ \t\n\r]*"
+ "\\(" cc-imenu-java-comment-regexp "\\)*"
+ ))
+
+(defconst cc-imenu-java-generic-expression
`((nil
,(concat
- "[" c-alpha "_][\]\[." c-alnum "_<> ]+[
\t\n\r]+" ; type spec
- "\\([" c-alpha "_][" c-alnum "_]*\\)" ; method name
+ cc-imenu-java-type-spec-regexp
+ "\\(" ; method name which gets captured
+ ; into index
+ "[" c-alpha "_]"
+ "[" c-alnum "_]*"
+ "\\)"
"[ \t\n\r]*"
- ;; An argument list that is either empty or contains any number
- ;; of arppguments. An argument is any number of annotations
+ ;; An argument list that contains zero or more arguments.
+ (concat
+ "("
+ "[ \t\n\r]*"
+ "\\("
+ "\\(" cc-imenu-java-method-arg-regexp ",[ \t\n\r]*\\)*"
+ cc-imenu-java-method-arg-regexp
+ "\\)?"
+ ")"
+ "[.,_" c-alnum " \t\n\r]*" ; throws etc.
+ "{"
+ )) 7))
+ "Imenu generic expression for Java mode. See
`imenu-generic-expression'.")
- ;; followed by a type spec followed by a word. A word is an
- ;; identifier. A type spec is an identifier, possibly followed
- ;; by < typespec > possibly followed by [].
- (concat "("
- "\\("
- "[ \t\n\r]*"
- "\\("
- "@"
- "[" c-alpha "_]"
- "[" c-alnum "._]*"
- "[ \t\n\r]+"
- "\\)*"
- "\\("
- "[" c-alpha "_]"
- "[][" c-alnum "_.]*"
- "\\("
- "<"
- "[ \t\n\r]*"
- "[\]\[.," c-alnum "_<> \t\n\r]*"
- ">"
- "\\)?"
- "[\]\[ \t\n\r]+"
- "\\)"
- "[" c-alpha "_]"
- "[" c-alnum "_]*"
- "[ \t\n\r,]*"
- "\\)*"
- ")"
- "[.," c-alnum " \t\n\r]*"
- "{"
- )) 1))
- "Imenu generic expression for Java mode. See
`imenu-generic-expression'.")
;; Internal variables
(defvar cc-imenu-objc-generic-expression-noreturn-index nil)
https://bitbucket.org/xemacs/cc-mode/commits/595d627b2433/
Changeset: 595d627b2433
User: acm
Date: 2013-04-15 17:41:30
Summary: Correct the placement of c-cpp-delimiters when there're #s not at col 0.
cc-langs.el (c-anchored-cpp-prefix): Reformulate and place a submatch
around the #.
cc-mode.el (c-neutralize-syntax-in-and-mark-CPP): Start a search at BOL.
Put the c-cpp-delimiter category text propertiy on the #, not BOL.
Affected #: 2 files
diff -r 141dc5e3316f5510b4f8cc03bef0ba782722ed98 -r
595d627b2433db1d3b428d20902f06e51c4b7dda cc-langs.el
--- a/cc-langs.el
+++ b/cc-langs.el
@@ -805,8 +805,8 @@
(c-lang-defconst c-anchored-cpp-prefix
"Regexp matching the prefix of a cpp directive anchored to BOL,
in the languages that have a macro preprocessor."
- t (if (c-lang-const c-opt-cpp-prefix)
- (concat "^" (c-lang-const c-opt-cpp-prefix))))
+ t "^\\s *\\(#\\)\\s *"
+ (java awk) nil)
(c-lang-defvar c-anchored-cpp-prefix (c-lang-const c-anchored-cpp-prefix))
(c-lang-defconst c-opt-cpp-start
diff -r 141dc5e3316f5510b4f8cc03bef0ba782722ed98 -r
595d627b2433db1d3b428d20902f06e51c4b7dda cc-mode.el
--- a/cc-mode.el
+++ b/cc-mode.el
@@ -954,7 +954,8 @@
;; Add needed properties to each CPP construct in the region.
(goto-char c-new-BEG)
- (let ((pps-position c-new-BEG) pps-state mbeg)
+ (skip-chars-backward " \t")
+ (let ((pps-position (point)) pps-state mbeg)
(while (and (< (point) c-new-END)
(search-forward-regexp c-anchored-cpp-prefix c-new-END t))
;; If we've found a "#" inside a string/comment, ignore it.
@@ -963,15 +964,13 @@
pps-position (point))
(unless (or (nth 3 pps-state) ; in a string?
(nth 4 pps-state)) ; in a comment?
- (goto-char (match-beginning 0))
+ (goto-char (match-beginning 1))
(setq mbeg (point))
(if (> (c-syntactic-end-of-macro) mbeg)
(progn
(c-neutralize-CPP-line mbeg (point)) ; "punctuation" properties
(if (memq 'category-properties c-emacs-features) ; GNU Emacs.
- (c-set-cpp-delimiters mbeg (point))) ; "comment" markers
- ;(setq pps-position (point))
- )
+ (c-set-cpp-delimiters mbeg (point)))) ; "comment" markers
(forward-line)) ; no infinite loop with, e.g., "#//"
)))))
Repository URL:
https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches