branch: externals/phpinspect
commit a75ea69ad7f97e8e902b659fb765af383d53acec
Author: Hugo Thunnissen <de...@hugot.nl>
Commit: Hugo Thunnissen <de...@hugot.nl>

    Remove unneeded variables, remove worker pausing code and remove 
company-backend
    
     - Company backend wasn't being maintained, CAPF implementation works fine
     - Worker pausing is no longer necessary as collaborative threading
       implementation in the parser has been drastically improved.
     - Remove unused configuration variables
---
 phpinspect-pipeline.el |  15 --------
 phpinspect-project.el  |   9 +----
 phpinspect-thread.el   |   2 +-
 phpinspect-worker.el   |  32 ++--------------
 phpinspect.el          | 102 +------------------------------------------------
 5 files changed, 8 insertions(+), 152 deletions(-)

diff --git a/phpinspect-pipeline.el b/phpinspect-pipeline.el
index 5413bbc185..0c59166de2 100644
--- a/phpinspect-pipeline.el
+++ b/phpinspect-pipeline.el
@@ -32,21 +32,6 @@
 (defun phpinspect-pipeline-error-p (obj)
   (eq 'phpinspect-pipeline-error (car-safe obj)))
 
-(defcustom phpinspect-pipeline-pause-time 0.1
-  "Number of seconds to pause a pipeline thread when emacs receives
-user input. This is similar to `phpinspect-worker-pause-time',
-but pipelines are meant to run in bursts. For that reason, the
-default pause time for pipelines is lower to be a little more
-aggressive in hogging cpu time.
-
-Set this variable to a higher value if you experience a lot of
-jitter when editing during pipeline operations.  At the time of
-writing, pipelines are used to refresh the project
-index/autoloader and for the indexation of \"include\"
-directories."
-  :type 'number
-  :group 'phpinspect)
-
 (cl-defstruct (phpinspect-pipeline-end (:constructor 
phpinspect-make-pipeline-end))
   (value nil
          :type any)
diff --git a/phpinspect-project.el b/phpinspect-project.el
index 582b7bbbff..329b93edd3 100644
--- a/phpinspect-project.el
+++ b/phpinspect-project.el
@@ -402,7 +402,7 @@ before the search is executed."
        (phpinspect--type= (phpinspect-index-task-type task1) 
(phpinspect-index-task-type task2))))
 
 (cl-defmethod phpinspect-task-execute ((task phpinspect-index-task)
-                                       (worker phpinspect-worker))
+                                       (_worker phpinspect-worker))
   "Execute index TASK for WORKER."
   (let ((project (phpinspect-index-task-project task))
         (is-native-type (phpinspect--type-is-native
@@ -413,12 +413,7 @@ before the search is executed."
 
     (cond (is-native-type
            (phpinspect--log "Skipping indexation of native type %s as task"
-                            (phpinspect-index-task-type task))
-
-           ;; We can skip pausing when a native type is encountered
-           ;; and skipped, as we haven't done any intensive work that
-           ;; may cause hangups.
-           (setf (phpinspect-worker-skip-next-pause worker) t))
+                            (phpinspect-index-task-type task)))
           (t
            (let* ((type (phpinspect-index-task-type task))
                   (root-index (phpinspect-project-index-type-file project 
type)))
diff --git a/phpinspect-thread.el b/phpinspect-thread.el
index d80058aa9a..76b28e77df 100644
--- a/phpinspect-thread.el
+++ b/phpinspect-thread.el
@@ -114,7 +114,7 @@
   (signal 'phpinspect-job-queue-end nil))
 
 (define-inline phpi-thread-yield ()
-  "Like `thread-yield', but takes extra care not to starve the main thread.
+  "Like `thread-yield', but takes extra care not to yield the main thread.
 
 If current thread is the main thread, this function does nothing."
   (inline-quote
diff --git a/phpinspect-worker.el b/phpinspect-worker.el
index 979a256594..1885d2ea71 100644
--- a/phpinspect-worker.el
+++ b/phpinspect-worker.el
@@ -34,14 +34,6 @@
 (eval-when-compile
   (phpinspect--declare-log-group 'worker))
 
-(defcustom phpinspect-worker-pause-time 1
-  "Number of seconds that `phpinspect-worker' should pause when
-user input is detected. A higher value means better
-responsiveness, at the cost of slower code indexation. On modern
-hardware this probably doesn't need to be tweaked."
-  :type 'number
-  :group 'phpinspect)
-
 (defvar phpinspect-worker nil
   "Contains the phpinspect worker that is used by all projects.")
 
@@ -59,11 +51,7 @@ hardware this probably doesn't need to be tweaked."
                     :type bool
                     :documentation
                     "Whether or not the thread should continue
-running. If this is nil, the thread is stopped.")
-  (skip-next-pause nil
-                   :type bool
-                   :documentation
-                   "Whether or not the thread should skip its next scheduled 
pause."))
+running. If this is nil, the thread is stopped."))
 
 (cl-defstruct (phpinspect-dynamic-worker
                (:constructor phpinspect-make-dynamic-worker-generated))
@@ -133,17 +121,12 @@ already present in the queue."
 (cl-defgeneric phpinspect-worker-make-thread-function (worker)
   "Create a function that can be used to start WORKER's thread.")
 
-(defun phpinspect--worker-pause ()
-  (let* ((mx (make-mutex))
-         (continue (make-condition-variable mx)))
-    (phpinspect-thread-pause phpinspect-worker-pause-time mx continue)))
-
 (cl-defmethod phpinspect-worker-make-thread-function ((worker 
phpinspect-worker))
   (lambda ()
     (let ((inhibit-quit t))
       (while (phpinspect-worker-continue-running worker)
         (condition-case err
-            (progn
+            (phpi-progn
               (phpinspect--log "Dequeueing next task")
               (let* ((task (phpinspect-queue-dequeue (phpinspect-worker-queue 
worker))))
                 (if task
@@ -155,16 +138,7 @@ already present in the queue."
                       (phpinspect-task-execute task worker))
                   ;; else: join with the main thread until wakeup is signaled
                   (phpinspect--log "No tasks, joining main thread")
-                  (thread-join main-thread)))
-
-              ;; Pause for a second after indexing something, to allow user 
input to
-              ;; interrupt the thread.
-              (when (or (phpinspect--input-pending-p)
-                        ;; Pause if quit-flag is set
-                        quit-flag
-                        (not (phpinspect-worker-skip-next-pause worker)))
-                (phpinspect--worker-pause))
-              (setf (phpinspect-worker-skip-next-pause worker) nil))
+                  (thread-join main-thread))))
           ;; This error is used to wake up the thread when new tasks are added
           ;; to the queue.
           (phpinspect-wakeup-thread)
diff --git a/phpinspect.el b/phpinspect.el
index 50f79b4bbc..7762e3c33a 100644
--- a/phpinspect.el
+++ b/phpinspect.el
@@ -25,7 +25,7 @@
 
 ;; PHPInspect is a minor mode that provides code intelligence for PHP in Emacs.
 ;; At its core is a PHP parser implemented in Emacs Lisp.  PHPInspect comes 
with
-;; backends for `completion-at-point`, `company-mode` and `eldoc`.  A backend
+;; backends for `completion-at-point` and `eldoc`.  A backend
 ;; for `xref` (which provides go-to-definition functionality) is planned to be
 ;; implemented at a later date.
 ;;
@@ -137,10 +137,6 @@
    (lambda () (phpinspect-buffer-reset phpinspect-current-buffer)))
   (add-hook 'kill-buffer-hook #'phpinspect-unregister-current-buffer)
 
-  (when (featurep 'company)
-    (make-local-variable 'company-backends)
-    (add-to-list 'company-backends #'phpinspect-company-backend))
-
   (add-hook 'completion-at-point-functions #'phpinspect-complete-at-point nil 
'local)
 
 
@@ -169,7 +165,6 @@ Reparses the entire buffer without token reuse."
   "Clean up the buffer environment for the mode to be disabled."
   (setq phpinspect-current-buffer nil)
   (kill-local-variable 'phpinspect--buffer-project)
-  (kill-local-variable 'company-backends)
   (kill-local-variable 'eldoc-documentation-function)
   (kill-local-variable 'eldoc-message-commands)
   (phpinspect-unregister-current-buffer))
@@ -199,10 +194,6 @@ For completion see `phpinspect-complete-at-point' which is
 automatically added to `completion-at-point-functions' when
 phpinspect-mode is activated.
 
-For company users, there is also
-`phpinspect-company-backend'. This is automatically added to
-`company-backends' when company is detected.
-
 For eldoc see `phpinspect-eldoc-function'.
 
 For finding/opening class files see
@@ -274,41 +265,8 @@ With a classic hook function:
 
     (add-hook \\='php-mode-hook #\\='my-php-personal-hook)
 
+;; end example configuration."
 
-Example configuration for `company-mode':
-
-    (defun my-php-personal-hook ()
-      ;; Assuming you already have company-mode enabled, these settings
-      ;; add some IDE-like flair to it. This is of course not required, do
-      ;; with it what you like.
-      (setq-local company-minimum-prefix-length 0)
-      (setq-local company-tooltip-align-annotations t)
-      (setq-local company-idle-delay 0.1)
-
-      ;; If you don't have company-mode enabled by default, uncomment this 
line:
-      ;; (company-mode)
-
-      ;; By default, phpinspect-mode adds itself as a backend to
-      ;; the `company-backends' of the current buffer. You can completely
-      ;; disable all other backends with the statement below.
-      (setq-local company-backends \\='(phpinspect-company-backend))
-
-      ;; Shortcut to add use statements for classes you use.
-      (define-key php-mode-map (kbd \"C-c u\") #\\='phpinspect-fix-imports)
-
-      ;; Shortcuts to quickly search/open files of PHP classes.
-      ;; You can make these local to php-mode, but making them global
-      ;; like this makes them work in other modes/filetypes as well, which
-      ;; can be handy when jumping between templates, config files and PHP 
code.
-      (global-set-key (kbd \"C-c a\") #\\='phpinspect-find-class-file)
-      (global-set-key (kbd \"C-c c\") #\\='phpinspect-find-own-class-file)
-
-      ;; Enable phpinspect-mode
-      (phpinspect-mode))
-
-    (add-hook \\='php-mode-hook #\\='my-php-personal-hook)
-
-    ;; End example configuration."
   :after-hook (phpinspect--mode-function)
   :keymap  (list (cons (kbd "C-c u") #'phpinspect-fix-imports)))
 
@@ -320,62 +278,6 @@ Example configuration for `company-mode':
     :completion-point (phpinspect--determine-completion-point)
     :point (point))))
 
-(eval-when-compile
-  (declare-function company-begin-backend "company.el"))
-
-(defun phpinspect-company-backend (command &optional arg &rest _ignored)
-  "A company backend for PHP."
-  (interactive (list 'interactive))
-  (require 'company)
-  (cond
-   ((eq command 'interactive)
-    (company-begin-backend 'company-phpinspect-backend))
-   ((eq command 'prefix)
-    (cond ((looking-back "->[A-Za-z_0-9-]*" nil)
-           (let ((match (match-string 0)))
-             (substring match 2 (length match))))
-          ((looking-back "::[A-Za-z_0-9-]*" nil)
-           (let ((match (match-string 0)))
-             (substring match 2 (length match))))
-          ((looking-back "\\$[A-Za-z_0-9-]" nil)
-           (let ((match (match-string 0)))
-             (substring match 1 (length match))))
-          ((looking-back "[A-Za-z_0-9-]+" nil t)
-           (match-string 0))))
-   ((eq command 'post-completion)
-    (when (eq 'function (phpinspect--completion-kind
-                         (phpinspect--completion-list-get-metadata
-                          phpinspect--last-completion-list
-                          arg)))
-      (insert "(")))
-   ((eq command 'candidates)
-    (catch 'phpinspect-interrupted
-      (let ((completion-list (phpinspect--suggest-at-point))
-            (candidates))
-
-        (setq candidates
-              (seq-filter (lambda (completion)
-                            (when completion
-                              (string-match (concat "^" (regexp-quote arg))
-                                            completion)))
-                          (phpinspect--completion-list-strings
-                           completion-list)))
-        (setq phpinspect--last-completion-list completion-list)
-        candidates)))
-   ((eq command 'annotation)
-    (concat " " (phpinspect--completion-annotation
-                 (phpinspect--completion-list-get-metadata
-                  phpinspect--last-completion-list
-                  arg))))
-   ((eq command 'kind)
-    (phpinspect--completion-kind
-     (phpinspect--completion-list-get-metadata
-      phpinspect--last-completion-list
-      arg)))
-   ((eq command 'meta)
-    (phpinspect--completion-meta
-              (phpinspect--completion-list-get-metadata 
phpinspect--last-completion-list arg)))))
-
 (defsubst phpinspect-insert-file-contents (&rest args)
   "Call `phpinspect-insert-file-contents-function' with ARGS as arguments."
   (apply phpinspect-insert-file-contents-function args))

Reply via email to