Skip to content

Commit

Permalink
Implement incremental tag collection and other major updates
Browse files Browse the repository at this point in the history
- `vhdl-ext-tags-get` now collects and updates tags only for modified files
- Optimize tags collection algorithms
- Replace use of `vhdl-proj-alist` in favor of `vhdl-ext-proj-alist`
- Optimize hierarchy processing functions
- Update async tags/hierarchy functions
  • Loading branch information
gmlarumbe committed Sep 29, 2023
1 parent 50cee99 commit 2bee52e
Show file tree
Hide file tree
Showing 10 changed files with 631 additions and 318 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Enabling of `vhdl-ext-mode` minor-mode creates the following keybindings:
* <kbd>C-c C-v</kbd> `vhdl-ext-hierarchy-current-buffer`
* <kbd>C-c C-t</kbd> `vhdl-ext-hydra/body`
* <kbd>C-c C-f</kbd> `vhdl-ext-flycheck-mode`
* <kbd>C-c C-u></kbd> `vhdl-ext-tags-get`
* <kbd>C-c \<f5\></kbd> `vhdl-ext-compile-ghdl-project`

* Navigation
Expand Down Expand Up @@ -163,7 +164,7 @@ For configuration information, see the [wiki](https://github.com/gmlarumbe/vhdl-

## Find definitions and references ##

`vhdl-ext` provides a builtin `xref` backend to navigate definitions and references of current project in `vhdl-project-alist`.
`vhdl-ext` provides a builtin `xref` backend to navigate definitions and references of current project in `vhdl-ext-project-alist`.

<img src="https://github.com/gmlarumbe/vhdl-ext/assets/51021955/7fde4bc6-0c84-4da0-8e37-6a0e0dac36f6" width=80%>

Expand Down
2 changes: 1 addition & 1 deletion test-hdl
Submodule test-hdl updated 43 files
+5 −5 vhdl/files/capf/vhdl-ext/ref/axi_if_converter.annotations.el
+5 −5 vhdl/files/capf/vhdl-ext/ref/axi_if_converter.capf.el
+4 −4 vhdl/files/capf/vhdl-ext/ref/global_sim.annotations.el
+4 −4 vhdl/files/capf/vhdl-ext/ref/global_sim.capf.el
+25 −1 vhdl/files/common/misc.vhd
+25 −1 vhdl/files/faceup/vhdl-ext/ref/misc.faceup
+1 −1 vhdl/files/faceup/vhdl-ts-mode/ref/instances.faceup
+25 −1 vhdl/files/faceup/vhdl-ts-mode/ref/misc.faceup
+3 −3 vhdl/files/faceup/vhdl-ts-mode/ref/sexp.faceup
+1 −1 vhdl/files/faceup/vhdl-ts-mode/ref/tb_axi_if_converter.faceup
+5 −2 vhdl/files/imenu/vhdl-ext/ref/misc.el
+5 −1 vhdl/files/imenu/vhdl-ts-mode/ref/misc.el
+25 −1 vhdl/files/indent/vhdl-ts-mode/ref/misc.no_deindent.vhd
+25 −1 vhdl/files/indent/vhdl-ts-mode/ref/misc.vhd
+1 −1 vhdl/files/navigation/vhdl-ts-mode/ref/misc.block.bwd.el
+1 −1 vhdl/files/navigation/vhdl-ts-mode/ref/misc.block.fwd.el
+480 −724 vhdl/files/tags/vhdl-ext/ref/axi_if_converter.ts.defs.el
+2,375 −1,968 vhdl/files/tags/vhdl-ext/ref/axi_if_converter.ts.refs.el
+58 −93 vhdl/files/tags/vhdl-ext/ref/global_pkg.ts.defs.el
+130 −141 vhdl/files/tags/vhdl-ext/ref/global_pkg.ts.refs.el
+307 −282 vhdl/files/tags/vhdl-ext/ref/global_sim.ts.defs.el
+841 −547 vhdl/files/tags/vhdl-ext/ref/global_sim.ts.refs.el
+1,448 −1,805 vhdl/files/tags/vhdl-ext/ref/hierarchy.ts.defs.el
+8,357 −5,535 vhdl/files/tags/vhdl-ext/ref/hierarchy.ts.refs.el
+12 −16 vhdl/files/tags/vhdl-ext/ref/indent_misc.ts.defs.el
+78 −89 vhdl/files/tags/vhdl-ext/ref/indent_misc.ts.refs.el
+24 −34 vhdl/files/tags/vhdl-ext/ref/instances.ts.defs.el
+157 −129 vhdl/files/tags/vhdl-ext/ref/instances.ts.refs.el
+6 −6 vhdl/files/tags/vhdl-ext/ref/misc.ts.defs.el
+48 −24 vhdl/files/tags/vhdl-ext/ref/misc.ts.refs.el
+78 −79 vhdl/files/tags/vhdl-ext/ref/sexp.ts.defs.el
+235 −174 vhdl/files/tags/vhdl-ext/ref/sexp.ts.refs.el
+362 −547 vhdl/files/tags/vhdl-ext/ref/tb_axi_if_converter.ts.defs.el
+1,841 −1,445 vhdl/files/tags/vhdl-ext/ref/tb_axi_if_converter.ts.refs.el
+843 −111 vhdl/files/xref/vhdl-ext/ref/axi_if_converter.xref.defs.el
+3,768 −804 vhdl/files/xref/vhdl-ext/ref/axi_if_converter.xref.refs.el
+151 −15 vhdl/files/xref/vhdl-ext/ref/global_sim.xref.defs.el
+712 −68 vhdl/files/xref/vhdl-ext/ref/global_sim.xref.refs.el
+53 −62 vhdl/vhdl-ext/test-hdl-vhdl-ext-capf.el
+116 −129 vhdl/vhdl-ext/test-hdl-vhdl-ext-hierarchy.el
+2 −2 vhdl/vhdl-ext/test-hdl-vhdl-ext-navigation.el
+50 −73 vhdl/vhdl-ext/test-hdl-vhdl-ext-tags.el
+6 −6 vhdl/vhdl-ext/test-hdl-vhdl-ext-xref.el
32 changes: 16 additions & 16 deletions vhdl-ext-compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;; - (vhdl-ext-compile-ghdl (concat "ghdl -s " buffer-file-name))
;;
;; It also includes a function to compile current project of
;; `vhdl-project-alist' with GHDL: `vhdl-ext-compile-ghdl-project'
;; `vhdl-ext-project-alist' with GHDL: `vhdl-ext-compile-ghdl-project'
;;
;;; Code:

Expand Down Expand Up @@ -116,31 +116,31 @@ ARGS is a property list."
:comp-mode vhdl-ext-compile-ghdl-mode)

