Mercurial > emacs
view lisp/progmodes/cc-menus.el @ 110523:a5ad4f188e19
Synch Semantic to CEDET 1.0.
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog.
* semantic.el (semantic-version): Update to 2.0.
(semantic-mode-map): Add "," and "m" bindings.
(navigate-menu): Update.
* semantic/symref.el (semantic-symref-calculate-rootdir):
New function.
(semantic-symref-detect-symref-tool): Use it.
* semantic/symref/grep.el (semantic-symref-grep-shell): New var.
(semantic-symref-perform-search): Use it. Calculate root dir with
semantic-symref-calculate-rootdir.
(semantic-symref-derive-find-filepatterns): Improve error message.
* semantic/symref/list.el
(semantic-symref-results-mode-map): New bindings.
(semantic-symref-auto-expand-results): New option.
(semantic-symref-results-dump): Obey auto-expand.
(semantic-symref-list-expand-all, semantic-symref-regexp)
(semantic-symref-list-contract-all)
(semantic-symref-list-map-open-hits)
(semantic-symref-list-update-open-hits)
(semantic-symref-list-create-macro-on-open-hit)
(semantic-symref-list-call-macro-on-open-hits): New functions.
(semantic-symref-list-menu-entries)
(semantic-symref-list-menu): New vars.
(semantic-symref-list-map-open-hits): Move cursor to beginning of
match before calling the mapped function.
* semantic/doc.el
(semantic-documentation-comment-preceeding-tag): Do nothing if the
mode doesn't provide comment-start-skip.
* semantic/scope.el
(semantic-analyze-scope-nested-tags-default): Strip duplicates.
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
(semantic-decoration-on-includes-highlight-default): Check that
the include tag has a postion.
* semantic/complete.el (semantic-collector-local-members):
(semantic-complete-read-tag-local-members)
(semantic-complete-jump-local-members): New class and functions.
(semantic-complete-self-insert): Save excursion before completing.
* semantic/analyze/complete.el
(semantic-analyze-possible-completions-default): If no completions
are found, return the raw by-name-only completion list. Add FLAGS
arguments. Add support for 'no-tc (type constraint) and
'no-unique, or no stripping duplicates.
(semantic-analyze-possible-completions-default): Add FLAGS arg.
* semantic/util-modes.el
(semantic-stickyfunc-show-only-functions-p): New option.
(semantic-stickyfunc-fetch-stickyline): Don't show stickytext for
the very first line in a buffer.
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
* semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the
:filename property and the tag position.
* semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Add recursion limit.
* semantic/imenu.el (semantic-imenu-bucketize-type-members):
Make this buffer local, not the obsoleted variable.
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
(semantic-idle-symbol-maybe-highlight): Rename from *-summary-*.
Callers changed.
(semantic-idle-work-parse-neighboring-files-flag): Default to nil.
(semantic-idle-work-update-headers-flag): New var.
(semantic-idle-work-for-one-buffer): Use it.
(semantic-idle-local-symbol-highlight): Rename from
semantic-idle-tag-highlight.
(semantic-idle-truncate-long-summaries): New option.
* semantic/ia.el (semantic-ia-cache)
(semantic-ia-get-completions): Deleted. Callers changed.
(semantic-ia-show-variants): New command.
(semantic-ia-show-doc): If doc is empty, don't make a temp buffer.
(semantic-ia-show-summary): If there isn't anything to show, say so.
* semantic/grammar.el (semantic-grammar-create-package):
Save the buffer even in batch mode.
* semantic/fw.el
(semanticdb-without-unloaded-file-searches): New macro.
* semantic/dep.el (semantic-dependency-find-file-on-path):
Fix case dereferencing ede-object when it is a list.
* semantic/db-typecache.el (semanticdb-expand-nested-tag)
(semanticdb-typecache-faux-namespace): New functions.
(semanticdb-typecache-file-tags)
(semanticdb-typecache-merge-streams): Use them.
(semanticdb-typecache-file-tags): When deriving tags from a file,
give the mode a chance to monkey with the tag copy.
(semanticdb-typecache-find-default): Wrap find in save-excursion.
(semanticdb-typecache-find-by-name-helper): Merge found names down.
* semantic/db-global.el
(semanticdb-enable-gnu-global-in-buffer): Don't show messages if
GNU Global is not available and we don't want to throw an error.
* semantic/db-find.el (semanticdb-find-result-nth-in-buffer):
When trying to normalize the tag to a buffer, don't error if
set-buffer method doesn't exist.
* semantic/db-file.el (semanticdb-save-db): Simplify msg.
* semantic/db.el (semanticdb-refresh-table): If forcing a
refresh on a file not in a buffer, use semantic-find-file-noselect
and delete the buffer after use.
(semanticdb-current-database-list): When calculating root via
hooks, force it through true-filename and skip the list of
possible roots.
* semantic/ctxt.el (semantic-ctxt-imported-packages): New.
* semantic/analyze/debug.el
(semantic-analyzer-debug-insert-tag): Reset standard output to
current buffer.
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype): Change "prefix" to
"symbol" in messages.
* semantic/analyze/refs.el: (semantic-analyze-refs-impl)
(semantic-analyze-refs-proto): When calculating value, make sure
the found tag is 'similar' to the originating tag.
(semantic--analyze-refs-find-tags-with-parent): Attempt to
identify matches via imported symbols of parents.
(semantic--analyze-refs-full-lookup-with-parents): Do a deep
search during the brute search.
* semantic/analyze.el
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
(semantic-expand-c-tag-namelist): Split a full type from a typedef
out to its own tag.
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
* semantic/wisent/python-wy.el: Regenerate.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 18 Sep 2010 22:49:54 -0400 |
parents | 1d1d5d9bd884 |
children | 280c8ae2476d 376148b31b5e |
line wrap: on
line source
;;; cc-menus.el --- imenu support for CC Mode ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 ;; Free Software Foundation, Inc. ;; Authors: 1998- Martin Stjernholm ;; 1992-1999 Barry A. Warsaw ;; 1987 Dave Detlefs ;; 1987 Stewart Clamen ;; 1985 Richard M. Stallman ;; Maintainer: bug-cc-mode@gnu.org ;; Created: 22-Apr-1997 (split from cc-mode.el) ;; Version: See cc-mode.el ;; Keywords: c languages oop ;; This file is part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;;; Commentary: ;;; Code: (eval-when-compile (let ((load-path (if (and (boundp 'byte-compile-dest-file) (stringp byte-compile-dest-file)) (cons (file-name-directory byte-compile-dest-file) load-path) load-path))) (load "cc-bytecomp" nil t))) (cc-require 'cc-defs) ;; The things referenced in imenu, which we don't require. (cc-bytecomp-defvar imenu-case-fold-search) (cc-bytecomp-defvar imenu-generic-expression) (cc-bytecomp-defvar imenu-create-index-function) ;; imenu integration (defvar cc-imenu-c-prototype-macro-regexp nil "RE matching macro names used to conditionally specify function prototypes. For example: #ifdef __STDC__ #define _P(x) x #else #define _P(x) /*nothing*/ #endif int main _P( (int argc, char *argv[]) ) A sample value might look like: `\\(_P\\|_PROTO\\)'.") (defvar cc-imenu-c++-generic-expression `( ;; Try to match ::operator definitions first. Otherwise `X::operator new ()' ;; will be incorrectly recognised as function `new ()' because the regexps ;; work by backtracking from the end of the definition. (nil ,(concat "^\\<.*" "[^" c-alnum "_:<>~]" ; match any non-identifier char ; (note: this can be `\n') "\\(" "\\([" c-alnum "_:<>~]*::\\)?" ; match an operator "operator\\>[ \t]*" "\\(()\\|[^(]*\\)" ; special case for `()' operator "\\)" "[ \t]*([^)]*)[ \t]*[^ \t;]" ; followed by ws, arg list, ; require something other than ; a `;' after the (...) to ; avoid prototypes. Can't ; catch cases with () inside ; the parentheses surrounding ; the parameters. e.g.: ; `int foo(int a=bar()) {...}' ) 1) ;; Special case to match a line like `main() {}' ;; e.g. no return type, not even on the previous line. (nil ,(concat "^" "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name "[ \t]*(" ; see above, BUT "[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start "[ \t]*[^ \t;(]" ; with an asterisk or parentheses ) 1) ;; General function name regexp (nil ,(concat "^\\<" ; line MUST start with word char ;; \n added to prevent overflow in regexp matcher. ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-02/msg00021.html "[^()\n]*" ; no parentheses before "[^" c-alnum "_:<>~]" ; match any non-identifier char "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name "\\([ \t\n]\\|\\\\\n\\)*(" ; see above, BUT the arg list "\\([ \t\n]\\|\\\\\n\\)*\\([^ \t\n(*][^)]*\\)?)" ; must not start "\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]" ; with an asterisk or parentheses ) 1) ;; Special case for definitions using phony prototype macros like: ;; `int main _PROTO( (int argc,char *argv[]) )'. ;; This case is only included if cc-imenu-c-prototype-macro-regexp is set. ;; Only supported in c-code, so no `:<>~' chars in function name! ,@(if cc-imenu-c-prototype-macro-regexp `((nil ,(concat "^\\<.*" ; line MUST start with word char "[^" c-alnum "_]" ; match any non-identifier char "\\([" c-alpha "_][" c-alnum "_]*\\)" ; match function name "[ \t]*" ; whitespace before macro name cc-imenu-c-prototype-macro-regexp "[ \t]*(" ; ws followed by first paren. "[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above ) 1))) ;; Class definitions ("Class" ,(concat "^" ; beginning of line is required "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>' "\\(class\\|struct\\)[ \t]+" "\\(" ; the string we want to get "[" c-alnum "_]+" ; class name "\\(<[^>]+>\\)?" ; possibly explicitly specialized "\\)" "\\([ \t\n]\\|\\\\\n\\)*[:{]" ) 3)) "Imenu generic expression for C++ mode. See `imenu-generic-expression'.") (defvar cc-imenu-c-generic-expression cc-imenu-c++-generic-expression "Imenu generic expression for C mode. See `imenu-generic-expression'.") (defvar cc-imenu-java-generic-expression `((nil ,(concat "[" c-alpha "_][\]\[." c-alnum "_<> ]+[ \t\n\r]+" ; type spec "\\([" c-alpha "_][" c-alnum "_]*\\)" ; method name "[ \t\n\r]*" ;; An argument list htat is either empty or contains any number ;; of arguments. An argument is any number of annotations ;; 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'.") ;; *Warning for cc-mode developers* ;; ;; `cc-imenu-objc-generic-expression' elements depend on ;; `cc-imenu-c++-generic-expression'. So if you change this ;; expression, you need to change following variables, ;; `cc-imenu-objc-generic-expression-*-index', ;; too. `cc-imenu-objc-function' uses these *-index variables, in ;; order to know where the each regexp *group \\(foobar\\)* elements ;; are started. ;; ;; *-index variables are initialized during `cc-imenu-objc-generic-expression' ;; being initialized. ;; ;; Internal variables (defvar cc-imenu-objc-generic-expression-noreturn-index nil) (defvar cc-imenu-objc-generic-expression-general-func-index nil) (defvar cc-imenu-objc-generic-expression-proto-index nil) (defvar cc-imenu-objc-generic-expression-objc-base-index nil) (defvar cc-imenu-objc-generic-expression (concat ;; ;; For C ;; ;; > Special case to match a line like `main() {}' ;; > e.g. no return type, not even on the previous line. ;; Pick a token by (match-string 1) (car (cdr (nth 1 cc-imenu-c++-generic-expression))) ; -> index += 2 (prog2 (setq cc-imenu-objc-generic-expression-noreturn-index 1) "") "\\|" ;; > General function name regexp ;; Pick a token by (match-string 3) (car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 5 (prog2 (setq cc-imenu-objc-generic-expression-general-func-index 3) "") ;; > Special case for definitions using phony prototype macros like: ;; > `int main _PROTO( (int argc,char *argv[]) )'. ;; Pick a token by (match-string 8) (if cc-imenu-c-prototype-macro-regexp (concat "\\|" (car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1 (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "") ) (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 8) "") "") ; -> index += 0 (prog2 (setq cc-imenu-objc-generic-expression-proto-index 8) "") ;; ;; For Objective-C ;; Pick a token by (match-string 8 or 9) ;; "\\|\\(" "^[-+][:" c-alnum "()*_<>\n\t ]*[;{]" ; Methods "\\|" "^@interface[\t ]+[" c-alnum "_]+[\t ]*:" "\\|" "^@interface[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)" "\\|" ;; For NSObject, NSProxy and Object... They don't have super class. "^@interface[\t ]+[" c-alnum "_]+[\t ]*.*$" "\\|" "^@implementation[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)" "\\|" "^@implementation[\t ]+[" c-alnum "_]+" "\\|" "^@protocol[\t ]+[" c-alnum "_]+" "\\)") "Imenu generic expression for ObjC mode. See `imenu-generic-expression'.") ;; Imenu support for objective-c uses functions. (defsubst cc-imenu-objc-method-to-selector (method) "Return the objc selector style string of METHOD. Example: - perform: (SEL)aSelector withObject: object1 withObject: object2; /* METHOD */ => -perform:withObject:withObject:withObject: /* selector */" (let ((return "") ; String to be returned (p 0) ; Current scanning position in METHOD (pmax (length method)) ; char ; Current scanning target (betweenparen 0) ; CHAR is in parentheses. argreq ; An argument is required. inargvar) ; position of CHAR is in an argument variable. (while (< p pmax) (setq char (aref method p) p (1+ p)) (cond ;; Is CHAR part of a objc token? ((and (not inargvar) ; Ignore if CHAR is part of an argument variable. (eq 0 betweenparen) ; Ignore if CHAR is in parentheses. (or (and (<= ?a char) (<= char ?z)) (and (<= ?A char) (<= char ?Z)) (and (<= ?0 char) (<= char ?9)) (= ?_ char))) (if argreq (setq inargvar t argreq nil) (setq return (concat return (char-to-string char))))) ;; Or a white space? ((and inargvar (or (eq ?\ char) (eq ?\n char)) (setq inargvar nil))) ;; Or a method separator? ;; If a method separator, the next token will be an argument variable. ((eq ?: char) (setq argreq t return (concat return (char-to-string char)))) ;; Or an open parentheses? ((eq ?\( char) (setq betweenparen (1+ betweenparen))) ;; Or a close parentheses? ((eq ?\) char) (setq betweenparen (1- betweenparen))))) return)) (defun cc-imenu-objc-remove-white-space (str) "Remove all spaces and tabs from STR." (let ((return "") (p 0) (max (length str)) char) (while (< p max) (setq char (aref str p)) (setq p (1+ p)) (if (or (= char ?\ ) (= char ?\t)) () (setq return (concat return (char-to-string char))))) return)) (defun cc-imenu-objc-function () "Imenu support for Objective C mode." (let (methodlist clist ;; ;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants. ;; ;; *Warning for developers* ;; These constants depend on `cc-imenu-c++-generic-expression'. ;; (OBJC cc-imenu-objc-generic-expression-objc-base-index) ;; Special case to match a line like `main() {}' (Cnoreturn cc-imenu-objc-generic-expression-noreturn-index) ;; General function name regexp (Cgeneralfunc cc-imenu-objc-generic-expression-general-func-index) ;; Special case for definitions using phony prototype macros like: (Cproto cc-imenu-objc-generic-expression-proto-index) langnum ;; (classcount 0) toplist str str2 (intflen (length "@interface")) (implen (length "@implementation")) (prtlen (length "@protocol")) (func ;; ;; Does this emacs have buffer-substring-no-properties? ;; (if (fboundp 'buffer-substring-no-properties) 'buffer-substring-no-properties 'buffer-substring))) (goto-char (point-max)) ;; (while (re-search-backward cc-imenu-objc-generic-expression nil t) (setq langnum (if (match-beginning OBJC) OBJC (cond ((match-beginning Cproto) Cproto) ((match-beginning Cgeneralfunc) Cgeneralfunc) ((match-beginning Cnoreturn) Cnoreturn)))) (setq str (funcall func (match-beginning langnum) (match-end langnum))) ;; (cond ;; ;; C ;; ((not (eq langnum OBJC)) (setq clist (cons (cons str (match-beginning langnum)) clist))) ;; ;; ObjC ;; ;; An instance Method ((eq (aref str 0) ?-) (setq str (concat "-" (cc-imenu-objc-method-to-selector str))) (setq methodlist (cons (cons str (match-beginning langnum)) methodlist))) ;; A factory Method ((eq (aref str 0) ?+) (setq str (concat "+" (cc-imenu-objc-method-to-selector str))) (setq methodlist (cons (cons str (match-beginning langnum)) methodlist))) ;; Interface or implementation or protocol ((eq (aref str 0) ?@) (setq classcount (1+ classcount)) (cond ((and (> (length str) implen) (string= (substring str 0 implen) "@implementation")) (setq str (substring str implen) str2 "@implementation")) ((string= (substring str 0 intflen) "@interface") (setq str (substring str intflen) str2 "@interface")) ((string= (substring str 0 prtlen) "@protocol") (setq str (substring str prtlen) str2 "@protocol"))) (setq str (cc-imenu-objc-remove-white-space str)) (setq methodlist (cons (cons str2 (match-beginning langnum)) methodlist)) (setq toplist (cons nil (cons (cons str methodlist) toplist)) methodlist nil)))) ;; (if (eq (car toplist) nil) (setq toplist (cdr toplist))) ;; In this buffer, there is only one or zero @{interface|implementation|protocol}. (if (< classcount 2) (let ((classname (car (car toplist))) (p (cdr (car (cdr (car toplist))))) last) (setq toplist (cons (cons classname p) (cdr (cdr (car toplist))))) ;; Add C lang token (if clist (progn (setq last toplist) (while (cdr last) (setq last (cdr last))) (setcdr last clist)))) ;; Add C lang tokens as a sub menu (if clist (setq toplist (cons (cons "C" clist) toplist)))) ;; toplist )) ;(defvar cc-imenu-pike-generic-expression ; ()) ; FIXME: Please contribute one! (defun cc-imenu-init (mode-generic-expression &optional mode-create-index-function) (setq imenu-generic-expression mode-generic-expression imenu-case-fold-search nil) (when mode-create-index-function (setq imenu-create-index-function mode-create-index-function))) (cc-provide 'cc-menus) ;; arch-tag: f6b60933-91f0-4145-ab44-70ca6d1b919b ;;; cc-menus.el ends here