Anonymous avatar Anonymous committed 624eb6d

Update to semantic 1.3.1

Comments (0)

Files changed (7)

+2000-10-25  Steve Youngs  <youngs@xemacs.org>
+
+	* Import Semantic 1.3.1
+
 2000-10-19  Steve Youngs  <youngs@xemacs.org>
 
 	* Import Semantic 1.3.
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.02
-AUTHOR_VERSION = 1.3
+VERSION = 1.03
+AUTHOR_VERSION = 1.3.1
 MAINTAINER = Eric M. Ludlam <zappo@gnu.org>
 PACKAGE = semantic
 PKG_TYPE = regular
-REQUIRES = xemacs-base speedbar fsf-compat
+REQUIRES = semantic xemacs-base speedbar
 CATEGORY = prog
 
 ELCS = document-vars.elc document.elc semantic-bnf.elc semantic-c.elc \
 TEXI_FILES = $(PACKAGE).texi
 MANUAL = $(PACKAGE)
 
-PRELOADS = -eval "(setq load-path \
-			(nconc load-path \
-                           '((expand-file-name \"./\") \
-                                (expand-file-name \"../libs/fsf-compat/\"))))"
-
 include ../../XEmacs.rules
 
 GENERATED += custom-load.elc
 ;; EDE project file.
 (ede-proj-project "ede-proj-project"
   :name "semantic"
-  :version "1.3a"
+  :version "1.3.1"
   :file "Project.ede"
   :targets (list   (ede-proj-target-aux "misc"
     :name "misc"
   (kill-all-local-variables)
   (setq major-mode 'semantic-bnf-mode
 	mode-name "BNF")
+  (make-local-variable 'comment-start)
+  (setq comment-start "#")
+  (make-local-variable 'comment-start-skip)
+  (setq comment-start-skip "# *")
   (set-syntax-table semantic-bnf-syntax-table)
   (use-local-map semantic-bnf-map)
   (make-local-variable 'semantic-toplevel-bovine-table)

semantic-imenu.el

 Used to override function `imenu-default-goto-function' so that we can continue
 to use overlays to maintain the current position.
 Optional argument REST is some extra stuff."
-  (imenu-default-goto-function name (semantic-overlay-start position) rest))
+  (let ((os (semantic-overlay-start position)))
+    (if os
+	(imenu-default-goto-function name os rest)
+      ;; This should never happen, but check anyway.
+      (message "Imenu is out of date, try again. (internal bug)")
+      (setq imenu--index-alist nil))))
 
+(defun semantic-imenu-flush-fcn ()
+  "This function is called as a hook to clear the imenu cache.
+This is added to `semantic-before-toplevel-cache-flush-hook'."
+  (if (eq imenu-create-index-function 'semantic-create-imenu-index)
+      (setq imenu--index-alist nil))
+  (remove-hook 'semantic-before-toplevel-cache-flush-hook
+	       'semantic-imenu-flush-fcn))
 
 ;;;###autoload
 (defun semantic-create-imenu-index (&optional stream)
 Uses the output of the Semantic Bovinator to create the index.
 Optional argument STREAM STREAM is an optional stream of tokens used to create menus."
   (setq imenu-default-goto-function 'semantic-imenu-goto-function)
+  (add-hook 'semantic-before-toplevel-cache-flush-hook
+	    'semantic-imenu-flush-fcn nil t)
+  (semantic-create-imenu-index-1 stream))
+
+(defun semantic-create-imenu-index-1 (&optional stream)
+  "Create an imenu index for any buffer which supports Semantic.
+Uses the output of the Semantic Bovinator to create the index.
+Optional argument STREAM STREAM is an optional stream of tokens used to create menus."
   (let ((tokens (or stream (semantic-bovinate-toplevel t))))
     (if semantic-imenu-bucketize-file
 	(let ((buckets (semantic-bucketize
                                    (if parts
                                        (if (and semantic-imenu-bucketize-type-parts
                                                 semantic-imenu-bucketize-file)
-                                           (semantic-create-imenu-index parts)
+                                           (semantic-create-imenu-index-1 parts)
                                          (semantic-create-imenu-subindex
                                           (reverse parts))))))
                             index))
 		       (set-buffer streamorbuffer)
 		       (semantic-bovinate-toplevel))
 		   streamorbuffer))
-	(nl nil) (ts nil))
+	(nl nil))
     (while stream
       (if (funcall function (car stream))
 	  (setq nl (cons (car stream) nl)))
 		       (set-buffer streamorbuffer)
 		       (semantic-bovinate-toplevel))
 		   streamorbuffer))
-	(ts nil) (found nil))
+	(found nil))
     (while (and (not found) stream)
       (if (funcall function (car stream))
 	  (setq found (car stream)))
 	     (if f (find-file f))))
       nil
     (let ((s (semantic-fetch-overload 'find-nonterminal)))
-      (if s (funcall s token)
+      (if s (funcall s token parent)
 	(set-buffer (semantic-token-buffer token))
 	(let ((start (semantic-token-start token)))
 	  (if (numberp start)
   (if (not token)
       (setq token (car (semantic-find-nonterminal-by-overlay nil))))
   (let ((s (semantic-fetch-overload 'find-documentation)))
-    (if s (funcall s token)
+    (if s (funcall s token nosnarf)
       ;; No override.  Try something simple to find documentation nearby
       (save-excursion
 	(set-buffer (semantic-token-buffer token))
 
 ;;; Interactive Functions for bovination
 ;;
-(eval-when-compile (require 'pp))
+(eval-when-compile
+  (condition-case nil (require 'pp) (error nil)))
 
 (defun bovinate (&optional clear)
   "Bovinate the current buffer.  Show output in a temp buffer.
 
 (require 'working)
 (require 'semantic-util)
-(require 'overlay)
 
 (defgroup semantic nil
   "File and tag browser frame."
 
 ;;; Compatibility
 ;;
-(if (fboundp 'make-overlay)
+(if (featurep 'xemacs)
     (progn
-      (defalias 'semantic-make-overlay 'make-overlay)
-      (defalias 'semantic-overlay-put 'overlay-put)
-      (defalias 'semantic-overlay-get 'overlay-get)
-      (defalias 'semantic-overlay-delete 'delete-overlay)
-      (defalias 'semantic-overlays-at 'overlays-at)
-      (defalias 'semantic-overlays-in 'overlays-in)
-      (defalias 'semantic-overlay-buffer 'overlay-buffer)
-      (defalias 'semantic-overlay-start 'overlay-start)
-      (defalias 'semantic-overlay-end 'overlay-end)
-      (defalias 'semantic-overlay-next-change 'next-overlay-change)
-      (defalias 'semantic-overlay-previous-change 'previous-overlay-change)
+      (defalias 'semantic-overlay-live-p 'extent-live-p)
+      (defalias 'semantic-make-overlay 'make-extent)
+      (defalias 'semantic-overlay-put 'set-extent-property)
+      (defalias 'semantic-overlay-get 'extent-property)
+      (defalias 'semantic-overlay-delete 'delete-extent)
+      (defalias 'semantic-overlays-at 'extents-at)
+      (defalias 'semantic-overlays-in 'extents-in)
+      (defalias 'semantic-overlay-buffer 'extent-buffer)
+      (defalias 'semantic-overlay-start 'extent-start-position)
+      (defalias 'semantic-overlay-end 'extent-end-position)
+      (defalias 'semantic-overlay-next-change 'next-extent-change)
+      (defalias 'semantic-overlay-previous-change 'previous-extent-change)
+      (defalias 'semantic-overlay-lists
+	(lambda () (list (extent-list))))
       )
-  (defalias 'semantic-make-overlay 'make-extent)
-  (defalias 'semantic-overlay-put 'set-extent-property)
-  (defalias 'semantic-overlay-get 'get-extent-property)
-  (defalias 'semantic-overlay-delete 'delete-extent)
-  (defalias 'semantic-overlays-at 'extents-at)
-  (defalias 'semantic-overlays-in 'extents-in)
-  (defalias 'semantic-overlay-buffer 'extent-buffer)
-  (defalias 'semantic-overlay-start 'extent-start)
-  (defalias 'semantic-overlay-end 'extent-end)
-  (defalias 'semantic-overlay-next-change 'next-extent-change)
-  (defalias 'semantic-overlay-previous-change 'previous-extent-change)
+  (defalias 'semantic-overlay-live-p 'overlay-buffer)
+  (defalias 'semantic-make-overlay 'make-overlay)
+  (defalias 'semantic-overlay-put 'overlay-put)
+  (defalias 'semantic-overlay-get 'overlay-get)
+  (defalias 'semantic-overlay-delete 'delete-overlay)
+  (defalias 'semantic-overlays-at 'overlays-at)
+  (defalias 'semantic-overlays-in 'overlays-in)
+  (defalias 'semantic-overlay-buffer 'overlay-buffer)
+  (defalias 'semantic-overlay-start 'overlay-start)
+  (defalias 'semantic-overlay-end 'overlay-end)
+  (defalias 'semantic-overlay-next-change 'next-overlay-change)
+  (defalias 'semantic-overlay-previous-change 'previous-overlay-change)
+  (defalias 'semantic-overlay-lists 'overlay-lists)
   )
 
 (defvar semantic-edebug nil
 
 TOP-LEVEL ENTRIES:
 
- (\"NAME\" variable \"TYPE\" CONST DEFAULT-VALUE MODIFIERS [OPTSUFFIX] 
+ (\"NAME\" variable \"TYPE\" CONST DEFAULT-VALUE MODIFIERS [OPTSUFFIX]
            \"DOCSTRING\" OVERLAY)
    The definition of a variable, or constant.
    CONST is a boolean representing if this variable is considered a constant.
 (defvar semantic-flex-depth 0
   "Default flexing depth.
 This specifies how many lists to create tokens in.")
+(make-variable-buffer-local 'semantic-flex-depth)
 
 (defvar semantic-ignore-comments t
   "Default comment handling.
 t means to strip comments when flexing.  Nil means to keep comments
 as part of the token stream.")
+(make-variable-buffer-local 'semantic-ignore-comments)
 
 (defvar semantic-expand-nonterminal nil
   "Function to call for each returned Non-terminal.
 This function should behave as the function `semantic-bovinate-toplevel'.")
 (make-variable-buffer-local 'semantic-toplevel-bovinate-override)
 
+(defvar semantic-after-toplevel-bovinate-hook nil
+  "Hooks run after a toplevel token parse.
+It is not run if the toplevel parse command is called, and buffer does
+not need to be reparsed.
+For language specific hooks, make sure you define this as a local hook.")
+
+(defvar semantic-before-toplevel-cache-flush-hook nil
+  "Hooks run before the toplevel nonterminal cache is flushed.
+For language specific hooks, make sure you define this as a local hook.")
+
+(defvar semantic-reparse-needed-change-hook nil
+  "Hooks run when a user edit is detected as needing a reparse.
+For language specific hooks, make sure you define this as a local hook.")
+
+(defvar semantic-no-reparse-needed-change-hook nil
+  "Hooks run when a user edit is detected as not needing a reparse.
+If the hook returns non-nil, then declare that a reparse is needed.
+For language specific hooks, make sure you define this as a local hook.")
+
 
 ;;; Utility API functions
 ;;
 (defun semantic-clear-toplevel-cache ()
   "Clear the toplevel bovin cache for the current buffer."
   (interactive)
+  (run-hooks 'semantic-before-toplevel-cache-flush-hook)
   (setq semantic-toplevel-bovine-cache nil)
   ;; Nuke all semantic overlays.  This is faster than deleting based
   ;; on our data structure.
-  (let ((l (overlay-lists)))
+  (let ((l (semantic-overlay-lists)))
     (mapcar 'semantic-delete-overlay-maybe (car l))
     (mapcar 'semantic-delete-overlay-maybe (cdr l))
     )
 	   checkcache
 	   semantic-toplevel-bovine-cache-check)
       (semantic-clear-toplevel-cache))
-  (cond
-   (semantic-toplevel-bovinate-override
-    (funcall semantic-toplevel-bovinate-override checkcache))
-   ((and semantic-toplevel-bovine-cache
-	 (car semantic-toplevel-bovine-cache)
-	 ;; Add a rule that knows how to see if there have
-	 ;; been "big chagnes"
-	 )
-    (car semantic-toplevel-bovine-cache))
-   (t
-    (let ((ss (semantic-flex (point-min) (point-max)))
-	  (res nil)
-	  (semantic-overlay-error-recovery-stack nil))
-      ;; Init a dump
-      (if semantic-dump-parse (semantic-dump-buffer-init))
-      ;; Parse!
-      (working-status-forms (buffer-name) "done"
-	(setq res
-	      (semantic-bovinate-nonterminals
-	       ss 'bovine-toplevel semantic-flex-depth))
-	(working-status t))
-      (setq semantic-toplevel-bovine-cache
-	    (list (nreverse res) (point-max))
-	    semantic-toplevel-bovine-cache-check nil)
-      (add-hook 'after-change-functions 'semantic-change-function nil t)
-      (car semantic-toplevel-bovine-cache)))))
+  (prog1
+      (cond
+       (semantic-toplevel-bovinate-override
+	(funcall semantic-toplevel-bovinate-override checkcache))
+       ((and semantic-toplevel-bovine-cache
+	     (car semantic-toplevel-bovine-cache)
+	     ;; Add a rule that knows how to see if there have
+	     ;; been "big chagnes"
+	     )
+	(car semantic-toplevel-bovine-cache))
+       (t
+	(let ((ss (semantic-flex (point-min) (point-max)))
+	      (res nil)
+	      (semantic-overlay-error-recovery-stack nil))
+	  ;; Init a dump
+	  (if semantic-dump-parse (semantic-dump-buffer-init))
+	  ;; Parse!
+	  (working-status-forms (buffer-name) "done"
+	    (setq res
+		  (semantic-bovinate-nonterminals
+		   ss 'bovine-toplevel semantic-flex-depth))
+	    (working-status t))
+	  (setq semantic-toplevel-bovine-cache
+		(list (nreverse res) (point-max))
+		semantic-toplevel-bovine-cache-check nil)
+	  (add-hook 'after-change-functions 'semantic-change-function nil t)
+	  (run-hooks 'semantic-after-toplevel-bovinate-hook)
+	  (car semantic-toplevel-bovine-cache))))
+    ))
 
 (defun semantic-change-function (start end length)
   "Run whenever a buffer controlled by `semantic-mode' change.
 	      (if (and (eq (semantic-token-token (car tl)) 'type)
 		       (not (cdr tl))
 		       (semantic-token-type-parts (car tl)))
-		  ;; This is between two items in a type with
-		  ;; stuff in it.
-		  (setq semantic-toplevel-bovine-cache-check t)
-		;; This is ok, chuck it.
-		nil))
+		  (progn
+		    ;; This is between two items in a type with
+		    ;; stuff in it.
+		    (setq semantic-toplevel-bovine-cache-check t)
+		    (run-hooks 'semantic-reparse-needed-change-hook))
+		;; This is might be ok, chuck it.
+		(if (run-hooks 'semantic-no-reparse-needed-change-hook)
+		    (progn
+		      ;; The hook says so, so flush it.
+		      (setq semantic-toplevel-bovine-cache-check t)
+		      (run-hooks 'semantic-reparse-needed-change-hook))
+		  nil)))
 	     ;; If we  cover the beginning or end of this item, we must
 	     ;; reparse this object.
 	     (t
-	      (setq semantic-toplevel-bovine-cache-check t)))
+	      (setq semantic-toplevel-bovine-cache-check t)
+	      (run-hooks 'semantic-reparse-needed-change-hook)))
 	    ;; next
 	    (setq tl (cdr tl)))
 	;; There was no hit, perhaps we need to reparse this intermediate area.
 					     (car motok))
 			    ;; this will support new overlays created by
 			    ;; the special function, or recycles
-			    start (or (semantic-overlay-start
-				       (car startcdr)) start)
-			    end (or (semantic-overlay-end
-				     (car startcdr)) end)
+			    start (if (semantic-overlay-live-p (car startcdr))
+				      (semantic-overlay-start (car startcdr))
+				    start)
+			    end (if (semantic-overlay-live-p (car startcdr))
+				    (semantic-overlay-end (car startcdr))
+				  end)
 			    o (semantic-make-overlay start end
 						     (current-buffer)))
-		      (if (semantic-overlay-buffer (car startcdr))
+		      (if (semantic-overlay-live-p (car startcdr))
 			  (semantic-overlay-delete (semantic-token-overlay
 						    (car motok))))
 		      (semantic-overlay-stack-add o)
   "Updates to the syntax table for this buffer.
 These changes are active only while this file is being flexed.
 This is a list where each element is of the form:
-  (CHAR CLASS) 
+  (CHAR CLASS)
 Where CHAR is the char passed to `modify-syntax-entry',
 and CLASS is the string also passed to `modify-syntax-entry' to define
 what class of syntax CHAR is.")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.