Function: semantic-analyze-current-context-srecode-template-mode
semantic-analyze-current-context-srecode-template-mode is a
byte-compiled function defined in srt-mode.el.gz.
Signature
(semantic-analyze-current-context-srecode-template-mode POINT)
Documentation
Provide a Semantic analysis in SRecode template mode.
Override semantic-analyze-current-context in srecode-template-mode
buffers.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/srecode/srt-mode.el.gz
(define-mode-local-override semantic-analyze-current-context
srecode-template-mode (point)
"Provide a Semantic analysis in SRecode template mode."
(let* ((context-return nil)
(prefixandbounds (semantic-ctxt-current-symbol-and-bounds))
(prefix (car prefixandbounds))
(bounds (nth 2 prefixandbounds))
(key (car (srecode-parse-this-macro (point))))
(prefixsym nil)
(prefix-var nil)
(prefix-context nil)
(prefix-function nil)
(prefixclass (semantic-ctxt-current-class-list))
(globalvar (semantic-find-tags-by-class 'variable (current-buffer)))
(argtype 'macro)
(scope (semantic-calculate-scope point))
)
(oset scope fullscope (append (oref scope localvar) globalvar))
(when prefix
;; First, try to find the variable for the first
;; entry in the prefix list.
(setq prefix-var (semantic-find-first-tag-by-name
(car prefix) (oref scope fullscope)))
(cond
((and (or (not key) (string= key "?"))
(> (length prefix) 1))
;; Variables can have lisp function names.
(with-mode-local emacs-lisp-mode
(let ((fcns (semanticdb-find-tags-by-name (car (last prefix)))))
(setq prefix-function (car (semanticdb-find-result-nth fcns 0)))
(setq argtype 'elispfcn)))
)
((or (string= key "<") (string= key ">"))
;; Includes have second args that is the template name.
(if (= (length prefix) 3)
(let ((contexts (semantic-find-tags-by-class
'context (current-buffer))))
(setq prefix-context
(or (semantic-find-first-tag-by-name
(nth 1 prefix) contexts)
;; Calculate from location
(semantic-tag
(symbol-name
(srecode-template-current-context))
'context)))
(setq argtype 'template))
(setq prefix-context
;; Calculate from location
(semantic-tag
(symbol-name (srecode-template-current-context))
'context))
(setq argtype 'template)
)
;; The last one?
(when (> (length prefix) 1)
(let ((toc (srecode-template-find-templates-of-context
(read (semantic-tag-name prefix-context))))
)
(setq prefix-function
(or (semantic-find-first-tag-by-name
(car (last prefix)) toc)
;; Not in this buffer? Search the master
;; templates list.
nil))
))
)
)
(setq prefixsym
(cond ((= (length prefix) 3)
(list (or prefix-var (nth 0 prefix))
(or prefix-context (nth 1 prefix))
(or prefix-function (nth 2 prefix))))
((= (length prefix) 2)
(list (or prefix-var (nth 0 prefix))
(or prefix-function (nth 1 prefix))))
((= (length prefix) 1)
(list (or prefix-var (nth 0 prefix)))
)))
(setq context-return
(semantic-analyze-context-functionarg
:buffer (current-buffer)
:scope scope
:bounds bounds
:prefix (or prefixsym
prefix)
:prefixtypes nil
:prefixclass prefixclass
:errors nil
;; Use the functionarg analyzer class so we
;; can save the current key, and the index
;; into the macro part we are completing on.
:function (list key)
:index (length prefix)
:argument (list argtype)
))
context-return)))