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

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

[elpa] externals/phps-mode 171e96b043 123/135: Fixes for some tests


From: Christian Johansson
Subject: [elpa] externals/phps-mode 171e96b043 123/135: Fixes for some tests
Date: Sun, 29 Jan 2023 03:11:11 -0500 (EST)

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

    Fixes for some tests
---
 phps-mode-ast.el           |   2 +-
 phps-mode-parser-sdt.el    | 128 +++++++++++++++++++++++++--------------------
 test/phps-mode-test-ast.el |   4 +-
 3 files changed, 74 insertions(+), 60 deletions(-)

diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index 841303509d..fb60a01009 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -159,7 +159,7 @@
                       (listp (cdr b)))
                      (< (cdr (car (car (cdr a)))) (cdr (car (car (cdr b))))))
                     ((listp (cdr a))
-                     (< (cdr (car (car (cdr a))) (cdr b))))
+                     (< (cdr (car (car (cdr a)))) (cdr b)))
                     ((listp (cdr b))
                      (< (cdr a) (cdr (car (car (cdr b))))))
                     (t
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 804eacc724..511a51657c 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -1052,15 +1052,15 @@
                              imenu-nail2
                              (gethash
                               imenu-nail
-                              phps-mode-parser-sdt-symbol-imenu--table))))
-                      (let ((imenu-object (make-hash-table :test 'equal)))
-                        (puthash 'declaration (nth imenu-function))
-                        (puthash
-                         imenu-nail2
-                         imenu-object
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))))))))
+                              phps-mode-parser-sdt-symbol-imenu--table)))
+                        (let ((imenu-object (make-hash-table :test 'equal)))
+                          (puthash 'declaration (nth imenu-function))
+                          (puthash
+                           imenu-nail2
+                           imenu-object
+                           (gethash
+                            imenu-nail
+                            phps-mode-parser-sdt-symbol-imenu--table)))))))))
 
              (imenu-trait
               (let ((imenu-nail (format "trait %s" (nth 0 imenu-trait))))
@@ -1081,15 +1081,15 @@
                              imenu-nail2
                              (gethash
                               imenu-nail
-                              phps-mode-parser-sdt-symbol-imenu--table))))
-                      (let ((imenu-object (make-hash-table :test 'equal)))
-                        (puthash 'declaration (nth imenu-function))
-                        (puthash
-                         imenu-nail2
-                         imenu-object
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))))))))
+                              phps-mode-parser-sdt-symbol-imenu--table)))
+                        (let ((imenu-object (make-hash-table :test 'equal)))
+                          (puthash 'declaration (nth imenu-function))
+                          (puthash
+                           imenu-nail2
+                           imenu-object
+                           (gethash
+                            imenu-nail
+                            phps-mode-parser-sdt-symbol-imenu--table)))))))))
 
              (imenu-interface
               (let ((imenu-nail (format "interface %s" (nth 0 
imenu-interface))))
@@ -1110,15 +1110,15 @@
                              imenu-nail2
                              (gethash
                               imenu-nail
-                              phps-mode-parser-sdt-symbol-imenu--table))))
-                      (let ((imenu-object (make-hash-table :test 'equal)))
-                        (puthash 'declaration (nth imenu-function))
-                        (puthash
-                         imenu-nail2
-                         imenu-object
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))))))))
+                              phps-mode-parser-sdt-symbol-imenu--table)))
+                        (let ((imenu-object (make-hash-table :test 'equal)))
+                          (puthash 'declaration (nth imenu-function))
+                          (puthash
+                           imenu-nail2
+                           imenu-object
+                           (gethash
+                            imenu-nail
+                            phps-mode-parser-sdt-symbol-imenu--table)))))))))
 
              (imenu-function
               (let ((imenu-nail (format "function %s" (nth 0 imenu-function))))
@@ -1529,12 +1529,6 @@
         ;; and place a reference to it in the symbol URI hash-map
         (if (gethash symbol-uri phps-mode-parser-sdt-symbol-table-by-uri)
             (progn
-              (let ((symbol-uri-duplicate
-                     (format
-                      "%s (%d)"
-                      symbol-uri
-                      (1+ (length (gethash symbol-uri 
phps-mode-parser-sdt-symbol-table-by-uri)))))))
-
               (puthash
                phps-mode-parser-sdt-symbol-table-index
                (list
@@ -2124,13 +2118,13 @@
      ast-type
      namespace
      ast-name
-     ,name
+     ,(nth 1 args)
      ast-index
-     ,index
+     ,(car (cdr (nth 1 terminals)))
      ast-start
-     ,start
+     ,(car (cdr (nth 1 terminals)))
      ast-end
-     ,end))
+     ,(cdr (cdr (nth 1 terminals)))))
  phps-mode-parser--table-translations)
 
 ;; 112 top_statement -> (T_NAMESPACE namespace_declaration_name "{" 
top_statement_list "}")
@@ -3270,16 +3264,26 @@
 
      ;; Add class scope to all functions in class
      (when phps-mode-parser-sdt-symbol-imenu--stack
-       (dolist (items phps-mode-parser-sdt-symbol-imenu--stack))
-       (dolist (item items)
-         (let ((item-start (nth 2 item))
-               (item-end (nth 3 item)))
-           (when (and
-                  (>= item-start class-start)
-                  (<= item-end class-end))
-             (setf
-              item
-              (append (list (list 'class class-name class-start class-end)) 
item))))))
+       (let ((imenu-stack-count
+              (length phps-mode-parser-sdt-symbol-imenu--stack))
+             (imenu-stack-index 0))
+         (while (< imenu-stack-index imenu-stack-count)
+           (let* ((items (nth imenu-stack-index 
phps-mode-parser-sdt-symbol-imenu--stack))
+                  (item-count (length items))
+                  (item-index 0))
+             (while (< item-index item-count)
+               (let* ((item (nth item-index items))
+                      (item-start (nth 2 item))
+                      (item-end (nth 3 item)))
+                 (when (and
+                        (>= item-start class-start)
+                        (<= item-end class-end))
+                   (push
+                    (list 'trait class-name class-start class-end)
+                    (nth imenu-stack-index 
phps-mode-parser-sdt-symbol-imenu--stack))
+                   (setq item-index item-count)))
+               (setq item-index (1+ item-index))))
+           (setq imenu-stack-index (1+ imenu-stack-index)))))
 
      ;; Add class to imenu stack
      (if phps-mode-parser-sdt-symbol-imenu--stack
@@ -3370,16 +3374,26 @@
 
      ;; Add class scope to all functions in class
      (when phps-mode-parser-sdt-symbol-imenu--stack
-       (dolist (items phps-mode-parser-sdt-symbol-imenu--stack)
-         (dolist (item items)
-           (let ((item-start (nth 2 item))
-                 (item-end (nth 3 item)))
-             (when (and
-                    (>= item-start class-start)
-                    (<= item-end class-end))
-               (setf
-                item
-                (append (list (list 'class class-name class-start class-end)) 
item)))))))
+       (let ((imenu-stack-count
+              (length phps-mode-parser-sdt-symbol-imenu--stack))
+             (imenu-stack-index 0))
+         (while (< imenu-stack-index imenu-stack-count)
+           (let* ((items (nth imenu-stack-index 
phps-mode-parser-sdt-symbol-imenu--stack))
+                  (item-count (length items))
+                  (item-index 0))
+             (while (< item-index item-count)
+               (let* ((item (nth item-index items))
+                      (item-start (nth 2 item))
+                      (item-end (nth 3 item)))
+                 (when (and
+                        (>= item-start class-start)
+                        (<= item-end class-end))
+                   (push
+                    (list 'interface class-name class-start class-end)
+                    (nth imenu-stack-index 
phps-mode-parser-sdt-symbol-imenu--stack))
+                   (setq item-index item-count)))
+               (setq item-index (1+ item-index))))
+           (setq imenu-stack-index (1+ imenu-stack-index)))))
 
      ;; Add class to imenu stack
      (if phps-mode-parser-sdt-symbol-imenu--stack
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index f2c41dd112..eacf0d2eca 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -167,8 +167,8 @@
   (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 ( [...]
    "Bookkeeping of conditional assignments"
-   '(((36 42) 1) ((97 102) 2) ((80 85) 2) ((70 76) 1) ((187 193) 3) ((179 183) 
4) ((161 167) 3) ((153 157) 4) ((143 149) 1) ((274 276) 5) ((258 260) 5) ((249 
255) 1) ((238 240) 5) ((230 232) 5) ((332 334) 6) ((312 314) 6) ((393 395) 6) 
((373 375) 7) ((457 459) 8))
-   '(("id $items" . 36) ("id $item" . 80) ("id $value" . 161) ("id $key" . 
153) ("id $i" . 230) ("id $a" . 312) ("id $b" . 373) ("id $c" . 457)))
+   '(((36 42) 1) ((70 76) 1) ((80 85) 2) ((97 102) 2) ((143 149) 1) ((153 157) 
3) ((161 167) 4) ((179 183) 3) ((187 193) 4) ((230 232) 5) ((238 240) 5) ((249 
255) 1) ((258 260) 5) ((274 276) 5) ((312 314) 6) ((332 334) 6) ((373 375) 7) 
((393 395) 6) ((457 459) 8))
+   '(("$items" . 36) ("$item" . 80) ("$key" . 153) ("$value" . 161) ("$i" . 
230) ("$a" . 312) ("$b" . 373) ("$c" . 457)))
 
   (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 [...]



reply via email to

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