[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 9c43bc30c4 103/135: Removed old bookkeeping a
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 9c43bc30c4 103/135: Removed old bookkeeping and imenu and integrated new via SDT |
Date: |
Sun, 29 Jan 2023 03:11:09 -0500 (EST) |
branch: externals/phps-mode
commit 9c43bc30c43ef7e6587eb17f5fa00ea36f5e3972
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Removed old bookkeeping and imenu and integrated new via SDT
---
phps-mode-ast-bookkeeping.el | 257 -------------------------------------------
phps-mode-ast-imenu.el | 122 --------------------
phps-mode-ast.el | 6 +-
phps-mode-lex-analyzer.el | 81 ++++----------
test/phps-mode-test-ast.el | 3 -
5 files changed, 23 insertions(+), 446 deletions(-)
diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
deleted file mode 100644
index 6bf8875c65..0000000000
--- a/phps-mode-ast-bookkeeping.el
+++ /dev/null
@@ -1,257 +0,0 @@
-;;; phps-mode-ast-bookkeeping.el --- Bookkeeping from AST -*- lexical-binding:
t -*-
-
-;; Copyright (C) 2018-2022 Free Software Foundation, Inc.
-
-
-;;; Commentary:
-
-
-;;; Code:
-
-
-(require 'phps-mode-ast)
-
-
-;;; Variables:
-
-
-(defvar-local
- phps-mode-ast-bookkeeping--index
- nil
- "Bookkeeping string index for current buffer.")
-
-(defvar-local
- phps-mode-ast-bookkeeping--object-index
- nil
- "Bookkeeping object index for current buffer.")
-
-(defvar
- phps-mode-ast-bookkeeping--superglobal-variable-p
- #s(hash-table size 12 test equal rehash-size 1.5 rehash-threshold 0.8125
data ("$_GET" 1 "$_POST" 1 "$_COOKIE" 1 "$_SESSION" 1 "$_REQUEST" 1 "$GLOBALS"
1 "$_SERVER" 1 "$_FILES" 1 "$_ENV" 1 "$argc" 1 "$argv" 1
"$http_​response_​header" 1))
- "Hash-table of super-global variables.")
-
-
-;; Functions:
-
-
-(defun phps-mode-ast-bookkeeping--generate-symbol-scope-string
- (scope name)
- "Generate symbol scope string from SCOPE and NAME."
- (let ((scope-string ""))
- (dolist (bubble (reverse scope))
- (let ((scope-type (plist-get bubble 'type))
- (scope-name (plist-get bubble 'name)))
- (cond
-
- ((and
- (equal scope-type 'namespace)
- scope-name)
- (setq
- scope-string
- (format
- "%s namespace %s"
- scope-string
- scope-name)))
-
- ((and
- (or (equal scope-type 'class)
- (equal scope-type 'interface))
- scope-name)
- (setq
- scope-string
- (format
- "%s class %s"
- scope-string
- scope-name)))
-
- ((and
- (equal scope-type 'function)
- (setq
- scope-string
- (format
- "%s function %s"
- scope-string
- scope-name))))
-
- ((and
- (equal scope-type 'inline-function)
- scope-name)
- (setq
- scope-string
- (format
- "%s anonymous function %s"
- scope-string
- scope-name)))
-
- ((and
- (equal scope-type 'arrow-function)
- scope-name)
- (setq
- scope-string
- (format
- "%s arrow function %s"
- scope-string
- scope-name)))
-
- ((and
- (equal scope-type 'static)
- (setq
- scope-string
- (format
- "%s static"
- scope-string))))
-
- )))
- (setq
- scope-string
- (format
- "%s id %s"
- scope-string
- name))
- scope-string))
-
-(defun phps-mode-ast-bookkeeping--generate-variable-scope-string
- (scope name &optional read-only)
- "Generate variable scope string from SCOPE and NAME and optionally
READ-ONLY."
- (let ((scope-strings)
- (bubbles-stack (list (list "" nil nil (reverse scope))))
- (bubbles-data))
- (while bubbles-stack
- (setq
- bubbles-data
- (pop bubbles-stack))
- (let ((scope-string (car bubbles-data))
- (namespace (car (cdr bubbles-data)))
- (class (car (cdr (cdr bubbles-data))))
- (bubbles (car (cdr (cdr (cdr bubbles-data))))))
- (while bubbles
- (let* ((bubble (pop bubbles))
- (scope-type (plist-get bubble 'type))
- (scope-name (plist-get bubble 'name)))
- (cond
-
- ((and
- (equal scope-type 'namespace)
- scope-name)
- (setq
- namespace
- scope-name))
-
- ((and
- (or (equal scope-type 'class)
- (equal scope-type 'interface))
- scope-name)
- (if namespace
- (setq
- scope-string
- (format
- "%s namespace %s class %s"
- scope-string
- namespace
- scope-name))
- (setq
- scope-string
- (format
- "%s class %s"
- scope-string
- scope-name)))
- (setq
- class
- scope-name))
-
- ((and
- (equal scope-type 'function)
- scope-name)
- (if (and
- namespace
- (not class))
- (setq
- scope-string
- (format
- "%s namespace %s function %s"
- scope-string
- namespace
- scope-name))
- (setq
- scope-string
- (format
- "%s function %s"
- scope-string
- scope-name))))
-
- ((and
- (equal scope-type 'inline-function)
- scope-name)
- (setq
- scope-string
- (format
- "%s anonymous function %s"
- scope-string
- scope-name)))
-
- ((and
- (equal scope-type 'defined)
- scope-name)
- (when read-only
- ;; Branch off here in alternative scope without this defined
context
- ;; but only for read-only contexts
- (push
- (list
- scope-string
- namespace
- class
- bubbles)
- bubbles-stack))
- (setq
- scope-string
- (format
- "%s defined %s"
- scope-string
- scope-name)))
-
- ((and
- (equal scope-type 'arrow-function)
- scope-name)
- (when read-only
- ;; Branch off here in alternative scope without arrow context
- ;; but only for read-only contexts
- (push
- (list
- scope-string
- namespace
- class
- bubbles)
- bubbles-stack))
- (setq
- scope-string
- (format
- "%s arrow function %s"
- scope-string
- scope-name)))
-
- ((and
- (equal scope-type 'static)
- (setq
- scope-string
- (format
- "%s static"
- scope-string))))
-
- )))
- (setq
- scope-string
- (format
- "%s id %s"
- scope-string
- name))
- (push scope-string scope-strings)))
- scope-strings))
-
-(defun phps-mode-ast-bookkeeping--generate (&optional tree)
- "Generate AST for current buffer or optionally for TREE."
- (setq phps-mode-ast-bookkeeping--index phps-mode-parser-sdt-bookkeeping)
- phps-mode-ast-bookkeeping--index)
-
-
-(provide 'phps-mode-ast-bookkeeping)
-;;; phps-mode-ast-bookkeeping.el ends here
diff --git a/phps-mode-ast-imenu.el b/phps-mode-ast-imenu.el
deleted file mode 100644
index 1b3528ee33..0000000000
--- a/phps-mode-ast-imenu.el
+++ /dev/null
@@ -1,122 +0,0 @@
-;;; phps-mode-ast-imenu.el --- Imenu from AST -*- lexical-binding: t -*-
-
-;; Copyright (C) 2018-2022 Free Software Foundation, Inc.
-
-
-;;; Commentary:
-
-
-;;; Code:
-
-
-(require 'phps-mode-ast)
-
-(defvar-local
- phps-mode-ast-imenu--index
- nil
- "Imenu for current buffer.")
-
-(defun phps-mode-ast-imenu--generate (&optional tree)
- "Generate imenu from current buffer AST or optionally from TREE."
- (let ((imenu-index)
- (ast-tree (if tree tree phps-mode-ast--tree))
- (global-namespace-name)
- (global-namespace-items))
- (dolist (item ast-tree)
- (let ((children (plist-get item 'children))
- (item-type (plist-get item 'ast-type))
- (item-index (plist-get item 'index))
- (item-name (plist-get item 'name))
- (parent))
- (when (and
- item-index
- item-name
- item-type)
- (if (or
- (equal item-type 'namespace)
- (equal item-type 'class)
- (equal item-type 'interface))
- (if children
- (progn
- (dolist (child children)
- (let ((grand-children (plist-get child 'children))
- (child-type (plist-get child 'ast-type))
- (child-name (plist-get child 'name))
- (child-index (plist-get child 'index))
- (subparent))
- (when (and
- child-name
- child-index)
- (if (and
- (or
- (equal child-type 'class)
- (equal child-type 'interface))
- grand-children)
- (progn
- (dolist (grand-child grand-children)
- (let ((grand-child-index
- (plist-get grand-child 'index))
- (grand-child-name
- (plist-get grand-child 'name)))
- (when (and
- grand-child-index
- grand-child-name)
- (push
- `(,grand-child-name .
,grand-child-index)
- subparent))))
- (when subparent
- (push
- (append
- (list child-name)
- (reverse subparent))
- parent)))
- (push
- `(,child-name . ,child-index)
- parent)))))
- (when parent
- (let ((parent-item
- (append
- (list item-name)
- (reverse parent))))
- (if global-namespace-name
- (push
- parent-item
- global-namespace-items)
- (push
- parent-item
- imenu-index))
- imenu-index)))
- (if (equal item-type 'namespace)
- (setq
- global-namespace-name
- item-name)
- (if global-namespace-name
- (push
- `(,item-name . ,item-index)
- global-namespace-items)
- (push
- `(,item-name . ,item-index)
- imenu-index))))
- (if global-namespace-name
- (push
- `(,item-name . ,item-index)
- global-namespace-items)
- (push
- `(,item-name . ,item-index)
- imenu-index))))))
- (when global-namespace-name
- (push
- (append
- (list global-namespace-name)
- (reverse global-namespace-items))
- imenu-index))
- (setq
- phps-mode-ast-imenu--index
- (reverse imenu-index)))
-
- ;; (message "imenu:\n%S\n\n" phps-mode-ast-imenu--index)
- phps-mode-ast-imenu--index)
-
-
-(provide 'phps-mode-ast-imenu)
-;;; phps-mode-ast-imenu.el ends here
diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index f38af310d2..f73cd46f4d 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -9,6 +9,7 @@
;;; Code:
+(require 'phps-mode-macros)
(require 'phps-mode-parser-sdt)
@@ -67,9 +68,8 @@
phps-mode-ast--parse-trail
parse-trail)
- (message "\nTranslation:\n%S\n\n" translation)
-
- ;; TODO Should sort this by position
+ (phps-mode-debug-message
+ (message "\nTranslation:\n%S\n\n" translation))
(setq
phps-mode-parser-sdt-symbol-imenu
(nreverse phps-mode-parser-sdt-symbol-imenu))
diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 73dce8050a..320e3c12d3 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -24,8 +24,6 @@
(require 'phps-mode-serial)
(require 'phps-mode-syntax-color)
(require 'phps-mode-ast)
-(require 'phps-mode-ast-bookkeeping)
-(require 'phps-mode-ast-imenu)
(require 'subr-x)
@@ -260,46 +258,26 @@
(setq phps-mode-lex-analyzer--parse-trail (nth 7 lex-result))
(setq phps-mode-lex-analyzer--parse-error (nth 8 lex-result))
(setq phps-mode-lex-analyzer--ast (nth 9 lex-result))
-
- ;; Catch errors in bookkeeping generation
- (condition-case conditions
- (phps-mode-ast-bookkeeping--generate
- phps-mode-lex-analyzer--ast)
- (error
- (display-warning
- 'phps-mode
- (format "Failed to generate bookkeeping: %S" conditions)
- :warning
- "*PHPs Bookkeeping Generation Errors*")))
- (setq phps-mode-lex-analyzer--bookkeeping
- phps-mode-ast-bookkeeping--index)
-
- ;; Catch errors in imenu generation
- (condition-case conditions
- (phps-mode-ast-imenu--generate
- phps-mode-lex-analyzer--ast)
- (error
- (display-warning
- 'phps-mode
- (format "Failed to generate imenu: %S" conditions)
- :warning
- "*PHPs Imenu Generation Errors*")))
- (setq phps-mode-lex-analyzer--imenu phps-mode-ast-imenu--index)
+ (setq phps-mode-lex-analyzer--bookkeeping (nth 10 lex-result))
+ (setq phps-mode-lex-analyzer--imenu (nth 11 lex-result))
(setq phps-mode-lex-analyzer--processed-buffer-p t)
(phps-mode-lex-analyzer--reset-imenu)
- ;; Apply syntax color on tokens
+ ;; Apply syntax color
+ (phps-mode-lex-analyzer--clear-region-syntax-color
+ (point-min)
+ (point-max))
(dolist (token phps-mode-lex-analyzer--tokens)
(let ((start (car (cdr token)))
(end (cdr (cdr token))))
(let ((token-syntax-color
(phps-mode-lex-analyzer--get-token-syntax-color token)))
- (if token-syntax-color
+ (when token-syntax-color
(phps-mode-lex-analyzer--set-region-syntax-color
- start end (list 'font-lock-face token-syntax-color))
- (phps-mode-lex-analyzer--clear-region-syntax-color
- start end)))))
+ start
+ end
+ (list 'font-lock-face token-syntax-color))))))
;; Reset buffer changes minimum index
(phps-mode-lex-analyzer--reset-changes)
@@ -425,49 +403,30 @@
(setq phps-mode-lex-analyzer--parse-trail (nth 7 lex-result))
(setq phps-mode-lex-analyzer--parse-error (nth 8 lex-result))
(setq phps-mode-lex-analyzer--ast (nth 9 lex-result))
-
- ;; Catch errors in bookkeeping generation
- (condition-case conditions
- (phps-mode-ast-bookkeeping--generate
- phps-mode-lex-analyzer--ast)
- (error
- (display-warning
- 'phps-mode
- (format "Failed to generate bookkeeping: %S" conditions)
- :warning
- "*PHPs Bookkeeping Generation Errors*")))
- (setq phps-mode-lex-analyzer--bookkeeping
- phps-mode-ast-bookkeeping--index)
-
- ;; Catch errors in imenu generation
- (condition-case conditions
- (phps-mode-ast-imenu--generate
- phps-mode-lex-analyzer--ast)
- (error
- (display-warning
- 'phps-mode
- (format "Failed to generate imenu: %S" conditions)
- :warning
- "*PHPs Imenu Generation Errors*")))
- (setq phps-mode-lex-analyzer--imenu phps-mode-ast-imenu--index)
+ (setq phps-mode-lex-analyzer--bookkeeping (nth 10 lex-result))
+ (setq phps-mode-lex-analyzer--imenu (nth 11 lex-result))
(phps-mode-debug-message
- (message "Incremental tokens: %s" phps-mode-lex-analyzer--tokens))
+ (message
+ "Incremental tokens: %s"
+ phps-mode-lex-analyzer--tokens))
;; Save processed result
(setq phps-mode-lex-analyzer--processed-buffer-p t)
(phps-mode-lex-analyzer--reset-imenu)
;; Apply syntax color on tokens
+ (phps-mode-lex-analyzer--clear-region-syntax-color
+ incremental-start-new-buffer
+ point-max)
(dolist (token phps-mode-lex-analyzer--tokens)
(let ((start (car (cdr token)))
(end (cdr (cdr token))))
;; Apply syntax color on token
(let ((token-syntax-color
(phps-mode-lex-analyzer--get-token-syntax-color token)))
- (if token-syntax-color
- (phps-mode-lex-analyzer--set-region-syntax-color start
end (list 'font-lock-face token-syntax-color))
- (phps-mode-lex-analyzer--clear-region-syntax-color start
end)))))
+ (when token-syntax-color
+ (phps-mode-lex-analyzer--set-region-syntax-color start
end (list 'font-lock-face token-syntax-color))))))
;; Reset buffer changes minimum index
(phps-mode-lex-analyzer--reset-changes)
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index d08cb31e05..65ebb01de2 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -14,8 +14,6 @@
(require 'ert)
(require 'phps-mode)
(require 'phps-mode-ast)
-(require 'phps-mode-ast-bookkeeping)
-(require 'phps-mode-ast-imenu)
(require 'phps-mode-lex-analyzer)
(require 'phps-mode-test)
@@ -38,7 +36,6 @@
(car (cdr production))))))
(message "\n")
(phps-mode-ast--generate)
- (phps-mode-ast-bookkeeping--generate)
;; (message "symbol-table: \n%S\n" phps-mode-parser-sdt-symbol-table)
;; (message "phps-mode-parser-sdt-symbol-table-by-uri: \n%S\n"
phps-mode-parser-sdt-symbol-table-by-uri)
- [elpa] externals/phps-mode 1afe6aaec7 086/135: Passing more tests for static variables, (continued)
- [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, 2023/01/29
- [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 <=
- [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
- [elpa] externals/phps-mode d5bdadc6fc 135/135: Improved installation documentation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 8259e390b4 092/135: Added TODO item, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 9f21c86dd1 108/135: SDT integration now passing byte-compilation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ddc5b5aa2a 112/135: Using sorted bookkeeping for test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode b7d5d7823c 118/135: Starting on sorting imenu, Christian Johansson, 2023/01/29