]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/scope.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / semantic / scope.el
index 13e858ca000232447ede78eaf4f0fddcdc811faf..2c0dea20107be9cf86cd38f6ad2dd311eed0f18c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic/scope.el --- Analyzer Scope Calculations
 
-;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2015 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 
@@ -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)
@@ -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.