Skip to content

Commit d0fa7cb

Browse files
committed
Merge with conflicts
2 parents 0c53e70 + f107b55 commit d0fa7cb

22 files changed

+2400
-1781
lines changed

RetailCoder.VBE/UI/FindSymbol/FindSymbolControl.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
<ColumnDefinition Width="32" />
2222
</Grid.ColumnDefinitions>
2323

24-
<ComboBox IsEditable="True"
24+
<ComboBox x:Name="searchComboBox"
25+
IsEditable="True"
2526
ItemsSource="{Binding MatchResults}"
2627
SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
2728
IsTextSearchCaseSensitive="False"

RetailCoder.VBE/UI/FindSymbol/FindSymbolControl.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public partial class FindSymbolControl : UserControl
1111
public FindSymbolControl()
1212
{
1313
InitializeComponent();
14+
Loaded += FindSymbolControl_Loaded;
1415
}
1516

1617
private FindSymbolViewModel ViewModel { get { return (FindSymbolViewModel)DataContext; } }
@@ -43,5 +44,10 @@ private void UIElement_OnPreviewKeyDown(object sender, KeyEventArgs e)
4344
e.Handled = true;
4445
}
4546
}
47+
48+
private void FindSymbolControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
49+
{
50+
searchComboBox.Focus();
51+
}
4652
}
47-
}
53+
}

RetailCoder.VBE/UI/FindSymbol/FindSymbolDialog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private void viewModel_Navigate(object sender, NavigateCodeEventArgs e)
2626
public FindSymbolDialog()
2727
{
2828
InitializeComponent();
29-
29+
3030
Text = string.Format("Rubberduck - {0}", RubberduckUI.FindSymbolDialog_Caption);
3131
}
3232

@@ -40,4 +40,4 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
4040
return base.ProcessCmdKey(ref msg, keyData);
4141
}
4242
}
43-
}
43+
}

RetailCoder.VBE/UI/FindSymbol/FindSymbolViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public string SearchString
8383
get { return _searchString; }
8484
set
8585
{
86-
//Adding SelectedItem.set() will allow pasting to work?
8786
SearchResult firstResult = GetSearchResultCollectionOfString(value).FirstOrDefault();
8887
SelectedItem = firstResult;
8988

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Rubberduck.Inspections.Abstract;
5+
using Rubberduck.Parsing.Inspections.Abstract;
6+
using Rubberduck.Parsing.Inspections.Resources;
7+
using Antlr4.Runtime;
8+
using Antlr4.Runtime.Misc;
9+
using Rubberduck.Parsing.Grammar;
10+
using Rubberduck.Parsing;
11+
using Rubberduck.Parsing.VBA;
12+
using Rubberduck.Inspections.Results;
13+
14+
namespace Rubberduck.Inspections.Concrete
15+
{
16+
[Flags]
17+
public enum ConditionBlockToInspect
18+
{
19+
NA = 0x0,
20+
If = 0x1,
21+
ElseIf = 0x2,
22+
Else = 0x4,
23+
All = If | ElseIf | Else
24+
}
25+
26+
internal class EmptyConditionBlockInspection : ParseTreeInspectionBase
27+
{
28+
public EmptyConditionBlockInspection(RubberduckParserState state,
29+
ConditionBlockToInspect BlockToInspect)
30+
: base(state, CodeInspectionSeverity.Suggestion)
31+
{
32+
_blockToInspect = BlockToInspect;
33+
_listener = new EmptyConditionBlockListener(BlockToInspect);
34+
}
35+
36+
public static ConditionBlockToInspect _blockToInspect { get; private set; }
37+
38+
public override Type Type => typeof(EmptyConditionBlockInspection);
39+
40+
public override IEnumerable<IInspectionResult> GetInspectionResults()
41+
{
42+
return Listener.Contexts
43+
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
44+
.Select(result => new QualifiedContextInspectionResult(this,
45+
InspectionsUI.EmptyConditionBlockInspectionsResultFormat,
46+
result));
47+
}
48+
49+
private IInspectionListener _listener;
50+
public override IInspectionListener Listener { get { return _listener; } }
51+
52+
public class EmptyConditionBlockListener : EmptyBlockInspectionListenerBase
53+
{
54+
ConditionBlockToInspect _blockToInspect;
55+
56+
public EmptyConditionBlockListener(ConditionBlockToInspect blockToInspect)
57+
{
58+
_blockToInspect = blockToInspect;
59+
}
60+
61+
public override void EnterIfStmt([NotNull] VBAParser.IfStmtContext context)
62+
{
63+
if (_blockToInspect.HasFlag(ConditionBlockToInspect.If))
64+
{
65+
InspectBlockForExecutableStatements(context.block(), context);
66+
}
67+
}
68+
69+
public override void EnterElseIfBlock([NotNull] VBAParser.ElseIfBlockContext context)
70+
{
71+
if (_blockToInspect.HasFlag(ConditionBlockToInspect.ElseIf))
72+
{
73+
InspectBlockForExecutableStatements(context.block(), context);
74+
}
75+
}
76+
77+
public override void EnterSingleLineIfStmt([NotNull] VBAParser.SingleLineIfStmtContext context)
78+
{
79+
if (context.ifWithEmptyThen() != null & _blockToInspect.HasFlag(ConditionBlockToInspect.If))
80+
{
81+
AddResult(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context.ifWithEmptyThen()));
82+
}
83+
}
84+
85+
public override void EnterElseBlock([NotNull] VBAParser.ElseBlockContext context)
86+
{
87+
if (_blockToInspect.HasFlag(ConditionBlockToInspect.Else))
88+
{
89+
InspectBlockForExecutableStatements(context.block(), context);
90+
}
91+
}
92+
}
93+
}
94+
}

