Repository navigation
Show 'else' within Ifs within Elses #734
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Stat | |
|
|
||
| If context.IsSingleLineStatementContext AndAlso | ||
| context.IsInStatementBlockOfKind(SyntaxKind.MultiLineIfBlock, SyntaxKind.ElseIfBlock) AndAlso | ||
| Not context.IsInStatementBlockOfKind(SyntaxKind.ElseBlock) Then | ||
| IsNotDirectlyInElseBlock(context) Then | ||
|
|
||
| Return SpecializedCollections.SingletonEnumerable(New RecommendedKeyword("Else", VBFeaturesResources.ElseKeywordToolTip)) | ||
| End If | ||
|
|
@@ -45,5 +45,23 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Stat | |
|
|
||
| Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)() | ||
| End Function | ||
|
|
||
| Private Function IsNotDirectlyInElseBlock(context As VisualBasicSyntaxContext) As Boolean | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the current implementation, this method name seems wrong ("directness" isn't required) |
||
| Dim parent = context.TargetToken.Parent | ||
| Do While parent IsNot Nothing | ||
| If parent.IsKind(SyntaxKind.MultiLineIfBlock, SyntaxKind.ElseIfBlock) Then | ||
| Return True | ||
| End If | ||
|
|
||
| If parent.IsKind(SyntaxKind.ElseBlock) Then | ||
| Return False | ||
| End If | ||
|
|
||
| parent = parent.Parent | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a case where we actually have to go up multiple levels, or should this just look at
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will we offer "Else" inside a more nested scope (say, a Do While loop) just because the Do While loop itself is in an If?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we can just look at the parents of the TargetToken. |
||
| Loop | ||
|
|
||
| ' We already know we're inside a Multiline If or ElseIf | ||
| Throw ExceptionUtilities.Unreachable | ||
| End Function | ||
| End Class | ||
| End Namespace | ||
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.
<WorkItem(...)>