emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode e8a47de694 052/212: Work on supported arrow f


From: Christian Johansson
Subject: [elpa] externals/phps-mode e8a47de694 052/212: Work on supported arrow functions for bookkeeping via AST
Date: Wed, 26 Jan 2022 01:50:42 -0500 (EST)

branch: externals/phps-mode
commit e8a47de694e7e72c44acefc2a3f3c672dc154f07
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Work on supported arrow functions for bookkeeping via AST
---
 phps-mode-ast-bookkeeping.el |  15 +++-
 phps-mode-parser-sdt.el      |  89 ++++++++++++++++++++-
 test/phps-mode-test-ast.el   | 179 ++++++++++++++++++++++++-------------------
 3 files changed, 203 insertions(+), 80 deletions(-)

diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index e048469f17..eeeab5f929 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -398,6 +398,14 @@
                defined
                bookkeeping)))
 
+           ((equal type 'addition-expression)
+            (when-let ((bs (reverse (plist-get item 'b))))
+              (dolist (b bs)
+                (push `(,scope ,b) bookkeeping-stack)))
+            (when-let ((as (reverse (plist-get item 'a))))
+              (dolist (a as)
+                (push `(,scope ,a) bookkeeping-stack))))
+
            ((equal type 'global-statement)
             (when-let ((global-var-list (reverse (plist-get item 
'global-var-list))))
               (dolist (global-var global-var-list)
@@ -614,6 +622,9 @@
 
                 ))))
 
+           ((equal type 'static-inline-function)
+            (push `(,scope ,(plist-get item 'inline-function)) 
bookkeeping-stack))
+
            ((equal type 'inline-function)
             (setq
              inline-function-count
@@ -623,7 +634,7 @@
               (when-let ((inner-statement-list (reverse (plist-get item 
'inner-statement-list))))
                 (dolist (inner-statement inner-statement-list)
                   (push `(,sub-scope ,inner-statement) bookkeeping-stack)))
-              (when-let ((parameter-list (reverse (plist-get item 
'parameter-list))))
+              (when-let ((parameter-list (plist-get item 'parameter-list)))
                 (dolist (parameter parameter-list)
                   (let ((id
                          
(phps-mode-ast-bookkeeping--generate-variable-scope-string
@@ -641,7 +652,7 @@
                      object
                      1
                      bookkeeping))))
-              (when-let ((lexical-vars (reverse (plist-get item 
'lexical-vars))))
+              (when-let ((lexical-vars (plist-get item 'lexical-vars)))
                 (dolist (lexical-var lexical-vars)
                   (let ((id
                          
(phps-mode-ast-bookkeeping--generate-variable-scope-string
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 46a06251be..1112367852 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -433,6 +433,36 @@
      ast-object))
  phps-mode-parser--table-translations)
 
+;; 242: parameter -> (optional_visibility_modifier 
optional_type_without_static is_reference is_variadic T_VARIABLE 
backup_doc_comment "=" expr)
+(puthash
+ 242
+ (lambda(args terminals)
+   ;; (message "parameter: %S %S" args _terminals)
+   (let ((ast-object
+          (list
+           'ast-type
+           'parameter-with-default-value
+           'visibility
+           (nth 0 args)
+           'type
+           (nth 1 args)
+           'is-reference
+           (nth 2 args)
+           'is-variadic
+           (nth 3 args)
+           'name
+           (nth 4 args)
+           'start
+           (car (cdr (nth 4 terminals)))
+           'end
+           (cdr (cdr (nth 4 terminals)))
+           'backup-doc-comment
+           (nth 5 args)
+           'default-value
+           (phps-mode-parser-sdt--get-list-of-object (nth 7 args)))))
+     ast-object))
+ phps-mode-parser--table-translations)
+
 ;; 262: argument_list -> ("(" ")")
 (puthash
  262
@@ -654,6 +684,32 @@
      ast-object))
  phps-mode-parser--table-translations)
 
+;; expr -> (expr "+" expr)
+(puthash
+ 366
+ (lambda(args _terminals)
+   (let ((ast-object
+          (list
+           'ast-type
+           'addition-expression
+           'a
+           (phps-mode-parser-sdt--get-list-of-object (nth 0 args))
+           'b
+           (phps-mode-parser-sdt--get-list-of-object (nth 2 args)))))
+     ast-object))
+ phps-mode-parser--table-translations)
+
+;; expr -> (T_STATIC inline_function)
+(puthash
+ 413
+ (lambda(args _terminals)
+   `(
+     'ast-type
+     'static-inline-function
+     'inline-function
+     ,(nth 1 args)))
+ phps-mode-parser--table-translations)
+
 ;; inline_function -> (function returns_ref backup_doc_comment "(" 
parameter_list ")" lexical_vars return_type backup_fn_flags "{" 
inner_statement_list "}" backup_fn_flags)
 (puthash
  416
@@ -679,12 +735,43 @@
            'backup-fn-flags-1
            (nth 8 args)
            'inner-statement-list
-           (nth 10 args)
+           (phps-mode-parser-sdt--get-list-of-object (nth 10 args))
            'backup-fn-flags-2
            (nth 12 args))))
      ast-object))
  phps-mode-parser--table-translations)
 
+;; inline_function -> (fn returns_ref backup_doc_comment "(" parameter_list 
")" return_type T_DOUBLE_ARROW backup_fn_flags backup_lex_pos expr 
backup_fn_flags)
+(puthash
+ 417
+ (lambda(args terminals)
+   (let ((ast-object
+          (list
+           'ast-type
+           'inline-function
+           'start
+           (car (cdr (nth 9 terminals)))
+           'end
+           (cdr (cdr (nth 11 terminals)))
+           'returns-ref
+           (nth 1 args)
+           'backup-doc-comment
+           (nth 2 args)
+           'parameter-list
+           (phps-mode-parser-sdt--get-list-of-object (nth 4 args))
+           'return-type
+           (nth 6 args)
+           'backup-fn-flags-1
+           (nth 8 args)
+           'backup-lex-pos
+           (nth 9 args)
+           'inner-statement-list
+           (phps-mode-parser-sdt--get-list-of-object (nth 10 args))
+           'backup-fn-flags-2
+           (nth 11 args))))
+     ast-object))
+ phps-mode-parser--table-translations)
+
 ;; lexical_vars -> (T_USE "(" lexical_var_list possible_comma ")")
 (puthash
  426
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 0ab8142928..883d2b8eb2 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -248,9 +248,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $var" 1) (list (list 8 12) 1) (list (list 27 
32) 0) (list (list 73 77) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $var" 1) ((8 12) 1) ((27 32) 0) ((73 77) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\n$var = 'abc';\n\nif ($var) {\n    echo 'This never 
happens';\n}\nif ($var2) {\n    echo 'This happens';\n}"
@@ -269,9 +270,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-   (should (equal
-            (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-            (list (list " id $var" 1) (list (list 8 12) 1) (list (list 27 31) 
1) (list (list 72 77) 0))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $var" 1) ((8 12) 1) ((27 31) 1) ((72 77) 0))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?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}"
@@ -290,9 +292,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" id $var2" 1) ((8 13) 1) (" function myFunction id $var" 1) 
((40 44) 1) (" function myFunction id $var3" 1) ((52 57) 1) ((71 75) 1) ((113 
118) 0) ((157 162) 1) (" function myFunction2 id $abc" 1) ((216 220) 1) ((232 
236) 0) ((275 279) 1) ((316 320) 0) ((347 352) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $var2" 1) ((8 13) 1) (" function myFunction id $var" 1) ((40 
44) 1) (" function myFunction id $var3" 1) ((52 57) 1) ((71 75) 1) ((113 118) 
0) ((157 162) 1) (" function myFunction2 id $abc" 1) ((216 220) 1) ((232 236) 
0) ((275 279) 1) ((316 320) 0) ((347 352) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\n// Super-globals\n\nif ($_GET) {\n    echo 'Hit';\n}\nif ($_POST) 
{\n    echo 'Hit';\n}\nif ($_COOKIE) {\n    echo 'Hit';\n}\nif ($_SESSION) {\n  
  echo 'Hit';\n}\nif ($_REQUEST) {\n    echo 'Hit';\n}\nif ($GLOBALS) {\n    
echo 'Hit';\n}\nif ($_SERVER) {\n    echo 'Hit';\n}\nif ($_FILES) {\n    echo 
'Hit';\n}\nif ($_ENV) {\n    echo 'Hit';\n}\nif ($argc) {\n    echo 
'Hit';\n}\nif ($argv) {\n    echo 'Hit';\n}\nif ($http_​response_​header) {\n   
 echo 'Hit';\n}"
@@ -314,7 +317,7 @@
      (should
       (equal
        (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       (list (list (list 30 35) 1) (list (list 61 67) 1) (list (list 93 101) 
1) (list (list 127 136) 1) (list (list 162 171) 1) (list (list 197 205) 1) 
(list (list 231 239) 1) (list (list 265 272) 1) (list (list 298 303) 1) (list 
(list 329 334) 1) (list (list 360 365) 1)  (list (list 391 414) 1))))))
+       '(((30 35) 1) ((61 67) 1) ((93 101) 1) ((127 136) 1) ((162 171) 1) 
((197 205) 1) ((231 239) 1) ((265 272) 1) ((298 303) 1) ((329 334) 1) ((360 
365) 1) ((391 414) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\nnamespace myNamespaceA {\n    $var = 123;\n    class myClassA {\n 
       private $var2 = 123;\n        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        
function myFuncti [...]
@@ -336,7 +339,7 @@
      (should
       (equal
        (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index 1)
-       (list (list " id $var" 1) (list (list 37 41) 1) (list " namespace 
myNamespaceA class myClassA id $var2" 1) (list (list 86 91) 1) (list " 
namespace myNamespaceA class myClassA function myFunctionA id $this" 1) (list " 
namespace myNamespaceA class myClassA function myFunctionA id $var3" 1) (list 
(list 128 133) 1) (list " namespace myNamespaceA class myClassA function 
myFunctionA id $var4" 1) (list (list 149 154) 1) (list (list 178 182) 0) (list 
(list 245 250) 0) (list (list 313 318) [...]
+       '((" id $var" 1) ((37 41) 1) (" namespace myNamespaceA class myClassA 
id $var2" 1) ((86 91) 1) (" namespace myNamespaceA class myClassA function 
myFunctionA id $this" 1) (" namespace myNamespaceA class myClassA function 
myFunctionA id $var3" 1) ((128 133) 1) (" namespace myNamespaceA class myClassA 
function myFunctionA id $var4" 1) ((149 154) 1) ((178 182) 0) ((245 250) 0) 
((313 318) 1) ((380 385) 1) (" namespace myNamespaceA class myClassA function 
myFunctionB id $this" 1) (" nam [...]
 
   (phps-mode-test-ast--buffer-contents
    "<?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 ( [...]
@@ -355,9 +358,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $items" 1) (list (list 36 42) 1) (list (list 70 
76) 1) (list " id $item" 1) (list (list 80 85) 1) (list (list 97 102) 1) (list 
(list 143 149) 1) (list " id $key" 1) (list (list 153 157) 1) (list " id 
$value" 1) (list (list 161 167) 1) (list (list 179 183) 1) (list (list 187 193) 
1) (list " id $i" 1) (list (list 230 232) 1) (list (list 238 240) 1) (list 
(list 249 255) 1) (list (list 258 260) 1) (list (list 274 276) 1) (list " id 
$a" 1) (list (list 312 314) 1 [...]
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $items" 1) ((36 42) 1) ((70 76) 1) (" id $item" 1) ((80 85) 1) 
((97 102) 1) ((143 149) 1) (" id $key" 1) ((153 157) 1) (" id $value" 1) ((161 
167) 1) ((179 183) 1) ((187 193) 1) (" id $i" 1) ((230 232) 1) ((238 240) 1) 
((249 255) 1) ((258 260) 1) ((274 276) 1) (" id $a" 1) ((312 314) 1) ((332 334) 
1) (" id $b" 1) ((373 375) 1) ((393 395) 1) (" id $c" 1) ((457 459) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?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 
($this->var3) {\n   [...]
@@ -376,9 +380,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" class myClass id $var1" 1) ((93 98) 1) (" class myClass 
static id $var2" 1) ((127 132) 1) (" class myClass id $var3" 1) ((145 150) 1) 
(" class myClass id $var4" 1) ((160 165) 1) (" class myClass function 
__construct id $this" 1) ((208 213) 1) ((263 268) 1) ((270 274) 1) ((330 335) 
0) ((392 397) 1) ((447 452) 1) ((454 458) 1) ((508 513) 1) ((515 519) 1) ((569 
574) 1) ((576 580) 0) ((688 693) 0))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" class myClass id $var1" 1) ((93 98) 1) (" class myClass static id 
$var2" 1) ((127 132) 1) (" class myClass id $var3" 1) ((145 150) 1) (" class 
myClass id $var4" 1) ((160 165) 1) (" class myClass function __construct id 
$this" 1) ((208 213) 1) ((263 268) 1) ((270 274) 1) ((330 335) 0) ((392 397) 1) 
((447 452) 1) ((454 458) 1) ((508 513) 1) ((515 519) 1) ((569 574) 1) ((576 
580) 0) ((688 693) 0))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\ntry {\n    \n} catch (\\Exception $e) {\n    if ($e) {\n        
echo 'Hit';\n    }\n}\n\nif ($e) {\n    echo 'Miss';\n}\n"
@@ -397,9 +402,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $e" 1) (list (list 39 41) 1) (list (list 53 55) 
1) (list (list 92 94) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $e" 1) ((39 41) 1) ((53 55) 1) ((92 94) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\n$example = function ($test) {\n    if ($test) {\n        echo 
'Hit';\n    }\n    if ($example) {\n        echo 'Miss';\n    }\n};\n$example2 
= function ($test2) use ($example) {\n    if ($test2) {\n        echo 'Hit';\n  
  }\n    if ($example) {\n        echo 'Hit';\n    }\n    if ($example2) {\n    
    echo 'Miss';\n    }\n    if ($example3) {\n        echo 'Miss';\n    
}\n};\nif ($test) {\n    echo 'Miss';\n}\nif ($test2) {\n    echo 'Miss';\n}"
@@ -418,9 +424,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $example" 1) (list (list 8 16) 1) (list " 
anonymous function 1 id $test" 1) (list (list 29 34) 1) (list (list 46 51) 1) 
(list (list 89 97) 0) (list " id $example2" 1) (list (list 131 140) 1) (list " 
anonymous function 2 id $test2" 1) (list (list 153 159) 1) (list " anonymous 
function 2 id $example" 1) (list (list 166 174) 1) (list (list 186 192) 1) 
(list (list 230 238) 1) (list (list 276 285) 0) (list (list 324 333) 0) (list 
(list 371 376) 0) (list (list 40 [...]
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $example" 1) ((8 16) 1) (" anonymous function 1 id $test" 1) 
((29 34) 1) ((46 51) 1) ((89 97) 0) (" id $example2" 1) ((131 140) 1) (" 
anonymous function 2 id $test2" 1) ((153 159) 1) (" anonymous function 2 id 
$example" 1) ((166 174) 1) ((186 192) 1) ((230 238) 1) ((276 285) 0) ((324 333) 
0) ((371 376) 0) ((403 409) 0))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\nclass myClass {\n    function random() {}\n    function 
__construct()\n    {\n        $this->random();\n        $this->random['abc'] = 
123;\n    }\n}"
@@ -439,9 +446,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " class myClass function random id $this" 1) (list " 
class myClass function __construct id $this" 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" class myClass function random id $this" 1) (" class myClass 
function __construct id $this" 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n$items = array(1, 2, 3);\nforeach ($items as &$item) {\n    if 
($item) {\n        echo 'Hit';\n    }\n}\nforeach ($items as $key => &$item2) 
{\n    if ($item) {\n        echo 'Hit';\n    }\n}"
@@ -460,9 +468,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $items" 1) (list (list 7 13) 1) (list (list 41 
47) 1) (list " id $item" 1) (list (list 52 57) 1) (list (list 69 74) 1) (list 
(list 115 121) 1) (list " id $key" 1) (list (list 125 129) 1) (list " id 
$item2" 1) (list (list 134 140) 1) (list (list 152 157) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $items" 1) ((7 13) 1) ((41 47) 1) (" id $item" 1) ((52 57) 1) 
((69 74) 1) ((115 121) 1) (" id $key" 1) ((125 129) 1) (" id $item2" 1) ((134 
140) 1) ((152 157) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\n[$random, $bandom] = myValues();\nif ($random) {\n    echo 
'Hit';\n}\nif ($bandom) {\n    echo 'Hit';\n}\n"
@@ -481,9 +490,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" id $random" 1) ((9 16) 1) (" id $bandom" 1) ((18 25) 1) 
((45 52) 1) ((78 85) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $random" 1) ((9 16) 1) (" id $bandom" 1) ((18 25) 1) ((45 52) 
1) ((78 85) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\n$var = 123;\n\nfunction test($abc) {\n    global $var;\n    if 
($var) {\n        echo 'Hit';\n    }\n}"
@@ -502,9 +512,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $var" 1) (list (list 8 12) 1) (list " function 
test id $abc" 1) (list (list 35 39) 1) (list " function test id $var" 1) (list 
(list 54 58) 1) (list (list 68 72) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+              '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 
39) 1) (" function test id $var" 1) ((54 58) 1) ((68 72) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?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;"
@@ -523,9 +534,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $y" 1) (list (list 7 9) 1) (list " id $fn1" 1) 
(list (list 15 19) 1) (list " arrow function 1 id $x" 1) (list (list 25 27) 1) 
(list (list 32 34) 1) (list (list 37 39) 1) (list " id $z" 1) (list (list 41 
43) 1) (list " id $fn" 1) (list (list 49 52) 1) (list " arrow function 2 id 
$x2" 1) (list (list 58 61) 1) (list " arrow function 2 id $y2" 1) (list (list 
69 72) 1) (list (list 77 80) 1) (list (list 83 86) 1) (list (list 89 91) 1) 
(list " arrow function 3 id  [...]
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $y" 1) ((7 9) 1) (" id $fn1" 1) ((15 19) 1) (" anonymous 
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) (" anonymous function 2 id $x2" 1) ((58 61) 1) (" 
anonymous function 2 anonymous function 3 id $y2" 1) ((69 72) 1) ((77 80) 1) 
((83 86) 1) ((89 91) 1) (" anonymous function 3 id $x3" 1) ((102 105) 1) ((110 
113) 1) (" id $x4" 1) ((115 118) 1) ((144 147) 1) (" anonymous function 6 id 
$x5" 1) ((152 155) 1) ((165 1 [...]
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n$z = (object) array('name' => 'random');\nif ($z->name) {\n    echo 
'Hit';\n}"
@@ -544,9 +556,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $z" 1) (list (list 7 9) 1) (list (list 52 54) 
1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       (list (list " id $z" 1) (list (list 7 9) 1) (list (list 52 54) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\nif (!$var = false) {\n    echo 'Hit';\n}\n"
@@ -565,9 +578,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $var" 1) (list (list 12 16) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       (list (list " id $var" 1) (list (list 12 16) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?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 ( [...]
@@ -586,9 +600,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " defined 1 id $x" 1) (list (list 18 20) 1) (list 
(list 33 35) 1) (list " defined 2 id $i" 1) (list (list 77 79) 1) (list " 
defined 2 id $u" 1) (list (list 81 83) 1) (list (list 104 106) 1) (list (list 
168 170) 1) (list (list 232 234) 1) (list (list 302 304) 0) (list (list 355 
357) 0) (list (list 408 410) 0) (list " defined 3 id $y" 1) (list (list 445 
447) 1) (list (list 460 462) 1) (list " defined 4 id $k" 1) (list (list 505 
507) 1) (list " defined 4 id $L" 1)  [...]
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" defined 1 id $x" 1) ((18 20) 1) ((33 35) 1) (" defined 2 id $i" 1) 
((77 79) 1) (" defined 2 id $u" 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 4 id $k" 1) ((505 507) 1) (" defined 4 
id $L" 1) ((519 521) 1) ((542 544) 1) ((606 608) 1) ((670 672) 1) ((740 742) 0) 
((793 795) 0) ((846 848) 0))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\ninterface myInterface\n{\n    function myFunction1();\n    function 
myFunction2($x);\n}\n"
@@ -607,9 +622,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " class myInterface function myFunction2 id $x" 1) 
(list (list 84 86) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" class myInterface function myFunction2 id $x" 1) ((84 86) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\nfunction myFunction1()\n{\n    return isset($a);\n}\n\nfunction 
myFunction2()\n{\n    $b = 2;\n    if ($b) {\n        echo 'Hit';\n    }\n    
if ($b) {\n        echo 'Hit';\n    }\n}\n"
@@ -628,9 +644,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '(((50 52) 0) (" function myFunction2 id $b" 1) ((87 89) 1) 
((103 105) 1) ((143 145) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '(((50 52) 0) (" function myFunction2 id $b" 1) ((87 89) 1) ((103 105) 
1) ((143 145) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\n$a = array(1, 2, 3);\nforeach ($a as $uri => $page)\n{\n    if 
(isset($pages)) {\n        if ($a) {\n            echo 'Hit';\n        }\n      
  if ($uri) {\n            echo 'Hit';\n        }\n        if ($page) {\n       
     echo 'Hit';\n        }\n    }\n}\n"
@@ -649,9 +666,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" id $a" 1) ((8 10) 1) ((38 40) 1) (" id $uri" 1) ((44 48) 1) 
(" id $page" 1) ((52 57) 1) (" defined 1 id $pages" 1) ((75 81) 1) ((98 100) 1) 
((150 154) 1) ((204 209) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $a" 1) ((8 10) 1) ((38 40) 1) (" id $uri" 1) ((44 48) 1) (" id 
$page" 1) ((52 57) 1) (" defined 1 id $pages" 1) ((75 81) 1) ((98 100) 1) ((150 
154) 1) ((204 209) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\nif (isset($b)) {\n    $b = false;\n}\n$c = 2;\n\nif ($c) {\n    
echo 'Hit';\n}\n"
@@ -670,9 +688,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" defined 1 id $b" 2) ((17 19) 1) ((28 30) 1) (" id $c" 1) 
((42 44) 1) ((55 57) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" defined 1 id $b" 2) ((17 19) 1) ((28 30) 1) (" id $c" 1) ((42 44) 
1) ((55 57) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\nif (!isset($a)) {\n    if ($a) {\n        echo 'Miss';\n    }\n}"
@@ -691,9 +710,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '(((18 20) 0) ((33 35) 0))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '(((18 20) 0) ((33 35) 0))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\nfunction myFunction($a, $b, $c, $d)\n{\n    global $f, $g;\n    
if (isset($f)) {\n        if (!empty($g)) {\n            if ($a) {\n            
    echo 'Hit';\n            }\n            if ($b) {\n                echo 
'Hit';\n            }\n            if ($c) {\n                echo 'Hit';\n     
       }\n            if ($d) {\n                echo 'Hit';\n            }\n   
     }\n    }\n}\n"
@@ -712,9 +732,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" function myFunction id $a" 1) ((28 30) 1) (" function 
myFunction id $b" 1) ((32 34) 1) (" function myFunction id $c" 1) ((36 38) 1) 
(" function myFunction id $d" 1) ((40 42) 1) (" function myFunction id $f" 1) 
((57 59) 1) (" function myFunction id $g" 1) ((61 63) 1) (" function myFunction 
defined 1 id $f" 1) ((79 81) 1) (" function myFunction defined 2 id $g" 1) 
((105 107) 1) ((128 130) 1) ((192 194) 1) ((256 258) 1) ((320 322) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" function myFunction id $a" 1) ((28 30) 1) (" function myFunction 
id $b" 1) ((32 34) 1) (" function myFunction id $c" 1) ((36 38) 1) (" function 
myFunction id $d" 1) ((40 42) 1) (" function myFunction id $f" 1) ((57 59) 1) 
(" function myFunction id $g" 1) ((61 63) 1) (" function myFunction defined 1 
id $f" 1) ((79 81) 1) (" function myFunction defined 2 id $g" 1) ((105 107) 1) 
((128 130) 1) ((192 194) 1) ((256 258) 1) ((320 322) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\n$var = 123;\n\nfunction test($abc) {\n    static $var;\n    if 
($var) {\n        echo 'Hit';\n    }\n}"
@@ -733,9 +754,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 
39) 1) (" function test id $var" 1) ((54 58) 1) ((68 72) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 39) 1) (" 
function test id $var" 1) ((54 58) 1) ((68 72) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\nglobal $a, $b;\n\nif ($a) {\n    echo 'Hit';\n}\n\nfunction 
myFunction($c)\n{\n    global $a;\n    if ($a) {\n        echo 'Hit';\n    }\n  
  if ($b) {\n        echo 'Miss';\n    }\n}\n"
@@ -754,9 +776,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" id $a" 1) ((15 17) 1) (" id $b" 1) ((19 21) 1) ((28 30) 1) 
(" function myFunction id $c" 1) ((73 75) 1) (" function myFunction id $a" 1) 
((90 92) 1) ((102 104) 1) ((142 144) 0))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $a" 1) ((15 17) 1) (" id $b" 1) ((19 21) 1) ((28 30) 1) (" 
function myFunction id $c" 1) ((73 75) 1) (" function myFunction id $a" 1) ((90 
92) 1) ((102 104) 1) ((142 144) 0))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\nstatic $a;\n\nif ($a) {}\n\nfunction test()\n{\n    static $a;\n  
  if ($a) {}\n}\n\nclass There\n{\n    function here()\n    {\n        static 
$a;\n        if ($a) {}\n    }\n}"
@@ -775,9 +798,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" id $a" 1) ((15 17) 1) ((24 26) 1) (" function test id $a" 
1) ((61 63) 1) ((73 75) 1) (" class There function here id $this" 1) (" class 
There function here id $a" 1) ((138 140) 1) ((154 156) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" id $a" 1) ((15 17) 1) ((24 26) 1) (" function test id $a" 1) ((61 
63) 1) ((73 75) 1) (" class There function here id $this" 1) (" class There 
function here id $a" 1) ((138 140) 1) ((154 156) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\nnamespace Here\n{\n    function here()\n    {\n        static 
$a;\n        if ($a) {}\n    }\n    class There\n    {\n        public function 
Near()\n        {\n            static $a;\n            if ($a) {}\n        }\n  
  }\n}\nnamespace\n{\n    static $a;\n    if ($a) {}\n}\n"
@@ -796,9 +820,10 @@
             (car (cdr production))))))
      (phps-mode-ast--generate)
      (phps-mode-ast-bookkeeping--generate)
-     (should (equal
-              (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" namespace Here function here id $a" 1) ((66 68) 1) ((82 84) 
1) (" namespace Here class There function Near id $this" 1) (" namespace Here 
class There function Near id $a" 1)  ((177 179) 1) ((197 199) 1) (" id $a" 1) 
((245 247) 1) ((257 259) 1))))))
+     (should
+      (equal
+       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+       '((" namespace Here function here id $a" 1) ((66 68) 1) ((82 84) 1) (" 
namespace Here class There function Near id $this" 1) (" namespace Here class 
There function Near id $a" 1)  ((177 179) 1) ((197 199) 1) (" id $a" 1) ((245 
247) 1) ((257 259) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\nclass There\n{\n    private $variable;\n    private \\My\\Random 
$variable2;\n    private string $variable3;\n    private static $variable4;\n   
 private static \\My\\Random $variable5;\n    private static string 
$variable6;\n    function here()\n    {\n        if ($this->variable) {}\n      
  if ($this->variable2) {}\n        if ($this->variable3) {}\n        if 
($this->variable4) {}\n        if (self::$variable4) {}\n        if 
(self::$variable5) {}\n        if (self::$varia [...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]