[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode ada5e79291 097/135: Passing bookkeeping test
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode ada5e79291 097/135: Passing bookkeeping test for class properties in class constructor |
Date: |
Sun, 29 Jan 2023 03:11:08 -0500 (EST) |
branch: externals/phps-mode
commit ada5e79291a73aea54915076a4e7faddf2bf6e38
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing bookkeeping test for class properties in class constructor
---
phps-mode-parser-sdt.el | 57 +++++++++++++++++++++++++++++++---------------
test/phps-mode-test-ast.el | 3 +--
2 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 636d9aefe1..9debeadd39 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -780,7 +780,7 @@
(let ((potential-uri-count (length potential-uris))
(potential-uri-index 0)
(matching-uri))
- (message "potential-uris: %S" potential-uris)
+ ;; (message "potential-uris: %S" potential-uris)
;; Iterate potential-uris, select first match or if no match return
the first
(while (< potential-uri-index potential-uri-count)
@@ -815,13 +815,13 @@
symbol-name
symbol-scope)))
- (message
- "assign symbol uri: %S from %S + %S, start: %S, end: %S"
- symbol-uri
- symbol-name
- symbol-scope
- symbol-start
- symbol-end)
+ ;; (message
+ ;; "assign symbol uri: %S from %S + %S, start: %S, end: %S"
+ ;; symbol-uri
+ ;; symbol-name
+ ;; symbol-scope
+ ;; symbol-start
+ ;; symbol-end)
(if (gethash symbol-uri phps-mode-parser-sdt-bookkeeping)
(puthash
@@ -884,14 +884,14 @@
symbol-hit
phps-mode-parser-sdt-bookkeeping)
- (message
- "reference symbol uri: %S from %S + %S, start: %S, end: %S, hit?: %S"
- symbol-uri
- symbol-name
- symbol-scope
- symbol-start
- symbol-end
- symbol-hit)
+ ;; (message
+ ;; "reference symbol uri: %S from %S + %S, start: %S, end: %S, hit?:
%S"
+ ;; symbol-uri
+ ;; symbol-name
+ ;; symbol-scope
+ ;; symbol-start
+ ;; symbol-end
+ ;; symbol-hit)
))
(setq
@@ -3445,10 +3445,12 @@
;; - add function scope but only for:
;; - non-super-global variables
;; - symbols defined inside function limits
- (let ((function-name
+ (let* ((function-name
(plist-get
attributed-class-statement
'ast-name))
+ (function-name-downcased
+ (downcase function-name))
(function-start
(plist-get
attributed-class-statement
@@ -3461,7 +3463,11 @@
(plist-get
attributed-class-statement
'parameter-list))
- (is-static-p))
+ (is-static-p)
+ (is-contructor-p
+ (string=
+ function-name-downcased
+ "__construct")))
;; Is static method?
(when-let (method-modifiers
@@ -3540,12 +3546,27 @@
'parameter))
(attributed-parameter-name
(plist-get attributed-parameter 'ast-name))
+ (attributed-parameter-visibility
+ (plist-get attributed-parameter 'visibility))
(symbol-name
attributed-parameter-name)
(symbol-start
(plist-get attributed-parameter 'ast-start))
(symbol-end
(plist-get attributed-parameter 'ast-end)))
+
+ (when (and
+ is-contructor-p
+ attributed-parameter-visibility)
+ ;; Declare class properties here
+ (push
+ (list
+ symbol-name
+ phps-mode-parser-sdt--bookkeeping-namespace
+ symbol-start
+ symbol-end)
+
phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack))
+
(push
(list
symbol-name
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index be42e58ddd..98a7fa7ccf 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -383,11 +383,10 @@
"A basic trait class"
'((" trait MyTrait function sayHello id $this" ((80 147))) (" trait MyTrait
id $var" ((35 39))) ((101 104) 1) ((94 99) 1) ((35 39) 1)))
- ;; TODO Make this test pass
(phps-mode-test-ast--should-bookkeep
"<?php\nclass Person {\n public function __construct(\n private
string $name,\n private int $age,\n public $address\n ) {}\n}"
"Class with class properties in constructor."
- nil)
+ '((" class Person function __construct id $address" ((126 134))) (" class
Person id $address" ((126 134))) (" class Person function __construct id $age"
((105 109))) (" class Person id $age" ((105 109))) (" class Person function
__construct id $name" ((78 83))) (" class Person id $name" ((78 83))) ((126
134) 1) ((105 109) 1) ((78 83) 1)))
(message "\n-- Ran tests for bookkeeping generation. --"))
- [elpa] externals/phps-mode 962b905ca0 057/135: Bookkeeping working for class non-static properties, (continued)
- [elpa] externals/phps-mode 962b905ca0 057/135: Bookkeeping working for class non-static properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7b9f8011f1 056/135: More testing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e2f2c86e18 059/135: Improved class properties bookkeeping test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode eac10d63e6 063/135: Started on bookkeeping of variables inside anonymous functions, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e924ac83b6 065/135: Improved bookkeeping test for anonymous function, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e614a20ada 066/135: Added bookkeeping for referenced foreach variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d33625bb1a 067/135: Bookkeeping for array assignment passing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode a646676781 084/135: Passing more bookkeeping tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7609f09f04 090/135: More bookkeeping final touches, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test for trait class symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ada5e79291 097/135: Passing bookkeeping test for class properties in class constructor,
Christian Johansson <=
- [elpa] externals/phps-mode 8aae220c57 098/135: Started on integrating imenu generation in SDT bookkeeping, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 95f563fc70 102/135: Passing bookkeeping tests with integrated imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ae516f9e19 105/135: Using separate imenu items for redeclared symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode b21c9f3f3a 107/135: Imenu generation via SDT all tests now passing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 3332b2bfa9 109/135: Fixes syntax coloring of super-globals, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode bddf800099 111/135: Added failing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d98f6d78d8 114/135: Saving symbol-table after parse, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1594c15e9e 117/135: More work on imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 776c818ff9 121/135: Passing some more imenu tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode c6e4844753 122/135: Some byte-compilation fixes, Christian Johansson, 2023/01/29