]> git.eshelyaron.com Git - emacs.git/commitdiff
semantic: Introduce `semantic-analyze-tag-type-members'
authorEric Ludlam <eric@siege-engine.com>
Thu, 23 Apr 2015 00:56:04 +0000 (20:56 -0400)
committerDavid Engster <deng@randomsample.de>
Sun, 22 Jan 2017 21:25:15 +0000 (22:25 +0100)
* lisp/cedet/semantic/analyze.el (semantic-analyze-tag-type-members)
 (semantic-analyze-tag-type-members-default): New
 (semantic-analyze-find-tag-sequence-default)
 (semantic-analyze-current-context-default):
* lisp/cedet/semantic/db-typecache.el
 (semanticdb-typecache-find):
* lisp/cedet/semantic/scope.el (semantic-completable-tags-from-type)
 (semantic-scope-find):
* lisp/cedet/semantic/analyze/complete.el
 (semantic-analyze-possible-completions-default):
* lisp/cedet/semantic/analyze/debug.el
  (semantic-analyzer-debug-missing-innertype): Use new
 `semantic-analyze-tag-type-members'.

lisp/cedet/semantic/analyze.el
lisp/cedet/semantic/analyze/complete.el
lisp/cedet/semantic/analyze/debug.el
lisp/cedet/semantic/db-typecache.el
lisp/cedet/semantic/scope.el

index c7062fb24cded9554b4afb752661cdcfe1df0c2e..a8cd95d679393f327120dc634edfe3e5170380c1 100644 (file)
@@ -219,6 +219,23 @@ Optional argument DESIRED-TYPE may be a non-type tag to analyze."
   "Try the base, and if that fails, return what we are assigning into."
   (or (cl-call-next-method) (car-safe (oref context :assignee))))
 
+;;; TYPE MEMBERS
+;;
+;; When analyzing tag sequences, we dive through structured data
+;; such as structs, classes, unions, etc.  The raw member list
+;; is sometimes insufficient for generating completions, so each
+;; language needs an opportunity to get the type members that are
+;; accessable via a code snippet.  A key example is anonymous
+;; unions in C/C++, whose members are completable in the parent
+;; member list, but are structured in the tag as a single item.
+(define-overloadable-function semantic-analyze-tag-type-members (tag)
+  "Return a list of members of TAG, where TAG is a type.
+By default, call `semantic-tag-type-members'.")
+
+(defun semantic-analyze-tag-type-members-default (tag)
+  "Return a list of members of TAG, where TAG is a type."
+  (semantic-tag-type-members tag))
+
 ;;; ANALYSIS
 ;;
 ;; Start out with routines that will calculate useful parts of
@@ -345,7 +362,7 @@ This function knows of flags:
        (when miniscope
          (let ((rawscope
                 (apply 'append
-                       (mapcar 'semantic-tag-type-members tagtype))))
+                       (mapcar 'semantic-analyze-tag-type-members tagtype))))
            (oset miniscope fullscope rawscope)))
        )
       (setq s (cdr s)))
@@ -589,7 +606,7 @@ Returns an object based on symbol `semantic-analyze-context'."
                ;; the found datatype.
                (setq fcn (semantic-find-tags-by-name
                           (semantic-tag-name (car ty))
-                          (semantic-tag-type-members (car ty))))
+                          (semantic-analyze-tag-type-members (car ty))))
                (if fcn
                    (let ((lp fcn))
                      (while lp
index 1ddbe131e6a01befa240d93cf70e3f9cdfc87315..f99a70bb2920bb520e94eca5f3da3b114722b7dc 100644 (file)
@@ -235,7 +235,7 @@ FLAGS can be any number of:
           ((semantic-tag-type (car loopc))
            (let ((att (semantic-analyze-tag-type (car loopc) scope))
                )
-             (if (and att (semantic-tag-type-members att))
+             (if (and att (semantic-analyze-tag-type-members att))
                  (setq c (cons (car loopc) c))))
            )
 
index fd218b6782758ea4eca3c96c39c34c1ca78b17be..eb4e9947ed2095f471d2354cb2b99517eb44ba40 100644 (file)
@@ -307,7 +307,7 @@ possible completions for \"")
        (princ "\nKnown members of ")
        (princ (semantic-tag-name dt))
        (princ ":\n")
-       (dolist (M (semantic-tag-type-members dt))
+       (dolist (M (semantic-analyze-tag-type-members dt))
          (princ "  ")
          ;;(princ (semantic-format-tag-prototype M))
          (semantic-analyzer-debug-insert-tag M)
index 8c8cf15eaf274b56812f43f3875d1176e19e0135..48e439e54f95fd4c057c60119043007ae19d74bc 100644 (file)
@@ -499,7 +499,9 @@ found tag to be loaded."
       ;; the next set of members.
       (if (not ans)
          (setq notdone nil)
-       (setq stream (semantic-tag-type-members ans)))
+       ;; When pulling the next stream, only get the members we
+       ;; are supposed to complete on.
+       (setq stream (semantic-analyze-tag-type-members ans)))
 
       (setq lastans ans
            ans nil
index 272f37d9858df7caf48897c0ddddf28ba24b6c25..0ac994cbd49bdd451756f940b999c38d0938d0e4 100644 (file)
@@ -508,7 +508,9 @@ the access would be 'protected.  Otherwise, access is 'public")
   "Return a list of slots that are valid completions from the list of SLOTS.
 If a tag in SLOTS has a named parent, then that implies that the
 tag is not something you can complete from within TYPE."
-  (let ((allslots (semantic-tag-components type))
+  ;; Pull in analyzed type members.
+  ;; For C, this strips out anon unions, and merges in anon union members.
+  (let ((allslots (semantic-analyze-tag-type-members type))
        (leftover nil)
        )
     (dolist (S allslots)
@@ -819,7 +821,7 @@ hits in order, with the first tag being in the closest scope."
                  (if (not ans)
                      (setq typescoperaw nil)
                    (when (cdr namesplit)
-                     (setq typescoperaw (semantic-tag-type-members
+                     (setq typescoperaw (semantic-analyze-tag-type-members
                                          (car ans)))))
 
                  (setq namesplit (cdr namesplit)))