comparison lisp/cedet/semantic/symref/list.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 93141d34a175
comparison
equal deleted inserted replaced
110522:4bca1a43c0d3 110523:a5ad4f188e19
31 ;; 31 ;;
32 ;; NOTE: Need to add some refactoring tools. 32 ;; NOTE: Need to add some refactoring tools.
33 33
34 (require 'semantic/symref) 34 (require 'semantic/symref)
35 (require 'semantic/complete) 35 (require 'semantic/complete)
36 (require 'semantic/senator)
36 (require 'pulse) 37 (require 'pulse)
37 38
38 ;;; Code: 39 ;;; Code:
39 40
40 ;;;###autoload 41 ;;;###autoload
41 (defun semantic-symref () 42 (defun semantic-symref ()
42 "Find references to the current tag. 43 "Find references to the current tag.
43 This command uses the currently configured references tool within the 44 This command uses the currently configured references tool within the
44 current project to find references to the current tag. The 45 current project to find references to the current tag. The
45 references are the organized by file and the name of the function 46 references are organized by file and the name of the function
46 they are used in. 47 they are used in.
47 Display the references in`semantic-symref-results-mode'." 48 Display the references in `semantic-symref-results-mode'."
48 (interactive) 49 (interactive)
49 (semantic-fetch-tags) 50 (semantic-fetch-tags)
50 (let ((ct (semantic-current-tag)) 51 (let ((ct (semantic-current-tag))
51 (res nil) 52 (res nil)
52 ) 53 )
63 ;;;###autoload 64 ;;;###autoload
64 (defun semantic-symref-symbol (sym) 65 (defun semantic-symref-symbol (sym)
65 "Find references to the symbol SYM. 66 "Find references to the symbol SYM.
66 This command uses the currently configured references tool within the 67 This command uses the currently configured references tool within the
67 current project to find references to the input SYM. The 68 current project to find references to the input SYM. The
69 references are organized by file and the name of the function
70 they are used in.
71 Display the references in `semantic-symref-results-mode'."
72 (interactive (list (semantic-tag-name (semantic-complete-read-tag-buffer-deep
73 "Symrefs for: "))))
74 (semantic-fetch-tags)
75 (let ((res nil)
76 )
77 ;; Gather results and tags
78 (message "Gathering References...")
79 (setq res (semantic-symref-find-references-by-name sym))
80 (semantic-symref-produce-list-on-results res sym)))
81
82 ;;;###autoload
83 (defun semantic-symref-regexp (sym)
84 "Find references to the a symbol regexp SYM.
85 This command uses the currently configured references tool within the
86 current project to find references to the input SYM. The
68 references are the organized by file and the name of the function 87 references are the organized by file and the name of the function
69 they are used in. 88 they are used in.
70 Display the references in`semantic-symref-results-mode'." 89 Display the references in`semantic-symref-results-mode'."
71 (interactive (list (semantic-tag-name (semantic-complete-read-tag-buffer-deep 90 (interactive (list (semantic-tag-name (semantic-complete-read-tag-buffer-deep
72 "Symrefs for: ")))) 91 "Symrefs for: "))))
73 (semantic-fetch-tags) 92 (semantic-fetch-tags)
74 (let ((res nil) 93 (let ((res nil)
75 ) 94 )
76 ;; Gather results and tags 95 ;; Gather results and tags
77 (message "Gathering References...") 96 (message "Gathering References...")
78 (setq res (semantic-symref-find-references-by-name sym)) 97 (setq res (semantic-symref-find-text sym))
79 (semantic-symref-produce-list-on-results res sym))) 98 (semantic-symref-produce-list-on-results res sym)))
80 99
81 100
82 (defun semantic-symref-produce-list-on-results (res str) 101 (defun semantic-symref-produce-list-on-results (res str)
83 "Produce a symref list mode buffer on the results RES." 102 "Produce a symref list mode buffer on the results RES."
108 (define-key km "=" 'semantic-symref-list-toggle-showing) 127 (define-key km "=" 'semantic-symref-list-toggle-showing)
109 (define-key km "+" 'semantic-symref-list-toggle-showing) 128 (define-key km "+" 'semantic-symref-list-toggle-showing)
110 (define-key km "n" 'semantic-symref-list-next-line) 129 (define-key km "n" 'semantic-symref-list-next-line)
111 (define-key km "p" 'semantic-symref-list-prev-line) 130 (define-key km "p" 'semantic-symref-list-prev-line)
112 (define-key km "q" 'semantic-symref-hide-buffer) 131 (define-key km "q" 'semantic-symref-hide-buffer)
132 (define-key km "\C-c\C-e" 'semantic-symref-list-expand-all)
133 (define-key km "\C-c\C-r" 'semantic-symref-list-contract-all)
134 (define-key km "R" 'semantic-symref-list-rename-open-hits)
135 (define-key km "(" 'semantic-symref-list-create-macro-on-open-hit)
136 (define-key km "E" 'semantic-symref-list-call-macro-on-open-hits)
113 km) 137 km)
114 "Keymap used in `semantic-symref-results-mode'.") 138 "Keymap used in `semantic-symref-results-mode'.")
115 139
140 (defvar semantic-symref-list-menu-entries
141 (list
142 "Symref"
143 (semantic-menu-item
144 ["Toggle Line Open"
145 semantic-symref-list-toggle-showing
146 :active t
147 :help "Toggle the current line open or closed."
148 ])
149 (semantic-menu-item
150 ["Expand All Entries"
151 semantic-symref-list-expand-all
152 :active t
153 :help "Expand every expandable entry."
154 ])
155 (semantic-menu-item
156 ["Contract All Entries"
157 semantic-symref-list-contract-all
158 :active t
159 :help "Close every expandable entry."
160 ])
161 (semantic-menu-item
162 ["Rename Symbol in Open hits"
163 semantic-symref-list-rename-open-hits
164 :active t
165 :help "Rename the searched for symbol in all hits that are currently open."
166 ])
167 )
168 "Menu entries for the Semantic Symref list mode.")
169
170 (defvar semantic-symref-list-menu nil
171 "Menu keymap build from `semantic-symref-results-mode'.")
172
173 (easy-menu-define semantic-symref-list-menu
174 semantic-symref-results-mode-map
175 "Symref Mode Menu"
176 semantic-symref-list-menu-entries)
177
178 (defcustom semantic-symref-auto-expand-results nil
179 "Non-nil to expand symref results on buffer creation."
180 :group 'semantic-symref
181 :type 'boolean)
182
116 (defcustom semantic-symref-results-mode-hook nil 183 (defcustom semantic-symref-results-mode-hook nil
117 "*Hook run when `semantic-symref-results-mode' starts." 184 "Hook run when `semantic-symref-results-mode' starts."
118 :group 'semantic-symref 185 :group 'semantic-symref
119 :type 'hook) 186 :type 'hook)
120 187
121 (defvar semantic-symref-current-results nil 188 (defvar semantic-symref-current-results nil
122 "The current results in a results mode buffer.") 189 "The current results in a results mode buffer.")
186 'action 'semantic-symref-rb-goto-tag 253 'action 'semantic-symref-rb-goto-tag
187 'tag T) 254 'tag T)
188 (insert "\n") 255 (insert "\n")
189 256
190 )) 257 ))
258
259 ;; Auto expand
260 (when semantic-symref-auto-expand-results
261 (semantic-symref-list-expand-all))
191 262
192 ;; Clean up the mess 263 ;; Clean up the mess
193 (toggle-read-only 1) 264 (toggle-read-only 1)
194 (set-buffer-modified-p nil) 265 (set-buffer-modified-p nil)
195 ) 266 )
303 (line (button-get button 'line)) 374 (line (button-get button 'line))
304 (buff (semantic-tag-buffer tag)) 375 (buff (semantic-tag-buffer tag))
305 (win (selected-window)) 376 (win (selected-window))
306 ) 377 )
307 (switch-to-buffer-other-window buff) 378 (switch-to-buffer-other-window buff)
308 (with-no-warnings (goto-line line)) 379 (goto-char (point-min))
380 (forward-line (1- line))
309 (pulse-momentary-highlight-one-line (point)) 381 (pulse-momentary-highlight-one-line (point))
310 (when (eq last-command-event ?\s) (select-window win)) 382 (when (eq last-command-event ?\s) (select-window win))
311 ) 383 )
312 ) 384 )
313 385
321 "Next line in `semantic-symref-results-mode'." 393 "Next line in `semantic-symref-results-mode'."
322 (interactive) 394 (interactive)
323 (forward-line -1) 395 (forward-line -1)
324 (back-to-indentation)) 396 (back-to-indentation))
325 397
398 (defun semantic-symref-list-expand-all ()
399 "Expand all the nodes in the current buffer."
400 (interactive)
401 (let ((start (make-marker)))
402 (move-marker start (point))
403 (goto-char (point-min))
404 (while (re-search-forward "\\[[+]\\]" nil t)
405 (semantic-symref-list-toggle-showing))
406 ;; Restore position
407 (goto-char start)))
408
409 (defun semantic-symref-list-contract-all ()
410 "Expand all the nodes in the current buffer."
411 (interactive)
412 (let ((start (make-marker)))
413 (move-marker start (point))
414 (goto-char (point-min))
415 (while (re-search-forward "\\[[-]\\]" nil t)
416 (semantic-symref-list-toggle-showing))
417 ;; Restore position
418 (goto-char start)))
419
420 ;;; UTILS
421 ;;
422 ;; List mode utils for understadning the current line
423
424 (defun semantic-symref-list-on-hit-p ()
425 "Return the line number if the cursor is on a buffer line with a hit.
426 Hits are the line of code from the buffer, not the tag summar or file lines."
427 (save-excursion
428 (end-of-line)
429 (let* ((ol (car (semantic-overlays-at (1- (point)))))) ;; trust this for now
430 (when ol (semantic-overlay-get ol 'line)))))
431
432
433 ;;; Keyboard Macros on a Hit
434 ;;
435 ;; Record a macro on a hit, and store in a special way for execution later.
436 (defun semantic-symref-list-create-macro-on-open-hit ()
437 "Record a keyboard macro at the location of the hit in the current list.
438 Under point should be one hit for the active keyword. Move
439 cursor to the beginning of that symbol, then record a macro as if
440 `kmacro-start-macro' was pressed. Use `kmacro-end-macro',
441 {kmacro-end-macro} to end the macro, and return to the symbol found list."
442 (interactive)
443 (let* ((oldsym (oref (oref semantic-symref-current-results
444 :created-by)
445 :searchfor))
446 (ol (save-excursion
447 (end-of-line)
448 (car (semantic-overlays-at (1- (point))))))
449 (tag (when ol (semantic-overlay-get ol 'tag)))
450 (line (when ol (semantic-overlay-get ol 'line))))
451 (when (not line)
452 (error "Cannot create macro on a non-hit line"))
453 ;; Go there, and do something useful.
454 (switch-to-buffer-other-window (semantic-tag-buffer tag))
455 (goto-char (point-min))
456 (forward-line (1- line))
457 (when (not (re-search-forward (regexp-quote oldsym) (point-at-eol) t))
458 (error "Cannot find hit. Cannot record macro"))
459 (goto-char (match-beginning 0))
460 ;; Cursor is now in the right location. Start recording a macro.
461 (kmacro-start-macro nil)
462 ;; Notify the user
463 (message "Complete with C-x ). Use E in the symref buffer to call this macro.")))
464
465 (defun semantic-symref-list-call-macro-on-open-hits ()
466 "Call the most recently created keyboard macro on each hit.
467 Cursor is placed at the beginning of the symbol found, even if
468 there is more than one symbol on the current line. The
469 previously recorded macro is then executed."
470 (interactive)
471 (save-window-excursion
472 (let ((count (semantic-symref-list-map-open-hits
473 (lambda ()
474 (switch-to-buffer (current-buffer))
475 (kmacro-call-macro nil)))))
476 (semantic-symref-list-update-open-hits)
477 (message "Executed Macro %d times." count))))
478
479 ;;; REFACTORING EDITS
480 ;;
481 ;; Utilities and features for refactoring across a list of hits.
482 ;;
483 (defun semantic-symref-list-rename-open-hits (newname)
484 "Rename the discovered symbol references to NEWNAME.
485 Only renames the locations that are open in the symref list.
486 Closed items will be skipped."
487 (interactive
488 (list (read-string "Rename to: "
489 (oref (oref semantic-symref-current-results
490 :created-by)
491 :searchfor))))
492 (let ((count (semantic-symref-list-map-open-hits
493 (lambda () (replace-match newname nil t)))))
494 (semantic-symref-list-update-open-hits)
495 (message "Renamed %d occurances." count)))
496
497 ;;; REFACTORING UTILITIES
498 ;;
499 ;; Refactoring tools want to operate on only the "good" stuff the
500 ;; user selected.
501 (defun semantic-symref-list-map-open-hits (function)
502 "For every open hit in the symref buffer, perform FUNCTION.
503 The `match-data' will be set to a successful hit of the searched for symbol.
504 Return the number of occurances FUNCTION was operated upon."
505
506 ;; First Pass in this function - a straight rename.
507 ;; Second Pass - Allow context specification based on
508 ;; class members. (Not Done)
509
510 (let ((oldsym (oref (oref semantic-symref-current-results
511 :created-by)
512 :searchfor))
513 (count 0))
514 (save-excursion
515 (goto-char (point-min))
516 (while (not (eobp))
517 ;; Is this line a "hit" line?
518 (let* ((ol (car (semantic-overlays-at (1- (point))))) ;; trust this for now
519 (tag (when ol (semantic-overlay-get ol 'tag)))
520 (line (when ol (semantic-overlay-get ol 'line))))
521 (when line
522 ;; The "line" means we have an open hit.
523 (with-current-buffer (semantic-tag-buffer tag)
524 (goto-char (point-min))
525 (forward-line (1- line))
526 (beginning-of-line)
527 (while (re-search-forward (regexp-quote oldsym) (point-at-eol) t)
528 (setq count (1+ count))
529 (save-excursion ;; Leave cursor after the matched name.
530 (goto-char (match-beginning 0)) ;; Go to beginning of that sym
531 (funcall function))))))
532 ;; Go to the next line
533 (forward-line 1)
534 (end-of-line)))
535 count))
536
537 (defun semantic-symref-list-update-open-hits ()
538 "Update the text for all the open hits in the symref list."
539 (save-excursion
540 (goto-char (point-min))
541 (while (re-search-forward "\\[-\\]" nil t)
542 (end-of-line)
543 (let* ((ol (car (semantic-overlays-at (1- (point))))) ;; trust this for now
544 (tag (when ol (semantic-overlay-get ol 'tag))))
545 ;; If there is a tag, then close/open it.
546 (when tag
547 (semantic-symref-list-toggle-showing)
548 (semantic-symref-list-toggle-showing))))))
549
326 (provide 'semantic/symref/list) 550 (provide 'semantic/symref/list)
327 551
328 ;; Local variables: 552 ;; Local variables:
329 ;; generated-autoload-file: "../loaddefs.el" 553 ;; generated-autoload-file: "../loaddefs.el"
330 ;; generated-autoload-load-name: "semantic/symref/list" 554 ;; generated-autoload-load-name: "semantic/symref/list"