[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 1a1245f186 082/135: Passing bookkeeping test
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 1a1245f186 082/135: Passing bookkeeping test isset and empty variables |
Date: |
Sun, 29 Jan 2023 03:11:06 -0500 (EST) |
branch: externals/phps-mode
commit 1a1245f18695b571ad5b44cb740932e9a8abdcdf
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing bookkeeping test isset and empty variables
---
phps-mode-parser-sdt.el | 60 ++++++++++++++++++++++++++++++++++------------
test/phps-mode-test-ast.el | 2 +-
2 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 8537608f76..bf35794061 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -768,14 +768,6 @@
;; (message "potential-uris: %S" potential-uris)
))
- ;; TODO Below should alter symbol namespaces instead of build
namespace data
- ((equal space-type 'global)
- (setq namespace nil)
- (setq class nil)
- (setq function nil)
- (setq arrow-function nil)
- (setq anonymous-function nil))
-
)))
(setq scope-index (1+ scope-index)))))
@@ -842,7 +834,6 @@
(when phps-mode-parser-sdt--bookkeeping-symbol-stack
;; Bookkeeping hit / misses of symbol references here
- ;; TODO Should consider declaration position as well?
(dolist (
symbol-list
phps-mode-parser-sdt--bookkeeping-symbol-stack)
@@ -867,7 +858,15 @@
((gethash
symbol-uri
phps-mode-parser-sdt-bookkeeping)
- (setq symbol-hit 1)))
+ (let ((matching-symbols
+ (gethash
+ symbol-uri
+ phps-mode-parser-sdt-bookkeeping)))
+ (dolist (matching-symbol matching-symbols)
+ (let ((matching-symbol-start (car matching-symbol))
+ (matching-symbol-end (car (cdr matching-symbol))))
+ (when (<= matching-symbol-start symbol-start)
+ (setq symbol-hit 1)))))))
(puthash
(list
@@ -3428,7 +3427,6 @@
(plist-get property 'ast-type)))
(cond
((equal property-type 'property-variable)
- ;; TODO Bookkeep proerty-variable here
(let ((symbol-name
(plist-get property 'variable))
(symbol-start
@@ -3929,7 +3927,6 @@
(puthash
358
(lambda(args _terminals)
- ;; TODO Declare array-pair-list assignments here
(let ((array-pair-list (nth 1 args)))
(dolist (array-item array-pair-list)
(let ((array-item-type (plist-get array-item 'ast-type)))
@@ -6715,17 +6712,50 @@
;; 561 ((internal_functions_in_yacc) (T_ISSET "(" isset_variables
possible_comma ")"))
(puthash
561
- (lambda(args _terminals)
+ (lambda(args terminals)
+ (when phps-mode-parser-sdt--bookkeeping-symbol-stack
+ (let ((isset-start (car (cdr (nth 1 terminals))))
+ (isset-end (cdr (cdr (nth 4 terminals)))))
+ (dolist (item phps-mode-parser-sdt--bookkeeping-symbol-stack)
+ (let ((item-start (nth 2 item))
+ (item-end (nth 3 item)))
+ (when (and
+ (> item-start isset-start)
+ (< item-end isset-end))
+ (push
+ (list
+ (nth 0 item)
+ phps-mode-parser-sdt--bookkeeping-namespace
+ item-start
+ item-end)
+ phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack))))))
`(
ast-type
internal-isset
+ isset-variables
,(nth 2 args)))
phps-mode-parser--table-translations)
;; 562 ((internal_functions_in_yacc) (T_EMPTY "(" expr ")"))
(puthash
562
- (lambda(args _terminals)
+ (lambda(args terminals)
+ (when phps-mode-parser-sdt--bookkeeping-symbol-stack
+ (let ((empty-start (car (cdr (nth 1 terminals))))
+ (empty-end (cdr (cdr (nth 3 terminals)))))
+ (dolist (item phps-mode-parser-sdt--bookkeeping-symbol-stack)
+ (let ((item-start (nth 2 item))
+ (item-end (nth 3 item)))
+ (when (and
+ (> item-start empty-start)
+ (< item-end empty-end))
+ (push
+ (list
+ (nth 0 item)
+ phps-mode-parser-sdt--bookkeeping-namespace
+ item-start
+ item-end)
+ phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack))))))
`(
ast-type
internal-empty-expr
@@ -6806,7 +6836,7 @@
(puthash
570
(lambda(args _terminals)
- (list args))
+ args)
phps-mode-parser--table-translations)
(provide 'phps-mode-parser-sdt)
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 51c7758fd9..4930dacd01 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -296,7 +296,7 @@
(phps-mode-test-ast--should-bookkeep
"<?php\n\nif (isset($x)) {\n if ($x) {\n echo 'Hit';\n if
(isset($i, $u)) {\n if ($i) {\n echo 'Hit';\n
}\n if ($u) {\n echo 'Hit';\n }\n
if ($x) {\n echo 'Hit';\n }\n }\n
if ($i) {\n echo 'Miss';\n }\n if ($u) {\n
echo 'Miss';\n }\n }\n}\nif ($x) {\n echo 'Miss';\n}\n\nif
(!empty($y)) {\n if ( [...]
"Bookkeeping of isset() and !empty() scoped variables"
- '((" defined 1 id $x" 1) ((18 20) 1) ((33 35) 1) (" defined 1 defined 2 id
$i" 1) (" defined 1 defined 2 id $u" 1) ((77 79) 1) ((81 83) 1) ((104 106) 1)
((168 170) 1) ((232 234) 1) ((302 304) 0) ((355 357) 0) ((408 410) 0) ("
defined 3 id $y" 1) ((445 447) 1) ((460 462) 1) (" defined 3 defined 4 id $k"
1) (" defined 3 defined 4 id $L" 1) ((505 507) 1) ((519 521) 1) ((542 544) 1)
((606 608) 1) ((670 672) 1) ((740 742) 0) ((793 795) 0) ((846 848) 0)))
+ '((" id $i" ((77 79))) (" id $u" ((81 83))) (" id $x" ((18 20))) ((355 357)
1) ((302 304) 1) ((232 234) 1) ((168 170) 1) ((104 106) 1) ((81 83) 1) ((77 79)
1) ((33 35) 1) ((18 20) 1) ((408 410) 1) (" id $L" ((519 521))) (" id $k" ((505
507))) (" id $y" ((445 447))) ((793 795) 1) ((740 742) 1) ((670 672) 1) ((606
608) 1) ((542 544) 1) ((519 521) 1) ((505 507) 1) ((460 462) 1) ((445 447) 1)
((846 848) 1)))
(phps-mode-test-ast--should-bookkeep
"<?php\ninterface myInterface\n{\n function myFunction1();\n function
myFunction2($x);\n}\n"
- [elpa] externals/phps-mode eefe70b999 072/135: Work on improving symbol URI calculation, (continued)
- [elpa] externals/phps-mode eefe70b999 072/135: Work on improving symbol URI calculation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ebe28c3c9d 073/135: Work on improving symbol URI generation for class method variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 61d3e7b1e0 093/135: Passing bookkeeping test but via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d16c8a4e93 099/135: Passing some tests now with integrated bookkeeping and imenu-generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 9a45a530d0 100/135: Passing more imenu tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 749659769c 115/135: More work on imenu generation via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 42b983bb16 045/135: More work on bookkeeping via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode cba467b26c 050/135: Added TODO items, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e1752a3aa3 064/135: Bookkeeping of variables inside simple anonymous functions, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d464cb1f01 077/135: Fixed bookkeeping of global variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1a1245f186 082/135: Passing bookkeeping test isset and empty variables,
Christian Johansson <=
- [elpa] externals/phps-mode 696d66d7e7 085/135: Bookkeeping of static variable inside function, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode cffad0d620 131/135: Merge branch 'feature/full-sdt', Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 249f8a2a4d 087/135: Work on bookkeeping class static variable, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 177b00f06a 132/135: Updated copyright years, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 0654fe8899 134/135: Updated documentation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 6e43f9f6db 037/135: More messing around with SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 86ad9e35ee 047/135: Renamed symbol id to symbol URI, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode dbaf508512 052/135: Work on getting bookkeeping for class properties working, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 531c98cf2b 053/135: Improved bookkeeping of class properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 5080effb1d 014/135: Added TODO item, Christian Johansson, 2023/01/29