X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/16ddec7e9e6adcf615db097d9627d490ca29208c..0e963201d03d9229bb8ac4323291d2b0119526ed:/lisp/cedet/semantic/scope.el diff --git a/lisp/cedet/semantic/scope.el b/lisp/cedet/semantic/scope.el index 0882120fc6..ddef510589 100644 --- a/lisp/cedet/semantic/scope.el +++ b/lisp/cedet/semantic/scope.el @@ -1,6 +1,6 @@ ;;; semantic/scope.el --- Analyzer Scope Calculations -;; Copyright (C) 2007-2012 Free Software Foundation, Inc. +;; Copyright (C) 2007-2016 Free Software Foundation, Inc. ;; Author: Eric M. Ludlam @@ -101,7 +101,7 @@ Saves scoping information between runs of the analyzer.") ;; ;; Methods for basic management of the structure in semanticdb. ;; -(defmethod semantic-reset ((obj semantic-scope-cache)) +(cl-defmethod semantic-reset ((obj semantic-scope-cache)) "Reset OBJ back to it's empty settings." (oset obj tag nil) (oset obj scopetypes nil) @@ -114,13 +114,13 @@ Saves scoping information between runs of the analyzer.") (oset obj typescope nil) ) -(defmethod semanticdb-synchronize ((cache semantic-scope-cache) +(cl-defmethod semanticdb-synchronize ((cache semantic-scope-cache) new-tags) "Synchronize a CACHE with some NEW-TAGS." (semantic-reset cache)) -(defmethod semanticdb-partial-synchronize ((cache semantic-scope-cache) +(cl-defmethod semanticdb-partial-synchronize ((cache semantic-scope-cache) new-tags) "Synchronize a CACHE with some changed NEW-TAGS." ;; If there are any includes or datatypes changed, then clear. @@ -134,10 +134,10 @@ Saves scoping information between runs of the analyzer.") "Get the current cached scope, and reset it." (when semanticdb-current-table (let ((co (semanticdb-cache-get semanticdb-current-table - semantic-scope-cache))) + 'semantic-scope-cache))) (semantic-reset co)))) -(defmethod semantic-scope-set-typecache ((cache semantic-scope-cache) +(cl-defmethod semantic-scope-set-typecache ((cache semantic-scope-cache) types-in-scope) "Set the :typescope property on CACHE to some types. TYPES-IN-SCOPE is a list of type tags whos members are @@ -195,12 +195,18 @@ Use `semantic-ctxt-scoped-types' to find types." ;; Get this thing as a tag (let ((tmp (cond ((stringp (car sp)) - (semanticdb-typecache-find (car sp))) - ;(semantic-analyze-find-tag (car sp) 'type)) + (or (semanticdb-typecache-find (car sp)) + ;; If we did not find it in the typecache, + ;; look in the tags we found so far + (car (semantic-deep-find-tags-by-name + (car sp) + code-scoped-types)))) ((semantic-tag-p (car sp)) (if (semantic-tag-prototype-p (car sp)) - (semanticdb-typecache-find (semantic-tag-name (car sp))) - ;;(semantic-analyze-find-tag (semantic-tag-name (car sp)) 'type) + (or (semanticdb-typecache-find (semantic-tag-name (car sp))) + (car (semantic-deep-find-tags-by-name + (semantic-tag-name (car sp)) + code-scoped-types))) (car sp))) (t nil)))) (when tmp @@ -506,10 +512,33 @@ tag is not something you can complete from within TYPE." (leftover nil) ) (dolist (S allslots) - (when (or (not (semantic-tag-of-class-p S 'function)) - (not (semantic-tag-function-parent S))) - (setq leftover (cons S leftover))) - ) + ;; We have to specially deal with 'using' tags here, since those + ;; pull in namespaces or classes into the current scope. + ;; (Should this go into c.el? If so, into which override?) + (if (semantic-tag-of-class-p S 'using) + (let* ((fullname (semantic-analyze-unsplit-name + (list (semantic-tag-name type) + (semantic-tag-name S)))) + ;; Search the typecache, first for the unqualified name + (usingtype (or + (semanticdb-typecache-find (semantic-tag-name S)) + ;; If that didn't return anything, use + ;; fully qualified name + (semanticdb-typecache-find fullname))) + (filename (when usingtype (semantic-tag-file-name usingtype)))) + (when usingtype + ;; Use recursion to examine that namespace or class + (let ((tags (semantic-completable-tags-from-type usingtype))) + (if filename + ;; If we have a filename, copy the tags with it + (dolist (cur tags) + (setq leftover (cons (semantic-tag-copy cur nil filename) + leftover))) + ;; Otherwise just run with it + (setq leftover (append tags leftover)))))) + (when (or (not (semantic-tag-of-class-p S 'function)) + (not (semantic-tag-function-parent S))) + (setq leftover (cons S leftover))))) (nreverse leftover))) (defun semantic-analyze-scoped-type-parts (type &optional scope noinherit protection) @@ -677,7 +706,7 @@ The class returned from the scope calculation is variable (let* ((TAG (semantic-current-tag)) (scopecache (semanticdb-cache-get semanticdb-current-table - semantic-scope-cache)) + 'semantic-scope-cache)) ) (when (not (semantic-equivalent-tag-p TAG (oref scopecache tag))) (semantic-reset scopecache)) @@ -734,8 +763,9 @@ The class returned from the scope calculation is variable (when (called-interactively-p 'any) (require 'eieio-datadebug) (data-debug-show scopecache)) - ;; Return ourselves - scopecache)))) + ;; Return ourselves, but make a clone first so that the caller + ;; can reset the scope cache without affecting others. + (clone scopecache))))) (defun semantic-scope-find (name &optional class scope-in) "Find the tag with NAME, and optional CLASS in the current SCOPE-IN. @@ -799,7 +829,7 @@ hits in order, with the first tag being in the closest scope." ;;; DUMP ;; -(defmethod semantic-analyze-show ((context semantic-scope-cache)) +(cl-defmethod semantic-analyze-show ((context semantic-scope-cache)) "Insert CONTEXT into the current buffer in a nice way." (require 'semantic/analyze) (semantic-analyze-princ-sequence (oref context scopetypes) "-> ScopeTypes: " )