* titdic-cnv.el: Prevent "Local Variables" confusion.
[bpt/emacs.git] / lisp / cedet / semantic / analyze.el
index 5cdd157..000193d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic/analyze.el --- Analyze semantic tags against local context
 
-;; Copyright (C) 2000-2005, 2007-201 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2005, 2007-2013 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 
@@ -57,7 +57,7 @@
 ;;
 ;; context - A semantic datatype representing a point in a buffer.
 ;;
-;; constriant - If a context specifies a specific datatype is needed,
+;; constraint - If a context specifies a specific datatype is needed,
 ;;       that is a constraint.
 ;; constants - Some datatypes define elements of themselves as a
 ;;       constant.  These need to be returned as there would be no
@@ -106,7 +106,7 @@ called in a dereference sequence.")
    (prefixclass :initarg :prefixclass
                :type list
                :documentation "Tag classes expected at this context.
-These are clases for tags, such as 'function, or 'variable.")
+These are classes for tags, such as 'function, or 'variable.")
    (prefixtypes :initarg :prefixtypes
           :type list
           :documentation "List of tags defining types for :prefix.
@@ -161,7 +161,7 @@ be just a string in some circumstances.")
 (defclass semantic-analyze-context-return (semantic-analyze-context)
   () ; No extra data.
   "Analysis class for return data.
-Return data methods identify the requred type by the return value
+Return data methods identify the required type by the return value
 of the parent function.")
 
 ;;; METHODS
@@ -254,7 +254,7 @@ Optional argument THROWSYM specifies a symbol the throw on non-recoverable error
        (fname nil)
        (miniscope (when scope (clone scope)))
        )
-    ;; First order check.  Is this wholely contained in the typecache?
+    ;; First order check.  Is this wholly contained in the typecache?
     (setq tmp (semanticdb-typecache-find sequence))
 
     (if tmp
@@ -287,7 +287,7 @@ Optional argument THROWSYM specifies a symbol the throw on non-recoverable error
 
     ;; For the middle entries
     (while s
-      ;; Using the tag found in TMP, lets find the tag
+      ;; Using the tag found in TMP, let's find the tag
       ;; representing the full typeographic information of its
       ;; type, and use that to determine the search context for
       ;; (car s)
@@ -302,7 +302,7 @@ Optional argument THROWSYM specifies a symbol the throw on non-recoverable error
                                     (mapcar 'semantic-tag-type-members
                                             tagtype))))
                         (oset miniscope fullscope rawscope)))
-                    ;; Now analayze the type to remove metatypes.
+                    ;; Now analyze the type to remove metatypes.
                     (or (semantic-analyze-type tmp miniscope)
                         tmp))
                    (t
@@ -476,7 +476,7 @@ If called interactively, display interesting information about POSITION
 in a separate buffer.
 Returns an object based on symbol `semantic-analyze-context'.
 
-This function can be overriden with the symbol `analyze-context'.
+This function can be overridden with the symbol `analyze-context'.
 When overriding this function, your override will be called while
 cursor is at POSITION.  In addition, your function will not be called
 if a cached copy of the return object is found."
@@ -527,7 +527,7 @@ Returns an object based on symbol `semantic-analyze-context'."
         (function nil)
         (fntag nil)
         arg fntagend argtag
-        assign asstag
+        assign asstag newseq
         )
 
     ;; Pattern for Analysis:
@@ -601,16 +601,26 @@ Returns an object based on symbol `semantic-analyze-context'."
 
       (if debug-on-error
          (catch 'unfindable
-           ;; If debug on error is on, allow debugging in this fcn.
            (setq prefix (semantic-analyze-find-tag-sequence
-                         prefix scope 'prefixtypes 'unfindable)))
+                         prefix scope 'prefixtypes 'unfindable))
+           ;; If there's an alias, dereference it and analyze
+           ;; sequence again.
+           (when (setq newseq
+                       (semantic-analyze-dereference-alias prefix))
+             (setq prefix (semantic-analyze-find-tag-sequence
+                           newseq scope 'prefixtypes 'unfindable))))
        ;; Debug on error is off.  Capture errors and move on
        (condition-case err
            ;; NOTE: This line is duplicated in
            ;;       semantic-analyzer-debug-global-symbol
            ;;       You will need to update both places.
-           (setq prefix (semantic-analyze-find-tag-sequence
-                         prefix scope 'prefixtypes))
+           (progn
+             (setq prefix (semantic-analyze-find-tag-sequence
+                           prefix scope 'prefixtypes))
+             (when (setq newseq
+                         (semantic-analyze-dereference-alias prefix))
+               (setq prefix (semantic-analyze-find-tag-sequence
+                             newseq scope 'prefixtypes))))
          (error (semantic-analyze-push-error err))))
       )
 
@@ -679,6 +689,20 @@ Returns an object based on symbol `semantic-analyze-context'."
     ;; Return our context.
     context-return))
 
+(defun semantic-analyze-dereference-alias (taglist)
+  "Dereference first tag in TAGLIST if it is an alias.
+Returns a sequence of names which can then be fed again into
+`semantic-analyze-find-tag-sequence'.
+Returns nil if no alias was found."
+  (when (eq (semantic-tag-get-attribute (car taglist) :kind) 'alias)
+    (let ((tagname
+          (semantic-analyze-split-name
+           (semantic-tag-name 
+            (car (semantic-tag-get-attribute (car taglist) :members))))))
+      (append (if (listp tagname)
+                 tagname
+               (list tagname))
+             (cdr taglist)))))
 \f
 (defun semantic-adebug-analyze (&optional ctxt)
   "Perform `semantic-analyze-current-context'.
@@ -776,7 +800,7 @@ CONTEXT's content is described in `semantic-analyze-current-context'."
   (semantic-analyze-pulse context)
   (with-output-to-temp-buffer "*Semantic Context Analysis*"
     (princ "Context Type: ")
-    (princ (object-name context))
+    (princ (eieio-object-name context))
     (princ "\n")
     (princ "Bounds: ")
     (princ (oref context bounds))