[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode bfa60ea 2/3: Passed tests for bookkeeping of
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode bfa60ea 2/3: Passed tests for bookkeeping of static variables |
Date: |
Tue, 3 Aug 2021 17:45:13 -0400 (EDT) |
branch: externals/phps-mode
commit bfa60ea807d4743d7d2c84ce4c822ea808e16a12
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passed tests for bookkeeping of static variables
---
phps-mode-lex-analyzer.el | 23 ++++++++++-------------
test/phps-mode-test-lex-analyzer.el | 7 +++----
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 3e4384c..490afc5 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -1161,7 +1161,6 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
(in-anonymous-function-number 0)
(in-anonymous-function-nesting-level)
(in-global-declaration nil)
- (in-static-declaration nil)
(in-arrow-fn nil)
(in-arrow-fn-declaration nil)
(in-arrow-fn-number 0)
@@ -1358,10 +1357,14 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
(when (and
imenu-in-class-name
(equal previous-token 'T_STATIC)
- (not imenu-in-function-declaration))
- (setq bookkeeping-namespace (concat
bookkeeping-namespace " static"))
+ (not imenu-in-function-declaration)
+ (not imenu-in-function-name))
+ (setq
+ bookkeeping-namespace
+ (concat bookkeeping-namespace " static"))
(when bookkeeping-alternative-namespace
- (setq bookkeeping-alternative-namespace (concat
bookkeeping-alternative-namespace " static"))))
+ (setq bookkeeping-alternative-namespace
+ (concat bookkeeping-alternative-namespace "
static"))))
(setq bookkeeping-namespace (concat
bookkeeping-namespace " id " bookkeeping-variable-name))
(when bookkeeping-alternative-namespace
@@ -1445,9 +1448,8 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
(setq bookkeeping-in-assignment t))
;; In static variable declaration
- (when (and in-static-declaration
- (equal token 'T_VARIABLE)
- imenu-in-function-name)
+ (when (and (equal previous-token 'T_STATIC)
+ (equal token 'T_VARIABLE))
(setq bookkeeping-in-assignment t))
;; In [$abc, $def] = .. or array($abc, $def) = ...
@@ -1554,12 +1556,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
;; Keep track of global declaration for bookkeeping
(if (equal token 'T_GLOBAL)
(setq in-global-declaration t)
- (setq in-global-declaration nil))
-
- ;; Keep track of static declaration for bookkeeping
- (if (equal token 'T_STATIC)
- (setq in-static-declaration t)
- (setq in-static-declaration nil)))
+ (setq in-global-declaration nil)))
;; Keep track of open catch blocks for bookkeeping
(when (equal token 'T_CATCH)
diff --git a/test/phps-mode-test-lex-analyzer.el
b/test/phps-mode-test-lex-analyzer.el
index 2236e4a..370dc08 100644
--- a/test/phps-mode-test-lex-analyzer.el
+++ b/test/phps-mode-test-lex-analyzer.el
@@ -1469,8 +1469,7 @@
(phps-mode-test--with-buffer
"<?php\nclass myClass {\n function random() {}\n function
__construct()\n {\n $this->random();\n $this->random['abc'] =
123;\n }\n}"
- "Method calls should be avoied in bookkeeping"
- ;; (message "Bookkeeping: %s" (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t))
+ "Method calls should be avoided in bookkeeping"
(should (equal
(phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
(list (list " class myClass function __construct id $this" 1)
(list (list 89 94) 1) (list (list 114 119) 1)))))
@@ -1585,14 +1584,14 @@
"Bookkeeping of static variables in different scopes without namespaces"
(should (equal
(phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" $id $a" 1) ((15 17) 1) ((24 26) 1) (" function test id $a" 1)
((61 63) 1) ((73 75) 1) (" class There function here id $this" 1) (" class
There function here static id $a" 1) ((138 140) 1) ((154 156) 1)))))
+ '((" id $a" 1) ((15 17) 1) ((24 26) 1) (" function test id $a" 1)
((61 63) 1) ((73 75) 1) (" class There function here id $this" 1) (" class
There function here id $a" 1) ((138 140) 1) ((154 156) 1)))))
(phps-mode-test--with-buffer
"<?php\n\nnamespace Here\n{\n function here()\n {\n static
$a;\n if ($a) {}\n }\n class There\n {\n public function
Near()\n {\n static $a;\n if ($a) {}\n }\n
}\n}\nnamespace\n{\n static $a;\n if ($a) {}\n}\n"
"Bookkeeping of static variables in different scopes with namespaces"
(should (equal
(phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" namespace Here function here id $a" 1) ((66 68) 1) ((82 84)
1) (" namespace Here class There function Near id $this" 1) (" namespace Here
class There function Near id $a" 1) ((177 179) 1) ((197 199) 1) ("id $a" 1)
((245 247) 1) ((257 259) 1)))))
+ '((" namespace Here function here id $a" 1) ((66 68) 1) ((82 84)
1) (" namespace Here class There function Near id $this" 1) (" namespace Here
class There function Near id $a" 1) ((177 179) 1) ((197 199) 1) (" id $a" 1)
((245 247) 1) ((257 259) 1)))))
)