Function: semanticdb-find-translate-path-includes--internal

semanticdb-find-translate-path-includes--internal is a byte-compiled function defined in db-find.el.gz.

Signature

(semanticdb-find-translate-path-includes--internal PATH)

Documentation

Internal implementation of semanticdb-find-translate-path-includes-default.

This routine does not depend on the cache, but will always derive a new path from the provided PATH.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/db-find.el.gz
(defun semanticdb-find-translate-path-includes--internal (path)
  "Internal implementation of `semanticdb-find-translate-path-includes-default'.
This routine does not depend on the cache, but will always derive
a new path from the provided PATH."
  (let ((includetags nil)
	(curtable nil)
	(matchedtables (list semanticdb-current-table))
	(matchedincludes nil)
	(lostincludes nil)
	(scannedincludes nil)
	(incfname nil)
	nexttable)
    (cond ((null path)
	   (semantic-refresh-tags-safe)
	   (setq includetags (append
			      (semantic-find-tags-included (current-buffer))
			      semanticdb-implied-include-tags)
		 curtable semanticdb-current-table
		 incfname (buffer-file-name))
	   )
	  ((semanticdb-table-p path)
	   (setq includetags (semantic-find-tags-included path)
		 curtable path
		 incfname (semanticdb-full-filename path))
	   )
	  ((bufferp path)
	   (with-current-buffer path
	     (semantic-refresh-tags-safe))
	   (setq includetags (semantic-find-tags-included path)
		 curtable (with-current-buffer path
                            semanticdb-current-table)
		 incfname (buffer-file-name path)))
	  (t
	   (setq includetags (semantic-find-tags-included path))
	   (when includetags
	     ;; If we have some tags, derive a table from them.
	     ;; else we will do nothing, so the table is useless.

	     ;; @todo - derive some tables
	     (message "Need to derive tables for %S in translate-path-includes--default."
		      path)
	   )))

    ;; Make sure each found include tag has an originating file name associated
    ;; with it.
    (when incfname
      (dolist (it includetags)
	(semantic--tag-put-property it :filename incfname)))

    ;; Loop over all include tags adding to matchedtables
    (while includetags
      (semantic-throw-on-input 'semantic-find-translate-path-includes-default)

      ;; If we've seen this include string before, lets skip it.
      (if (member (semantic-tag-name (car includetags)) matchedincludes)
	  (progn
	    (setq nexttable nil)
	    (push (cons 'duplicate (semantic-tag-clone (car includetags)))
		  scannedincludes)
	    )
	(setq nexttable (semanticdb-find-table-for-include (car includetags) curtable))
	(when (not nexttable)
	  ;; Save the lost include.
	  (push (car includetags) lostincludes)
	  (push (cons 'lost (semantic-tag-clone (car includetags)))
		scannedincludes)
	  )
	)

      ;; Push the include file, so if we can't find it, we only
      ;; can't find it once.
      (push (semantic-tag-name (car includetags)) matchedincludes)

      ;; (message "Scanning %s" (semantic-tag-name (car includetags)))
      (when (and nexttable
		 (not (memq nexttable matchedtables))
		 (semanticdb-equivalent-mode-for-search nexttable
							(current-buffer))
		 )
	;; Add to list of tables
	(push nexttable matchedtables)

	;; Queue new includes to list
	(if (semanticdb-find-throttle-active-p 'recursive)
	    ;; @todo - recursive includes need to have the originating
	    ;;         buffer's location added to the path.
	    (let ((newtags
		   (cond
		    ((semanticdb-table-p nexttable)
		     (semanticdb-refresh-table nexttable)
		     ;; Use the method directly, or we will recurse
		     ;; into ourselves here.
		     (semanticdb-find-tags-by-class-method
		      nexttable 'include))
		    (t ;; @todo - is this ever possible???
		     (message "semanticdb-ftp - how did you do that?")
		     (semantic-find-tags-included
		      (semanticdb-get-tags nexttable)))
		    ))
		  (newincfname (semanticdb-full-filename nexttable))
		  )

	      (push (cons 'scanned (semantic-tag-clone (car includetags)))
		    scannedincludes)

	      ;; Setup new tags so we know where they are.
	      (dolist (it newtags)
		(semantic--tag-put-property it :filename
					    newincfname))

	      (setq includetags (nconc includetags newtags)))
	  ;; ELSE - not recursive throttle
	  (push (cons 'scanned-no-recurse
		      (semantic-tag-clone (car includetags)))
		scannedincludes)
	  )
	)
      (setq includetags (cdr includetags)))

    (setq semanticdb-find-lost-includes lostincludes)
    (setq semanticdb-find-scanned-include-tags (reverse scannedincludes))

    ;; Find all the omniscient databases for this major mode, and
    ;; add them if needed
    (when (and (semanticdb-find-throttle-active-p 'omniscience)
	       semanticdb-search-system-databases)
      ;; We can append any mode-specific omniscience databases into
      ;; our search list here.
      (let ((systemdb semanticdb-project-system-databases)
	    (ans nil))
	(while systemdb
	  (setq ans (semanticdb-file-table
		     (car systemdb)
		     ;; I would expect most omniscient to return the same
		     ;; thing regardless of filename, but we may have
		     ;; one that can return a table of all things the
		     ;; current file needs.
		     (buffer-file-name (current-buffer))))
	  (when (not (memq ans matchedtables))
	    (setq matchedtables (cons ans matchedtables)))
	  (setq systemdb (cdr systemdb))))
      )
    (nreverse matchedtables)))