[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode ae68e19c0a 080/135: Passing bookkeeping arrow
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode ae68e19c0a 080/135: Passing bookkeeping arrow function |
Date: |
Sun, 29 Jan 2023 03:11:06 -0500 (EST) |
branch: externals/phps-mode
commit ae68e19c0ae11baef1ab7a64a75adeacde838f04
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing bookkeeping arrow function
---
phps-mode-parser-sdt.el | 57 +++++++++++++++++++++++-----------------------
test/phps-mode-test-ast.el | 2 +-
2 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 6f2d4bbaa9..8537608f76 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -763,9 +763,9 @@
(format " arrow %s%s" space-name (nth
potential-uri-index potential-uris))
new-potential-uris)
(setq potential-uri-index (1+ potential-uri-index)))
- (setq potential-uris (append potential-uris
new-potential-uris))
- (message "new-potential-uris: %S" new-potential-uris)
- (message "potential-uris: %S" potential-uris)
+ (setq potential-uris (append new-potential-uris
potential-uris))
+ ;; (message "new-potential-uris: %S" new-potential-uris)
+ ;; (message "potential-uris: %S" potential-uris)
))
;; TODO Below should alter symbol namespaces instead of build
namespace data
@@ -782,15 +782,16 @@
(let ((potential-uri-count (length potential-uris))
(potential-uri-index 0)
(matching-uri))
+
;; Iterate potential-uris, select first match or if no match return
the first
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
(format "%s id %s" (nth potential-uri-index potential-uris) name))
- (setq potential-uri-index (1+ potential-uri-index))
(let ((potential-uri (nth potential-uri-index potential-uris)))
(when (gethash potential-uri phps-mode-parser-sdt-bookkeeping)
- (setq matching-uri potential-uri))))
+ (setq matching-uri potential-uri)))
+ (setq potential-uri-index (1+ potential-uri-index)))
(if matching-uri
matching-uri
(nth 0 potential-uris))))))
@@ -5192,7 +5193,6 @@
(puthash
440
(lambda(args terminals)
- ;; TODO Perform bookkeeping here
(let ((namespace
phps-mode-parser-sdt--bookkeeping-namespace)
(parameter-list
@@ -5206,6 +5206,27 @@
phps-mode-parser-sdt--bookkeeping-arrow-function-count)
namespace)
+ ;; Go through symbol stack in scope and add namespace
+ (when phps-mode-parser-sdt--bookkeeping-symbol-stack
+ (dolist (
+ symbol-list
+ phps-mode-parser-sdt--bookkeeping-symbol-stack)
+ (let ((symbol-name (nth 0 symbol-list))
+ (symbol-namespace (nth 1 symbol-list))
+ (symbol-start (nth 2 symbol-list)))
+ (unless (gethash
+ symbol-name
+ phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
+ (let ((symbol-scope (car (cdr symbol-list))))
+ (push
+ (list
+ 'arrow-function
+ phps-mode-parser-sdt--bookkeeping-arrow-function-count)
+ symbol-scope)
+ (setcar
+ (cdr symbol-list)
+ symbol-scope))))))
+
;; Go through parameters and assign variables inside function
(when parameter-list
(dolist (parameter parameter-list)
@@ -5236,29 +5257,7 @@
namespace
parameter-start
parameter-end)
- phps-mode-parser-sdt--bookkeeping-symbol-stack)))))))
-
- ;; Go through phps-mode-parser-sdt--bookkeeping-symbol-stack in scope and
add namespace
- (when phps-mode-parser-sdt--bookkeeping-symbol-stack
- (dolist (
- symbol-list
- phps-mode-parser-sdt--bookkeeping-symbol-stack)
- (let ((symbol-name (nth 0 symbol-list))
- (symbol-namespace (nth 1 symbol-list))
- (symbol-start (nth 2 symbol-list)))
- (unless (gethash
- symbol-name
- phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
- (let ((symbol-scope (car (cdr symbol-list))))
- (push
- (list
- 'arrow-function
- phps-mode-parser-sdt--bookkeeping-arrow-function-count)
- symbol-scope)
- (setcar
- (cdr symbol-list)
- symbol-scope)))))))
-
+ phps-mode-parser-sdt--bookkeeping-symbol-stack))))))))
`(
ast-type
inline-fn
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index a824a3a67a..da96e06aee 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -281,7 +281,7 @@
(phps-mode-test-ast--should-bookkeep
"<?php\n$y = 1;\n$fn1 = fn($x) => $x + $y;\n$z = 1;\n$fn = fn($x2) =>
fn($y2) => $x2 * $y2 + $z;\nfn(array $x3) => $x3;\n$x4 = 4;\nstatic fn(): int
=> $x4;\nfn($x5 = 42) => $x5;\nfn(&$x6) => $x6;\nfn&($x7) => $x7;\nfn($x8,
...$rest) => $rest;"
"Bookkeeping in arrow functions"
- '((" id $y" 1) ((7 9) 1) (" id $fn1" 1) ((15 19) 1) (" arrow function 1 id
$x" 1) ((25 27) 1) ((32 34) 1) ((37 39) 1) (" id $z" 1) ((41 43) 1) (" id $fn"
1) ((49 52) 1) (" arrow function 2 id $x2" 1) ((58 61) 1) (" arrow function 2
arrow function 3 id $y2" 1) ((69 72) 1) ((77 80) 1) ((83 86) 1) ((89 91) 1) ("
arrow function 4 id $x3" 1) ((102 105) 1) ((110 113) 1) (" id $x4" 1) ((115
118) 1) ((144 147) 1) (" arrow function 6 id $x5" 1) ((152 155) 1) ((165 168)
1) (" arrow function 7 i [...]
+ '((" id $y" ((7 9))) ((7 9) 1) (" id $fn1" ((15 19))) (" arrow 1 id $x"
((25 27))) ((25 27) 1) ((37 39) 1) ((32 34) 1) ((15 19) 1) (" id $z" ((41 43)))
((41 43) 1) (" id $fn" ((49 52))) (" arrow 3 id $x2" ((58 61))) (" arrow 2 id
$y2" ((69 72))) ((58 61) 1) ((69 72) 1) ((89 91) 1) ((83 86) 1) ((77 80) 1)
((49 52) 1) (" arrow 4 id $x3" ((102 105))) ((102 105) 1) ((110 113) 1) (" id
$x4" ((115 118))) ((115 118) 1) ((144 147) 1) (" arrow 6 id $x5" ((152 155)))
((152 155) 1) ((165 168) 1) [...]
(phps-mode-test-ast--should-bookkeep
"<?php\n$z = (object) array('name' => 'random');\nif ($z->name) {\n echo
'Hit';\n}"
- [elpa] externals/phps-mode 787aaa2bb4 081/135: Passing another bookkeeping test, (continued)
- [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
- [elpa] externals/phps-mode f4be94ccfc 094/135: Passing bookkeeping test for class properties inside conditional expression, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 18f1f12fc6 096/135: Added new bookkeeping test for class parameters in constructor method, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 6d3cadbdf0 104/135: More integration of new imenu and bookkeeping via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 171e96b043 123/135: Fixes for some tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 6944154fd3 125/135: Imenu via SDT passing some more tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d1b1fd0a19 071/135: Started bookkeeping of arrow function variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ae68e19c0a 080/135: Passing bookkeeping arrow function,
Christian Johansson <=
- [elpa] externals/phps-mode f053587ff6 091/135: Passing another bookkeeping test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 9c43bc30c4 103/135: Removed old bookkeeping and imenu and integrated new via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode a447ae69ba 106/135: Starting on generating imenu index for namespaces, classes, methods, traits, interfaces via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 16a63da318 113/135: More TODO items for bookkeeping, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 807c834649 116/135: More work on imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode a84bfdccd3 120/135: More fighting the AST, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 23ba458f20 133/135: Updated version and date for 0.4.31, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d5bdadc6fc 135/135: Improved installation documentation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 8259e390b4 092/135: Added TODO item, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 9f21c86dd1 108/135: SDT integration now passing byte-compilation, Christian Johansson, 2023/01/29