Skip to content

Commit

Permalink
Update tags collection for tree-sitter-systemverilog grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlarumbe committed Aug 30, 2024
1 parent 913dddf commit 5398a79
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test-hdl
Submodule test-hdl updated 74 files
+38 −38 verilog/files/beautify/verilog-ext/ref/axi_demux.ts.sv
+38 −38 verilog/files/beautify/verilog-ts-mode/ref/axi_demux.beauty.sv
+4 −4 verilog/files/capf/verilog-ext/ref/tb_program.annotations.el
+4 −4 verilog/files/capf/verilog-ext/ref/tb_program.capf.el
+3 −3 verilog/files/capf/verilog-ext/ref/ucontroller.annotations.el
+3 −3 verilog/files/capf/verilog-ext/ref/ucontroller.capf.el
+116 −116 verilog/files/faceup/verilog-ts-mode/ref/axi_demux.faceup
+267 −267 verilog/files/faceup/verilog-ts-mode/ref/axi_test.faceup
+1 −1 verilog/files/faceup/verilog-ts-mode/ref/instances.faceup
+19 −19 verilog/files/faceup/verilog-ts-mode/ref/tb_program.faceup
+44 −44 verilog/files/faceup/verilog-ts-mode/ref/uvm_component.faceup
+18 −18 verilog/files/imenu/verilog-ts-mode/ref/axi_demux.el
+1 −0 verilog/files/imenu/verilog-ts-mode/ref/axi_test.el
+1 −1 verilog/files/imenu/verilog-ts-mode/ref/instances.el
+99 −1 verilog/files/imenu/verilog-ts-mode/ref/uvm_component.el
+38 −38 verilog/files/indent/verilog-ts-mode/ref/axi_demux.sv
+81 −81 verilog/files/indent/verilog-ts-mode/ref/axi_test.sv
+16 −16 verilog/files/indent/verilog-ts-mode/ref/indent_always_decl.v
+6 −6 verilog/files/indent/verilog-ts-mode/ref/indent_analog.v
+4 −4 verilog/files/indent/verilog-ts-mode/ref/indent_assignment.v
+1 −1 verilog/files/indent/verilog-ts-mode/ref/indent_attributes.v
+2 −2 verilog/files/indent/verilog-ts-mode/ref/indent_begin_clapp.v
+4 −4 verilog/files/indent/verilog-ts-mode/ref/indent_bracket.v
+1 −1 verilog/files/indent/verilog-ts-mode/ref/indent_class.v
+1 −1 verilog/files/indent/verilog-ts-mode/ref/indent_comments_bug1717.v
+5 −5 verilog/files/indent/verilog-ts-mode/ref/indent_connectmodule.v
+2 −2 verilog/files/indent/verilog-ts-mode/ref/indent_decl-1.v
+7 −7 verilog/files/indent/verilog-ts-mode/ref/indent_list_nil_continued_line.sv
+10 −10 verilog/files/indent/verilog-ts-mode/ref/indent_list_nil_if.sv
+4 −4 verilog/files/indent/verilog-ts-mode/ref/indent_list_nil_report.sv
+2 −2 verilog/files/indent/verilog-ts-mode/ref/indent_macro_braces.v
+1 −1 verilog/files/indent/verilog-ts-mode/ref/indent_property.v
+6 −6 verilog/files/indent/verilog-ts-mode/ref/indent_randcase.v
+2 −2 verilog/files/indent/verilog-ts-mode/ref/indent_task.v
+2 −2 verilog/files/indent/verilog-ts-mode/ref/misc.sv
+45 −45 verilog/files/indent/verilog-ts-mode/ref/uvm_component.svh
+1 −1 verilog/files/navigation/verilog-ext/ref/axi_test.ts.tf.bwd.el
+1 −1 verilog/files/navigation/verilog-ext/ref/axi_test.ts.tf.fwd.el
+1 −1 verilog/files/navigation/verilog-ts-mode/ref/axi_test.block.bwd.el
+1 −1 verilog/files/navigation/verilog-ts-mode/ref/axi_test.block.fwd.el
+1 −1 verilog/files/navigation/verilog-ts-mode/ref/axi_test.tf.bwd.el
+1 −1 verilog/files/navigation/verilog-ts-mode/ref/axi_test.tf.fwd.el
+12 −0 verilog/files/tags/verilog-ext/ref/axi_demux.ts.refs.el
+38 −18 verilog/files/tags/verilog-ext/ref/axi_test.ts.defs.el
+234 −34 verilog/files/tags/verilog-ext/ref/axi_test.ts.refs.el
+20 −0 verilog/files/tags/verilog-ext/ref/tb_program.ts.refs.el
+42 −0 verilog/files/tags/verilog-ext/ref/uvm_component.ts.refs.el
+1 −1 verilog/files/utils/verilog-ext/ref/instances.ts.block.at.point.el
+1 −1 verilog/files/utils/verilog-ts-mode/ref/instances.block.at.point.el
+3 −9 verilog/files/xref/verilog-ext/ref/ucontroller.xref.refs.el
+170 −4 verilog/files/xref/verilog-ext/ref/uvm_component.xref.refs.el
+3 −3 verilog/scripts/install-ts-grammar.sh
+1 −1 vhdl/files/tags/vhdl-ext/ref/axi_if_converter.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/axi_if_converter.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/global_pkg.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/global_pkg.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/global_sim.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/global_sim.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/hierarchy.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/hierarchy.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/indent_misc.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/indent_misc.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/instances.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/instances.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/misc.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/misc.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/sexp.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/sexp.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/std_logic_1164-body.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/std_logic_1164-body.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/std_logic_1164.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/std_logic_1164.ts.refs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/tb_axi_if_converter.ts.defs.el
+1 −1 vhdl/files/tags/vhdl-ext/ref/tb_axi_if_converter.ts.refs.el
40 changes: 33 additions & 7 deletions verilog-ext-tags.el
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ temp-buffer."
"constraint_declaration"
;; Ports/arguments
"ansi_port_declaration"
"tf_port_item1"
"tf_port_item"
;; Variable/net/parameter/type declarations
"variable_decl_assignment"
"net_decl_assignment"
Expand All @@ -397,7 +397,11 @@ temp-buffer."
"enum_name_declaration"
;; Instances
"module_instantiation"
"interface_instantiation")
"interface_instantiation"
"program_instantiation"
"checker_instantiation"
"gate_instantiation"
"udp_instantiation")
'symbols))
"Regexp of tree-sitter node types to be used for tags definitions.
Expand All @@ -417,7 +421,28 @@ completion.")

