summaryrefslogtreecommitdiff
path: root/phpinspect-project-struct.el
blob: c24bd9e79c28dd3ebf591b3a465c0f485cb3c4b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
;;; phpinspect-project-struct.el --- PHP parsing and completion package  -*- lexical-binding: t; -*-

;; Copyright (C) 2021-2025  Free Software Foundation, Inc

;; Author: Hugo Thunnissen <devel@hugot.nl>
;; Keywords: php, languages, tools, convenience
;; Version: 3.0.1

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;;; Code:

(eval-when-compile
  (declare-function phpinspect-make-dynamic-worker "phpinspect-worker.el"))

(cl-defstruct (phpinspect-project (:constructor phpinspect--make-project))
  (read-only-p nil
               :type boolean
               :documentation
               "Whether this project instance is read-only, meaning that its data
should never be changed.

When this slot has a non-nil value:

- Methods and functions that are meant to manipulate typedef data
should become no-ops.
- All typedefes retrieved from it should be marked as read-only as well.")
  (extra-typedef-retriever nil
                         :type lambda
                         :documentation
                         "A function that should accept a `phpinspect--type' and return
matching `phpinspect--typedef' instances or nil. Used to discover
typedefes that are defined outside of project code.")
  (extra-function-retriever nil
                            :type lambda
                            :documentation
                            "A function that should accept a `phpinspect-name' (see
`phpinspect-intern-name') and return matching `phpinspect--function'
instances or nil. Used to discover functions that are defined
outside of project code.")
  (typedef-index (make-hash-table :test 'eq :size 100 :rehash-size 1.5)
               :type hash-table
               :documentation
               "A `hash-table` that contains all of the currently
indexed typedefs in the project")
  (function-index (make-hash-table :test 'eq :size 100 :rehash-size 2.0)
                  :type hash-table
                  :documentation
                  "A hash able that contains all of the currently indexed functions
in the project")
  (function-token-index (make-hash-table :test 'eq :size 100 :rehash-size 1.5))
  (fs nil
      :type phpinspect-fs
      :documentation
      "The filesystem object through which this project's files
can be accessed.")
  (autoload nil
    :type phpinspect-autoload
    :documentation
    "The autoload object through which this project's type
definitions can be retrieved")
  (worker (progn
            (unless (featurep 'phpinspect-worker)
              (require 'phpinspect-worker))
            (phpinspect-make-dynamic-worker))
          :type phpinspect-worker
          :documentation
          "The worker that this project may queue tasks for")
  (root nil
        :type string
        :documentation
        "The root directory of this project")
  (purged nil
          :type boolean
          :documentation "Whether or not the project has been purged or not.
Projects get purged when they are removed from the global cache.")
  (file-watchers (make-hash-table :test #'equal :size 10000 :rehash-size 10000)
                 :type hash-table
                 :documentation "All active file watchers in this project,
indexed by the absolute paths of the files they're watching."))

(provide 'phpinspect-project-struct)