[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 8a3492da41 09/12: Improved bookkeeping of ref
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 8a3492da41 09/12: Improved bookkeeping of referenced variable |
Date: |
Sun, 5 Feb 2023 03:06:14 -0500 (EST) |
branch: externals/phps-mode
commit 8a3492da41877a1d2d5b3467ef2ce146192145d4
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Improved bookkeeping of referenced variable
---
phps-mode-parser-sdt.el | 42 +++++++++++-------------------------------
test/phps-mode-test-ast.el | 16 +++++++++++-----
2 files changed, 22 insertions(+), 36 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 7d0bfe8c7c..4f9804b375 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -5393,59 +5393,35 @@
360
(lambda(args terminals)
;; Save variable declaration in bookkeeping buffer
- (let ((variable-type1 (plist-get (nth 0 args) 'ast-type))
- (variable-type2 (plist-get (nth 3 args) 'ast-type)))
+ (let ((variable-type1 (plist-get (nth 0 args) 'ast-type)))
(cond
- ((and
- (equal variable-type1 'variable-callable-variable)
- (equal variable-type2 'variable-callable-variable))
+ ((equal variable-type1 'variable-callable-variable)
(let* ((callable-variable1 (plist-get (nth 0 args) 'callable-variable))
- (callable-variable-type1 (plist-get callable-variable1
'ast-type))
- (callable-variable2 (plist-get (nth 3 args) 'callable-variable))
- (callable-variable-type2 (plist-get callable-variable2
'ast-type)))
+ (callable-variable-type1 (plist-get callable-variable1
'ast-type)))
(cond
- ((and
- (equal callable-variable-type1 'callable-variable-simple-variable)
- (equal callable-variable-type2 'callable-variable-simple-variable))
+ ((equal callable-variable-type1 'callable-variable-simple-variable)
(let* ((callable-variable-simple-variable1
(plist-get callable-variable1 'simple-variable))
(callable-variable-simple-variable-type1
(plist-get
callable-variable-simple-variable1
- 'ast-type))
- (callable-variable-simple-variable2
- (plist-get callable-variable2 'simple-variable))
- (callable-variable-simple-variable-type2
- (plist-get
- callable-variable-simple-variable2
'ast-type)))
(cond
- ((and
- (equal
- callable-variable-simple-variable-type1
- 'simple-variable-variable)
- (equal
- callable-variable-simple-variable-type2
- 'simple-variable-variable))
+ ((equal
+ callable-variable-simple-variable-type1
+ 'simple-variable-variable)
(let* ((variable-name1
(plist-get
callable-variable-simple-variable1
'variable))
- (variable-name2
- (plist-get
- callable-variable-simple-variable2
- 'variable))
(symbol-name1
variable-name1)
- (symbol-name2
- variable-name2)
(symbol-start
(car (cdr (car terminals))))
(symbol-end
(cdr (cdr (car terminals))))
(symbol-scope
phps-mode-parser-sdt--bookkeeping-namespace))
- (push `(reference ,symbol-name2) symbol-scope)
(push
(list
symbol-name1
@@ -7204,6 +7180,7 @@
(cond
((equal constant-name-type 'string-name)
+ ;; BLAHA
;; TODO When reading this symbol should check global namespace
;; and namespace constants for hit
(let ((symbol-scope phps-mode-parser-sdt--bookkeeping-namespace))
@@ -7217,10 +7194,12 @@
phps-mode-parser-sdt--bookkeeping-symbol-stack)))
((equal constant-name-type 'qualified-name)
+ ;; BLAHA\BLAHA
;; TODO Handle this
)
((equal constant-name-type 'fully-qualified-name)
+ ;; \BLAHA
(let* ((constant-namespace)
(string-pos 0)
(namespace-pos
@@ -7252,6 +7231,7 @@
phps-mode-parser-sdt--bookkeeping-symbol-stack)))
((equal constant-name-type 'relative-name)
+ ;; namespace\A inside namespace X\Y resolves to X\Y\A.
;; TODO Handle this
)
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 2362f06d2c..5e96cf133b 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -134,11 +134,11 @@
;; TODO v2 Should properly bookkeep inside potentially endlessly nested
anonymous functions / arrow functions / anonymous classes
;; TODO v2 bookkeep and include all kind of constants in imenu
- (phps-mode-test-ast--should-bookkeep
- "<?php\n\nnamespace mySpace\n{\n define('MY_CONSTANT', 'abc123');\n
const MY_CONSTANT2 = 'def456';\n\n if (\\MY_CONSTANT) {\n echo
'hit';\n }\n if (MY_CONSTANT) {\n echo 'hit';\n }\n if
(MY_CONSTANT2) {\n echo 'hit';\n }\n if (\\mySpace\\MY_CONSTANT2)
{\n echo 'hit';\n }\n\n if (\\YOUR_CONSTANT) {\n echo
'miss';\n }\n if (YOUR_CONSTANT) {\n echo 'miss';\n }\n if
(\\MY_CONSTANT2) {\n echo 'mis [...]
- "Constants in all possible scopes"
- '(((159 170) 1) ((208 220) 1) ((371 384) 0) ((848 862) 5) ((900 911) 1)
((1000 1011) 1))
- '(("abc")))
+ ;; (phps-mode-test-ast--should-bookkeep
+ ;; "<?php\n\nnamespace mySpace\n{\n define('MY_CONSTANT', 'abc123');\n
const MY_CONSTANT2 = 'def456';\n\n if (\\MY_CONSTANT) {\n echo
'hit';\n }\n if (MY_CONSTANT) {\n echo 'hit';\n }\n if
(MY_CONSTANT2) {\n echo 'hit';\n }\n if (\\mySpace\\MY_CONSTANT2)
{\n echo 'hit';\n }\n\n if (\\YOUR_CONSTANT) {\n echo
'miss';\n }\n if (YOUR_CONSTANT) {\n echo 'miss';\n }\n if
(\\MY_CONSTANT2) {\n echo ' [...]
+ ;; "Constants in all possible scopes"
+ ;; '(((159 170) 1) ((208 220) 1) ((371 384) 0) ((848 862) 5) ((900 911) 1)
((1000 1011) 1))
+ ;; '(("abc")))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$var = 'abc';\n\nif ($var2) {\n echo 'This never
happens';\n}\nif ($var) {\n echo 'This happens';\n}"
@@ -158,6 +158,12 @@
'(((8 12) 1) ((21 25) 2) ((30 34) 1) ((40 44) 2))
'(("$abc" . 8) ("$var" . 21)))
+ (phps-mode-test-ast--should-bookkeep
+ "<?php\n\n$var = ['abc' => 123];\n\n$ref = &$var['abc'];"
+ "Bookkeeping in root level variable assignments #4"
+ '(((8 12) 1) ((32 36) 2) ((40 44) 1))
+ '(("$var" . 8) ("$ref" . 32)))
+
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$var2 = 4;\n\nfunction myFunction($var)\n{\n $var3 = 3;\n
if ($var) {\n echo 'Hit';\n }\n if ($var2) {\n echo
'Miss';\n }\n if ($var3) {\n echo 'Hit';\n }\n}\n\nfunction
myFunction2($abc)\n{\n if ($var) {\n echo 'Miss';\n }\n if
($abc) {\n echo 'Hit';\n }\n}\n\nif ($var) {\n echo 'Miss';\n}\nif
($var2) {\n echo 'Hit';\n}"
"Bookkeeping in function level with variable assignments"
- [elpa] externals/phps-mode updated (a1aaad619a -> f13607bf1e), Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode d4832bfb92 05/12: Added flag to control display of profiling information, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode ee28b83099 01/12: Added support for bookkeeping and imenu for list() variable assignment, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode f6004f1b37 04/12: Added profiling outputs, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode 8f0b9459c4 07/12: More work on bookkeeping constants, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode 1e659967a8 08/12: More work on constants bookkeeping, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode 8a3492da41 09/12: Improved bookkeeping of referenced variable,
Christian Johansson <=
- [elpa] externals/phps-mode 541111abf7 03/12: More work on bookkeeping class constants, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode f13607bf1e 12/12: Updated version to 0.4.34, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode 7c2b17a4b6 06/12: Added new todo items, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode a034b63d56 02/12: Started on bookkeeping global constants, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode a9241a9b67 10/12: Added constants bookkeeping and imenu test again, Christian Johansson, 2023/02/05
- [elpa] externals/phps-mode 7f504111eb 11/12: Commented out work on bookkeeping constants, Christian Johansson, 2023/02/05