branch: externals/phps-mode
commit 9c67facc8673fc55152565e3c4763e7433994e39
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Work on bookkeeping of class static properties
---
phps-mode-parser-sdt.el | 232 ++++++++++++++++++++++++++----------------------
1 file changed, 124 insertions(+), 108 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 2f93d6bfd8..307086b390 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -634,116 +634,132 @@
name
(let ((potential-uris (list "")))
(when scope
- (dolist (item scope)
- (let ((space-type (car item))
- (space-name (car (cdr item))))
- (cond
-
- ((equal space-type 'namespace)
- (let ((potential-uri-count (length potential-uris))
- (potential-uri-index 0))
- (while (< potential-uri-index potential-uri-count)
- (setf
- (nth potential-uri-index potential-uris)
- (format " namespace %s%s" space-name (nth
potential-uri-index potential-uris)))
- (setq potential-uri-index (1+ potential-uri-index)))))
-
- ((equal space-type 'class)
- (let ((potential-uri-count (length potential-uris))
- (potential-uri-index 0))
- (while (< potential-uri-index potential-uri-count)
- (setf
- (nth potential-uri-index potential-uris)
- (format " class %s%s" space-name (nth potential-uri-index
potential-uris)))
- (setq potential-uri-index (1+ potential-uri-index)))))
-
- ((equal space-type 'interface)
- (let ((potential-uri-count (length potential-uris))
- (potential-uri-index 0))
- (while (< potential-uri-index potential-uri-count)
- (setf
- (nth potential-uri-index potential-uris)
- (format " interface %s%s" space-name (nth
potential-uri-index potential-uris)))
- (setq potential-uri-index (1+ potential-uri-index)))))
-
- ((equal space-type 'trait)
- (let ((potential-uri-count (length potential-uris))
- (potential-uri-index 0))
- (while (< potential-uri-index potential-uri-count)
- (setf
- (nth potential-uri-index potential-uris)
- (format " trait %s%s" space-name (nth potential-uri-index
potential-uris)))
- (setq potential-uri-index (1+ potential-uri-index)))))
-
- ((equal space-type 'function)
- (let ((potential-uri-count (length potential-uris))
- (potential-uri-index 0))
- (while (< potential-uri-index potential-uri-count)
- (setf
- (nth potential-uri-index potential-uris)
- (format " function %s%s" space-name (nth
potential-uri-index potential-uris)))
- (setq potential-uri-index (1+ potential-uri-index)))))
-
- ((equal space-type 'anonymous-function)
- (let ((potential-uri-count (length potential-uris))
- (potential-uri-index 0))
- (while (< potential-uri-index potential-uri-count)
- (setf
- (nth potential-uri-index potential-uris)
- (format " anonymous %s%s" space-name (nth
potential-uri-index potential-uris)))
- (setq potential-uri-index (1+ potential-uri-index)))))
-
- ((equal space-type 'static)
- (let ((potential-uri-count (length potential-uris))
- (potential-uri-index 0))
- (while (< potential-uri-index potential-uri-count)
- (setf
- (nth potential-uri-index potential-uris)
- (format " static%s" (nth potential-uri-index
potential-uris)))
- (setq potential-uri-index (1+ potential-uri-index)))))
-
- ((equal space-type 'arrow-function)
- ;; TODO Should branch of two here one with and one without the
arrow function scope
- (let ((potential-uri-count (length potential-uris))
- (potential-uri-index 0))
- (while (< potential-uri-index potential-uri-count)
- (setf
- (nth potential-uri-index potential-uris)
- (format " anonymous %s%s" space-name (nth
potential-uri-index potential-uris)))
- (setq potential-uri-index (1+ potential-uri-index)))))
-
- ;; TODO Below should alter symbol namespaces instead of build
namespace data
- ((equal space-type 'global)
- (setq namespace nil)
- (setq class nil)
- (setq function nil)
- (setq arrow-function nil)
- (setq anonymous-function nil))
-
- ((equal space-type 'object-operator)
- (let ((downcased-space-name
- (downcase space-name)))
+ (let ((scope-count (length scope))
+ (scope-index 0))
+ (while (< scope-index scope-count)
+ (let ((item (nth scope-index scope))
+ (next-scope)
+ (next-scope-type)
+ (next-scope-is-this-object-operator)
+ (next-scope-is-self-static-member-operator))
+
+ ;; Should add one scope look-ahead to determine if we should
+ ;; ignore function scope before a $this-> or self:: or static::
operator
+ (when (< scope-index (1- scope-count))
+ (setq next-scope (nth (1+ scope-index) scope))
+ (setq next-scope-type (car next-scope))
(cond
- ((string= downcased-space-name "$this")
- (setq function nil))
- (t
- ;; TODO Do something here
- ))))
-
- ((equal space-type 'static-member)
- (let ((downcased-space-name
- (downcase space-name)))
+ ((equal next-scope-type 'object-operator)
+ (let ((downcased-scope-name (downcase (car (cdr
next-scope)))))
+ (when (string= downcased-scope-name "$this")
+ (setq next-scope-is-this-object-operator t))))
+ ((equal next-scope-type 'static-member)
+ (let ((downcased-scope-name (downcase (car (cdr
next-scope)))))
+ (when (or
+ (string= downcased-scope-name "self")
+ (string= downcased-scope-name "static"))
+
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " static%s" (nth potential-uri-index
potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index))))
+
+ (setq next-scope-is-self-static-member-operator t))))))
+
+ (let ((space-type (car item))
+ (space-name (car (cdr item))))
(cond
- ((or
- (string= downcased-space-name "self")
- (string= downcased-space-name "static"))
- (setq is-static-p t)
- (setq function nil))
- (t
- ;; TODO Do something here
- ))))
-
- ))))
+
+ ((equal space-type 'namespace)
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " namespace %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index)))))
+
+ ((equal space-type 'class)
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " class %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index)))))
+
+ ((equal space-type 'interface)
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " interface %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index)))))
+
+ ((equal space-type 'trait)
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " trait %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index)))))
+
+ ((and
+ (equal space-type 'function)
+ (not (or
+ next-scope-is-this-object-operator
+ next-scope-is-self-static-member-operator)))
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " function %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index)))))
+
+ ((equal space-type 'anonymous-function)
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " anonymous %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index)))))
+
+ ((equal space-type 'static)
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " static%s" (nth potential-uri-index
potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index)))))
+
+ ((equal space-type 'arrow-function)
+ ;; TODO Should branch of two here one with and one without
the arrow function scope
+ (let ((potential-uri-count (length potential-uris))
+ (potential-uri-index 0))
+ (while (< potential-uri-index potential-uri-count)
+ (setf
+ (nth potential-uri-index potential-uris)
+ (format " anonymous %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (setq potential-uri-index (1+ potential-uri-index)))))
+
+ ;; TODO Below should alter symbol namespaces instead of build
namespace data
+ ((equal space-type 'global)
+ (setq namespace nil)
+ (setq class nil)
+ (setq function nil)
+ (setq arrow-function nil)
+ (setq anonymous-function nil))
+
+ )))
+ (setq scope-index (1+ scope-index)))))
(let ((potential-uri-count (length potential-uris))
(potential-uri-index 0)