-
Notifications
You must be signed in to change notification settings - Fork 6
Add Visual Basic support #26
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
Add Visual Basic support #26
Conversation
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.
@sagi1623 Thank you so much for this contribution! It's fantastic that we can support Visual Basic with so much code reuse. Nice job porting all the tests from C# to Visual Basic 👏🏻
Only minor suggestions, I am happy to merge this PR once those are addressed.
ScipDotnet/ScipIndexer.cs
Outdated
var walker = new ScipCSharpSyntaxWalker(symbolFormatter, semanticModel); | ||
walker.Visit(root); | ||
} | ||
else |
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.
It might make sense to guard against this here
else | |
else if (language == "Visual Basic") |
/// <summary> | ||
/// Walks a single VisualBasic syntax tree and produces a SCIP <code>Document</code>. | ||
/// </summary> | ||
public class ScipVisualBasicSyntaxWalker : VisualBasicSyntaxWalker |
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.
Impressive how much code reuse we can do between C# and Visual Basic!
ScipDotnet/ScipSymbolFormatter.cs
Outdated
_doc = doc; | ||
_options = options; | ||
_globals = globals; | ||
_languagePrefix = _doc.Language == "C#" ? "cs" : "vb"; |
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.
nit: I had to check how this variable was used to understand what it does, this name might be clearer
_languagePrefix = _doc.Language == "C#" ? "cs" : "vb"; | |
_markdownCodeFenceLanguage = _doc.Language == "C#" ? "cs" : "vb"; |
ScipDotnet/ScipIndexer.cs
Outdated
@@ -13,10 +13,8 @@ namespace ScipDotnet; | |||
/// </summary> | |||
public class ScipIndexer |
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.
public class ScipIndexer | |
public class ScipProjectIndexer |
ScipDotnet/ScipSymbolFormatter.cs
Outdated
/// <summary> | ||
/// Creates SCIP <code>Document</code> based on provided symbols. | ||
/// </summary> | ||
public class ScipSymbolFormatter |
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.
My initial interpretation of the name ScipSymbolFormatter
was that it formats SCIP symbols like this interface we have in Go https://sourcegraph.com/github.com/sourcegraph/scip/-/blob/bindings/[go/scip/symbol_formatter.go?L10](https://www.golinks.io/scip/symbol_formatter.go?L10?trackSource=github)
I propose we rename this class into something else to make it clearer that this class does more than just format symbols
public class ScipSymbolFormatter | |
public class ScipDocumentIndexer |
I also propose we rename ScipIndexer
into ScipProjectIndexer
ab76842
to
c9f4c57
Compare
@olafurpg,
|
Do you have a ready diff I can test locally? I'm happy to ensure we get Visual Basic support added.
Good question. SCIP symbols are case sensitive so I recommend we lowercase symbols during indexing time. |
Not yet, I will not have time next week to work on it. If you don't mind waiting, I can try to do it the week after and send you the PRs for testing and review?
Do you think we could merge this PR to limit the scope of it and I can create a new one some time later to tackle the problem of case insensitivity? |
Sounds good. FYI, I'm doing cross-Atlantic travel for work June 4-7th so I may be slow to respond that week.
That's fine. I am OK with merging this PR once the CI is green. It might help to rebase on top of main now that the flaky tests have been fixed thanks to your PR #27 😄 |
2f9532f
to
5ed9b04
Compare
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.
LGTM 👍🏻 Thank you so much for this contribution! This is a great improvement 😄
@@ -248,7 +253,7 @@ private string FormatDocument(Index index, Document document) | |||
if (isDefinition) | |||
{ | |||
var info = symtab.GetValueOrDefault(occurrence.Symbol, new SymbolInformation()); | |||
var prefix = "//" + indent + new String(' ', length + 1); | |||
var prefix = commentChar + indent + new String(' ', length + 1); |
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.
Alternative solution, not a request to change, just thinking out loud
``suggestion
var prefix = commentChar + indent + new String(' ', length + commentChar.length - 1);
Hello @olafurpg, Coming back to our discussion regarding VbNet being case insensitive. |
@sagi1623 good to confirm that. Should we update the indexer to emit case sensitive names? |
Could you please clarify what do you mean by that? I think that the current behaviour is correct. I mean C# is case sensitive so with whichever casing you declare a symbol you will need to reference it with the same one. For VbNet that is not the case, if you declare the symbol with one casing, you can reference it with another one. However, this difference is not syntax level. On a semantic level it will be the same symbol. Am I missing something? And I will soon add a new case in the snapshot project, that will document the current behaviour and should act as a safety net in case the implementation changes in the future. |
I thought we used all-lowercase for VB symbols but looking at the original discussion it seems like we left this change for a future PR. I agree the current behavior is correct and there's nothing we need to do 👍🏻 |
Yes we said it will come in a future PR. |
Previously, scip-dotnet only supported C#. This PR adds support for Visual Basic as well. We are able to reuse a lot of code from the C# indexer by extracting shared logic related to formatting symbols.