Mercurial > emacs
comparison lisp/cedet/semantic/format.el @ 104489:25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
* cedet/semantic/wisent/java-tags.el:
* cedet/semantic/wisent/javat-wy.el: New files.
* cedet/semantic/wisent/java.el:
* cedet/semantic/wisent/java-wy.el: Files removed.
* cedet/semantic/java.el (semantic-java-prototype-function)
(semantic-java-prototype-variable, semantic-java-prototype-type):
Doc fix
(java-mode::semantic-format-tag-prototype): Renamed from
semantic-format-prototype-tag, which didn't match the overloadable
function.
* cedet/semantic/bovine/c.el (semantic-c-dereference-namespace-alias):
Deal correctly with nested namespaces. Make sure type actually
exists in original namespace.
* cedet/semantic/lex-spp.el (semantic-lex-spp-hack-depth): New.
(semantic-lex-spp-lex-text-string): Use above to enable recursion.
* cedet/semantic/format.el: Whitespace cleanup.
(semantic-test-all-format-tag-functions): Move to end.
(semantic-format-tag-prototype, semantic-format-tag-name)
(semantic-format-tag-name-default): Revert to original upstream
positions.
* cedet/semantic/elp.el: File removed.
* cedet/semantic/analyze.el (semantic-adebug-analyze): New
function, moved here from semantic/adebug.
* cedet/semantic/adebug.el: Declare external semanticdb functions.
(semantic-adebug-analyze, semantic-adebug-edebug-expr): Deleted.
* emacs-lisp/eieio.el (eieio-unbound): Default value is now robust
to recompile.
* emacs-lisp/eieio-datadebug.el: Add eieio objects to the list of
data debug things to recognize.
* emacs-lisp/eieio-comp.el: Synch to upstream.
* cedet/data-debug.el: Don't require eieio and semantic/tag.
If eieio is loaded, require eieio-datadebug.
(data-debug-insert-ring-button): Do not be specific about the ring
contents.
(data-debug-thing-alist): Remove eieio and semantic specific
entries.
(data-debug-add-specialized-thing): New function.
* cedet/cedet.el: Update commentary.
* cedet/cedet-edebug.el: Require edebug and debug.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 13 Sep 2009 15:58:30 +0000 |
parents | 6ccad1511df1 |
children | 8db96f200ac8 |
comparison
equal
deleted
inserted
replaced
104488:7042156f9f43 | 104489:25e047f7f6a2 |
---|---|
31 ;; In addition, macros for setting up customizable variables that let | 31 ;; In addition, macros for setting up customizable variables that let |
32 ;; the user choose their default format type are also provided. | 32 ;; the user choose their default format type are also provided. |
33 ;; | 33 ;; |
34 | 34 |
35 ;;; Code: | 35 ;;; Code: |
36 (eval-when-compile (require 'font-lock)) | |
36 (require 'semantic) | 37 (require 'semantic) |
37 (require 'semantic/tag-ls) | 38 (require 'semantic/tag-ls) |
38 (require 'ezimage) | 39 (require 'ezimage) |
39 | 40 |
40 (eval-when-compile | 41 (eval-when-compile (require 'semantic/find)) |
41 (require 'font-lock) | |
42 (require 'semantic/find)) | |
43 | 42 |
44 ;;; Tag to text overload functions | 43 ;;; Tag to text overload functions |
45 ;; | 44 ;; |
46 ;; abbreviations, prototypes, and coloring support. | 45 ;; abbreviations, prototypes, and coloring support. |
47 (defvar semantic-format-tag-functions | 46 (defvar semantic-format-tag-functions |
66 would claim as a parent. | 65 would claim as a parent. |
67 COLOR indicates that the generated text should be colored using | 66 COLOR indicates that the generated text should be colored using |
68 `font-lock'.") | 67 `font-lock'.") |
69 | 68 |
70 (semantic-varalias-obsolete 'semantic-token->text-functions | 69 (semantic-varalias-obsolete 'semantic-token->text-functions |
71 'semantic-format-tag-functions) | 70 'semantic-format-tag-functions) |
72 | 71 |
73 (defvar semantic-format-tag-custom-list | 72 (defvar semantic-format-tag-custom-list |
74 (append '(radio) | 73 (append '(radio) |
75 (mapcar (lambda (f) (list 'const f)) | 74 (mapcar (lambda (f) (list 'const f)) |
76 semantic-format-tag-functions) | 75 semantic-format-tag-functions) |
77 '(function)) | 76 '(function)) |
78 "A List used by customizeable variables to choose a tag to text function. | 77 "A List used by customizeable variables to choose a tag to text function. |
79 Use this variable in the :type field of a customizable variable.") | 78 Use this variable in the :type field of a customizable variable.") |
80 | 79 |
81 (semantic-varalias-obsolete 'semantic-token->text-custom-list | 80 (semantic-varalias-obsolete 'semantic-token->text-custom-list |
82 'semantic-format-tag-custom-list) | 81 'semantic-format-tag-custom-list) |
83 | 82 |
84 (defcustom semantic-format-use-images-flag ezimage-use-images | 83 (defcustom semantic-format-use-images-flag ezimage-use-images |
85 "Non-nil means semantic format functions use images. | 84 "Non-nil means semantic format functions use images. |
86 Images can be used as icons instead of some types of text strings." | 85 Images can be used as icons instead of some types of text strings." |
87 :group 'semantic | 86 :group 'semantic |
92 (make-variable-buffer-local 'semantic-function-argument-separator) | 91 (make-variable-buffer-local 'semantic-function-argument-separator) |
93 | 92 |
94 (defvar semantic-format-parent-separator "::" | 93 (defvar semantic-format-parent-separator "::" |
95 "Text used to separate names when between namespaces/classes and functions.") | 94 "Text used to separate names when between namespaces/classes and functions.") |
96 (make-variable-buffer-local 'semantic-format-parent-separator) | 95 (make-variable-buffer-local 'semantic-format-parent-separator) |
97 | |
98 ;;;###autoload | |
99 (define-overloadable-function semantic-format-tag-name (tag &optional parent color) | |
100 "Return the name string describing TAG. | |
101 The name is the shortest possible representation. | |
102 Optional argument PARENT is the parent type if TAG is a detail. | |
103 Optional argument COLOR means highlight the prototype with font-lock colors.") | |
104 | |
105 (defun semantic-format-tag-name-default (tag &optional parent color) | |
106 "Return an abbreviated string describing TAG. | |
107 Optional argument PARENT is the parent type if TAG is a detail. | |
108 Optional argument COLOR means highlight the prototype with font-lock colors." | |
109 (let ((name (semantic-tag-name tag)) | |
110 (destructor | |
111 (if (eq (semantic-tag-class tag) 'function) | |
112 (semantic-tag-function-destructor-p tag)))) | |
113 (when destructor | |
114 (setq name (concat "~" name))) | |
115 (if color | |
116 (setq name (semantic--format-colorize-text name (semantic-tag-class tag)))) | |
117 name)) | |
118 | |
119 ;;;###autoload | |
120 (define-overloadable-function semantic-format-tag-prototype (tag &optional parent color) | |
121 "Return a prototype for TAG. | |
122 This function should be overloaded, though it need not be used. | |
123 This is because it can be used to create code by language independent | |
124 tools. | |
125 Optional argument PARENT is the parent type if TAG is a detail. | |
126 Optional argument COLOR means highlight the prototype with font-lock colors.") | |
127 | |
128 | |
129 (defun semantic-test-all-format-tag-functions (&optional arg) | |
130 "Test all outputs from `semantic-format-tag-functions'. | |
131 Output is generated from the function under `point'. | |
132 Optional argument ARG specifies not to use color." | |
133 (interactive "P") | |
134 (require 'semantic/find) | |
135 (semantic-fetch-tags) | |
136 (let* ((tag (semantic-current-tag)) | |
137 (par (semantic-current-tag-parent)) | |
138 (fns semantic-format-tag-functions)) | |
139 (with-output-to-temp-buffer "*format-tag*" | |
140 (princ "Tag->format function tests:") | |
141 (while fns | |
142 (princ "\n") | |
143 (princ (car fns)) | |
144 (princ ":\n ") | |
145 (let ((s (funcall (car fns) tag par (not arg)))) | |
146 (save-excursion | |
147 (set-buffer "*format-tag*") | |
148 (goto-char (point-max)) | |
149 (insert s))) | |
150 (setq fns (cdr fns)))) | |
151 )) | |
152 | 96 |
153 (defvar semantic-format-face-alist | 97 (defvar semantic-format-face-alist |
154 `( (function . font-lock-function-name-face) | 98 `( (function . font-lock-function-name-face) |
155 (variable . font-lock-variable-name-face) | 99 (variable . font-lock-variable-name-face) |
156 (type . font-lock-type-face) | 100 (type . font-lock-type-face) |
178 is a symbol representing a face. | 122 is a symbol representing a face. |
179 Faces used are generated in `font-lock' for consistency, and will not | 123 Faces used are generated in `font-lock' for consistency, and will not |
180 be used unless font lock is a feature.") | 124 be used unless font lock is a feature.") |
181 | 125 |
182 (semantic-varalias-obsolete 'semantic-face-alist | 126 (semantic-varalias-obsolete 'semantic-face-alist |
183 'semantic-format-face-alist) | 127 'semantic-format-face-alist) |
184 | 128 |
185 | 129 |
186 | 130 |
187 ;;; Coloring Functions | 131 ;;; Coloring Functions |
188 ;; | 132 ;; |
196 (put-text-property 0 (length text) 'face face newtext) | 140 (put-text-property 0 (length text) 'face face newtext) |
197 newtext) | 141 newtext) |
198 text)) | 142 text)) |
199 | 143 |
200 (make-obsolete 'semantic-colorize-text | 144 (make-obsolete 'semantic-colorize-text |
201 'semantic--format-colorize-text) | 145 'semantic--format-colorize-text) |
202 | 146 |
203 (defun semantic--format-colorize-merge-text (precoloredtext face-class) | 147 (defun semantic--format-colorize-merge-text (precoloredtext face-class) |
204 "Apply onto PRECOLOREDTEXT a color associated with FACE-CLASS. | 148 "Apply onto PRECOLOREDTEXT a color associated with FACE-CLASS. |
205 FACE-CLASS is a tag type found in 'semantic-face-alist'. See this | 149 FACE-CLASS is a tag type found in 'semantic-face-alist'. See this |
206 variable for details on adding new types." | 150 variable for details on adding new types." |
278 out) | 222 out) |
279 )) | 223 )) |
280 | 224 |
281 | 225 |
282 ;;; Abstract formatting functions | 226 ;;; Abstract formatting functions |
227 ;; | |
283 | 228 |
284 (defun semantic-format-tag-prin1 (tag &optional parent color) | 229 (defun semantic-format-tag-prin1 (tag &optional parent color) |
285 "Convert TAG to a string that is the print name for TAG. | 230 "Convert TAG to a string that is the print name for TAG. |
286 PARENT and COLOR are ignored." | 231 PARENT and COLOR are ignored." |
287 (format "%S" tag)) | 232 (format "%S" tag)) |
308 (setq ans (semantic-format-tag-type anything color))) | 253 (setq ans (semantic-format-tag-type anything color))) |
309 ans)) | 254 ans)) |
310 ((and (listp anything) | 255 ((and (listp anything) |
311 (stringp (car anything))) | 256 (stringp (car anything))) |
312 (semantic--format-colorize-text (car anything) colorhint)))) | 257 (semantic--format-colorize-text (car anything) colorhint)))) |
258 | |
259 ;;;###autoload | |
260 (define-overloadable-function semantic-format-tag-name (tag &optional parent color) | |
261 "Return the name string describing TAG. | |
262 The name is the shortest possible representation. | |
263 Optional argument PARENT is the parent type if TAG is a detail. | |
264 Optional argument COLOR means highlight the prototype with font-lock colors.") | |
265 | |
266 (defun semantic-format-tag-name-default (tag &optional parent color) | |
267 "Return an abbreviated string describing TAG. | |
268 Optional argument PARENT is the parent type if TAG is a detail. | |
269 Optional argument COLOR means highlight the prototype with font-lock colors." | |
270 (let ((name (semantic-tag-name tag)) | |
271 (destructor | |
272 (if (eq (semantic-tag-class tag) 'function) | |
273 (semantic-tag-function-destructor-p tag)))) | |
274 (when destructor | |
275 (setq name (concat "~" name))) | |
276 (if color | |
277 (setq name (semantic--format-colorize-text name (semantic-tag-class tag)))) | |
278 name)) | |
313 | 279 |
314 (declare-function semantic-go-to-tag "semantic/tag-file") | 280 (declare-function semantic-go-to-tag "semantic/tag-file") |
315 | 281 |
316 (defun semantic--format-tag-parent-tree (tag parent) | 282 (defun semantic--format-tag-parent-tree (tag parent) |
317 "Under Consideration. | 283 "Under Consideration. |
428 (defun semantic-format-tag-summarize-default (tag &optional parent color) | 394 (defun semantic-format-tag-summarize-default (tag &optional parent color) |
429 "Summarize TAG in a reasonable way. | 395 "Summarize TAG in a reasonable way. |
430 Optional argument PARENT is the parent type if TAG is a detail. | 396 Optional argument PARENT is the parent type if TAG is a detail. |
431 Optional argument COLOR means highlight the prototype with font-lock colors." | 397 Optional argument COLOR means highlight the prototype with font-lock colors." |
432 (let* ((proto (semantic-format-tag-prototype tag nil color)) | 398 (let* ((proto (semantic-format-tag-prototype tag nil color)) |
433 (names (if parent | 399 (names (if parent |
434 semantic-symbol->name-assoc-list-for-type-parts | 400 semantic-symbol->name-assoc-list-for-type-parts |
435 semantic-symbol->name-assoc-list)) | 401 semantic-symbol->name-assoc-list)) |
436 (tsymb (semantic-tag-class tag)) | 402 (tsymb (semantic-tag-class tag)) |
437 (label (capitalize (or (cdr-safe (assoc tsymb names)) | 403 (label (capitalize (or (cdr-safe (assoc tsymb names)) |
438 (symbol-name tsymb))))) | 404 (symbol-name tsymb))))) |
439 (if color | 405 (if color |
440 (setq label (semantic--format-colorize-text label 'label))) | 406 (setq label (semantic--format-colorize-text label 'label))) |
441 (concat label ": " proto))) | 407 (concat label ": " proto))) |
442 | 408 |
443 (define-overloadable-function semantic-format-tag-summarize-with-file (tag &optional parent color) | 409 (define-overloadable-function semantic-format-tag-summarize-with-file (tag &optional parent color) |
444 "Like `semantic-format-tag-summarize', but with the file name. | 410 "Like `semantic-format-tag-summarize', but with the file name. |
445 Optional argument PARENT is the parent type if TAG is a detail. | 411 Optional argument PARENT is the parent type if TAG is a detail. |
448 (defun semantic-format-tag-summarize-with-file-default (tag &optional parent color) | 414 (defun semantic-format-tag-summarize-with-file-default (tag &optional parent color) |
449 "Summarize TAG in a reasonable way. | 415 "Summarize TAG in a reasonable way. |
450 Optional argument PARENT is the parent type if TAG is a detail. | 416 Optional argument PARENT is the parent type if TAG is a detail. |
451 Optional argument COLOR means highlight the prototype with font-lock colors." | 417 Optional argument COLOR means highlight the prototype with font-lock colors." |
452 (let* ((proto (semantic-format-tag-prototype tag nil color)) | 418 (let* ((proto (semantic-format-tag-prototype tag nil color)) |
453 (file (semantic-tag-file-name tag)) | 419 (file (semantic-tag-file-name tag)) |
454 ) | 420 ) |
455 ;; Nothing for tag? Try parent. | 421 ;; Nothing for tag? Try parent. |
456 (when (and (not file) (and parent)) | 422 (when (and (not file) (and parent)) |
457 (setq file (semantic-tag-file-name parent))) | 423 (setq file (semantic-tag-file-name parent))) |
458 ;; Don't include the file name if we can't find one, or it is the | 424 ;; Don't include the file name if we can't find one, or it is the |
503 (setq doc (semantic--format-colorize-text doc 'documentation))) | 469 (setq doc (semantic--format-colorize-text doc 'documentation))) |
504 doc | 470 doc |
505 )) | 471 )) |
506 | 472 |
507 ;;; Prototype generation | 473 ;;; Prototype generation |
474 ;; | |
475 ;;;###autoload | |
476 (define-overloadable-function semantic-format-tag-prototype (tag &optional parent color) | |
477 "Return a prototype for TAG. | |
478 This function should be overloaded, though it need not be used. | |
479 This is because it can be used to create code by language independent | |
480 tools. | |
481 Optional argument PARENT is the parent type if TAG is a detail. | |
482 Optional argument COLOR means highlight the prototype with font-lock colors.") | |
508 | 483 |
509 (defun semantic-format-tag-prototype-default (tag &optional parent color) | 484 (defun semantic-format-tag-prototype-default (tag &optional parent color) |
510 "Default method for returning a prototype for TAG. | 485 "Default method for returning a prototype for TAG. |
511 This will work for C like languages. | 486 This will work for C like languages. |
512 Optional argument PARENT is the parent type if TAG is a detail. | 487 Optional argument PARENT is the parent type if TAG is a detail. |
514 (let* ((class (semantic-tag-class tag)) | 489 (let* ((class (semantic-tag-class tag)) |
515 (name (semantic-format-tag-name tag parent color)) | 490 (name (semantic-format-tag-name tag parent color)) |
516 (type (if (member class '(function variable type)) | 491 (type (if (member class '(function variable type)) |
517 (semantic-format-tag-type tag color))) | 492 (semantic-format-tag-type tag color))) |
518 (args (if (member class '(function type)) | 493 (args (if (member class '(function type)) |
519 (semantic--format-tag-arguments | 494 (semantic--format-tag-arguments |
520 (if (eq class 'function) | 495 (if (eq class 'function) |
521 (semantic-tag-function-arguments tag) | 496 (semantic-tag-function-arguments tag) |
522 (list "") | 497 (list "") |
523 ;;(semantic-tag-type-members tag) | 498 ;;(semantic-tag-type-members tag) |
524 ) | 499 ) |
525 #'semantic-format-tag-prototype | 500 #'semantic-format-tag-prototype |
526 color))) | 501 color))) |
527 (const (semantic-tag-get-attribute tag :constant-flag)) | 502 (const (semantic-tag-get-attribute tag :constant-flag)) |
528 (tm (semantic-tag-get-attribute tag :typemodifiers)) | 503 (tm (semantic-tag-get-attribute tag :typemodifiers)) |
529 (mods (append | 504 (mods (append |
530 (if const '("const") nil) | 505 (if const '("const") nil) |
531 (cond ((stringp tm) (list tm)) | 506 (cond ((stringp tm) (list tm)) |
579 'semantic-format-tag-concise-prototype | 554 'semantic-format-tag-concise-prototype |
580 color) | 555 color) |
581 ")")) | 556 ")")) |
582 ((eq class 'variable) | 557 ((eq class 'variable) |
583 (let* ((deref (semantic-tag-get-attribute | 558 (let* ((deref (semantic-tag-get-attribute |
584 tag :dereference)) | 559 tag :dereference)) |
585 (array "") | 560 (array "") |
586 ) | 561 ) |
587 (while (and deref (/= deref 0)) | 562 (while (and deref (/= deref 0)) |
588 (setq array (concat array "[]") | 563 (setq array (concat array "[]") |
589 deref (1- deref))) | 564 deref (1- deref))) |
590 (concat (semantic-format-tag-name tag parent color) | 565 (concat (semantic-format-tag-name tag parent color) |
591 array))) | 566 array))) |
592 (t | 567 (t |
593 (semantic-format-tag-abbreviate tag parent color))))) | 568 (semantic-format-tag-abbreviate tag parent color))))) |
594 | 569 |
595 ;;; UML display styles | 570 ;;; UML display styles |
596 ;; | 571 ;; |
754 (setq text (semantic--format-uml-post-colorize text tag parent))) | 729 (setq text (semantic--format-uml-post-colorize text tag parent))) |
755 text | 730 text |
756 )) | 731 )) |
757 | 732 |
758 | 733 |
734 ;;; Test routines | |
735 ;; | |
736 (defun semantic-test-all-format-tag-functions (&optional arg) | |
737 "Test all outputs from `semantic-format-tag-functions'. | |
738 Output is generated from the function under `point'. | |
739 Optional argument ARG specifies not to use color." | |
740 (interactive "P") | |
741 (semantic-fetch-tags) | |
742 (let* ((tag (semantic-current-tag)) | |
743 (par (semantic-current-tag-parent)) | |
744 (fns semantic-format-tag-functions)) | |
745 (with-output-to-temp-buffer "*format-tag*" | |
746 (princ "Tag->format function tests:") | |
747 (while fns | |
748 (princ "\n") | |
749 (princ (car fns)) | |
750 (princ ":\n ") | |
751 (let ((s (funcall (car fns) tag par (not arg)))) | |
752 (save-excursion | |
753 (set-buffer "*format-tag*") | |
754 (goto-char (point-max)) | |
755 (insert s))) | |
756 (setq fns (cdr fns)))) | |
757 )) | |
758 | |
759 | |
759 ;;; Compatibility and aliases | 760 ;;; Compatibility and aliases |
760 ;; | 761 ;; |
761 (semantic-alias-obsolete 'semantic-prin1-nonterminal | 762 (semantic-alias-obsolete 'semantic-prin1-nonterminal |
762 'semantic-format-tag-prin1) | 763 'semantic-format-tag-prin1) |
763 | 764 |