]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic.el
Merge from origin/emacs-24
[gnu-emacs] / lisp / cedet / semantic.el
index 909902a71fe10fb82fe100fea021fe0dd8a914ce..50e2082600b89390c24a189b97354c22cdc443bf 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic.el --- Semantic buffer evaluator.
 
-;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2014 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: syntax tools
@@ -311,14 +311,6 @@ a parse of the buffer.")
 (semantic-varalias-obsolete 'semantic-init-db-hooks
                            'semantic-init-db-hook "23.2")
 
-(defvar semantic-new-buffer-fcn-was-run nil
-  "Non-nil after `semantic-new-buffer-fcn' has been executed.")
-(make-variable-buffer-local 'semantic-new-buffer-fcn-was-run)
-
-(defsubst semantic-active-p ()
-  "Return non-nil if the current buffer was set up for parsing."
-  semantic-new-buffer-fcn-was-run)
-
 (defsubst semantic-error-if-unparsed ()
   "Raise an error if current buffer was not parsed by Semantic."
   (unless semantic-new-buffer-fcn-was-run
@@ -390,7 +382,7 @@ Arguments START and END bound the time being calculated."
 (defun bovinate (&optional clear)
   "Parse the current buffer.  Show output in a temp buffer.
 Optional argument CLEAR will clear the cache before parsing.
-If CLEAR is negative, it will do a full reparse, and also not display
+If CLEAR is negative, it will do a full reparse, and also display
 the output buffer."
   (interactive "P")
   (if clear (semantic-clear-toplevel-cache))
@@ -400,7 +392,8 @@ the output buffer."
         (end (current-time)))
     (message "Retrieving tags took %.2f seconds."
             (semantic-elapsed-time start end))
-    (when (or (null clear) (not (listp clear)))
+    (when (or (null clear) (not (listp clear))
+             (and (numberp clear) (< 0 clear)))
       (pop-to-buffer "*Parser Output*")
       (require 'pp)
       (erase-buffer)
@@ -1134,8 +1127,16 @@ Semantic mode.
        ;; Add semantic-ia-complete-symbol to
        ;; completion-at-point-functions, so that it is run from
        ;; M-TAB.
+       ;;
+       ;; Note: The first entry added is the last entry run, so the
+       ;;       most specific entry should be last.
+       (add-hook 'completion-at-point-functions
+                 'semantic-analyze-nolongprefix-completion-at-point-function)
+       (add-hook 'completion-at-point-functions
+                 'semantic-analyze-notc-completion-at-point-function)
        (add-hook 'completion-at-point-functions
-                 'semantic-completion-at-point-function)
+                 'semantic-analyze-completion-at-point-function)
+
        (if global-ede-mode
            (define-key cedet-menu-map [cedet-menu-separator] '("--")))
        (dolist (b (buffer-list))
@@ -1147,7 +1148,12 @@ Semantic mode.
     ;; Semantic can be re-activated cleanly.
     (remove-hook 'mode-local-init-hook 'semantic-new-buffer-fcn)
     (remove-hook 'completion-at-point-functions
-                'semantic-completion-at-point-function)
+                'semantic-analyze-completion-at-point-function)
+    (remove-hook 'completion-at-point-functions
+                'semantic-analyze-notc-completion-at-point-function)
+    (remove-hook 'completion-at-point-functions
+                'semantic-analyze-nolongprefix-completion-at-point-function)
+
     (remove-hook 'after-change-functions
                 'semantic-change-function)
     (define-key cedet-menu-map [cedet-menu-separator] nil)
@@ -1163,8 +1169,56 @@ Semantic mode.
     ;; re-activated.
     (setq semantic-new-buffer-fcn-was-run nil)))
 
-(defun semantic-completion-at-point-function ()
-  'semantic-ia-complete-symbol)
+;;; Completion At Point functions
+(defun semantic-analyze-completion-at-point-function ()
+  "Return possible analysis completions at point.
+The completions provided are via `semantic-analyze-possible-completions'.
+This function can be used by `completion-at-point-functions'."
+  (when (semantic-active-p)
+    (let* ((ctxt (semantic-analyze-current-context))
+           (possible (semantic-analyze-possible-completions ctxt)))
+
+      ;; The return from this is either:
+      ;; nil - not applicable here.
+      ;; A list: (START END COLLECTION . PROPS)
+      (when possible
+        (list (car (oref ctxt bounds))
+              (cdr (oref ctxt bounds))
+              possible))
+      )))
+
+(defun semantic-analyze-notc-completion-at-point-function ()
+  "Return possible analysis completions at point.
+The completions provided are via `semantic-analyze-possible-completions',
+but with the 'no-tc option passed in, which means constraints based
+on what is being assigned to are ignored.
+This function can be used by `completion-at-point-functions'."
+  (when (semantic-active-p)
+    (let* ((ctxt (semantic-analyze-current-context))
+           (possible (semantic-analyze-possible-completions ctxt 'no-tc)))
+
+      (when possible
+        (list (car (oref ctxt bounds))
+              (cdr (oref ctxt bounds))
+              possible))
+      )))
+
+(defun semantic-analyze-nolongprefix-completion-at-point-function ()
+  "Return possible analysis completions at point.
+The completions provided are via `semantic-analyze-possible-completions',
+but with the 'no-tc and 'no-longprefix option passed in, which means
+constraints resulting in a long multi-symbol dereference are ignored.
+This function can be used by `completion-at-point-functions'."
+  (when (semantic-active-p)
+    (let* ((ctxt (semantic-analyze-current-context))
+           (possible (semantic-analyze-possible-completions
+                      ctxt 'no-tc 'no-longprefix)))
+
+      (when possible
+        (list (car (oref ctxt bounds))
+              (cdr (oref ctxt bounds))
+              possible))
+      )))
 
 ;;; Autoload some functions that are not in semantic/loaddefs