[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode a1af5b11fb 040/212: More work on bookkeeping
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode a1af5b11fb 040/212: More work on bookkeeping of class properties via AST |
Date: |
Wed, 26 Jan 2022 01:50:24 -0500 (EST) |
branch: externals/phps-mode
commit a1af5b11fb798f22b2cda39ea182d0947e1bbf6c
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More work on bookkeeping of class properties via AST
---
phps-mode-ast-bookkeeping.el | 54 +++++++++++++++++++++++++++++++++++++++-----
test/phps-mode-test-ast.el | 2 +-
2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index b695406d00..7daf64317b 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -566,8 +566,8 @@
(let* ((sub-variable-namespace
(phps-mode-ast-bookkeeping--generate-variable-namespace
namespace
- nil
- function))
+ class
+ nil))
(variable-id
(format
"%s id $%s"
@@ -576,8 +576,8 @@
(sub-symbol-namespace
(phps-mode-ast-bookkeeping--generate-variable-namespace
namespace
- nil
- function))
+ class
+ nil))
(symbol-id
(format
"%s id %s"
@@ -587,20 +587,62 @@
(list
(plist-get item 'property-start)
(plist-get item 'property-end))))
+ ;; (message "dereferenced: %S %S" variable-id symbol-id)
(if (or
(gethash variable-id bookkeeping)
(gethash symbol-id bookkeeping))
(puthash
bookkeeping-object
- t
+ 1
bookkeeping)
(puthash
bookkeeping-object
- nil
+ 0
bookkeeping))))
)))
+ ((equal type 'static-member)
+ (let* ((parent-class (plist-get item 'class))
+ (downcased-parent-class (downcase parent-class))
+ (member (plist-get item 'member))
+ (member-type (plist-get member 'ast-type)))
+
+ (cond
+
+ ((string= downcased-parent-class "self")
+
+ (cond
+
+ ((equal member-type 'simple-variable)
+ (let* ((sub-variable-namespace
+
(phps-mode-ast-bookkeeping--generate-variable-namespace
+ namespace
+ class
+ nil))
+ (variable-id
+ (format
+ "%s static id %s"
+ sub-variable-namespace
+ (plist-get member 'name)))
+ (bookkeeping-object
+ (list
+ (plist-get member 'start)
+ (plist-get member 'end))))
+ (if (gethash variable-id bookkeeping)
+ (puthash
+ bookkeeping-object
+ 1
+ bookkeeping)
+ (puthash
+ bookkeeping-object
+ 0
+ bookkeeping))))
+
+ )
+
+ ))))
+
))))
(setq
phps-mode-ast-bookkeeping--index
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index c57b9420f8..ba863c74cf 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -378,7 +378,7 @@
(phps-mode-ast-bookkeeping--generate)
(should (equal
(phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
- (list (list " class myParent id $var1" 1) (list (list 93 98) 1)
(list " class myParent static id $var2" 1) (list (list 127 132) 1) (list "
class myParent id $var3" 1) (list (list 145 150) 1) (list " class myParent id
$var4" 1) (list (list 160 165) 1) (list " class myParent function __construct
id $this" 1) (list (list 208 213) 1) (list (list 263 268) 1) (list (list 270
274) 1) (list (list 330 335) 0) (list (list 392 397) 1) (list (list 447 452) 1)
(list (list 454 458) 1) (l [...]
+ '((" class myParent id $var1" 1) ((93 98) 1) (" class myParent
static id $var2" 1) ((127 132) 1) (" class myParent id $var3" 1) ((145 150) 1)
(" class myParent id $var4" 1) ((160 165) 1) (" class myParent 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"
- [elpa] externals/phps-mode 84d447e4e6 119/212: Added TODO item, (continued)
- [elpa] externals/phps-mode 84d447e4e6 119/212: Added TODO item, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1ab6ac7324 131/212: Added failing tests for indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 7135a30446 173/212: Updated TODO items, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 63c5fef240 175/212: Started on tests for more basic functions of indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 735f1e0c89 176/212: More notes, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 73d460d5a4 181/212: Passing lexer tests with optimized lexer, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e5df43eea9 187/212: More tweaking of indentation helpers, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 413547fbf1 188/212: Searching for previous bracket now steps over optional PHP starting tags, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4b4a96fda2 208/212: Improved cache filename, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode ef97058a67 184/212: Added more tests for indentation helper functions, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a1af5b11fb 040/212: More work on bookkeeping of class properties via AST,
Christian Johansson <=
- [elpa] externals/phps-mode 4dc07c9041 050/212: Bookkeeping via AST working with assigned variables from array, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4d226f18cc 048/212: Bookkeeping via AST working with referenced foreach variables, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5603e6266b 047/212: SDT for array values, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 787d82313e 045/212: Bookkeeping via AST now tracks variables around inline-functions, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a629baba89 053/212: More work on bookkeeping via AST for arrow function variables, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode df0b707a61 044/212: Added parser SDT for inline-function, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 432382eddb 051/212: Added bookkeeping support for global variables in functions, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode bb381d8127 041/212: Bookkeeping of class properties via AST passed test, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e95df1027b 042/212: Reverted old tests for imenu and bookkeeping for lex-analyzer, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a65c8af308 008/212: Extract ast code into separate file and test, Christian Johansson, 2022/01/26