Skip to content

Commit 1e3e615

Browse files
authored
Merge pull request #4838 from comintern/next
Misc. fixes
2 parents a770343 + 1e6e40d commit 1e3e615

File tree

6 files changed

+151
-3
lines changed

6 files changed

+151
-3
lines changed

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public virtual void Synchronize(ref List<Declaration> updated)
4343

4444
var matching = updated.FirstOrDefault(decl =>
4545
Declaration.DeclarationType == decl?.DeclarationType &&
46-
Declaration.QualifiedName.Equals(decl.QualifiedName));
46+
Declaration.QualifiedName.Equals(decl.QualifiedName) &&
47+
(Declaration.ParentDeclaration is null || Declaration.ParentDeclaration.QualifiedName.Equals(decl.ParentDeclaration?.QualifiedName)));
4748

4849
if (matching is null)
4950
{

Rubberduck.Core/UI/AddRemoveReferences/AddRemoveReferencesWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
Command="{Binding BrowseCommand}">
186186
<StackPanel Orientation="Horizontal">
187187
<Image Margin="0,0,5,0" Height="16" Source="{StaticResource BrowseIcon}" />
188-
<TextBlock Background="Transparent" Text="Browse..."></TextBlock>
188+
<TextBlock Background="Transparent" Text="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=References_BrowseButtonText}" />
189189
</StackPanel>
190190
</Button>
191191
<Grid Grid.Row="1" Margin="10,10,10,5">

Rubberduck.Parsing/Grammar/VBAParser.g4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,9 @@ elseBlock :
416416
// 5.4.2.9 Single-line If Statement
417417
singleLineIfStmt : ifWithNonEmptyThen | ifWithEmptyThen;
418418
ifWithNonEmptyThen : IF whiteSpace? booleanExpression whiteSpace? THEN whiteSpace? listOrLabel (whiteSpace singleLineElseClause)?;
419-
ifWithEmptyThen : IF whiteSpace? booleanExpression whiteSpace? THEN endOfStatement? whiteSpace? singleLineElseClause;
419+
ifWithEmptyThen : IF whiteSpace? booleanExpression whiteSpace? THEN whiteSpace? emptyThenStatement? singleLineElseClause;
420420
singleLineElseClause : ELSE whiteSpace? listOrLabel?;
421+
421422
// lineNumberLabel should actually be "statement-label" according to MS VBAL but they only allow lineNumberLabels:
422423
// A <statement-label> that occurs as the first element of a <list-or-label> element has the effect
423424
// as if the <statement-label> was replaced with a <goto-statement> containing the same
@@ -427,7 +428,9 @@ listOrLabel :
427428
lineNumberLabel (whiteSpace? COLON whiteSpace? sameLineStatement?)*
428429
| (COLON whiteSpace?)? sameLineStatement (whiteSpace? COLON whiteSpace? sameLineStatement?)*
429430
;
431+
430432
sameLineStatement : mainBlockStmt;
433+
emptyThenStatement : (COLON whiteSpace?)+;
431434
booleanExpression : expression;
432435

433436
implementsStmt : IMPLEMENTS whiteSpace expression;

Rubberduck.Resources/RubberduckUI.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/RubberduckUI.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,4 +1549,7 @@ NOTE: Restart is required for the setting to take effect.</value>
15491549
<data name="Language_ES" xml:space="preserve">
15501550
<value>Español</value>
15511551
</data>
1552+
<data name="References_BrowseButtonText" xml:space="preserve">
1553+
<value>Browse...</value>
1554+
</data>
15521555
</root>

RubberduckTests/Grammar/VBAParserTests.cs

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,129 @@ If False Then MsgBox True Else
20462046
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
20472047
}
20482048

2049+
[Category("Parser")]
2050+
[Test]
2051+
public void TestSingleLineIfSingleEmptyThenEmptyElse()
2052+
{
2053+
string code = @"
2054+
Sub Test()
2055+
If False Then:: Else:
2056+
End Sub";
2057+
var parseResult = Parse(code);
2058+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2059+
}
2060+
2061+
public void TestSingleLineIfSingleMultipleEmptyThensEmptyElse()
2062+
{
2063+
string code = @"
2064+
Sub Test()
2065+
If False Then:: _
2066+
:Else:
2067+
End Sub";
2068+
var parseResult = Parse(code);
2069+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2070+
}
2071+
2072+
public void TestSingleLineIfSingleMultipleEmptyThensElse()
2073+
{
2074+
string code = @"
2075+
Sub Test()
2076+
If False Then:: _
2077+
:Else Bar
2078+
End Sub";
2079+
var parseResult = Parse(code);
2080+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2081+
}
2082+
2083+
[Category("Parser")]
2084+
[Test]
2085+
public void TestSingleLineIfSingleEmptyMultiLineThenEmptyElse()
2086+
{
2087+
string code = @"
2088+
Sub Test()
2089+
If False Then: _
2090+
: Else:
2091+
End Sub";
2092+
var parseResult = Parse(code);
2093+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2094+
}
2095+
2096+
[Category("Parser")]
2097+
[Test]
2098+
public void TestSingleLineIfSingleEmptyThenEmptyMultiLineElse()
2099+
{
2100+
string code = @"
2101+
Sub Test()
2102+
If False Then Else _
2103+
:
2104+
End Sub";
2105+
var parseResult = Parse(code);
2106+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2107+
}
2108+
2109+
[Category("Parser")]
2110+
[Test]
2111+
public void TestSingleLineIfSingleEmptyThenElse()
2112+
{
2113+
string code = @"
2114+
Sub Test()
2115+
If False Then Else _
2116+
: Bar
2117+
End Sub";
2118+
var parseResult = Parse(code);
2119+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2120+
}
2121+
2122+
[Category("Parser")]
2123+
[Test]
2124+
public void TestSingleLineIfNestedEmptyThenEmptyElse()
2125+
{
2126+
string code = @"
2127+
Sub Test()
2128+
If True Then If False Then If True Then Else
2129+
End Sub";
2130+
var parseResult = Parse(code);
2131+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2132+
}
2133+
2134+
[Category("Parser")]
2135+
[Test]
2136+
public void TestSingleLineIfNestedThenEmptyElse()
2137+
{
2138+
string code = @"
2139+
Sub Test()
2140+
If True Then If False Then If True Then Bar Else
2141+
End Sub";
2142+
var parseResult = Parse(code);
2143+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2144+
}
2145+
2146+
[Category("Parser")]
2147+
[Test]
2148+
public void TestSingleLineIfNestedEmptyThenElse()
2149+
{
2150+
string code = @"
2151+
Sub Test()
2152+
If True Then If False Then If True Then Else Bar
2153+
End Sub";
2154+
var parseResult = Parse(code);
2155+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2156+
}
2157+
2158+
[Category("Parser")]
2159+
[Test]
2160+
public void TestSingleLineIfSingleEmptyMultiLineThenEmptyMultiLineElse()
2161+
{
2162+
string code = @"
2163+
Sub Test()
2164+
If False Then: _
2165+
Else _
2166+
:
2167+
End Sub";
2168+
var parseResult = Parse(code);
2169+
AssertTree(parseResult.Item1, parseResult.Item2, "//singleLineIfStmt");
2170+
}
2171+
20492172
[Category("Parser")]
20502173
[Test]
20512174
public void TestSingleLineIfImplicitGoTo()

0 commit comments

Comments
 (0)