   (setq	*ojs-buffers-functions-cache-regexp* nil)
   (setq *ojs-buffers-vars-cache* nil)
   (setq *ojs-buffers-vars-cache-regexp* nil))
+
+(defun pjs-reset-cache ()
+  (ojs-reset-cache)
+  (setq *pjs-buffers-class-members-cache* nil)
+  (setq *pjs-buffers-class-members-cache-regexp* nil))
 
 ;;;;; generic function to find candidates based on a regexp 
 ;;;;; it returns a candidates list containing cons (name . documentation) 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defconst *ojs-function-method-definition-regexp* 
  "^[ \t]*\\(?:function\\|method\\)[ \t]+\\(\\w+\\).*$")

;; contains list of cons (name . documentation)
;; used for autocomplete 

  (setq *ojs-buffers-functions-cache-regexp*
	(format "\\(%s\\)" (js--regexp-opt-symbol (loop for item in *ojs-buffers-functions-cache*
							 collect (car item))))))
;;;;; class members in ojs2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defconst *pjs-namespace-definition*
  "^\\s-*namespace\\s-+\\(\\w+\\);")

;; return the current namespace 
(defun pjs-current-namespace ()
  (save-excursion
    (let* ((found (re-search-backward *pjs-namespace-definition* nil t))
	   (namespace (when found (match-string-no-properties 1))))
      (while (and found
		  (not (eq (get-text-property (point) 'face) 'font-lock-keyword-face)))
	(setq found (re-search-backward *pjs-namespace-definition* nil t))
	(when found
	  (setq namespace (match-string-no-properties 1))))
      (if found namespace "plw"))))
  

;; contains list of cons (name . documentation)
;; used for autocomplete 
(defvar *pjs-buffers-class-members-cache* nil)
;; contains the master regexp for syntax highlighting
(defvar *pjs-buffers-class-members-cache-regexp* nil)


(defconst *pjs-class-declaration-regexp*
  "^\\s-*class\\s-+\\(\\w+\\)\\s-*{")

(defun pjs-class-members ()
  (or *pjs-buffers-class-members-cache*
      (progn (generate-pjs-class-members-cache)
	     *pjs-buffers-class-members-cache*)))

(defun pjs-class-members-regexp ()
  (or *pjs-buffers-class-members-cache-regexp*
      (progn (generate-pjs-class-members-cache)
	     *pjs-buffers-class-members-cache-regexp*)))

(defun generate-pjs-class-members-cache ()
  (save-excursion
    (goto-char (point-min))
    (unless (hash-table-p *pjs-buffers-class-members-cache*)
      (setq *pjs-buffers-class-members-cache* (make-hash-table :test 'equal)))
    (unless (hash-table-p *pjs-buffers-class-members-cache-regexp*)
      (setq *pjs-buffers-class-members-cache-regexp* (make-hash-table :test 'equal)))
    
    (while (re-search-forward *pjs-class-declaration-regexp* nil t)
      ;; we are at the beginning of a class
      (let* ((class-name (match-string-no-properties 1))
	     (namespace  (pjs-current-namespace))
	     (members    (when (fi::lep-open-connection-p) (fi:eval-in-lisp (format "(when (fboundp 'jvs::get-pjs-class-members) (jvs::get-pjs-class-members \"%s\" \"%s\"))" class-name namespace))))
	     )
	(when members
	  (puthash (format "%s.%s" namespace class-name) members *pjs-buffers-class-members-cache*)
	  (puthash (format "%s.%s" namespace class-name) (js--regexp-opt-symbol (loop for item in members
										      collect item))
		   *pjs-buffers-class-members-cache-regexp*)
	  )))))
	 
	 
;;;;; buffer dependant cache for script-level var definitions and global vars
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defconst *ojs-file-vars-regexp*  
  "^var\\s-+\\(\\w+\\)\\s-*\\(=\\|in\\|;\\).*$")

(defconst *pjs-file-vars-regexp*
  "^var\\s-*\\(?:[[:word:].]+\\)?\\s-+\\(\\w+\\)\\s-*[=;].*$")
;;  "^var\\s-+\\(\\w+\\)\\s-*\\(=\\|in\\|;\\).*$")

(defconst *ojs-global-vars-regexp*  
  "^\\s-*global\\s-+var\\s-+\\(\\w+\\)\\s-*\\(=\\|in\\|;\\).*$")

;; used for autocomplete 
(defvar *ojs-buffers-vars-cache* nil)
