mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-19 04:10:18 -08:00
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog. * semantic.el (semantic-version): Update to 2.0. (semantic-mode-map): Add "," and "m" bindings. (navigate-menu): Update. * semantic/symref.el (semantic-symref-calculate-rootdir): New function. (semantic-symref-detect-symref-tool): Use it. * semantic/symref/grep.el (semantic-symref-grep-shell): New var. (semantic-symref-perform-search): Use it. Calculate root dir with semantic-symref-calculate-rootdir. (semantic-symref-derive-find-filepatterns): Improve error message. * semantic/symref/list.el (semantic-symref-results-mode-map): New bindings. (semantic-symref-auto-expand-results): New option. (semantic-symref-results-dump): Obey auto-expand. (semantic-symref-list-expand-all, semantic-symref-regexp) (semantic-symref-list-contract-all) (semantic-symref-list-map-open-hits) (semantic-symref-list-update-open-hits) (semantic-symref-list-create-macro-on-open-hit) (semantic-symref-list-call-macro-on-open-hits): New functions. (semantic-symref-list-menu-entries) (semantic-symref-list-menu): New vars. (semantic-symref-list-map-open-hits): Move cursor to beginning of match before calling the mapped function. * semantic/doc.el (semantic-documentation-comment-preceeding-tag): Do nothing if the mode doesn't provide comment-start-skip. * semantic/scope.el (semantic-analyze-scope-nested-tags-default): Strip duplicates. (semantic-analyze-scoped-inherited-tag-map): Take the tag we are looking for as part of the scoped tags list. * semantic/html.el (semantic-default-html-setup): Add senator-step-at-tag-classes. * semantic/decorate/include.el (semantic-decoration-on-unknown-includes): Change light bgcolor. (semantic-decoration-on-includes-highlight-default): Check that the include tag has a postion. * semantic/complete.el (semantic-collector-local-members): (semantic-complete-read-tag-local-members) (semantic-complete-jump-local-members): New class and functions. (semantic-complete-self-insert): Save excursion before completing. * semantic/analyze/complete.el (semantic-analyze-possible-completions-default): If no completions are found, return the raw by-name-only completion list. Add FLAGS arguments. Add support for 'no-tc (type constraint) and 'no-unique, or no stripping duplicates. (semantic-analyze-possible-completions-default): Add FLAGS arg. * semantic/util-modes.el (semantic-stickyfunc-show-only-functions-p): New option. (semantic-stickyfunc-fetch-stickyline): Don't show stickytext for the very first line in a buffer. * semantic/util.el (semantic-hack-search) (semantic-recursive-find-nonterminal-by-name) (semantic-current-tag-interactive): Deleted. (semantic-describe-buffer): Fix expand-nonterminal. Add lex-syntax-mods, type relation separator char, and command separation char. (semantic-sanity-check): Only message if called interactively. * semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the :filename property and the tag position. * semantic/lex-spp.el (semantic-lex-spp-lex-text-string): Add recursion limit. * semantic/imenu.el (semantic-imenu-bucketize-type-members): Make this buffer local, not the obsoleted variable. * semantic/idle.el: Add breadcrumbs support. (semantic-idle-summary-current-symbol-info-default) (semantic-idle-tag-highlight) (semantic-idle-completion-list-default): Use semanticdb-without-unloaded-file-searches for speed, and to conform to the controls that specify if the idle timer is supposed to be parsing unparsed includes. (semantic-idle-symbol-highlight-face) (semantic-idle-symbol-maybe-highlight): Rename from *-summary-*. Callers changed. (semantic-idle-work-parse-neighboring-files-flag): Default to nil. (semantic-idle-work-update-headers-flag): New var. (semantic-idle-work-for-one-buffer): Use it. (semantic-idle-local-symbol-highlight): Rename from semantic-idle-tag-highlight. (semantic-idle-truncate-long-summaries): New option. * semantic/ia.el (semantic-ia-cache) (semantic-ia-get-completions): Deleted. Callers changed. (semantic-ia-show-variants): New command. (semantic-ia-show-doc): If doc is empty, don't make a temp buffer. (semantic-ia-show-summary): If there isn't anything to show, say so. * semantic/grammar.el (semantic-grammar-create-package): Save the buffer even in batch mode. * semantic/fw.el (semanticdb-without-unloaded-file-searches): New macro. * semantic/dep.el (semantic-dependency-find-file-on-path): Fix case dereferencing ede-object when it is a list. * semantic/db-typecache.el (semanticdb-expand-nested-tag) (semanticdb-typecache-faux-namespace): New functions. (semanticdb-typecache-file-tags) (semanticdb-typecache-merge-streams): Use them. (semanticdb-typecache-file-tags): When deriving tags from a file, give the mode a chance to monkey with the tag copy. (semanticdb-typecache-find-default): Wrap find in save-excursion. (semanticdb-typecache-find-by-name-helper): Merge found names down. * semantic/db-global.el (semanticdb-enable-gnu-global-in-buffer): Don't show messages if GNU Global is not available and we don't want to throw an error. * semantic/db-find.el (semanticdb-find-result-nth-in-buffer): When trying to normalize the tag to a buffer, don't error if set-buffer method doesn't exist. * semantic/db-file.el (semanticdb-save-db): Simplify msg. * semantic/db.el (semanticdb-refresh-table): If forcing a refresh on a file not in a buffer, use semantic-find-file-noselect and delete the buffer after use. (semanticdb-current-database-list): When calculating root via hooks, force it through true-filename and skip the list of possible roots. * semantic/ctxt.el (semantic-ctxt-imported-packages): New. * semantic/analyze/debug.el (semantic-analyzer-debug-insert-tag): Reset standard output to current buffer. (semantic-analyzer-debug-global-symbol) (semantic-analyzer-debug-missing-innertype): Change "prefix" to "symbol" in messages. * semantic/analyze/refs.el: (semantic-analyze-refs-impl) (semantic-analyze-refs-proto): When calculating value, make sure the found tag is 'similar' to the originating tag. (semantic--analyze-refs-find-tags-with-parent): Attempt to identify matches via imported symbols of parents. (semantic--analyze-refs-full-lookup-with-parents): Do a deep search during the brute search. * semantic/analyze.el (semantic-analyze-find-tag-sequence-default): Be robust to calculated scopes being nil. * semantic/bovine/c.el (semantic-c-describe-environment): Add project macro symbol array. (semantic-c-parse-lexical-token): Add recursion limit. (semantic-ctxt-imported-packages, semanticdb-expand-nested-tag): New overrides. (semantic-expand-c-tag-namelist): Split a full type from a typedef out to its own tag. (semantic-expand-c-tag-namelist): Do not split out a typedef'd inline type if it is an anonymous type. (semantic-c-reconstitute-token): Use the optional initializers as a clue that some function is probably a constructor. When defining the type of these constructors, split the parent name, and use only the class part, if applicable. * semantic/bovine/c-by.el: * semantic/wisent/python-wy.el: Regenerate.
280 lines
9 KiB
EmacsLisp
280 lines
9 KiB
EmacsLisp
;;; semantic/analyze/complete.el --- Smart Completions
|
|
|
|
;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
|
|
|
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
;;; Commentary:
|
|
;;
|
|
;; Calculate smart completions.
|
|
;;
|
|
;; Uses the analyzer context routine to determine the best possible
|
|
;; list of completions.
|
|
;;
|
|
;;; History:
|
|
;;
|
|
;; Code was moved here from semantic-analyze.el
|
|
|
|
(require 'semantic/analyze)
|
|
|
|
;; For semantic-find-* macros:
|
|
(eval-when-compile (require 'semantic/find))
|
|
|
|
;;; Code:
|
|
|
|
;;; Helper Fcns
|
|
;;
|
|
;;
|
|
;;;###autoload
|
|
(define-overloadable-function semantic-analyze-type-constants (type)
|
|
"For the tag TYPE, return any constant symbols of TYPE.
|
|
Used as options when completing.")
|
|
|
|
(defun semantic-analyze-type-constants-default (type)
|
|
"Do nothing with TYPE."
|
|
nil)
|
|
|
|
(defun semantic-analyze-tags-of-class-list (tags classlist)
|
|
"Return the tags in TAGS that are of classes in CLASSLIST."
|
|
(let ((origc tags))
|
|
;; Accept only tags that are of the datatype specified by
|
|
;; the desired classes.
|
|
(setq tags (apply 'nconc ;; All input lists are permutable.
|
|
(mapcar (lambda (class)
|
|
(semantic-find-tags-by-class class origc))
|
|
classlist)))
|
|
tags))
|
|
|
|
;;; MAIN completion calculator
|
|
;;
|
|
;;;###autoload
|
|
(define-overloadable-function semantic-analyze-possible-completions (context &rest flags)
|
|
"Return a list of semantic tags which are possible completions.
|
|
CONTEXT is either a position (such as point), or a precalculated
|
|
context. Passing in a context is useful if the caller also needs
|
|
to access parts of the analysis.
|
|
The remaining FLAGS arguments are passed to the mode specific completion engine.
|
|
Bad flags should be ignored by modes that don't use them.
|
|
See `semantic-analyze-possible-completions-default' for details on the default FLAGS.
|
|
|
|
Completions run through the following filters:
|
|
* Elements currently in scope
|
|
* Constants currently in scope
|
|
* Elements match the :prefix in the CONTEXT.
|
|
* Type of the completion matches the type of the context.
|
|
Context type matching can identify the following:
|
|
* No specific type
|
|
* Assignment into a variable of some type.
|
|
* Argument to a function with type constraints.
|
|
When called interactively, displays the list of possible completions
|
|
in a buffer."
|
|
(interactive "d")
|
|
;; In theory, we don't need the below since the context will
|
|
;; do it for us.
|
|
;;(semantic-refresh-tags-safe)
|
|
(with-syntax-table semantic-lex-syntax-table
|
|
(let* ((context (if (semantic-analyze-context-child-p context)
|
|
context
|
|
(semantic-analyze-current-context context)))
|
|
(ans (if (not context)
|
|
(error "Nothing to complete")
|
|
(:override))))
|
|
;; If interactive, display them.
|
|
(when (called-interactively-p 'any)
|
|
(with-output-to-temp-buffer "*Possible Completions*"
|
|
(semantic-analyze-princ-sequence ans "" (current-buffer)))
|
|
(shrink-window-if-larger-than-buffer
|
|
(get-buffer-window "*Possible Completions*")))
|
|
ans)))
|
|
|
|
(defun semantic-analyze-possible-completions-default (context &optional flags)
|
|
"Default method for producing smart completions.
|
|
Argument CONTEXT is an object specifying the locally derived context.
|
|
The optional argument FLAGS changes which return options are returned.
|
|
FLAGS can be any number of:
|
|
'no-tc - do not apply data-type constraint.
|
|
'no-unique - do not apply unique by name filtering."
|
|
(let* ((a context)
|
|
(desired-type (semantic-analyze-type-constraint a))
|
|
(desired-class (oref a prefixclass))
|
|
(prefix (oref a prefix))
|
|
(prefixtypes (oref a prefixtypes))
|
|
(completetext nil)
|
|
(completetexttype nil)
|
|
(scope (oref a scope))
|
|
(localvar (when scope (oref scope localvar)))
|
|
(origc nil)
|
|
(c nil)
|
|
(any nil)
|
|
(do-typeconstraint (not (memq 'no-tc flags)))
|
|
(do-unique (not (memq 'no-unique flags)))
|
|
)
|
|
|
|
;; Calculate what our prefix string is so that we can
|
|
;; find all our matching text.
|
|
(setq completetext (car (reverse prefix)))
|
|
(if (semantic-tag-p completetext)
|
|
(setq completetext (semantic-tag-name completetext)))
|
|
|
|
(if (and (not completetext) (not desired-type))
|
|
(error "Nothing to complete"))
|
|
|
|
(if (not completetext) (setq completetext ""))
|
|
|
|
;; This better be a reasonable type, or we should fry it.
|
|
;; The prefixtypes should always be at least 1 less than
|
|
;; the prefix since the type is never looked up for the last
|
|
;; item when calculating a sequence.
|
|
(setq completetexttype (car (reverse prefixtypes)))
|
|
(when (or (not completetexttype)
|
|
(not (and (semantic-tag-p completetexttype)
|
|
(eq (semantic-tag-class completetexttype) 'type))))
|
|
;; What should I do here? I think this is an error condition.
|
|
(setq completetexttype nil)
|
|
;; If we had something that was a completetexttype but it wasn't
|
|
;; valid, then express our dismay!
|
|
(when (> (length prefix) 1)
|
|
(let* ((errprefix (car (cdr (reverse prefix)))))
|
|
(error "Cannot find types for `%s'"
|
|
(cond ((semantic-tag-p errprefix)
|
|
(semantic-format-tag-prototype errprefix))
|
|
(t
|
|
(format "%S" errprefix)))))
|
|
))
|
|
|
|
;; There are many places to get our completion stream for.
|
|
;; Here we go.
|
|
(if completetexttype
|
|
|
|
(setq c (semantic-find-tags-for-completion
|
|
completetext
|
|
(semantic-analyze-scoped-type-parts completetexttype scope)
|
|
))
|
|
|
|
;; No type based on the completetext. This is a free-range
|
|
;; var or function. We need to expand our search beyond this
|
|
;; scope into semanticdb, etc.
|
|
(setq c (nconc
|
|
;; Argument list and local variables
|
|
(semantic-find-tags-for-completion completetext localvar)
|
|
;; The current scope
|
|
(semantic-find-tags-for-completion completetext (when scope (oref scope fullscope)))
|
|
;; The world
|
|
(semantic-analyze-find-tags-by-prefix completetext))
|
|
)
|
|
)
|
|
|
|
(let ((loopc c)
|
|
(dtname (semantic-tag-name desired-type)))
|
|
|
|
;; Save off our first batch of completions
|
|
(setq origc c)
|
|
|
|
;; Reset c.
|
|
(setq c nil)
|
|
|
|
;; Loop over all the found matches, and catagorize them
|
|
;; as being possible features.
|
|
(while (and loopc do-typeconstraint)
|
|
|
|
(cond
|
|
;; Strip operators
|
|
((semantic-tag-get-attribute (car loopc) :operator-flag)
|
|
nil
|
|
)
|
|
|
|
;; If we are completing from within some prefix,
|
|
;; then we want to exclude constructors and destructors
|
|
((and completetexttype
|
|
(or (semantic-tag-get-attribute (car loopc) :constructor-flag)
|
|
(semantic-tag-get-attribute (car loopc) :destructor-flag)))
|
|
nil
|
|
)
|
|
|
|
;; If there is a desired type, we need a pair of restrictions
|
|
(desired-type
|
|
|
|
(cond
|
|
;; Ok, we now have a completion list based on the text we found
|
|
;; we want to complete on. Now filter that stream against the
|
|
;; type we want to search for.
|
|
((string= dtname (semantic-analyze-type-to-name (semantic-tag-type (car loopc))))
|
|
(setq c (cons (car loopc) c))
|
|
)
|
|
|
|
;; Now anything that is a compound type which could contain
|
|
;; additional things which are of the desired type
|
|
((semantic-tag-type (car loopc))
|
|
(let ((att (semantic-analyze-tag-type (car loopc) scope))
|
|
)
|
|
(if (and att (semantic-tag-type-members att))
|
|
(setq c (cons (car loopc) c))))
|
|
)
|
|
|
|
) ; cond
|
|
); desired type
|
|
|
|
;; No desired type, no other restrictions. Just add.
|
|
(t
|
|
(setq c (cons (car loopc) c)))
|
|
|
|
); cond
|
|
|
|
(setq loopc (cdr loopc)))
|
|
|
|
(when desired-type
|
|
;; Some types, like the enum in C, have special constant values that
|
|
;; we could complete with. Thus, if the target is an enum, we can
|
|
;; find possible symbol values to fill in that value.
|
|
(let ((constants
|
|
(semantic-analyze-type-constants desired-type)))
|
|
(if constants
|
|
(progn
|
|
;; Filter
|
|
(setq constants
|
|
(semantic-find-tags-for-completion
|
|
completetext constants))
|
|
;; Add to the list
|
|
(setq c (nconc c constants)))
|
|
)))
|
|
)
|
|
|
|
(when desired-class
|
|
(setq c (semantic-analyze-tags-of-class-list c desired-class)))
|
|
|
|
(if do-unique
|
|
(if c
|
|
;; Pull out trash.
|
|
;; NOTE TO SELF: Is this too slow?
|
|
(setq c (semantic-unique-tag-table-by-name c))
|
|
(setq c (semantic-unique-tag-table-by-name origc)))
|
|
(when (not c)
|
|
(setq c origc)))
|
|
|
|
;; All done!
|
|
c))
|
|
|
|
(provide 'semantic/analyze/complete)
|
|
|
|
;; Local variables:
|
|
;; generated-autoload-file: "../loaddefs.el"
|
|
;; generated-autoload-load-name: "semantic/analyze/complete"
|
|
;; End:
|
|
|
|
;; arch-tag: 97071c7e-2459-4e7a-8875-8cc5bbbc1f4d
|
|
;;; semantic/analyze/complete.el ends here
|