(defun vhdl-ext-compile-ghdl-project ()
"Compile current project from `vhdl-project-alist' using GHDL.
"Compile current project from `vhdl-ext-project-alist' using GHDL.
Files in `vhdl-project-alist' need to be in the correct order.
Files in `vhdl-ext-project-alist' need to be in the correct order.
According to GHDL documentation:
- GHDL analyzes each filename in the given order, and stops the analysis in
case of error (the following files are not analyzed)."
(interactive)
(let* ((project (vhdl-ext-buffer-proj))
(root (nth 1 (vhdl-aget vhdl-project-alist (or project vhdl-project))))
(workdir (vhdl-ext-proj-workdir))
sources sources-filtered)
;; Get sources and put them in the expected order
(setq sources (vhdl-ext-proj-files))
(setq sources-filtered (seq-take-while (lambda (elm) (not (string= elm buffer-file-name))) sources))
(let* ((proj (vhdl-ext-buffer-proj))
(root (vhdl-ext-buffer-proj-root proj))
(workdir (vhdl-ext-proj-workdir proj))
;; Get files and put them in the expected order
(files (vhdl-ext-proj-files proj))
(files-filtered (seq-take-while (lambda (elm) (not (string= elm buffer-file-name))) files)))
;; Create workdir if it does not exist
(unless (and (file-exists-p workdir)
(file-directory-p workdir))
(make-directory workdir :parents))
;; Compile current buffer
(vhdl-ext-compile-ghdl (concat "cd " root " && "
"ghdl -a "
"-fno-color-diagnostics "
(vhdl-ext-ghdl-proj-args) " "
(mapconcat #'identity sources-filtered " ") " "
buffer-file-name))))
(vhdl-ext-compile-ghdl (mapconcat #'identity
`("cd" ,root "&&"
"ghdl" "-a" "-fno-color-diagnostics"
,(vhdl-ext-ghdl-proj-args)
,(mapconcat #'identity files-filtered " ")
,buffer-file-name)
" "))))


(provide 'vhdl-ext-compile)
Expand Down
10 changes: 5 additions & 5 deletions vhdl-ext-flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ See URL `https://github.com/ghdl/ghdl'."
:command ("ghdl"
"-s" ; only do the syntax checking
(option "--std=" flycheck-ghdl-language-standard concat) ; Set by `vhdl-ext' based on `vhdl-standard'
(option "--workdir=" flycheck-ghdl-workdir concat) ; Set by `vhdl-ext' based on `vhdl-project-alist'
(option "--workdir=" flycheck-ghdl-workdir concat) ; Set by `vhdl-ext' based on `vhdl-ext-project-alist'
(option "--ieee=" flycheck-ghdl-ieee-library concat)
;; Additional options
(option "--work=" flycheck-ghdl-work-lib concat) ; Set by `vhdl-ext' based on `vhdl-project-alist'
(option "--work=" flycheck-ghdl-work-lib concat) ; Set by `vhdl-ext' based on `vhdl-ext-project-alist'
(eval vhdl-ext-flycheck-ghdl-extra-args)
;; Extra dirs and files
(option-list "-P" vhdl-ext-flycheck-ghdl-include-path concat)
Expand Down Expand Up @@ -115,7 +115,7 @@ See URL `https://github.com/VHDL-LS/rust_hdl'."
(defun vhdl-ext-flycheck-vhdl-tool-directory-fn (_checker)
"Return directory where vhdl-tool is executed.
Needed to keep in sync where the server and the client are run."
(vhdl-ext-project-root))
(vhdl-ext-buffer-proj-root))

;; https://git.vhdltool.com/vhdl-tool/configs/src/master/emacs
(flycheck-define-checker vhdl-tool
Expand All @@ -139,9 +139,9 @@ See URL `http://vhdltool.com'."
(unless (locate-dominating-file buffer-file-name flycheck-vhdl-lang-config-file)
(error "Could not find \"vhdl_lang.toml\" in project root!")))
('vhdl-tool
(let ((buf (concat " *vhdl-tool-server@" (vhdl-ext-project-root) "*")))
(let ((buf (concat " *vhdl-tool-server@" (vhdl-ext-buffer-proj-root) "*")))
(unless (get-buffer-process buf)
(start-process-shell-command buf buf (concat "cd " (vhdl-ext-project-root) " && vhdl-tool server"))
(start-process-shell-command buf buf (concat "cd " (vhdl-ext-buffer-proj-root) " && vhdl-tool server"))
(message "Started process @ %s" buf))))))

(defun vhdl-ext-flycheck-set-linter (&optional linter)
Expand Down
Loading

0 comments on commit 2bee52e

Please sign in to comment.