;;; semantic/complete.el --- Routines for performing tag completion
-;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010
-;; Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005, 2007-2011 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Keywords: syntax
default-tag initial-input
history)
"Read a semantic tag, and return a tag for the selection.
-Argument COLLECTOR is an object which can be used to to calculate
+Argument COLLECTOR is an object which can be used to calculate
a list of possible hits. See `semantic-completion-collector-engine'
for details on COLLECTOR.
Argument DISPLAYOR is an object used to display a list of possible
\f
;;; Keybindings
;;
-;; Keys are bound to to perform completion using our mechanisms.
+;; Keys are bound to perform completion using our mechanisms.
;; Do that work here.
(defun semantic-complete-done ()
"Accept the current input."
(defun semantic-complete-inline-tag-engine
(collector displayor buffer start end)
"Perform completion based on semantic tags in a buffer.
-Argument COLLECTOR is an object which can be used to to calculate
+Argument COLLECTOR is an object which can be used to calculate
a list of possible hits. See `semantic-completion-collector-engine'
for details on COLLECTOR.
Argument DISPLAYOR is an object used to display a list of possible
(require 'semantic/db-find)
(semanticdb-brute-deep-find-tags-for-completion prefix (oref obj path)))
+;;; Current Datatype member search.
+(defclass semantic-collector-local-members (semantic-collector-project-abstract)
+ ((scope :initform nil
+ :type (or null semantic-scope-cache)
+ :documentation
+ "The scope the local members are being completed from."))
+ "Completion engine for tags in a project.")
+
+(defmethod semantic-collector-calculate-completions-raw
+ ((obj semantic-collector-local-members) prefix completionlist)
+ "Calculate the completions for prefix from completionlist."
+ (let* ((scope (or (oref obj scope)
+ (oset obj scope (semantic-calculate-scope))))
+ (localstuff (oref scope scope)))
+ (list
+ (cons
+ (oref scope :table)
+ (semantic-find-tags-for-completion prefix localstuff)))))
+ ;(semanticdb-brute-deep-find-tags-for-completion prefix (oref obj path))))
+
+;;; Smart completion collector
(defclass semantic-collector-analyze-completions (semantic-collector-abstract)
((context :initarg :context
:type semantic-analyze-context
;; A typical displayor accepts a pre-determined list of completions
;; generated by a collector. This format is in semanticdb search
;; form. This vaguely standard form is a bit challenging to navigate
-;; because the tags do not contain buffer info, but the file assocated
+;; because the tags do not contain buffer info, but the file associated
;; with the tags preceed the tag in the list.
;;
;; Basic displayors don't care, and can strip the results.
history)
)
+(defun semantic-complete-read-tag-local-members (prompt &optional
+ default-tag
+ initial-input
+ history)
+ "Ask for a tag by name from the local type members.
+Available tags are from the the current scope.
+Completion options are presented in a traditional way, with highlighting
+to resolve same-name collisions.
+PROMPT is a string to prompt with.
+DEFAULT-TAG is a semantic tag or string to use as the default value.
+If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
+HISTORY is a symbol representing a variable to store the history in."
+ (semantic-complete-read-tag-engine
+ (semantic-collector-local-members prompt :buffer (current-buffer))
+ (semantic-displayor-traditional-with-focus-highlight "simple")
+ ;;(semantic-displayor-tooltip "simple")
+ prompt
+ default-tag
+ initial-input
+ history)
+ )
+
(defun semantic-complete-read-tag-project (prompt &optional
default-tag
initial-input
\f
;;;###autoload
(defun semantic-complete-jump-local ()
- "Jump to a semantic symbol."
+ "Jump to a local semantic symbol."
(interactive)
(let ((tag (semantic-complete-read-tag-buffer-deep "Jump to symbol: ")))
(when (semantic-tag-p tag)
(semantic-tag-class tag)
(semantic-tag-name tag)))))
+;;;###autoload
+(defun semantic-complete-jump-local-members ()
+ "Jump to a semantic symbol."
+ (interactive)
+ (let* ((tag (semantic-complete-read-tag-local-members "Jump to symbol: ")))
+ (when (semantic-tag-p tag)
+ (let ((start (condition-case nil (semantic-tag-start tag)
+ (error nil))))
+ (unless start
+ (error "Tag %s has no location" (semantic-format-tag-prototype tag)))
+ (push-mark)
+ (goto-char start)
+ (semantic-momentary-highlight-tag tag)
+ (message "%S: %s "
+ (semantic-tag-class tag)
+ (semantic-tag-name tag))))))
+
;;;###autoload
(defun semantic-complete-analyze-and-replace ()
"Perform prompt completion to do in buffer completion.
;; Prepare for doing completion, but exit quickly if there is keyboard
;; input.
- (when (and (not (semantic-exit-on-input 'csi
- (semantic-fetch-tags)
- (semantic-throw-on-input 'csi)
- nil))
- (= arg 1)
- (not (semantic-exit-on-input 'csi
- (semantic-analyze-current-context)
- (semantic-throw-on-input 'csi)
- nil)))
+ (when (save-window-excursion
+ (save-excursion
+ (and (not (semantic-exit-on-input 'csi
+ (semantic-fetch-tags)
+ (semantic-throw-on-input 'csi)
+ nil))
+ (= arg 1)
+ (not (semantic-exit-on-input 'csi
+ (semantic-analyze-current-context)
+ (semantic-throw-on-input 'csi)
+ nil)))))
(condition-case nil
(semantic-complete-analyze-inline)
;; Ignore errors. Seems likely that we'll get some once in a while.
;; generated-autoload-load-name: "semantic/complete"
;; End:
-;; arch-tag: a07c8f71-e53b-416e-9704-3a99ef101b09
;;; semantic/complete.el ends here