]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/format.el
Update copyright year to 2016
[gnu-emacs] / lisp / cedet / semantic / format.el
index ad6523f4fa8c6e7f9df4e26663daff3ffa7cb976..1fe703fd09a1c3253a7b5b51828a50eae2d5ec40 100644 (file)
@@ -1,7 +1,6 @@
-;;; format.el --- Routines for formatting tags
+;;; semantic/format.el --- Routines for formatting tags
 
-;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
-;;; 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2005, 2007-2016 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: syntax
 
 ;;; Code:
 (eval-when-compile (require 'font-lock))
-(require 'semantic/tag)
+(require 'semantic)
+(require 'semantic/tag-ls)
 (require 'ezimage)
 
+(eval-when-compile (require 'semantic/find))
+
 ;;; Tag to text overload functions
 ;;
 ;; abbreviations, prototypes, and coloring support.
@@ -63,19 +65,14 @@ would claim as a parent.
 COLOR indicates that the generated text should be colored using
 `font-lock'.")
 
-(semantic-varalias-obsolete 'semantic-token->text-functions
-                            'semantic-format-tag-functions)
 (defvar semantic-format-tag-custom-list
   (append '(radio)
          (mapcar (lambda (f) (list 'const f))
                  semantic-format-tag-functions)
          '(function))
-  "A List used by customizeable variables to choose a tag to text function.
+  "A List used by customizable variables to choose a tag to text function.
 Use this variable in the :type field of a customizable variable.")
 
-(semantic-varalias-obsolete 'semantic-token->text-custom-list
-                            'semantic-format-tag-custom-list)
-
 (defcustom semantic-format-use-images-flag ezimage-use-images
   "Non-nil means semantic format functions use images.
 Images can be used as icons instead of some types of text strings."
@@ -90,29 +87,6 @@ Images can be used as icons instead of some types of text strings."
   "Text used to separate names when between namespaces/classes and functions.")
 (make-variable-buffer-local 'semantic-format-parent-separator)
 
-(defun semantic-test-all-format-tag-functions (&optional arg)
-  "Test all outputs from `semantic-format-tag-functions'.
-Output is generated from the function under `point'.
-Optional argument ARG specifies not to use color."
-  (interactive "P")
-  (semantic-fetch-tags)
-  (let* ((tag (semantic-current-tag))
-        (par (semantic-current-tag-parent))
-        (fns semantic-format-tag-functions))
-    (with-output-to-temp-buffer "*format-tag*"
-      (princ "Tag->format function tests:")
-      (while fns
-       (princ "\n")
-       (princ (car fns))
-       (princ ":\n ")
-       (let ((s (funcall (car fns) tag par (not arg))))
-         (save-excursion
-           (set-buffer "*format-tag*")
-           (goto-char (point-max))
-           (insert s)))
-       (setq fns (cdr fns))))
-      ))
-
 (defvar semantic-format-face-alist
   `( (function . font-lock-function-name-face)
      (variable . font-lock-variable-name-face)
@@ -142,17 +116,13 @@ is a symbol representing a face.
 Faces used are generated in `font-lock' for consistency, and will not
 be used unless font lock is a feature.")
 
-(semantic-varalias-obsolete 'semantic-face-alist
-                            'semantic-format-face-alist)
-
-
 \f
 ;;; Coloring Functions
 ;;
 (defun semantic--format-colorize-text (text face-class)
   "Apply onto TEXT a color associated with FACE-CLASS.
-FACE-CLASS is a tag type found in `semantic-face-alist'.  See this variable
-for details on adding new types."
+FACE-CLASS is a tag type found in `semantic-format-face-alist'.
+See that variable for details on adding new types."
   (if (featurep 'font-lock)
       (let ((face (cdr-safe (assoc face-class semantic-format-face-alist)))
            (newtext (concat text)))
@@ -160,13 +130,10 @@ for details on adding new types."
        newtext)
     text))
 
-(make-obsolete 'semantic-colorize-text
-               'semantic--format-colorize-text)
-
 (defun semantic--format-colorize-merge-text (precoloredtext face-class)
   "Apply onto PRECOLOREDTEXT a color associated with FACE-CLASS.
-FACE-CLASS is a tag type found in 'semantic-face-alist'.  See this
-variable for details on adding new types."
+FACE-CLASS is a tag type found in `semantic-formatface-alist'.
+See that variable for details on adding new types."
   (let ((face (cdr-safe (assoc face-class semantic-format-face-alist)))
        (newtext (concat precoloredtext))
        )
@@ -243,6 +210,7 @@ Argument COLOR specifies to colorize the text."
 
 \f
 ;;; Abstract formatting functions
+;;
 
 (defun semantic-format-tag-prin1 (tag &optional parent color)
   "Convert TAG to a string that is the print name for TAG.
@@ -274,6 +242,7 @@ of FACE-CLASS for which this is used."
              (stringp (car anything)))
         (semantic--format-colorize-text (car anything) colorhint))))
 
+;;;###autoload
 (define-overloadable-function semantic-format-tag-name (tag &optional parent color)
   "Return the name string describing TAG.
 The name is the shortest possible representation.
@@ -294,6 +263,8 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
        (setq name (semantic--format-colorize-text name (semantic-tag-class tag))))
     name))
 
+(declare-function semantic-go-to-tag "semantic/tag-file")
+
 (defun semantic--format-tag-parent-tree (tag parent)
   "Under Consideration.
 
@@ -311,6 +282,7 @@ local definitions."
     ;; is nil because there isn't one.
     (setq parent (or (semantic-tag-function-parent tag)
                     (save-excursion
+                      (require 'semantic/tag-file)
                       (semantic-go-to-tag tag)
                       (semantic-current-tag-parent)))))
   (when (stringp parent)
@@ -319,19 +291,19 @@ local definitions."
   ;; Try and find a trail of parents from PARENT
   (let ((rlist (list parent))
        )
-    ;; IMPLELEMENT ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    ;; IMPLEMENT ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     (reverse rlist)))
 
 (define-overloadable-function semantic-format-tag-canonical-name (tag &optional parent color)
   "Return a canonical name for TAG.
-A canonical name includes the names of any parents or namespaces preceeding
+A canonical name includes the names of any parents or namespaces preceding
 the tag.
 Optional argument PARENT is the parent type if TAG is a detail.
 Optional argument COLOR means highlight the prototype with font-lock colors.")
 
 (defun semantic-format-tag-canonical-name-default (tag &optional parent color)
   "Return a canonical name for TAG.
-A canonical name includes the names of any parents or namespaces preceeding
+A canonical name includes the names of any parents or namespaces preceding
 the tag with colons separating them.
 Optional argument PARENT is the parent type if TAG is a detail.
 Optional argument COLOR means highlight the prototype with font-lock colors."
@@ -395,10 +367,7 @@ This is a simple C like default."
     (setq str (concat prefix name suffix))
     str))
 
-;; Semantic 1.2.x had this misspelling.  Keep it for backwards compatibiity.
-(semantic-alias-obsolete
- 'semantic-summerize-nonterminal 'semantic-format-tag-summarize)
-
+;;;###autoload
 (define-overloadable-function semantic-format-tag-summarize (tag &optional parent color)
   "Summarize TAG in a reasonable way.
 Optional argument PARENT is the parent type if TAG is a detail.
@@ -409,14 +378,14 @@ Optional argument COLOR means highlight the prototype with font-lock colors.")
 Optional argument PARENT is the parent type if TAG is a detail.
 Optional argument COLOR means highlight the prototype with font-lock colors."
   (let* ((proto (semantic-format-tag-prototype tag nil color))
-         (names (if parent
-                    semantic-symbol->name-assoc-list-for-type-parts
-                  semantic-symbol->name-assoc-list))
-         (tsymb (semantic-tag-class tag))
-         (label (capitalize (or (cdr-safe (assoc tsymb names))
-                                (symbol-name tsymb)))))
+        (names (if parent
+                   semantic-symbol->name-assoc-list-for-type-parts
+                 semantic-symbol->name-assoc-list))
+        (tsymb (semantic-tag-class tag))
+        (label (capitalize (or (cdr-safe (assoc tsymb names))
+                               (symbol-name tsymb)))))
     (if color
-        (setq label (semantic--format-colorize-text label 'label)))
+       (setq label (semantic--format-colorize-text label 'label)))
     (concat label ": " proto)))
 
 (define-overloadable-function semantic-format-tag-summarize-with-file (tag &optional parent color)
@@ -429,7 +398,7 @@ Optional argument COLOR means highlight the prototype with font-lock colors.")
 Optional argument PARENT is the parent type if TAG is a detail.
 Optional argument COLOR means highlight the prototype with font-lock colors."
   (let* ((proto (semantic-format-tag-prototype tag nil color))
-         (file (semantic-tag-file-name tag))
+        (file (semantic-tag-file-name tag))
         )
     ;; Nothing for tag?  Try parent.
     (when (and (not file) (and parent))
@@ -449,6 +418,8 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
 Optional argument PARENT is the parent type if TAG is a detail.
 Optional argument COLOR means highlight the prototype with font-lock colors.")
 
+(declare-function semantic-documentation-for-tag "semantic/doc")
+
 (defun semantic-format-tag-short-doc-default (tag &optional parent color)
   "Display a short form of TAG's documentation.  (Comments, or docstring.)
 Optional argument PARENT is the parent type if TAG is a detail.
@@ -460,10 +431,12 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
         (doc (semantic-tag-docstring tag buf)))
     (when (and (not doc) (not buf) fname)
       ;; If there is no doc, and no buffer, but we have a filename,
-      ;; lets try again.
-      (setq buf (find-file-noselect fname))
+      ;; let's try again.
+      (save-match-data
+       (setq buf (find-file-noselect fname)))
       (setq doc (semantic-tag-docstring tag buf)))
     (when (not doc)
+      (require 'semantic/doc)
       (setq doc (semantic-documentation-for-tag tag))
       )
     (setq doc
@@ -482,6 +455,7 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
 
 ;;; Prototype generation
 ;;
+;;;###autoload
 (define-overloadable-function semantic-format-tag-prototype (tag &optional parent color)
   "Return a prototype for TAG.
 This function should be overloaded, though it need not be used.
@@ -500,14 +474,14 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
         (type (if (member class '(function variable type))
                   (semantic-format-tag-type tag color)))
         (args (if (member class '(function type))
-                   (semantic--format-tag-arguments
-                    (if (eq class 'function)
-                        (semantic-tag-function-arguments tag)
+                  (semantic--format-tag-arguments
+                   (if (eq class 'function)
+                       (semantic-tag-function-arguments tag)
                      (list "")
-                      ;;(semantic-tag-type-members tag)
+                     ;;(semantic-tag-type-members tag)
                      )
-                    #'semantic-format-tag-prototype
-                    color)))
+                   #'semantic-format-tag-prototype
+                   color)))
         (const (semantic-tag-get-attribute tag :constant-flag))
         (tm (semantic-tag-get-attribute tag :typemodifiers))
         (mods (append
@@ -525,7 +499,12 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
                        (setq r (concat r "[]")
                              deref (1- deref)))
                      r)))
-        )
+        (default (when (eq class 'variable)
+                   (let ((defval
+                           (semantic-tag-get-attribute tag :default-value)))
+                     (when (and defval (stringp defval))
+                       (concat "[=" defval "]")))))
+        )
     (if args
        (setq args
              (concat " "
@@ -538,8 +517,10 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
            (if type (concat type " "))
            name
            (or args "")
-           (or array ""))))
+           (or array "")
+           (or default ""))))
 
+;;;###autoload
 (define-overloadable-function semantic-format-tag-concise-prototype (tag &optional parent color)
   "Return a concise prototype for TAG.
 Optional argument PARENT is the parent type if TAG is a detail.
@@ -564,14 +545,14 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
              ")"))
      ((eq class 'variable)
       (let* ((deref (semantic-tag-get-attribute
-                     tag :dereference))
-             (array "")
-             )
-        (while (and deref (/= deref 0))
-          (setq array (concat array "[]")
-                deref (1- deref)))
-        (concat (semantic-format-tag-name tag parent color)
-                array)))
+                    tag :dereference))
+            (array "")
+            )
+       (while (and deref (/= deref 0))
+         (setq array (concat array "[]")
+               deref (1- deref)))
+       (concat (semantic-format-tag-name tag parent color)
+               array)))
      (t
       (semantic-format-tag-abbreviate tag parent color)))))
 
@@ -628,7 +609,7 @@ This associates a symbol, such as 'public with the st ring \"+\".")
   "Convert PROTECTION-SYMBOL to a string for UML.
 By default, uses `semantic-format-tag-protection-symbol-to-string-assoc-list'
 to convert.
-By defaul character returns are:
+By default character returns are:
   public    -- +
   private   -- -
   protected -- #.
@@ -735,40 +716,13 @@ Optional argument COLOR means highlight the prototype with font-lock colors."
     (setq text (concat prot cp type))
     (if color
        (setq text (semantic--format-uml-post-colorize text tag parent)))
-    text
-    ))
-
-\f
-;;; Compatibility and aliases
-;;
-(semantic-alias-obsolete 'semantic-prin1-nonterminal
-                        'semantic-format-tag-prin1)
-
-(semantic-alias-obsolete 'semantic-name-nonterminal
-                        'semantic-format-tag-name)
-
-(semantic-alias-obsolete 'semantic-abbreviate-nonterminal
-                        'semantic-format-tag-abbreviate)
-
-(semantic-alias-obsolete 'semantic-summarize-nonterminal
-                        'semantic-format-tag-summarize)
-
-(semantic-alias-obsolete 'semantic-prototype-nonterminal
-                        'semantic-format-tag-prototype)
-
-(semantic-alias-obsolete 'semantic-concise-prototype-nonterminal
-                        'semantic-format-tag-concise-prototype)
-
-(semantic-alias-obsolete 'semantic-uml-abbreviate-nonterminal
-                        'semantic-format-tag-uml-abbreviate)
-
-(semantic-alias-obsolete 'semantic-uml-prototype-nonterminal
-                        'semantic-format-tag-uml-prototype)
-
-(semantic-alias-obsolete 'semantic-uml-concise-prototype-nonterminal
-                        'semantic-format-tag-uml-concise-prototype)
-
+    text))
 
 (provide 'semantic/format)
 
-;;; semantic-format.el ends here
+;; Local variables:
+;; generated-autoload-file: "loaddefs.el"
+;; generated-autoload-load-name: "semantic/format"
+;; End:
+
+;;; semantic/format.el ends here