[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 7609f09f04 090/135: More bookkeeping final to
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 7609f09f04 090/135: More bookkeeping final touches |
Date: |
Sun, 29 Jan 2023 03:11:07 -0500 (EST) |
branch: externals/phps-mode
commit 7609f09f043627f9ff487b8eb358d65224822b99
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More bookkeeping final touches
---
phps-mode-parser-sdt.el | 40 ++++++++++++++++++++++++++++------------
test/phps-mode-test-ast.el | 6 ++++--
2 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 7904d8ccf4..5054cbacac 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -667,13 +667,14 @@
(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))))
+ (when (equal next-scope-index (1+ scope-index))
+ (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)))))))
@@ -3323,6 +3324,7 @@
(attributed-class-statement-type
(plist-get attributed-class-statement 'ast-type)))
(cond
+ ;; Property
((equal attributed-class-statement-type 'property)
(let ((property-list
(plist-get attributed-class-statement 'subject))
@@ -3336,7 +3338,9 @@
(let ((property-type
(plist-get property 'ast-type)))
(cond
- ((equal property-type 'property-variable)
+ ((or
+ (equal property-type 'property-variable)
+ (equal property-type 'property-assigned-variable))
(let ((symbol-name
(plist-get property 'variable))
(symbol-start
@@ -3353,7 +3357,14 @@
symbol-scope
symbol-start
symbol-end)
-
phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack))))))))
+ phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack)
+ (push
+ (list
+ symbol-name
+ symbol-scope
+ symbol-start
+ symbol-end)
+ phps-mode-parser-sdt--bookkeeping-symbol-stack))))))))
;; Method Declaration
((equal attributed-class-statement-type 'method)
@@ -3400,8 +3411,6 @@
(plist-get attributed-class-statement 'ast-end))
phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack))
- ;; TODO if we have a arrow function scope function should come
before it (to the right)
-
;; Add function scope to symbol assignments
(when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
(dolist (
@@ -3470,7 +3479,14 @@
symbol-scope
symbol-start
symbol-end)
-
phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack)))))))))))
+ phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack)
+ (push
+ (list
+ symbol-name
+ symbol-scope
+ symbol-start
+ symbol-end)
+ phps-mode-parser-sdt--bookkeeping-symbol-stack)))))))))))
`(
ast-type
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 091167e56a..f5c1c25482 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -236,7 +236,7 @@
(phps-mode-test-ast--should-bookkeep
"<?php\n\nnamespace myNamespaceA {\n $var = 123;\n class myClassA {\n
private $var2 = 123;\n public static function myFunctionA($var3)
{\n $var4 = 123;\n if ($var) {\n echo
'Miss';\n }\n if ($var2) {\n echo
'Miss';\n }\n if ($var3) {\n echo 'Hit';\n
}\n if ($var4) {\n echo 'Hit';\n
}\n }\n\n fun [...]
"Bookkeeping in maximum level with namespaces, classes and functions."
- '((" namespace myNamespaceA id $var" ((37 41))) ((37 41) 1) (" namespace
myNamespaceA class myClassA function myFunctionB id $var5" ((485 490))) ("
namespace myNamespaceA class myClassA function myFunctionB id $this" ((500
941))) (" namespace myNamespaceA class myClassA function myFunctionB id $var6"
((514 519))) (" namespace myNamespaceA class myClassA function myFunctionA id
$var3" ((142 147))) (" namespace myNamespaceA class myClassA function
myFunctionA id $var4" ((163 168))) (" n [...]
+ '((" namespace myNamespaceA id $var" ((37 41))) ((37 41) 1) (" namespace
myNamespaceA class myClassA function myFunctionB id $var5" ((485 490))) ("
namespace myNamespaceA class myClassA function myFunctionB id $this" ((500
941))) (" namespace myNamespaceA class myClassA function myFunctionB id $var6"
((514 519))) (" namespace myNamespaceA class myClassA function myFunctionA id
$var3" ((142 147))) (" namespace myNamespaceA class myClassA function
myFunctionA id $var4" ((163 168))) (" n [...]
(phps-mode-test-ast--should-bookkeep
"<?php\n\n// Conditional assignments\n\n$items = array(1, 2, 3);\nforeach
($items as $item) {\n if ($item) {\n echo 'Hit';\n }\n}\nforeach
($items as $key => $value) {\n if ($key || $value) {\n echo 'Hit';\n
}\n}\nfor ($i = 0; $i < count($items); $i++) {\n if ($i) {\n echo
'Hit';\n }\n}\nif ($a = 123) {\n if ($a) {\n echo 'Hit';\n
}\n}\nwhile ($b = 123) {\n if ($a) {\n echo 'Hit';\n }\n}\ndo {\n
echo 'Hit';\n} while ( [...]
@@ -246,7 +246,7 @@
(phps-mode-test-ast--should-bookkeep
"<?php\n\n// Class properties\n\nclass myParent {}\n\nclass myClass extends
myParent {\n private $var1 = 123;\n protected static $var2;\n public
$var3;\n var $var4;\n function __construct() {\n if ($this) {\n
echo 'Hit';\n }\n if ($this->var1) {\n echo
'Hit';\n }\n if (self::$var1) {\n echo 'Miss';\n
}\n if (self::$var2) {\n echo 'Hit';\n }\n if
(static::$var2) {\n [...]
"Bookkeeping of class properties"
- '((" class myClass function __construct id $this" ((194 743))) (" class
myClass id $var4" ((160 165))) (" class myClass id $var3" ((145 150))) (" class
myClass static id $var2" ((127 132))) (" class myClass id $var1" ((93 98)))
((639 643) 0) ((632 637) 1) ((578 582) 1) ((571 576) 1) ((517 521) 1) ((510
515) 1) ((455 460) 1) ((392 397) 1) ((330 335) 0) ((270 274) 1) ((263 268) 1)
((208 213) 1) ((751 756) 0)))
+ '((" class myClass function __construct id $this" ((194 743))) (" class
myClass id $var4" ((160 165))) (" class myClass id $var3" ((145 150))) (" class
myClass static id $var2" ((127 132))) (" class myClass id $var1" ((93 98) (93
98))) ((639 643) 0) ((632 637) 1) ((578 582) 1) ((571 576) 1) ((517 521) 1)
((510 515) 1) ((455 460) 1) ((392 397) 1) ((330 335) 0) ((270 274) 1) ((263
268) 1) ((208 213) 1) ((160 165) 1) ((145 150) 1) ((127 132) 1) ((93 98) 1)
((751 756) 0)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\ntry {\n \n} catch (\\Exception $e) {\n if ($e) {\n
echo 'Hit';\n }\n}\n\nif ($e) {\n echo 'Miss';\n}\n"
@@ -368,6 +368,8 @@
"Bookkeeping of $this reference inside arrow function inside of method"
'((" class myClass function test id $d" ((76 78))) (" class myClass
function test id $this" ((84 139))) (" class myClass arrow 1 function test id
$e" ((104 106))) (" class myClass id $tost" ((36 41))) ((104 106) 1) ((130 132)
1) ((125 127) 1) ((118 122) 1) ((111 116) 1) (" id $a" ((143 145))) ((143 145)
1) ((168 170) 1)))
+ ;; TODO Should bookkeep class method parameters
+
(phps-mode-test-ast--should-bookkeep
"<?php\n\nclass myClass\n{\n static $var = '123';\n static function
myMethod($a)\n {\n return fn($b) => self::$var . $a . $b;\n
}\n}\n\necho myClass::myMethod('4')('5');"
"Bookkeeping of self reference inside arrow function inside of static
method"
- [elpa] externals/phps-mode 4981a1eb45 032/135: SDT rules up to 520, (continued)
- [elpa] externals/phps-mode 4981a1eb45 032/135: SDT rules up to 520, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode b2454f1967 058/135: Bookkeeping of static class property, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 962b905ca0 057/135: Bookkeeping working for class non-static properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7b9f8011f1 056/135: More testing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e2f2c86e18 059/135: Improved class properties bookkeeping test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode eac10d63e6 063/135: Started on bookkeeping of variables inside anonymous functions, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e924ac83b6 065/135: Improved bookkeeping test for anonymous function, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e614a20ada 066/135: Added bookkeeping for referenced foreach variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d33625bb1a 067/135: Bookkeeping for array assignment passing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode a646676781 084/135: Passing more bookkeeping tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7609f09f04 090/135: More bookkeeping final touches,
Christian Johansson <=
- [elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test for trait class symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ada5e79291 097/135: Passing bookkeeping test for class properties in class constructor, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 8aae220c57 098/135: Started on integrating imenu generation in SDT bookkeeping, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 95f563fc70 102/135: Passing bookkeeping tests with integrated imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ae516f9e19 105/135: Using separate imenu items for redeclared symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode b21c9f3f3a 107/135: Imenu generation via SDT all tests now passing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 3332b2bfa9 109/135: Fixes syntax coloring of super-globals, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode bddf800099 111/135: Added failing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d98f6d78d8 114/135: Saving symbol-table after parse, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1594c15e9e 117/135: More work on imenu generation, Christian Johansson, 2023/01/29