Fix tests and patch bugs that came to light in the process
parent
3a3e2cd362
commit
0bc9e795b2
@ -0,0 +1,105 @@
|
||||
;;; phpinspect-index.el --- PHP parsing and completion package -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2021 Free Software Foundation, Inc
|
||||
|
||||
;; Author: Hugo Thunnissen <devel@hugot.nl>
|
||||
;; Keywords: php, languages, tools, convenience
|
||||
;; Version: 0
|
||||
|
||||
;; 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:
|
||||
|
||||
(require 'phpinspect-type)
|
||||
(require 'phpinspect-class)
|
||||
|
||||
(cl-defmethod phpinspect--serialize-type ((type phpinspect--type))
|
||||
`(phpinspect--make-type
|
||||
:name ,(phpinspect--type-name type)
|
||||
:collection ,(phpinspect--type-collection type)
|
||||
:contains ,(when (phpinspect--type-contains type)
|
||||
(phpinspect--serialize-type (phpinspect--type-contains type)))
|
||||
:fully-qualified ,(phpinspect--type-fully-qualified type)))
|
||||
|
||||
(cl-defmethod phpinspect--serialize-function ((func phpinspect--function))
|
||||
`(phpinspect--make-function
|
||||
:name ,(phpinspect--function-name func)
|
||||
:scope (quote ,(phpinspect--function-scope func))
|
||||
:arguments ,(append '(list)
|
||||
(mapcar (lambda (arg)
|
||||
`(list ,(car arg) ,(phpinspect--serialize-type (cadr arg))))
|
||||
(phpinspect--function-arguments func)))
|
||||
:return-type ,(when (phpinspect--function-return-type func)
|
||||
(phpinspect--serialize-type
|
||||
(phpinspect--function-return-type func)))))
|
||||
|
||||
(cl-defmethod phpinspect--serialize-variable ((var phpinspect--variable))
|
||||
`(phpinspect--make-variable :name ,(phpinspect--variable-name var)
|
||||
:type ,(when (phpinspect--variable-type var)
|
||||
(phpinspect--serialize-type
|
||||
(phpinspect--variable-type var)))
|
||||
:scope (quote ,(phpinspect--variable-scope var))))
|
||||
|
||||
|
||||
(cl-defmethod phpinspect--serialize-indexed-class ((class (head phpinspect--indexed-class)))
|
||||
``(phpinspect--indexed-class
|
||||
(class-name . ,,(phpinspect--serialize-type (alist-get 'class-name class)))
|
||||
(imports . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-import
|
||||
(alist-get 'imports class))))
|
||||
(methods . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-function
|
||||
(alist-get 'methods class))))
|
||||
(static-methods . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-function
|
||||
(alist-get 'static-methods class))))
|
||||
(static-variables . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-variable
|
||||
(alist-get 'static-variables class))))
|
||||
(variables . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-variable
|
||||
(alist-get 'variables class))))
|
||||
(constants . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-variable
|
||||
(alist-get 'constants class))))
|
||||
(extends . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-type
|
||||
(alist-get 'extends class))))
|
||||
(implements . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-type
|
||||
(alist-get 'implements class))))))
|
||||
|
||||
(cl-defmethod phpinspect--serialize-root-index ((index (head phpinspect--root-index)))
|
||||
``(phpinspect--root-index
|
||||
(imports . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-import
|
||||
(alist-get 'imports index))))
|
||||
(classes ,,@(mapcar (lambda (cons-class)
|
||||
`(list ,(phpinspect--serialize-type (car cons-class))
|
||||
,(phpinspect--serialize-indexed-class (cdr cons-class))))
|
||||
(alist-get 'classes index)))
|
||||
(functions . ,,(append '(list)
|
||||
(mapcar #'phpinspect--serialize-function
|
||||
(alist-get 'functions index))))))
|
||||
|
||||
|
||||
(defun phpinspect--serialize-import (import)
|
||||
`(cons
|
||||
(phpinspect-intern-name ,(symbol-name (car import)))
|
||||
,(phpinspect--serialize-type (cdr import))))
|
||||
|
||||
(provide 'phpinspect-serialize)
|
||||
;;; phpinspect-serialize.el ends here
|
@ -1 +1 @@
|
||||
(phpinspect--root-index (classes ("\\App\\Entity\\AuthToken" phpinspect--class (methods #s(phpinspect--function "getCreationTime" (:public) nil "\\DateTime") #s(phpinspect--function "isValid" (:public) nil "\\bool") #s(phpinspect--function "hasStudentRole" (:public) nil "\\bool") #s(phpinspect--function "getUser" (:public) nil "\\App\\Entity\\User") #s(phpinspect--function "getToken" (:public) nil "\\string") #s(phpinspect--function "__construct" (:public) (("token" "\\string") ("user" "\\App\\Entity\\User") ("valid" "\\bool") ("creation_time" "\\DateTime")) nil)) (class-name . "\\App\\Entity\\AuthToken") (static-methods) (static-variables) (variables #s(phpinspect--variable "creation_time" (:private) "\\DateTime") #s(phpinspect--variable "valid" (:private) "\\bool") #s(phpinspect--variable "user" (:private) "\\App\\Entity\\App\\\\Entity\\\\User") #s(phpinspect--variable "token" (:private) "\\string")) (constants) (extends) (implements))) (functions))
|
||||
`(phpinspect--root-index (imports \, (list)) (classes ,(list (phpinspect--make-type :name "\\App\\Entity\\AuthToken" :collection nil :contains nil :fully-qualified t) `(phpinspect--indexed-class (class-name \, (phpinspect--make-type :name "\\App\\Entity\\AuthToken" :collection nil :contains nil :fully-qualified t)) (imports \, (list (cons (phpinspect-intern-name "ORM") (phpinspect--make-type :name "\\Doctrine\\ORM\\Mapping" :collection nil :contains nil :fully-qualified t)))) (methods \, (list (phpinspect--make-function :name "getCreationTime" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\DateTime" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "isValid" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "hasStudentRole" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "getUser" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\App\\Entity\\User" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "getToken" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\string" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "__construct" :scope '(:public) :arguments (list (list "token" (phpinspect--make-type :name "\\string" :collection nil :contains nil :fully-qualified t)) (list "user" (phpinspect--make-type :name "\\App\\Entity\\User" :collection nil :contains nil :fully-qualified t)) (list "valid" (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t)) (list "creation_time" (phpinspect--make-type :name "\\DateTime" :collection nil :contains nil :fully-qualified t))) :return-type (phpinspect--make-type :name "\\null" :collection nil :contains nil :fully-qualified t)))) (static-methods \, (list)) (static-variables \, (list)) (variables \, (list (phpinspect--make-variable :name "creation_time" :type (phpinspect--make-type :name "\\DateTime" :collection nil :contains nil :fully-qualified t) :scope '(:private)) (phpinspect--make-variable :name "valid" :type (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t) :scope '(:private)) (phpinspect--make-variable :name "user" :type (phpinspect--make-type :name "\\App\\Entity\\App\\\\Entity\\\\User" :collection nil :contains nil :fully-qualified t) :scope '(:private)) (phpinspect--make-variable :name "token" :type (phpinspect--make-type :name "\\string" :collection nil :contains nil :fully-qualified t) :scope '(:private)))) (constants \, (list)) (extends \, (list)) (implements \, (list))))) (functions \, (list)))
|
@ -1 +1 @@
|
||||
(phpinspect--root-index (classes ("\\App\\Entity\\AuthToken" phpinspect--class (methods #s(phpinspect--function "getCreationTime" (:public) nil "\\DateTime") #s(phpinspect--function "anAddedFunction" (:public) nil nil) #s(phpinspect--function "isValid" (:public) nil "\\bool") #s(phpinspect--function "hasStudentRole" (:public) nil "\\bool") #s(phpinspect--function "getUser" (:public) nil "\\App\\Entity\\User") #s(phpinspect--function "getToken" (:public) nil "\\bool") #s(phpinspect--function "__construct" (:public) (("token" "\\string") ("user" "\\App\\Entity\\User") ("valid" "\\bool") ("creation_time" "\\DateTime")) nil)) (class-name . "\\App\\Entity\\AuthToken") (static-methods) (static-variables) (variables #s(phpinspect--variable "creation_time" (:private) "\\DateTime") #s(phpinspect--variable "valid" (:private) "\\bool") #s(phpinspect--variable "user" (:private) "\\App\\Entity\\App\\\\Entity\\\\User") #s(phpinspect--variable "extra" (:private) nil) #s(phpinspect--variable "token" (:private) "\\string")) (constants) (extends) (implements))) (functions))
|
||||
`(phpinspect--root-index (imports \, (list)) (classes ,(list (phpinspect--make-type :name "\\App\\Entity\\AuthToken" :collection nil :contains nil :fully-qualified t) `(phpinspect--indexed-class (class-name \, (phpinspect--make-type :name "\\App\\Entity\\AuthToken" :collection nil :contains nil :fully-qualified t)) (imports \, (list (cons (phpinspect-intern-name "ORM") (phpinspect--make-type :name "\\Doctrine\\ORM\\Mapping" :collection nil :contains nil :fully-qualified t)))) (methods \, (list (phpinspect--make-function :name "getCreationTime" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\DateTime" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "anAddedFunction" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\null" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "isValid" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "hasStudentRole" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "getUser" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\App\\Entity\\User" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "getToken" :scope '(:public) :arguments (list) :return-type (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t)) (phpinspect--make-function :name "__construct" :scope '(:public) :arguments (list (list "token" (phpinspect--make-type :name "\\string" :collection nil :contains nil :fully-qualified t)) (list "user" (phpinspect--make-type :name "\\App\\Entity\\User" :collection nil :contains nil :fully-qualified t)) (list "valid" (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t)) (list "creation_time" (phpinspect--make-type :name "\\DateTime" :collection nil :contains nil :fully-qualified t))) :return-type (phpinspect--make-type :name "\\null" :collection nil :contains nil :fully-qualified t)))) (static-methods \, (list)) (static-variables \, (list)) (variables \, (list (phpinspect--make-variable :name "creation_time" :type (phpinspect--make-type :name "\\DateTime" :collection nil :contains nil :fully-qualified t) :scope '(:private)) (phpinspect--make-variable :name "valid" :type (phpinspect--make-type :name "\\bool" :collection nil :contains nil :fully-qualified t) :scope '(:private)) (phpinspect--make-variable :name "user" :type (phpinspect--make-type :name "\\App\\Entity\\App\\\\Entity\\\\User" :collection nil :contains nil :fully-qualified t) :scope '(:private)) (phpinspect--make-variable :name "extra" :type nil :scope '(:private)) (phpinspect--make-variable :name "token" :type (phpinspect--make-type :name "\\string" :collection nil :contains nil :fully-qualified t) :scope '(:private)))) (constants \, (list)) (extends \, (list)) (implements \, (list))))) (functions \, (list)))
|
Loading…
Reference in New Issue