-
Notifications
You must be signed in to change notification settings - Fork 5
Ctags support for visual basic .net #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hey @olafurpg, |
--langdef=vbnet | ||
--langmap=vbnet:.vb | ||
--regex-vbnet=/^(?i)\s*(?:(?:Public|Private|Protected|Friend|Overloads|Overrides|Overridable|NotOverridable|MustOverride|Shared|Shadows|Async|Iterator)\s+)*\s*(?:Function|Sub)\s+([A-Z_0-9\[\]]*)\(.*?\)\s*(?:As\s+[\w.]+)?/\1/m,method/ | ||
--regex-vbnet=/^(?i)\s*(?:(?:Default|Public|Private|Protected|Friend|Overloads|Overrides|Overridable|NotOverridable|MustOverride|Shared|Shadows|WriteOnly|ReadOnly|Iterator)\s+)*\s*(?:Property)\s+([A-Z_0-9\[\]]*)\s+As\s+/\1/p,property/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this regex have an extra check for Let
/Set
/Get
?
Looking at one of the code examples here:
Property Let Names(intX As Integer, intY As Integer, varZ As Variant)
' Statement here.
End Property
Property Get Names(intX As Integer, intY As Integer) As Variant
' Statement here.
End Property
This regex seems like it'll misidentify Let
/Get
/Set
as the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link you provided is for VBA (Visual Basic for Applications). While this implementation is supposed to add support for Visual Basic (.NET).
My source for the implementation was: https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/property-statement
ctagsdotd/vbnet.ctags
Outdated
@@ -0,0 +1,12 @@ | |||
# See additional-language.ctags for maintaining this file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add a link to https://learn.microsoft.com/en-us/dotnet/visual-basic/reference/language-specification/type-members in the comment so that is easier for someone to cross-check this.
ctagsdotd/vbnet.ctags
Outdated
--langmap=vbnet:.vb | ||
--regex-vbnet=/^(?i)\s*(?:(?:Public|Private|Protected|Friend|Overloads|Overrides|Overridable|NotOverridable|MustOverride|Shared|Shadows|Async|Iterator)\s+)*\s*(?:Function|Sub)\s+([A-Z_0-9\[\]]*)\(.*?\)\s*(?:As\s+[\w.]+)?/\1/m,method/ | ||
--regex-vbnet=/^(?i)\s*(?:(?:Default|Public|Private|Protected|Friend|Overloads|Overrides|Overridable|NotOverridable|MustOverride|Shared|Shadows|WriteOnly|ReadOnly|Iterator)\s+)*\s*(?:Property)\s+([A-Z_0-9\[\]]*)\s+As\s+/\1/p,property/ | ||
--regex-vbnet=/^(?i)\s*(?:(?:Public|Private|Protected|Friend|Shared|Shadows|Custom)\s+)*\s*(?:Event)\s+([A-Z_0-9\[\]]*)/\1/e,event/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the output of ctags --list-kinds-full
from universal-ctags
, I see that it has E event
, e enumerator
and g enum
. So I recommend following the same here, instead of using e,event
, e,enum
(Based on the distinct short codes in the ctags --list-kinds-full
output, I suspect using the same short code for different kinds might cause some problem, but I haven't tested it.)
# See additional-language.ctags for maintaining this file | ||
--langdef=vbnet | ||
--langmap=vbnet:.vb | ||
--regex-vbnet=/^(?i)\s*(?:(?:Public|Private|Protected|Friend|Overloads|Overrides|Overridable|NotOverridable|MustOverride|Shared|Shadows|Async|Iterator)\s+)*\s*(?:Function|Sub)\s+([A-Z_0-9\[\]]*)\(.*?\)\s*(?:As\s+[\w.]+)?/\1/m,method/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I have ~0 Visual Basic knowledge). Could you explain why this is using m,method
instead of f,function
? For example, Rust supports both methods and functions, so the output of ctags --list-kinds-full=Rust
has both P method
and f function
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are actually two types in VB.NET Subs and Functions. The difference between them is that Functions have a return value while Subs do not. And since the [language-specification] (https://learn.microsoft.com/en-us/dotnet/visual-basic/reference/language-specification/type-members)calls both methods, I opted for that one.
As I mentioned here I was unable to isntall sg and it seems to me that I would need to reinstall windows to be able to properly set up the environment to develop.
I have followed this guideline to add support for symbol search for visual basic .net and without a proper testing environment I have no idea if I did the right thing or not 😄.
I would kindly ask you @olafurpg or somebody else from Sourcegraph to take a look at this draft PR and help me test it and make it to the main branch if possible.
Notes:
ctagsKindToLSPSymbolKind
handles all the ctag kinds, however I was not able to find the correct place to check it so the PR might be missing something.