**[WARNING: Work in progress]**
Add SystemVerilog support, which was relatively easy since both ctags and the lexer support it.
**Done:** * [x] Create SystemVerilog filetype (with all the SystemVerilog keywords) * [x] Add filetype to Geany source code (create GEANY_FILETYPES_SYSVERILOG et al, create tag map in tm_parser.c, etc) * [x] Compile and test it
**TO DO:** * [ ] Select which of the tag categories parsed by ctags to process in Geany * [ ] Provide meaningful tag associations (tm_tag_*_t) in tm_parser.c * [ ] Arrange into groups and provide meaningful icons You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/4039
-- Commit Summary --
* Add SystemVerilog filetype * !TODO! (WIP) SystemVerilog: provide appropriate Ctags
-- File Changes --
A data/filedefs/filetypes.systemverilog (62) M data/filetype_extensions.conf (3) M src/filetypes.c (1) M src/filetypes.h (1) M src/highlighting.c (2) M src/highlightingmappings.h (7) M src/tagmanager/tm_parser.c (60) M src/tagmanager/tm_parser.h (1) M src/tagmanager/tm_parsers.h (1)
-- Patch Links --
https://github.com/geany/geany/pull/4039.patch https://github.com/geany/geany/pull/4039.diff
So, I thought that since the Verilog ctags parser already supports both Verilog and SystemVerilog, it would be a matter of enabling the latter within Geany. But I'm currently stuck at creating a proper tag map in tm_parser.c - I didn't consider that tags have *meaning*.
I understood that tag categories were named mostly for convenience, but apparently the behavior of something marked as `tm_tag_variable_t` is not the same as that of something marked `tm_tag_local_var_t`, for example. And now, the problem is that SystemVerilog is not a "programming language" but a hardware description language, so trying to figure out how a "port" or a "module" maps to a set of tags intended for programming is complicated. If this were a matter of "getting creative" and assigning the tags randomly, that'd be done, but apparently I need to be careful because assigning one tag or another will result in different propagation rules, showing up or not on the left panel, etc.
For the time being I created a draft PR so I can discuss it further.
(Right now, there is a commit that does the SV integration, but the result is little more than what I would have gotten by adding a bunch of keywords to the filetypes.systemverilog file. The second commit attempts to do the right thing but it's still a WIP.)
@techee requested changes on this pull request.
@@ -195,6 +195,7 @@ static void init_builtin_filetypes(void)
FT_INIT( NIM, NONE, "Nim", NULL, SOURCE_FILE, COMPILED ); FT_INIT( ZIG, NONE, "Zig", NULL, SOURCE_FILE, COMPILED ); FT_INIT( DART, NONE, "Dart", NULL, SOURCE_FILE, COMPILED ); + FT_INIT( SYSVERILOG, SYSVERILOG, "SystemVerilog", NULL, SOURCE_FILE, COMPILED );
Remove.
@@ -115,6 +115,7 @@ typedef enum
GEANY_FILETYPES_NIM, GEANY_FILETYPES_ZIG, GEANY_FILETYPES_DART, + GEANY_FILETYPES_SYSVERILOG,
Remove.
@@ -1057,6 +1057,7 @@ void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co
init_styleset_case(TXT2TAGS); init_styleset_case(VHDL); init_styleset_case(VERILOG); + init_styleset_case(SYSVERILOG);
Remove.
@@ -1155,6 +1156,7 @@ void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft)
styleset_case(TXT2TAGS); styleset_case(VHDL); styleset_case(VERILOG); + styleset_case(SYSVERILOG);
Remove.
@@ -1896,6 +1896,13 @@ static const HLKeyword highlighting_keywords_VERILOG[] =
#define highlighting_properties_VERILOG EMPTY_PROPERTIES
+/* SystemVerilog */ +#define highlighting_lexer_SYSVERILOG highlighting_lexer_VERILOG +#define highlighting_styles_SYSVERILOG highlighting_styles_VERILOG +#define highlighting_keywords_SYSVERILOG highlighting_keywords_VERILOG +#define highlighting_properties_SYSVERILOG highlighting_properties_VERILOG + +
Remove.
@@ -0,0 +1,62 @@
+# For complete documentation of this file, please see Geany's main documentation
I don't think SystemVerilog should be implemented as a builtin filetype. Have a look at e.g. `filetypes.JSON.conf` how to add a non-builtin filetype. Under the `[settings]` section, add `tag_parser=SystemVerilog` and `lexer_filetype=verilog`.
Rename this file to `filetypes.Systemverilog.conf` so it becomes a non-builtin filetype
@@ -120,6 +120,7 @@ enum
TM_PARSER_TXT2TAGS, TM_PARSER_ABC, TM_PARSER_VERILOG, + TM_PARSER_SYSVERILOG,
This should be moved to the end of the array so it doesn't break ABI.
@@ -1257,6 +1315,7 @@ static TMParserMap parser_map[] = {
MAP_ENTRY(TXT2TAGS), MAP_ENTRY(ABC), MAP_ENTRY(VERILOG), + MAP_ENTRY(SYSVERILOG),
Move to the end, see below.
@@ -55,6 +55,7 @@
Txt2tagsParser, \ AbcParser, \ VerilogParser, \ + SystemVerilogParser, \
Move to the end of the array.
@@ -76,11 +76,12 @@ Sh=*.sh;configure;configure.in;configure.in.in;configure.ac;*.ksh;*.mksh;*.zsh;*
Smalltalk=*.st; SQL=*.sql; Swift=*.swift; +SystemVerilog=*.sv;*.svh;
Add `SystemVerilog` to the `[Groups]` below under `Programming`.
@@ -0,0 +1,62 @@
+# For complete documentation of this file, please see Geany's main documentation +[styling]
Replace with `[styling=Verilog]` and remove the rest of the section.
I added a few review comments - mostly, since the filetype uses an existing lexer, it doesn't have to be a builtin filetype.
> I understood that tag categories were named mostly for convenience, but apparently the behavior of something marked as tm_tag_variable_t is not the same as that of something marked tm_tag_local_var_t, for example. And now, the problem is that SystemVerilog is not a "programming language" but a hardware description language, so trying to figure out how a "port" or a "module" maps to a set of tags intended for programming is complicated. If this were a matter of "getting creative" and assigning the tags randomly, that'd be done, but apparently I need to be careful because assigning one tag or another will result in different propagation rules, showing up or not on the left panel, etc.
There are many other languages that don't fit the "classical programming language" pattern - for them, you can make the assignments almost arbitrarily. Just avoid `tm_tag_local_var_t` which doesn't show symbols in the sidebar. `tm_tag_undef_t` ignores the symbol completely. You also have to specify these in the groups below so they are shon correctly in the sidebar.
@cousteaulecommandant commented on this pull request.
@@ -0,0 +1,62 @@
+# For complete documentation of this file, please see Geany's main documentation
Oookay, that makes sense. That's how I initially thought this was meant to be done, but eventually I mistakenly understood that the only way to add SystemVerilog parsing was as a separate builtin language. Overall, I had a hard time figuring out what needed to be added and what would be reused.
So in summary, internally there are file types (lexer, GEANY_FILETYPES, highlighting, etc) and tag managers (ctags, TM_PARSER, etc). I should nix the former and keep the latter, correct? I thought they were somewhat related.
So the only changes in C/C++ code I get to keep are: 1. Adding SystemVerilogParser 2. Adding the stuff I added to tm_parser
@cousteaulecommandant commented on this pull request.
@@ -1257,6 +1315,7 @@ static TMParserMap parser_map[] = {
MAP_ENTRY(TXT2TAGS), MAP_ENTRY(ABC), MAP_ENTRY(VERILOG), + MAP_ENTRY(SYSVERILOG),
Will do. (Technically this one isn't really needed since the MAP_ENTRY() macro seems to take care of the order, but for consistency with the other two tm_parser*.h files that *do* need it it'll be best to do it here as well).
@cousteaulecommandant pushed 2 commits.
26e78be57d02dd83aa6f7a504ef2714c5694f8e4 Add SystemVerilog filetype 40278e8626a814efdde6ea5b9aac72a7bc24190d !TODO! (WIP) SystemVerilog: provide appropriate Ctags
@cousteaulecommandant pushed 1 commit.
c4bc40595d6baa93324d8ec18c3c51089290bf6b !TODO! (WIP) SystemVerilog: provide appropriate Ctags
OK, made the changes. Apparently it was easier to make this change than I thought; I went the excessively convoluted way :/ (it was my first time!). Tested and it works. Thanks!
> There are many other languages that don't fit the "classical programming language" pattern - for them, you can make the assignments almost arbitrarily. Just avoid `tm_tag_local_var_t` which doesn't show symbols in the sidebar. `tm_tag_undef_t` ignores the symbol completely. You also have to specify these in the groups below so they are shon correctly in the sidebar.
OK, noted :) I don't quite understand the use of `tm_tag_local_var_t`. I was thinking that perhaps it was only hidden on the sidebar but still accessible via Ctrl-click, but that doesn't seem to be the case. Anyway, I'll avoid that. And `tm_tag_include_t` too; seems to be the same. (Another question is whether these **should** show up at all, since the use I was giving it was for declaring "internal" signals, and maybe those shouldn't show up, like internal variables of functions.)
Overall, my concern is what's the purpose of the different tags. I think it has to do with how they "propagate" to other files and contexts, and that one tm_tag_t behaves differently from another. For example, if I open a file that declares a certain C typedef, or C++ class, and use it in another file, it appears highlighted in light blue. I suppose this has to do with ctags "exporting" the type to other files. I want to be careful not to have this filetype exporting stuff when it doesn't make sense.
OK, [made the changes]
Looks good.
I don't quite understand the use of tm_tag_local_var_t. I was thinking that perhaps it was only hidden on the sidebar but still accessible via Ctrl-click, but that doesn't seem to be the case.
This is used for parsers like C/C++ that also parse function bodies and extract all variables from functions - displaying them in the sidebar is just too verbose. I don't remember exactly how ctrl+click is implemented for these but it's possible that it works only within a function. I don't know if there is something in the verilog parser where tm_tag_local_var_t could be applied.
Overall, my concern is what's the purpose of the different tags. I think it has to do with how they "propagate" to other files and contexts, and that one tm_tag_t behaves differently from another.
The only problem I can think of is what we call "scope autocompletion". E.g. for C something like ```C typedef struct { int x; int y; } Foo;
int main(void) { Foo foo; foo. // <--- here you should get an autocompletion popup with x and y } ```
I think `.` is hard-coded in the Geany code and the tag manager checks whether `foo` is of a type that can contain members - see https://github.com/geany/geany/blob/c043996a9a3dc1b0aa36571cd5f5d61fd8d2eb59... This typically works well for "normal" languages but honestly we kind of ignore what mess it could produce in other languages ;-).
For example, if I open a file that declares a certain C typedef, or C++ class, and use it in another file, it appears highlighted in light blue. I suppose this has to do with ctags "exporting" the type to other files.
What we do is that we extract tags that can be types https://github.com/geany/geany/blob/c043996a9a3dc1b0aa36571cd5f5d61fd8d2eb59... and then inject the names of these types to all the Scintilla editors as fake keywords so they get colorized.
However, you'd have to enable this behavior for Verilog in https://github.com/geany/geany/blob/c043996a9a3dc1b0aa36571cd5f5d61fd8d2eb59... otherwise no such coloring will happen. The index 3 means that the type goes to keyword at index 3 which however isn't defined for verilog in https://github.com/geany/geany/blob/c043996a9a3dc1b0aa36571cd5f5d61fd8d2eb59... and would have to be added there. The verilog lexer seems to define more keyword groups so it should work if you decide to give it a try. https://github.com/geany/geany/blob/c043996a9a3dc1b0aa36571cd5f5d61fd8d2eb59...
So it depends whether you want to enable such a coloring - if not, it shouldn't happen automatically and you are free to use whatever `tm_tag_...` you wish - otherwise you have to be more careful.
The only problem I can think of is what we call "scope autocompletion". E.g. for C something like
https://github.com/geany/geany/blob/c043996a9a3dc1b0aa36571cd5f5d61fd8d2eb59...
Hm, OK. Since I'm being *sort of* consistent with the tags, I don't think this will be a problem. (It could even be useful, but it doesn't seem to work for Verilog - typing `.` after an object of a class didn't provide suggestions for members of that class. Not that I'm too worried about that.)
So it depends whether you want to enable such a coloring - if not, it shouldn't happen automatically and you are free to use whatever `tm_tag_...` you wish - otherwise you have to be more careful.
OK, I guess for the time being I'll leave it at that.
@techee requested changes on this pull request.
I don't know how much finished this PR is but I added a few comments. Also, I'm not sure if you want to apply some of the changes you made to https://github.com/geany/geany/pull/4037 to this PR as well.
Finally, a unit test should be added under tests/ctags (check the HACKING file for more details). The unit test should include some SystemVerilog code that covers all the kinds except those mapped to `tm_tag_undef_t`.
@@ -788,6 +788,64 @@ static TMParserMapGroup group_VERILOG[] = {
{N_("Variables"), TM_ICON_VAR, tm_tag_variable_t}, };
+static TMParserMapEntry map_SYSVERILOG[] = {
If the `tm_tag_...` mapping is identical for both Verilog and SystemVerilog, I think it would be best to define the common part using a macro and reuse the mapping for both the dialects - see how it's done for C/C++ using the COMMON_C macro above.
For the comment we use the full kind name (3rd member) defined here
https://github.com/universal-ctags/ctags/blob/dc5edb05845c65c67270a597c4a4e9...
@@ -788,6 +788,64 @@ static TMParserMapGroup group_VERILOG[] = {
{N_("Variables"), TM_ICON_VAR, tm_tag_variable_t}, };
+static TMParserMapEntry map_SYSVERILOG[] = { + // Verilog and SystemVerilog
Drop this comment.
- {'M', tm_tag_undef_t},/**/ // modport
+ {'K', tm_tag_package_t}, // package + {'P', tm_tag_namespace_t}, // program + {'Q', tm_tag_undef_t},/**/ // prototype + {'R', tm_tag_undef_t},/**/ // property + {'S', tm_tag_struct_t}, // struct + {'T', tm_tag_typedef_t}, // typedef + {'H', tm_tag_undef_t},/**/ // checker + {'L', tm_tag_undef_t},/**/ // clocking + {'q', tm_tag_undef_t},/**/ // sequence + {'w', tm_tag_member_t}, // member + {'l', tm_tag_class_t}, // ifclass (SV equivalent of a Java interface) + {'O', tm_tag_undef_t},/**/ // constraint + {'N', tm_tag_undef_t},/**/ // nettype + + // TODO: decide most fitting categories for each
Drop all the TODO comments and the `/**/` comments above.
@cousteaulecommandant commented on this pull request.
@@ -788,6 +788,64 @@ static TMParserMapGroup group_VERILOG[] = {
{N_("Variables"), TM_ICON_VAR, tm_tag_variable_t}, };
+static TMParserMapEntry map_SYSVERILOG[] = {
Yeah that can be a good idea. But that'll require Verilog and SystemVerilog to be made consistent. I was planning to do that in this PR once I've made up my mind about the SystemVerilog part. It will improve Verilog ctags (more groups, more Ctrl-clickable tags), with the only drawback that the "event" type is gone (merged with "net/register", which I think is quite related to); hope that's not a problem. :)
@cousteaulecommandant commented on this pull request.
@@ -788,6 +788,64 @@ static TMParserMapGroup group_VERILOG[] = {
{N_("Variables"), TM_ICON_VAR, tm_tag_variable_t}, };
+static TMParserMapEntry map_SYSVERILOG[] = {
For the comment we use the full kind name (3rd member) defined here
OK, I can remove the clarifications I added in parentheses. I felt they were helpful (at least they are for me right now), and thought that the comment was merely a hint as to what that line represented so it could use the clarification ("constant" is a bit of a misnomer here, and "ifclass" seems to be an abbreviation of "interface class" which may not be obvious).
@cousteaulecommandant commented on this pull request.
@@ -788,6 +788,64 @@ static TMParserMapGroup group_VERILOG[] = {
{N_("Variables"), TM_ICON_VAR, tm_tag_variable_t}, };
+static TMParserMapEntry map_SYSVERILOG[] = { + // Verilog and SystemVerilog
Makes sense once I replace that whole chunk with `COMMON_VERILOG`. Should I also remove the ones in `group_[SYS]VERILOG`? I intend to merge the two of them together and `#define group_SYSVERILOG group_VERILOG` so it might get confusing.
I don't know how much finished this PR is but I added a few comments.
Getting there, slowly but surely. Thanks a lot for your feedback and guidance :)
I'm not sure if you want to apply some of the changes you made to #4037 to this PR as well.
Yeah, as soon as I did that keyword rearrangement there I knew I would regret it :weary: It needs to be done here as well for consistency, problem is that there are many more keywords here and with all the OOP in SystemVerilog the barrier between "type" and "not type" gets fuzzier. But I'll figure it out.
Finally, a unit test should be added under tests/ctags (check the HACKING file for more details). The unit test should include some SystemVerilog code that covers all the kinds except those mapped to `tm_tag_undef_t`.
Noted! I'll see what I can make up.
@cousteaulecommandant pushed 1 commit.
13ae7e5f4b518d4fd1173ef1071e139ddaf03b90 tagmanager: SystemVerilog: map ctags
@cousteaulecommandant pushed 1 commit.
10b4e937ac99acbdac03643ce4591159ef4759a6 tagmanager: Unify Verilog and SystemVerilog tags
@cousteaulecommandant commented on this pull request.
@@ -788,6 +788,64 @@ static TMParserMapGroup group_VERILOG[] = {
{N_("Variables"), TM_ICON_VAR, tm_tag_variable_t}, };
+static TMParserMapEntry map_SYSVERILOG[] = {
...oh and I need to re-do the unit test for Verilog since I've changed it, of course.
@cousteaulecommandant pushed 4 commits.
5a31419ff0c4bbd3a6546cbf38295da2f1d87c72 Add SystemVerilog filetype 143cf1930b1b30a6ee2ad6fdd30ad02feb0b018b tagmanager: SystemVerilog: map ctags 6c1139c39eba96a0aad700cc0e85eb072fb4e36b tagmanager: Unify Verilog and SystemVerilog tags 26dc1eca5fbd522fa1d27a43605bb0a0092060ce Split SystemVerilog keywords into type / not type
@cousteaulecommandant pushed 2 commits.
a5dcc9d218c69f07171d3ba346c5b2c3ab84ff8e Add missing SystemVerilog tasks/functions eec080af505f143bfdd8a98d6d83b7350cc9fa7c Regenerate Verilog ctags unit tests
@cousteaulecommandant pushed 5 commits.
0151e80e1a36c281dc0084b396114b4f65f12a0b tagmanager: SystemVerilog: map ctags 4ae35826df8aee54d40ba79733822091d2d99edd tagmanager: Unify Verilog and SystemVerilog tags 2e7563729aea50aeb0494c3af3bd70586507cac1 Split SystemVerilog keywords into type / not type 096d52dcd4505a56e004e611fb57010679a48496 Add missing SystemVerilog tasks/functions e4f7c7241306a61d569317dd9f5b748cba541536 Regenerate Verilog ctags unit tests
@cousteaulecommandant pushed 6 commits.
09d250da7145b7a0083af1a8f5065150b8035921 tagmanager: SystemVerilog: map ctags 2fff652c169e708408ff5b4ebc4f85d69867a9c4 tagmanager: Unify Verilog and SystemVerilog tags 1e023bcce748fadf794188b63f600930b9cf5dac Split SystemVerilog keywords into type / not type 19d9250f7f9d7183191f189c4f0670826a77cd20 Add missing SystemVerilog tasks/functions 1ff70710453d66639456362a26027bee24e046af Regenerate Verilog ctags unit tests 41fb57391229ca678446c101b5cc5b50eb226c3a Add SystemVerilog ctags unit tests
It has been done. Hooray! @techee: there's only one issue pending which is whether it is OK to leave the comments I put in `group_SYSVERILOG` or if I should remove those as well.
I also re-generated the ctags unit tests for Verilog and added two for SystemVerilog. While doing so, I noticed a couple of issues/bugs in ctags (I think), but those should be fixed in ctags. I left the points of failure marked in comments in the unit tests.
Other than this, the PR is ready to go.
@cousteaulecommandant pushed 1 commit.
2560628da808b9ce4658b294749ec4eae5731d93 Add SystemVerilog ctags unit tests
Oddly enough, it works if I build with **meson**, but not if I build with **make** -- SystemVerilog is not recognized as a language in the latter, for some reason. The CI/CD tests are complaining for the non-Meson build, but not for the Meson ones.
Oddlier enough, if I run `make check` it works for me (even though Geany seems not to recognize the language when I open it graphically), so the mystery of why the CI/CD is failing deepens.
@cousteaulecommandant pushed 7 commits.
4ad90857cf94f8f0628f0eaeb440c06d070231db Add SystemVerilog filetype bee6076de639bcadd57eef4afd426e4e20cb1a32 tagmanager: SystemVerilog: map ctags 66710b09699d416e024574bb744f80ebe09eb186 tagmanager: Unify Verilog and SystemVerilog tags 85564aa10dbdc8b2e47354d913c797f39fd5c4fa Split SystemVerilog keywords into type / not type b26b7fc801316433683848da3b5d558cafcd8e5d Add missing SystemVerilog tasks/functions e7a215ddedc345e06a1878705c037b6694467868 Regenerate Verilog ctags unit tests 4b7c56e5f482d2fb562fe81bd45b8641c5642828 Add SystemVerilog ctags unit tests
@techee: there's only one issue pending which is whether it is OK to leave the comments I put in group_SYSVERILOG or if I should remove those as well.
These can stay.
I also re-generated the ctags unit tests for Verilog and added two for SystemVerilog.
There's one thing I noticed - I think you should also add mappings for types that can appear as parents of other symbols. For instance, because of the missing `oop` package mapping, the symbol tree doesn't generate it in the hierarchy and the bottom part of the screenshot below shows just flat symbol list instead of a proper tree. <img width="314" alt="Screenshot 2024-11-20 at 0 18 08" src="https://github.com/user-attachments/assets/3ab6831b-fa05-4ed8-90ff-ac8008b9861c">
While doing so, I noticed a couple of issues/bugs in ctags (I think), but those should be fixed in ctags.
If you decide to update the ctags parsers, you should get it merged to ctags first and then open a PR in Geany with the change.
Apart from the symbol tree issue, the PR looks pretty good to me 👍.
There's one thing I noticed - I think you should also add mappings for types that can appear as parents of other symbols. For instance, because of the missing `oop` package mapping, the symbol tree doesn't generate it in the hierarchy and the bottom part of the screenshot below shows just flat symbol list instead of a proper tree.
That's something that's confusing me. There IS an `oop` package mapping, it's not missing (if I understood correctly); and also an oop/enum_t, and an oop/other_class/s_member and oop/other_class/u_member, so why do their members appear outside of the tree hierarchy? Seems like a bug.
![Captura de pantalla_2024-11-20_01-26-02](https://github.com/user-attachments/assets/2af5386a-844c-46d4-8ed1-16b08c5a2...)
All of `package oop` (`"package"` → `tm_tag_package_t`), `typedef ... enum_t` (`"typedef"` (not "enum") → `tm_tag_typedef_t`), `typedef ... struct_t` (same), `typedef ... union_t` (same), `struct ... s_member` (`"struct"` → `tm_tag_struct_t`), `union ... u_member` (same), and `enum ... e_member` (`"enum"` → `tm_tag_enum_t`) are mapped and labelled, and appear in the symbol list. But the members don't appear inside. The only one that seems to work is the enum member inside the class for some reason.
So it seems to be a bug. Not sure if it's in Geany or in ctags. But it doesn't seem to be related to the changes I made. (Would be nice if it could be fixed though, by me or someone else.)
While doing so, I noticed a couple of issues/bugs in ctags (I think), but those should be fixed in ctags.
If you decide to update the ctags parsers, you should get it merged to ctags first and then open a PR in Geany with the change.
Yes, that's what I meant. That it needed to be fixed it in the ctags project.
There IS an oop package mapping,
Yeah, sorry, I was confused - I checked the `sysverilog.sv` test which had "package" test unchecked in the top comment so I thought it wasn't mapped.
I think I know what is going on - it doesn't work for types that are declared _after_ their members like ```verilog typedef struct packed { logic [7:0] data; logic parity; } struct_t; ```
where `struct_t` is behind `data` and `parity`. At least for C/C++ we dealt with such situations already for typedefs and I think it would work if you used `tm_tag_typedef_t` mapping but we should probably generalize it for other mappings - I'd have to check the code.
In any case, nothing for this PR which I think is ready to be merged.
@techee approved this pull request.
Merged #4039 into master.
I checked the `sysverilog.sv` test which had "package" test unchecked in the top comment so I thought it wasn't mapped.
Oh, I see :) My aim was to put those in both files so that it could be easily seen that the "overlap" of both covered all the captured (non-`undef`) cases. Didn't work all that well apparently :smile:
I think I know what is going on - it doesn't work for types that are declared _after_ their members
I think you may be onto something. I've found that if I write `typedef struct packed struct_t;` one line above, then delete it, under some weird circumstances the original definition works! Like I somehow tricked Geany into realizing that struct_t is a struct/typedef and now it remembers, and displays the members inside. But it all breaks if I reopen the file, of course.
At least for C/C++ we dealt with such situations already for typedefs and I think it would work if you used `tm_tag_typedef_t` mapping
Well I got some bad news, I was already using `tm_tag_typedef_t` for typedefs just in case, but that didn't help :'( Maybe that only works in C. I will try to look into the issue and at least submit an issue on ctags.
In any case, nothing for this PR which I think is ready to be merged.
Woohoo! Thanks :)
@cousteaulecommandant See https://github.com/geany/geany/pull/4063 - it seems to fix the symbol tree for SystemVerilog.
I've just noticed that function parameters appear in the symbol tree too - we normally don't display those (and this is where we use the "special" `tm_tag_local_var_t`). But as I understand it, parameters are shared in the ctags parser together with constants and you map them `tm_tag_field_t`, am I right? In that case hiding parameters would also hide constants from the symbol tree so I guess what you did is the better option.
There's one more drawback to have function parameters mapped to anything else than `tm_tag_local_var_t` - all parameters from other functions appear in the autocompletion popup everywhere while when you use `tm_tag_local_var_t` they appear only within the function body where they were declared.
Just to clarify, *it was like that when I got here*™. The problem is that the Verilog ctags parser doesn't seem to distinguish between "function inputs/outputs" (arguments) and "module inputs/outputs" (ports), and just tags both as "ports", and isn't too good at limiting their scope it seems. Now, it makes sense to have ports listed in the tree because they are in scope in all of the module (which usually spans the whole file; it's rare to have more than one module definition per file), even from within functions/tasks declared inside the module, kind of like file-scope variables in C. They're a rather important thing. Same goes for variables (nets/registers) declared inside the module (maybe to a lesser degree of importance). On the other hand, function argument names aren't used outside the function, and internal function variables aren't accessible from outside, but unfortunately ctags puts both in the same bag as module ports and variables respectively. So this is something that should be fixed in ctags. Or for the time being I could remove both (ports and arguments), but I don't think I should do that since it'd probably be a big loss, and functions aren't that common anyway (modules are often declared entirely without using a single function, but ports are almost always there).
There are other things to fix in the ctags parser. The fact that a module instantiation (e.g. `a_module uut (.*);`) creates tags for *both* the module and the instance is wrong. It's like `struct foo x;` creating tags for both `foo` and `x` - it should only create the latter, since `foo` isn't being *defined* here, just used, and Ctrl-click shouldn't suggest that line as a "definition". I'll file a few issues in ctags.
I think there's nothing urgent here that has to be fixed - I just mentioned it as I noticed it and I don't know Verilog so it's really up to you.
Yeah, it's in the "future plans". For now I'm more than happy to have proper syntax coloring and even Ctrl-click capability in SystemVerilog. Thanks for the help! :)
github-comments@lists.geany.org