;;; semantic/analyze.el --- Analyze semantic tags against local context
-;; Copyright (C) 2000-2005, 2007-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2005, 2007-2013 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;;
;; 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
(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.
(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
(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
;; 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)
(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
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."
(function nil)
(fntag nil)
arg fntagend argtag
- assign asstag
+ assign asstag newseq
)
;; Pattern for Analysis:
(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))))
)
;; 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'.
(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))