Commit dd9af436 authored by Chong Yidong's avatar Chong Yidong
Browse files

Synch Semantic to CEDET 1.0.

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.
parent 7ee54def
This diff is collapsed.
This diff is collapsed.
......@@ -4,7 +4,8 @@
;; 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Keywords: syntax
;; Keywords: syntax tools
;; Version: 2.0
;; This file is part of GNU Emacs.
......@@ -38,7 +39,7 @@
(require 'semantic/tag)
(require 'semantic/lex)
(defvar semantic-version "2.0pre7"
(defvar semantic-version "2.0"
"Current version of Semantic.")
(declare-function inversion-test "inversion")
......@@ -875,6 +876,7 @@ Throw away all the old tags, and recreate the tag database."
;; (define-key km "i" 'senator-isearch-toggle-semantic-mode)
(define-key map "\C-c,j" 'semantic-complete-jump-local)
(define-key map "\C-c,J" 'semantic-complete-jump)
(define-key map "\C-c,m" 'semantic-complete-jump-local-members)
(define-key map "\C-c,g" 'semantic-symref-symbol)
(define-key map "\C-c,G" 'semantic-symref)
(define-key map "\C-c,p" 'senator-previous-tag)
......@@ -885,6 +887,7 @@ Throw away all the old tags, and recreate the tag database."
(define-key map "\C-c,\M-w" 'senator-copy-tag)
(define-key map "\C-c,\C-y" 'senator-yank-tag)
(define-key map "\C-c,r" 'senator-copy-tag-to-register)
(define-key map "\C-c,," 'semantic-force-refresh)
(define-key map [?\C-c ?, up] 'senator-transpose-tags-up)
(define-key map [?\C-c ?, down] 'senator-transpose-tags-down)
(define-key map "\C-c,l" 'semantic-analyze-possible-completions)
......@@ -950,6 +953,9 @@ Throw away all the old tags, and recreate the tag database."
(define-key navigate-menu [semantic-complete-jump]
'(menu-item "Find Tag Globally..." semantic-complete-jump
:help "Read a tag name and find it in the current project"))
(define-key navigate-menu [semantic-complete-jump-local-members]
'(menu-item "Find Local Members ..." semantic-complete-jump-local-members
:help "Read a tag name and find a local member with that name"))
(define-key navigate-menu [semantic-complete-jump-local]
'(menu-item "Find Tag in This Buffer..." semantic-complete-jump-local
:help "Read a tag name and find it in this buffer"))
......@@ -1080,6 +1086,11 @@ Semantic mode.
(require 'semantic/db-ebrowse)
(semanticdb-load-ebrowse-caches)))
(add-hook 'mode-local-init-hook 'semantic-new-buffer-fcn)
;; Add semantic-ia-complete-symbol to
;; completion-at-point-functions, so that it is run from
;; M-TAB.
(add-hook 'completion-at-point-functions
'semantic-completion-at-point-function)
(if global-ede-mode
(define-key cedet-menu-map [cedet-menu-separator] '("--")))
(dolist (b (buffer-list))
......@@ -1087,6 +1098,8 @@ Semantic mode.
(semantic-new-buffer-fcn))))
;; Disable all Semantic features.
(remove-hook 'mode-local-init-hook 'semantic-new-buffer-fcn)
(remove-hook 'completion-at-point-functions
'semantic-completion-at-point-function)
(define-key cedet-menu-map [cedet-menu-separator] nil)
(define-key cedet-menu-map [semantic-options-separator] nil)
;; FIXME: handle semanticdb-load-ebrowse-caches
......@@ -1094,6 +1107,9 @@ Semantic mode.
(if (and (boundp mode) (eval mode))
(funcall mode -1)))))
(defun semantic-completion-at-point-function ()
'semantic-ia-complete-symbol)
;;; Autoload some functions that are not in semantic/loaddefs
(autoload 'global-semantic-idle-completions-mode "semantic/idle"
......
......@@ -253,7 +253,7 @@ Optional argument THROWSYM specifies a symbol the throw on non-recoverable error
(tag nil) ; tag return list
(tagtype nil) ; tag types return list
(fname nil)
(miniscope (clone scope))
(miniscope (when scope (clone scope)))
)
;; First order check. Is this wholely contained in the typecache?
(setq tmp (semanticdb-typecache-find sequence))
......@@ -297,11 +297,12 @@ Optional argument THROWSYM specifies a symbol the throw on non-recoverable error
;; and we can use it directly.
(cond ((semantic-tag-of-class-p tmp 'type)
;; update the miniscope when we need to analyze types directly.
(let ((rawscope
(apply 'append
(mapcar 'semantic-tag-type-members
tagtype))))
(oset miniscope fullscope rawscope))
(when miniscope
(let ((rawscope
(apply 'append
(mapcar 'semantic-tag-type-members
tagtype))))
(oset miniscope fullscope rawscope)))
;; Now analayze the type to remove metatypes.
(or (semantic-analyze-type tmp miniscope)
tmp))
......@@ -351,7 +352,7 @@ Optional argument SCOPE specifies a scope object which has
additional tags which are in SCOPE and do not need prefixing to
find.
This is a wrapper on top of semanticdb, semanticdb-typecache,
This is a wrapper on top of semanticdb, semanticdb typecache,
semantic-scope, and semantic search functions. Almost all
searches use the same arguments."
(let ((namelst (if (consp name) name ;; test if pre-split.
......
......@@ -63,11 +63,15 @@ Used as options when completing.")
;;; MAIN completion calculator
;;
;;;###autoload
(define-overloadable-function semantic-analyze-possible-completions (context)
(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
......@@ -98,9 +102,13 @@ in a buffer."
(get-buffer-window "*Possible Completions*")))
ans)))
(defun semantic-analyze-possible-completions-default (context)
(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."
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))
......@@ -109,8 +117,13 @@ Argument CONTEXT is an object specifying the locally derived context."
(completetext nil)
(completetexttype nil)
(scope (oref a scope))
(localvar (oref scope localvar))
(c nil))
(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.
......@@ -160,33 +173,36 @@ Argument CONTEXT is an object specifying the locally derived context."
;; Argument list and local variables
(semantic-find-tags-for-completion completetext localvar)
;; The current scope
(semantic-find-tags-for-completion completetext (oref scope fullscope))
(semantic-find-tags-for-completion completetext (when scope (oref scope fullscope)))
;; The world
(semantic-analyze-find-tags-by-prefix completetext))
)
)
(let ((origc c)
(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 origc
(while (and loopc do-typeconstraint)
(cond
;; Strip operators
((semantic-tag-get-attribute (car origc) :operator-flag)
((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 origc) :constructor-flag)
(semantic-tag-get-attribute (car origc) :destructor-flag)))
(or (semantic-tag-get-attribute (car loopc) :constructor-flag)
(semantic-tag-get-attribute (car loopc) :destructor-flag)))
nil
)
......@@ -197,17 +213,17 @@ Argument CONTEXT is an object specifying the locally derived context."
;; 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 origc))))
(setq c (cons (car origc) c))
((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 origc))
(let ((att (semantic-analyze-tag-type (car origc) scope))
((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 origc) c))))
(setq c (cons (car loopc) c))))
)
) ; cond
......@@ -215,11 +231,11 @@ Argument CONTEXT is an object specifying the locally derived context."
;; No desired type, no other restrictions. Just add.
(t
(setq c (cons (car origc) c)))
(setq c (cons (car loopc) c)))
); cond
(setq origc (cdr origc)))
(setq loopc (cdr loopc)))
(when desired-type
;; Some types, like the enum in C, have special constant values that
......@@ -241,15 +257,16 @@ Argument CONTEXT is an object specifying the locally derived context."
(when desired-class
(setq c (semantic-analyze-tags-of-class-list c desired-class)))
;; Pull out trash.
;; NOTE TO SELF: Is this too slow?
;; OTHER NOTE: Do we not want to strip duplicates by name and
;; only by position? When are duplicate by name but not by tag
;; useful?
(setq c (semantic-unique-tag-table-by-name c))
(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)
......
......@@ -54,6 +54,8 @@
))
;; @TODO - If this happens, but the last found type is
;; a datatype, then the below is wrong
(defun semantic-analyzer-debug-found-prefix (ctxt)
"Debug the prefix found by the analyzer output CTXT."
(let* ((pf (oref ctxt prefix))
......@@ -97,7 +99,7 @@ Argument COMP are possible completions here."
)
(with-output-to-temp-buffer (help-buffer)
(with-current-buffer standard-output
(princ "Unable to find prefix ")
(princ "Unable to find symbol ")
(princ prefix)
(princ ".\n\n")
......@@ -217,7 +219,7 @@ Argument COMP are possible completions here."
(when (not dt) (error "Missing Innertype debugger is confused"))
(with-output-to-temp-buffer (help-buffer)
(with-current-buffer standard-output
(princ "Cannot find prefix \"")
(princ "Cannot find symbol \"")
(princ prefixitem)
(princ "\" in datatype:
")
......@@ -550,24 +552,25 @@ PARENT is a possible parent (by nesting) tag."
(let ((str (semantic-format-tag-prototype tag parent)))
(if (and (semantic-tag-with-position-p tag)
(semantic-tag-file-name tag))
(insert-button str
'mouse-face 'custom-button-pressed-face
'tag tag
'action
`(lambda (button)
(let ((buff nil)
(pnt nil))
(save-excursion
(semantic-go-to-tag
(button-get button 'tag))
(setq buff (current-buffer))
(setq pnt (point)))
(if (get-buffer-window buff)
(select-window (get-buffer-window buff))
(pop-to-buffer buff t))
(goto-char pnt)
(pulse-line-hook-function)))
)
(with-current-buffer standard-output
(insert-button str
'mouse-face 'custom-button-pressed-face
'tag tag
'action
`(lambda (button)
(let ((buff nil)
(pnt nil))
(save-excursion
(semantic-go-to-tag
(button-get button 'tag))
(setq buff (current-buffer))
(setq pnt (point)))
(if (get-buffer-window buff)
(select-window (get-buffer-window buff))
(pop-to-buffer buff t))
(goto-char pnt)
(pulse-line-hook-function)))
))
(princ "\"")
(princ str)
(princ "\""))
......
......@@ -104,6 +104,7 @@ Use `semantic-analyze-current-tag' to debug this fcn."
"Return the implementations derived in the reference analyzer REFS.
Optional argument IN-BUFFER indicates that the returned tag should be in an active buffer."
(let ((allhits (oref refs rawsearchdata))
(tag (oref refs :tag))
(impl nil)
)
(semanticdb-find-result-mapc
......@@ -113,7 +114,8 @@ Optional argument IN-BUFFER indicates that the returned tag should be in an acti
(aT (cdr ans))
(aDB (car ans))
)
(when (not (semantic-tag-prototype-p aT))
(when (and (not (semantic-tag-prototype-p aT))
(semantic-tag-similar-p tag aT :prototype-flag :parent))
(when in-buffer (save-excursion (semantic-go-to-tag aT aDB)))
(push aT impl))))
allhits)
......@@ -123,6 +125,7 @@ Optional argument IN-BUFFER indicates that the returned tag should be in an acti
"Return the prototypes derived in the reference analyzer REFS.
Optional argument IN-BUFFER indicates that the returned tag should be in an active buffer."
(let ((allhits (oref refs rawsearchdata))
(tag (oref refs :tag))
(proto nil))
(semanticdb-find-result-mapc
(lambda (T DB)
......@@ -131,7 +134,8 @@ Optional argument IN-BUFFER indicates that the returned tag should be in an acti
(aT (cdr ans))
(aDB (car ans))
)
(when (semantic-tag-prototype-p aT)
(when (and (semantic-tag-prototype-p aT)
(semantic-tag-similar-p tag aT :prototype-flag :parent))
(when in-buffer (save-excursion (semantic-go-to-tag aT aDB)))
(push aT proto))))
allhits)
......@@ -142,8 +146,8 @@ Optional argument IN-BUFFER indicates that the returned tag should be in an acti
(defun semantic--analyze-refs-full-lookup (tag scope)
"Perform a full lookup for all occurrences of TAG in the current project.
TAG should be the tag currently under point.
PARENT is the list of tags that are parents to TAG by
containment, as opposed to reference."
SCOPE is the scope the cursor is in. From this a list of parents is
derived. If SCOPE does not have parents, then only a simple lookup is done."
(if (not (oref scope parents))
;; If this tag has some named parent, but is not
(semantic--analyze-refs-full-lookup-simple tag)
......@@ -177,20 +181,36 @@ CLASS is the class of the tag that ought to be returned."
ans))
(defun semantic--analyze-refs-find-tags-with-parent (find-results parents)
"Find in FIND-RESULTS all tags with PARNTS.
"Find in FIND-RESULTS all tags with PARENTS.
NAME is the name of the tag needing finding.
PARENTS is a list of names."
(let ((ans nil))
(let ((ans nil) (usingnames nil))
;; Loop over the find-results passed in.
(semanticdb-find-result-mapc
(lambda (tag db)
(let* ((p (semantic-tag-named-parent tag))
(ps (when (stringp p)
(semantic-analyze-split-name p))))
(ps (when (stringp p) (semantic-analyze-split-name p))))
(when (stringp ps) (setq ps (list ps)))
(when (and ps (equal ps parents))
;; We could optimize this, but it seems unlikely.
(push (list db tag) ans))
))
(when ps
;; If there is a perfect match, then use it.
(if (equal ps parents)
(push (list db tag) ans))
;; No match, find something from our list of using names.
;; Do we need to split UN?
(save-excursion
(semantic-go-to-tag tag db)
(setq usingnames nil)
(let ((imports (semantic-ctxt-imported-packages)))
;; Derive the names from all the using statements.
(mapc (lambda (T)
(setq usingnames
(cons (semantic-format-tag-name-from-anything T) usingnames)))
imports))
(dolist (UN usingnames)
(when (equal (cons UN ps) parents)
(push (list db tag) ans)
(setq usingnames (cdr usingnames))))
))))
find-results)
ans))
......@@ -206,7 +226,7 @@ TAG should be the tag currently under point."
;; Find all hits for the first parent name.
(brute (semanticdb-find-tags-collector
(lambda (table tags)
(semanticdb-find-tags-by-name-method table name tags)
(semanticdb-deep-find-tags-by-name-method table name tags)
)
nil nil t))
;; Prime the answer.
......@@ -214,6 +234,7 @@ TAG should be the tag currently under point."
)
;; First parent is already search to initialize "brute".
(setq plist (cdr plist))
;; Go through the list of parents, and try to find matches.
;; As we cycle through plist, for each level look for NAME,
;; and compare the named-parent, and also dive into the next item of
......@@ -253,7 +274,8 @@ Only works for tags in the global namespace."
(lambda (table tags)
(semanticdb-find-tags-by-name-method table name tags)
)
nil nil t))
nil ;; This may need to be the entire project??
nil t))
)
(when (and (not brute) (not noerror))
......
......@@ -39,6 +39,7 @@
(declare-function semantic-brute-find-tag-by-attribute "semantic/find")
(declare-function semanticdb-minor-mode-p "semantic/db-mode")
(declare-function semanticdb-needs-refresh-p "semantic/db")
(declare-function semanticdb-typecache-faux-namespace "semantic/db-typecache")
(declare-function c-forward-conditional "cc-cmds")
(declare-function ede-system-include-path "ede")
......@@ -158,7 +159,7 @@ part of the preprocessor map.")
Each entry is a cons cell like this:
( \"KEYWORD\" . \"REPLACEMENT\" )
Where KEYWORD is the macro that gets replaced in the lexical phase,
and REPLACEMENT is a string that is inserted in it's place. Empty string
and REPLACEMENT is a string that is inserted in its place. Empty string
implies that the lexical analyzer will discard KEYWORD when it is encountered.
Alternately, it can be of the form:
......@@ -295,6 +296,7 @@ Moves completely over balanced #if blocks."
(cond
((looking-at "^\\s-*#\\s-*if")
;; We found a nested if. Skip it.
;; @TODO - can we use the new c-scan-conditionals
(c-forward-conditional 1))
((looking-at "^\\s-*#\\s-*elif")
;; We need to let the preprocessor analize this one.
......@@ -348,7 +350,6 @@ Uses known macro tables in SPP to determine what block to skip."
;; (message "%s %s yes" ift sym)
(beginning-of-line)
(setq pt (point))
;;(c-forward-conditional 1)
;; This skips only a section of a conditional. Once that section
;; is opened, encountering any new #else or related conditional
;; should be skipped.
......@@ -356,8 +357,8 @@ Uses known macro tables in SPP to determine what block to skip."
(setq semantic-lex-end-point (point))
(semantic-push-parser-warning (format "Skip #%s %s" ift sym)
pt (point))
;; (semantic-lex-push-token
;; (semantic-lex-token 'c-preprocessor-skip pt (point)))
;; (semantic-lex-push-token
;; (semantic-lex-token 'c-preprocessor-skip pt (point)))
nil)
;; Else, don't ignore it, but do handle the internals.
;;(message "%s %s no" ift sym)
......@@ -703,58 +704,60 @@ the regular parser."
(symtext (semantic-lex-token-text lexicaltoken))
(macros (get-text-property 0 'macros symtext))
)
(with-current-buffer buf
(erase-buffer)
(when (not (eq major-mode mode))
(save-match-data
;; Protect against user hooks throwing errors.
(condition-case nil
(funcall mode)
(error
(if (y-or-n-p
(format "There was an error initializing %s in buffer \"%s\". Debug your hooks? "
mode (buffer-name)))
(semantic-c-debug-mode-init mode)
(message "Macro parsing state may be broken...")
(sit-for 1))))
) ; save match data
;; Hack in mode-local
(activate-mode-local-bindings)
;; CHEATER! The following 3 lines are from
;; `semantic-new-buffer-fcn', but we don't want to turn
;; on all the other annoying modes for this little task.
(setq semantic-new-buffer-fcn-was-run t)
(semantic-lex-init)
(semantic-clear-toplevel-cache)
(remove-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook
t)
)
;; Get the macro symbol table right.
(setq semantic-lex-spp-dynamic-macro-symbol-obarray spp-syms)
;; (message "%S" macros)
(dolist (sym macros)
(semantic-lex-spp-symbol-set (car sym) (cdr sym)))
(insert symtext)
(setq stream
(semantic-parse-region-default
(point-min) (point-max) nonterminal depth returnonerror))
;; Clean up macro symbols
(dolist (sym macros)
(semantic-lex-spp-symbol-remove (car sym)))
;; Convert the text of the stream.
(dolist (tag stream)
;; Only do two levels here 'cause I'm lazy.
(semantic--tag-set-overlay tag (list start end))
(dolist (stag (semantic-tag-components-with-overlays tag))
(semantic--tag-set-overlay stag (list start end))
))
)
(if (> semantic-c-parse-token-hack-depth 5)
nil
(with-current-buffer buf
(erase-buffer)
(when (not (eq major-mode mode))
(save-match-data
;; Protect against user hooks throwing errors.
(condition-case nil
(funcall mode)
(error
(if (y-or-n-p
(format "There was an error initializing %s in buffer \"%s\". Debug your hooks? "
mode (buffer-name)))
(semantic-c-debug-mode-init mode)
(message "Macro parsing state may be broken...")
(sit-for 1))))
) ; save match data
;; Hack in mode-local
(activate-mode-local-bindings)
;; CHEATER! The following 3 lines are from
;; `semantic-new-buffer-fcn', but we don't want to turn
;; on all the other annoying modes for this little task.
(setq semantic-new-buffer-fcn-was-run t)
(semantic-lex-init)
(semantic-clear-toplevel-cache)
(remove-hook 'semantic-lex-reset-hooks 'semantic-lex-spp-reset-hook
t)
)
;; Get the macro symbol table right.
(setq semantic-lex-spp-dynamic-macro-symbol-obarray spp-syms)
;; (message "%S" macros)
(dolist (sym macros)
(semantic-lex-spp-symbol-set (car sym) (cdr sym)))
(insert symtext)
(setq stream
(semantic-parse-region-default
(point-min) (point-max) nonterminal depth returnonerror))
;; Clean up macro symbols
(dolist (sym macros)
(semantic-lex-spp-symbol-remove (car sym)))
;; Convert the text of the stream.
(dolist (tag stream)
;; Only do two levels here 'cause I'm lazy.
(semantic--tag-set-overlay tag (list start end))
(dolist (stag (semantic-tag-components-with-overlays tag))
(semantic--tag-set-overlay stag (list start end))
))
))
stream))
(defvar semantic-c-debug-mode-init-last-mode nil
......@@ -920,8 +923,34 @@ now.
;; of type "typedef".