[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 [...]
- [elpa] externals/phps-mode 804a0dbdb9 074/135: Added static uri for symbol names, (continued)
- [elpa] externals/phps-mode 804a0dbdb9 074/135: Added static uri for symbol names, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7bb676dc8b 076/135: Bookkeeping for anonymous function passing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode f86d8dc6ac 078/135: More work on arrow function variable uri, Christian Johansson, 2023/01/29
- [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 <=
- [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, 2023/01/29
- [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