 	  (let ((class-name (or (match-string-no-properties 3)
 				(match-string-no-properties 1)))
 		(namespace  (pjs-current-namespace)))
-	    (format "%s.%s" namespace class-name)))))))
-  
-
+	    (cons namespace class-name)))))))
+  
 (defun class-members-in-function ()
-  (gethash (pjs-current-class) (pjs-class-members-regexp)))
+  (let ((type (pjs-current-class)))
+    (when type
+      (pjs-class-members-regexp (car type) (cdr type)))))
 
 (defun search-class-members (end)
   (search-vars-in-context end 'class-members-in-function))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; highlight method / members depending on variable type
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;; get the variable type from context :
+;; if the variable is local to the function, search a var <type> varname =
+;; TODO: if it is a global var of the namespace, check its type
+;; TODO: if it is a member of a classe, check the type from the class.
+(defun get-variable-type-in-context (varname)
+  (let ((context (get-local-function-environment)))
+    (when context
+      (second (gethash (downcase varname) (getf context :vars))))))
+
+(defconst *pjs-vars-with-members-or-methods*
+  "\\<\\(\\w+\\)\\>\\.\\<\\w[[:word:]0-9]*\\>\\((\\)")
+
+(defconst *pjs-standard-types*
+  '("string"
+    "boolean"
+    "number"
+    "vector"
+    "array"
+    "hashtable"))
+
+(defun convert-pjs-type (type)
+  (cond ((member type *pjs-standard-types*)
+	 (cons "plw" type))
+	(t
+	 (let ((strings (split-string type ".")))
+	   (cond ((= (length strings 1))
+		  (cons (pjs-current-namespace) (car strings)))
+		 (t
+		  (cons (car strings) (second strings))))))))
+
+(defun search-vars-with-members-or-methods (end)
+  (let ((match-data (match-data))
+	continue)
+    (if (catch 'exit
+	  (while (re-real-search-forward *pjs-vars-with-members-or-methods* end t)
+	    (let* ((var-name (match-string-no-properties 1))
+		   (member   (match-string-no-properties 2))
+		   (type     (convert-pjs-type (get-variable-type-in-context var-name))))
+	      (when type
+		(let ((members (pjs-class-members (car type) (cdr type)))
+		      (methods (pjs-class-methods (car type) (cdr type))))
+		  (when (or (member member members)
+			    (member member methods))
+		    (throw 'exit (point))))))))
+	(progn (set-match-data match-data)
+	       nil))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; syntax hightlighting definition

;;;; (:require-patch "")
;;;; HISTORY :
;;;; $Log$
;;;; Revision 3.4  2015/12/18 15:09:40  troche
;;;; * better syntax colorations
;;;;

  (when (list-pjs-kernel-functions)
    (let ((search-pattern (list-pjs-kernel-functions)))
      (re-real-search-forward search-pattern end t))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; highlight class members 