(defconst verilog-ext-tags-method-declaration-ts-re
(eval-when-compile
(regexp-opt '("task_declaration" "function_declaration" "class_constructor_declaration") 'symbols)))
(regexp-opt
'("task_declaration"
"function_declaration"
"class_constructor_declaration")
'symbols)))

(defconst verilog-ext-tags-ts-ref-nodes-re
(eval-when-compile
(regexp-opt
'("simple_identifier"
"system_tf_identifier"
"escaped_identifier"
"array_method_name"
"string_method_name"
"enum_method_name"
"associative_array_method_name"
"queue_method_name"
"array_or_queue_method_name"
"enum_or_associative_array_method_name"
"new")
'symbols)))


(defun verilog-ext-tags-table-push-defs-ts (file)
"Push current FILE definitions using tree-sitter.
Expand All @@ -442,9 +467,10 @@ TS-TYPE is provided to avoid an additional call to `treesit-node-type' since
this function is synctactic sugar for
`verilog-ext-tags-table-push-defs-ts--recurse'."
(cond (;; Externally defined methods
(and (string-match verilog-ext-tags-method-declaration-ts-re ts-type)
(verilog-ts--node-has-child-recursive ts-node "class_type"))
(verilog-ts--node-identifier-name (verilog-ts--node-has-child-recursive ts-node "class_identifier")))
(let (class-type-node)
(and (string-match verilog-ext-tags-method-declaration-ts-re ts-type)
(setq class-type-node (verilog-ts--node-has-child-recursive ts-node "class_type")))
(verilog-ts--node-identifier-name class-type-node)))
(t ;; Default
(verilog-ts--node-identifier-name parent-node))))

Expand Down Expand Up @@ -491,7 +517,7 @@ PARENT is passed as an argument to build the :items prop list of
Update hash table `verilog-ext-tags-refs-current-file'."
(let (tag pos line)
(dolist (node (verilog-ts-nodes "simple_identifier"))
(dolist (node (verilog-ts-nodes verilog-ext-tags-ts-ref-nodes-re))
(setq tag (treesit-node-text node :no-prop))
(setq pos (treesit-node-start node))
(setq line (line-number-at-pos pos))
Expand Down

0 comments on commit 5398a79

Please sign in to comment.