Rubberduck.Inspections/Concrete/EmptyElseBlockInspection.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

Rubberduck.Inspections/Concrete/EmptyIfBlockInspection.cs

Lines changed: 0 additions & 58 deletions
This file was deleted.

Rubberduck.Inspections/QuickFixes/RemoveEmptyIfBlockQuickFix.cs renamed to Rubberduck.Inspections/QuickFixes/RemoveEmptyConditionBlockQuickFix.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
using System;
2-
using System.Diagnostics;
2+
using System.Collections.Generic;
33
using System.Linq;
4-
using Antlr4.Runtime;
5-
using Rubberduck.Inspections.Abstract;
64
using Rubberduck.Inspections.Concrete;
7-
using Rubberduck.Parsing.Grammar;
5+
using Rubberduck.Parsing.VBA;
86
using Rubberduck.Parsing.Inspections.Abstract;
9-
using Rubberduck.Parsing.Inspections.Resources;
7+
using Rubberduck.Parsing.Grammar;
108
using Rubberduck.Parsing.Rewriter;
11-
using Rubberduck.Parsing.VBA;
9+
using Antlr4.Runtime;
10+
using Rubberduck.Parsing.Inspections.Resources;
11+
using System.Diagnostics;
1212

1313
namespace Rubberduck.Inspections.QuickFixes
1414
{
15-
internal sealed class RemoveEmptyIfBlockQuickFix : QuickFixBase
15+
internal sealed class RemoveEmptyConditionBlockQuickFix : IQuickFix
1616
{
17+
private static readonly HashSet<Type> _supportedInspections = new HashSet<Type> { typeof(EmptyIfBlockInspection) };
1718
private readonly RubberduckParserState _state;
1819

19-
public RemoveEmptyIfBlockQuickFix(RubberduckParserState state)
20+
public RemoveEmptyConditionBlockQuickFix(RubberduckParserState state)
2021
: base(typeof(EmptyIfBlockInspection))
2122
{
2223
_state = state;
@@ -90,6 +91,16 @@ private void UpdateContext(VBAParser.ElseIfBlockContext context, IModuleRewriter
9091
rewriter.Remove(context);
9192
}
9293

94+
private void UpdateContext(VBAParser.ElseBlockContext context, IModuleRewriter rewriter)
95+
{
96+
var elseBlock = context.block();
97+
98+
if (elseBlock.ChildCount == 0)
99+
{
100+
rewriter.Remove(context);
101+
}
102+
}
103+
93104
private void UpdateCondition(VBAParser.RelationalOpContext condition, IModuleRewriter rewriter)
94105
{
95106
if (condition.EQ() != null)
@@ -176,7 +187,7 @@ private bool FirstBlockStmntHasLabel(VBAParser.BlockContext block)
176187

177188
public override string Description(IInspectionResult result)
178189
{
179-
return InspectionsUI.RemoveEmptyIfBlockQuickFix;
190+
return InspectionsUI.RemoveEmptyConditionBlockQuickFix;
180191
}
181192

182193
public override bool CanFixInProcedure { get; } = false;

Rubberduck.Inspections/QuickFixes/RemoveEmptyElseBlockQuickFix.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)