[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 3b6eb46d4c 129/135: Added new MVP bookkeeping
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 3b6eb46d4c 129/135: Added new MVP bookkeeping and imenu test |
Date: |
Sun, 29 Jan 2023 03:11:11 -0500 (EST) |
branch: externals/phps-mode
commit 3b6eb46d4c8216a3fd341320db038510857be3c3
Author: christian <christian@cvj.se>
Commit: christian <christian@cvj.se>
Added new MVP bookkeeping and imenu test
---
phps-mode-parser-sdt.el | 104 ++++++++++++++++++++++++---------------------
test/phps-mode-test-ast.el | 10 +++--
2 files changed, 61 insertions(+), 53 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 220d74e7bd..b44ca19edf 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -663,13 +663,15 @@
phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
(list
name
- (list 'namespace nil 'class nil 'trait nil 'interface nil 'function nil
'superglobal t))
+ (list 'namespace nil 'class nil 'trait nil 'interface nil 'function nil
'superglobal t 'object-operator nil 'static-member nil))
(let ((potential-uris (list ""))
(scope-namespace)
(scope-class)
(scope-trait)
(scope-interface)
- (scope-function))
+ (scope-function)
+ (scope-object-operator)
+ (scope-static-member))
(when scope
(let ((scope-count (length scope))
(scope-index 0))
@@ -700,10 +702,12 @@
((equal next-scope-type 'global)
(setq next-scope-is-global t))
((equal next-scope-type 'object-operator)
+ (setq scope-object-operator (car (cdr next-scope)))
(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)
+ (setq scope-static-member t)
(let ((downcased-scope-name (downcase (car (cdr
next-scope)))))
(when (or
(string= downcased-scope-name "self")
@@ -864,10 +868,10 @@
(if matching-uri
(list
matching-uri
- (list 'namespace scope-namespace 'class scope-class 'trait
scope-trait 'interface scope-interface 'function scope-function 'superglobal
nil))
+ (list 'namespace scope-namespace 'class scope-class 'trait
scope-trait 'interface scope-interface 'function scope-function 'superglobal
nil 'object-operator scope-object-operator 'static-member scope-static-member))
(list
(nth 0 potential-uris)
- (list 'namespace scope-namespace 'class scope-class 'trait
scope-trait 'interface scope-interface 'function scope-function 'superglobal
nil)))))))
+ (list 'namespace scope-namespace 'class scope-class 'trait
scope-trait 'interface scope-interface 'function scope-function 'superglobal
nil 'object-operator scope-object-operator 'static-member
scope-static-member)))))))
(defun phps-mode-parser-sdt--parse-top-statement ()
"Parse latest top statement."
@@ -1164,7 +1168,7 @@
(symbol-interface)
(symbol-trait)
(symbol-function)
- (symbol-superglobal)
+ (symbol-is-superglobal)
(symbol-is-this (string= (downcase symbol-name) "$this")))
;; Collect namespace, class, interface, trait and function here
@@ -1179,7 +1183,7 @@
(when (nth 9 (nth 1 symbol-uri-object))
(setq symbol-function (car (nth 9 (nth 1 symbol-uri-object)))))
(when (nth 11 (nth 1 symbol-uri-object))
- (setq symbol-superglobal t))
+ (setq symbol-is-superglobal t))
;; (message "\nsymbol-name: %S" symbol-name)
;; (message "symbol-scope: %S" symbol-scope)
@@ -1189,15 +1193,12 @@
;; (message "symbol-interface: %S" symbol-interface)
;; (message "symbol-function: %S" symbol-function)
- ;; TODO detect if symbol is super-global
- ;; TODO detect if symbol is $this, self, static
-
;; Place symbol in imenu if not there already
;; and is not superglobal
;; and is not $this
(unless (or
- symbol-superglobal
- symbol-is-this)
+ symbol-is-this
+ symbol-is-superglobal)
(cond
;; Symbol is inside namespace
@@ -1592,46 +1593,51 @@
symbol-name
symbol-scope))
(symbol-uri (car symbol-uri-object))
+ (symbol-object-operator
+ (nth 13 (nth 1 symbol-uri-object)))
(symbol-hit 0))
- (cond
-
- ;; Super-global variable
- ((gethash
- symbol-name
- phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
- (setq symbol-hit -1))
+ (unless (and
+ symbol-object-operator
+ (not (string= (downcase symbol-object-operator) "$this")))
+ (cond
- ;; Declared variable
- ((gethash
- symbol-uri
- phps-mode-parser-sdt-symbol-table-by-uri)
- ;; (message "matches: %S" (gethash
- ;; symbol-uri
- ;; phps-mode-parser-sdt-symbol-table-by-uri))
- (let* ((matching-symbol-ids
- (gethash
- symbol-uri
- phps-mode-parser-sdt-symbol-table-by-uri))
- (matching-symbol-index 0)
- (matching-symbol-count (length matching-symbol-ids))
- (matching-hit))
- (while (and
- (not matching-hit)
- (< matching-symbol-index matching-symbol-count))
- (let* ((matching-symbol-id
- (nth matching-symbol-index matching-symbol-ids))
- (matching-symbol
- (gethash
- matching-symbol-id
- phps-mode-parser-sdt-symbol-table))
- (matching-symbol-start
- (nth 1 matching-symbol)))
- ;; (message "matching-symbol: %S" matching-symbol)
- ;; (message "matching-symbol-start: %S" matching-symbol-start)
- (when (<= matching-symbol-start symbol-start)
- (setq matching-hit t)
- (setq symbol-hit matching-symbol-id)))
- (setq matching-symbol-index (1+ matching-symbol-index))))))
+ ;; Super-global variable
+ ((gethash
+ symbol-name
+ phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
+ (setq symbol-hit -1))
+
+ ;; Declared variable
+ ((gethash
+ symbol-uri
+ phps-mode-parser-sdt-symbol-table-by-uri)
+ ;; (message "matches: %S" (gethash
+ ;; symbol-uri
+ ;; phps-mode-parser-sdt-symbol-table-by-uri))
+ (let* ((matching-symbol-ids
+ (gethash
+ symbol-uri
+ phps-mode-parser-sdt-symbol-table-by-uri))
+ (matching-symbol-index 0)
+ (matching-symbol-count (length matching-symbol-ids))
+ (matching-hit))
+ (while (and
+ (not matching-hit)
+ (< matching-symbol-index matching-symbol-count))
+ (let* ((matching-symbol-id
+ (nth matching-symbol-index matching-symbol-ids))
+ (matching-symbol
+ (gethash
+ matching-symbol-id
+ phps-mode-parser-sdt-symbol-table))
+ (matching-symbol-start
+ (nth 1 matching-symbol)))
+ ;; (message "matching-symbol: %S" matching-symbol)
+ ;; (message "matching-symbol-start: %S"
matching-symbol-start)
+ (when (<= matching-symbol-start symbol-start)
+ (setq matching-hit t)
+ (setq symbol-hit matching-symbol-id)))
+ (setq matching-symbol-index (1+ matching-symbol-index)))))))
(puthash
(list
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index ee8d1bf6ae..3e77798291 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -217,10 +217,12 @@
'(((7 9) 1) ((15 19) 3) ((25 27) 2) ((32 34) 2) ((37 39) 1) ((41 43) 4)
((49 52) 7) ((58 61) 6) ((69 72) 5) ((77 80) 6) ((83 86) 5) ((89 91) 4) ((102
105) 8) ((110 113) 8) ((115 118) 9) ((144 147) 9) ((152 155) 10) ((165 168) 10)
((174 177) 11) ((182 185) 11) ((191 194) 12) ((199 202) 12) ((207 210) 13)
((215 220) 14) ((225 230) 14))
'(("$y" . 7) ("$fn1" . 15) ("$x" . 25) ("$z" . 41) ("$fn" . 49) ("$x2" .
58) ("$y2" . 69) ("$x3" . 102) ("$x4" . 115) ("$x5" . 152) ("$x6" . 174) ("$x7"
. 191) ("$x8" . 207) ("$rest" . 215)))
- ;; (phps-mode-test-ast--should-bookkeep
- ;; "<?php\n$z = (object) array('name' => 'random');\nif ($z->name) {\n
echo 'Hit';\n}"
- ;; "Bookkeeping ignoring variable properties"
- ;; '((" id $z" 1) ((7 9) 1) ((52 54) 1)))
+ ;; TODO Make this pass for MVP
+ (phps-mode-test-ast--should-bookkeep
+ "<?php\n$z = (object) ['name' => 'random', 'doThis' => function() {}];\nif
($z->name) {\n echo 'Hit';\n}\nif ($z->doThis()) {\n echo 'Hit';\n}"
+ "Bookkeeping ignoring variable properties that is not $this"
+ '(((7 9) 1) ((74 76) 1) ((108 110) 1))
+ '(("$z" . 7)))
(phps-mode-test-ast--should-bookkeep
"<?php\nif (!$var = false) {\n echo 'Hit';\n}\n"
- [elpa] externals/phps-mode a10656fc34 070/135: Passing bookkeeping test for global variables, (continued)
- [elpa] externals/phps-mode a10656fc34 070/135: Passing bookkeeping test for global variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 9c67facc86 075/135: Work on bookkeeping of class static properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 39a6fe03ae 079/135: Improved is-varadic and is-reference argument flags, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e8a5dbe153 126/135: Fix for trait and interface imenu, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 579034d1c6 127/135: Passing imenu test via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode fb9a181135 088/135: Passed more bookkeeping tsts, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e6bc401d0b 068/135: Work on improving test for global variable bookkeeping, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 4949daefd9 101/135: Passing another SDT imenu test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode c0c37bafd9 110/135: Added some TODO items, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 76ef8cceac 124/135: More fixes in code, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 3b6eb46d4c 129/135: Added new MVP bookkeeping and imenu test,
Christian Johansson <=
- [elpa] externals/phps-mode f9ddef260c 039/135: Passing first bookkeeping test using SDT generated bookkeeping, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode fb42b49970 044/135: Added more TODO items, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode dd2fadefe7 048/135: Bookkeeping class properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 804a0dbdb9 074/135: Added static uri for symbol names, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7bb676dc8b 076/135: Bookkeeping for anonymous function passing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode f86d8dc6ac 078/135: More work on arrow function variable uri, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 787aaa2bb4 081/135: Passing another bookkeeping test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 66c02b9be1 083/135: Passing test for bookkeeping of interface variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1afe6aaec7 086/135: Passing more tests for static variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d456658676 089/135: Passing bookkeeping test for $this inside arrow function, Christian Johansson, 2023/01/29