[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test fo
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test for trait class symbols |
Date: |
Sun, 29 Jan 2023 03:11:08 -0500 (EST) |
branch: externals/phps-mode
commit 6c6906317a60413f74966dcb447d621b932b94fd
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Added bookkeeping test for trait class symbols
---
phps-mode-parser-sdt.el | 55 ++++++++++++++++++++++++++++++++++++++++++++--
test/phps-mode-test-ast.el | 8 +++----
2 files changed, 56 insertions(+), 7 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 6926c821ea..636d9aefe1 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -2308,6 +2308,58 @@
(puthash
190
(lambda(args _terminals)
+ ;; Go through stacks and modify symbol name-spaces
+ ;; but only for non-super-global variables.
+ ;;
+ ;; Should place class scope first in scope
+ ;; unless a namespace exists, in that case it should be placed second in
scope
+ (let ((class-name (nth 1 args)))
+ (when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
+ (dolist (
+ symbol-list
+ phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack)
+ (let ((symbol-name (car symbol-list))
+ (symbol-start (nth 2 symbol-list))
+ (symbol-end (nth 3 symbol-list)))
+ (unless (gethash
+ symbol-name
+ phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
+ (let ((symbol-scope (reverse (car (cdr symbol-list)))))
+ (if (equal (car (car symbol-scope)) 'namespace)
+ (let ((namespace-name (car (cdr (car symbol-scope)))))
+ (setcar symbol-scope (list 'interface class-name))
+ (push (list 'namespace namespace-name) symbol-scope))
+ (push
+ (list 'trait class-name)
+ symbol-scope))
+ (setq symbol-scope (reverse symbol-scope))
+ (setcar
+ (cdr symbol-list)
+ symbol-scope))))))
+
+ (when phps-mode-parser-sdt--bookkeeping-symbol-stack
+ (dolist (
+ symbol-list
+ phps-mode-parser-sdt--bookkeeping-symbol-stack)
+ (let ((symbol-name (car symbol-list))
+ (symbol-start (nth 2 symbol-list))
+ (symbol-end (nth 3 symbol-list)))
+ (unless (gethash
+ symbol-name
+ phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
+ (let ((symbol-scope (reverse (car (cdr symbol-list)))))
+ (if (equal (car (car symbol-scope)) 'namespace)
+ (let ((namespace-name (car (cdr (car symbol-scope)))))
+ (setcar symbol-scope (list 'interface class-name))
+ (push (list 'namespace namespace-name) symbol-scope))
+ (push
+ (list 'trait class-name)
+ symbol-scope))
+ (setq symbol-scope (reverse symbol-scope))
+ (setcar
+ (cdr symbol-list)
+ symbol-scope)))))))
+
`(
ast-type
trait-declaration-statement
@@ -2316,8 +2368,7 @@
backup-doc-comment
,(nth 2 args)
class-statement-list
- ,(nth 4 args)
- ))
+ ,(nth 4 args)))
phps-mode-parser--table-translations)
;; 191 ((interface_declaration_statement) (T_INTERFACE T_STRING
interface_extends_list backup_doc_comment "{" class_statement_list "}"))
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index acabb60f85..8190db8fb0 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -379,14 +379,12 @@
'((" namespace myNamespace class myClass function myMethod id $argument3"
((180 190))) (" namespace myNamespace class myClass function myMethod id
$argument2" ((160 170))) (" namespace myNamespace class myClass function
myMethod id $argument1" ((140 150) (446 456))) (" namespace myNamespace class
myClass function myMethod id $this" ((197 581))) (" namespace myNamespace class
myClass id $property2" ((87 97))) (" namespace myNamespace class myClass id
$property1" ((58 68))) ((180 190) 1 [...]
(phps-mode-test-ast--should-bookkeep
- "<?php\ntrait Hello {\n public function sayHello() {\n echo
'Hello ';\n }\n}\n\ntrait World {\n public function sayWorld() {\n
echo 'World';\n }\n}\n\nclass MyHelloWorld {\n use Hello, World;\n
public function sayExclamationMark() {\n echo '!';\n }\n}\n\n$o = new
MyHelloWorld();\n$o->sayHello();\n$o->sayWorld();\n$o->sayExclamationMark();\n?>"
- "Trait classes"
- nil)
+ "<?php\ntrait MyTrait {\n private $var = 'abc';\n public function
sayHello() {\n if ($this->var) {\n echo 'Hit';\n }\n
}\n}\n"
+ "A basic trait class"
+ '((" trait MyTrait function sayHello id $this" ((80 147))) (" trait MyTrait
id $var" ((35 39))) ((101 104) 1) ((94 99) 1) ((35 39) 1)))
- ;; TODO Add trait class bookkeping test here
;; TODO Add test for class properties in class construct here
-
(message "\n-- Ran tests for bookkeeping generation. --"))
(defun phps-mode-test-ast ()
- [elpa] externals/phps-mode b2454f1967 058/135: Bookkeeping of static class property, (continued)
- [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, 2023/01/29
- [elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test for trait class symbols,
Christian Johansson <=
- [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
- [elpa] externals/phps-mode 776c818ff9 121/135: Passing some more imenu tests, Christian Johansson, 2023/01/29