[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 5686703a6b 074/212: Passing bookkeeping via A
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 5686703a6b 074/212: Passing bookkeeping via AST for $this inside arrow function body inside class method |
Date: |
Wed, 26 Jan 2022 01:50:54 -0500 (EST) |
branch: externals/phps-mode
commit 5686703a6bbcf9757ba745fcae16d4a70e2dd5bf
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing bookkeeping via AST for $this inside arrow function body inside
class method
---
phps-mode-ast-bookkeeping.el | 75 +++++++++++++++++++++++++++-----------------
phps-mode-parser-sdt.el | 4 +--
test/phps-mode-test-ast.el | 22 ++++++-------
3 files changed, 59 insertions(+), 42 deletions(-)
diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index a5b2d6953e..e0b7ec01b7 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -773,40 +773,57 @@
(plist-get subject 'end))
1
bookkeeping)
-
- (let* ((sub-scope (cdr scope))
- (predefined)
- (variable-ids
-
(phps-mode-ast-bookkeeping--generate-variable-scope-string
- sub-scope
- (concat "$" property-name)
- t))
- (symbol-id
-
(phps-mode-ast-bookkeeping--generate-symbol-scope-string
- sub-scope
- property-name))
- (bookkeeping-object
- (list
- (plist-get item 'property-start)
- (plist-get item 'property-end))))
- (when (gethash symbol-id bookkeeping)
+ ;; When current scope is arrow function
+ ;; we should go up in scope until we get out of
+ ;; arrow functions scope
+ (let ((sub-scope scope)
+ (head-scope)
+ (is-arrow-function-scope t))
+ (while (and
+ sub-scope
+ is-arrow-function-scope)
(setq
- predefined
- t))
- (dolist (variable-id variable-ids)
- (when (gethash variable-id bookkeeping)
+ head-scope
+ (car sub-scope))
+ (setq
+ sub-scope
+ (cdr sub-scope))
+ (unless (equal
+ (plist-get head-scope 'type)
+ 'arrow-function)
+ (setq is-arrow-function-scope nil)))
+ (let* ((predefined)
+ (variable-ids
+
(phps-mode-ast-bookkeeping--generate-variable-scope-string
+ sub-scope
+ (concat "$" property-name)
+ t))
+ (symbol-id
+
(phps-mode-ast-bookkeeping--generate-symbol-scope-string
+ sub-scope
+ property-name))
+ (bookkeeping-object
+ (list
+ (plist-get item 'property-start)
+ (plist-get item 'property-end))))
+ (when (gethash symbol-id bookkeeping)
(setq
predefined
- t)))
- (if predefined
+ t))
+ (dolist (variable-id variable-ids)
+ (when (gethash variable-id bookkeeping)
+ (setq
+ predefined
+ t)))
+ (if predefined
+ (puthash
+ bookkeeping-object
+ 1
+ bookkeeping)
(puthash
bookkeeping-object
- 1
- bookkeeping)
- (puthash
- bookkeeping-object
- 0
- bookkeeping))))
+ 0
+ bookkeeping)))))
(t
(let ((variable-ids
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 1ecb0b778c..3485fdf0ac 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -830,7 +830,7 @@
ast-type
logical-xor-expression
a
- (phps-mode-parser-sdt--get-list-of-object ,(nth 0 args))
+ ,(phps-mode-parser-sdt--get-list-of-object (nth 0 args))
b
,(phps-mode-parser-sdt--get-list-of-object (nth 2 args))))
phps-mode-parser--table-translations)
@@ -843,7 +843,7 @@
ast-type
concat-expression
a
- (phps-mode-parser-sdt--get-list-of-object ,(nth 0 args))
+ ,(phps-mode-parser-sdt--get-list-of-object (nth 0 args))
b
,(phps-mode-parser-sdt--get-list-of-object (nth 2 args))))
phps-mode-parser--table-translations)
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index e5b07e2737..1f223b9484 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -37,17 +37,17 @@
buffer-contents
name
(lambda()
- (let ((parse (phps-mode-parser-parse)))
- (message "Left-to-right with right-most derivation:\n%S\n" parse)
- (dolist (production-number (reverse parse))
- (let ((production
- (phps-mode-parser--get-grammar-production-by-number
- production-number)))
- (message
- "%d: %S -> %S"
- production-number
- (car (car production))
- (car (cdr production))))))
+ ;; (let ((parse (phps-mode-parser-parse)))
+ ;; (message "Left-to-right with right-most derivation:\n%S\n" parse)
+ ;; (dolist (production-number (reverse parse))
+ ;; (let ((production
+ ;; (phps-mode-parser--get-grammar-production-by-number
+ ;; production-number)))
+ ;; (message
+ ;; "%d: %S -> %S"
+ ;; production-number
+ ;; (car (car production))
+ ;; (car (cdr production))))))
(phps-mode-ast--generate)
(phps-mode-ast-bookkeeping--generate)
(should
- [elpa] externals/phps-mode 787d82313e 045/212: Bookkeeping via AST now tracks variables around inline-functions, (continued)
- [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
- [elpa] externals/phps-mode 23c001c33f 037/212: Moved parser SDT to separate file, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 261121f096 056/212: Fixed incorrect information in debug output in test, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e8a47de694 052/212: Work on supported arrow functions for bookkeeping via AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5686703a6b 074/212: Passing bookkeeping via AST for $this inside arrow function body inside class method,
Christian Johansson <=
- [elpa] externals/phps-mode a9d0e941df 066/212: Started on SDT for static variables statement, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a8fecdfd68 055/212: Bookkeeping of variables inside arrow functions now working, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e42646dc3a 058/212: Added SDT for isset() and empty(), Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 9ad46d061e 057/212: Bookkeeping via AST passing two more tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 806bb902b3 122/212: Improved indentation for chaining objects, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode cc3bf03786 123/212: Improved indentation after ending assignment expression, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3162dca5c4 159/212: Added two more failing indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1e44021653 163/212: Added more failing indent tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e7aff3f69d 157/212: Passed more indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode db7121941c 156/212: Passing indention on line after not equals condition, Christian Johansson, 2022/01/26