Skip to content

Commit 465cf12

Browse files
committed
Merge with conflicts
2 parents c369faa + c40927f commit 465cf12

20 files changed

+2012
-292
lines changed

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declarat
5151
_name = _declaration.IdentifierName;
5252

5353
var component = declaration.QualifiedName.QualifiedModuleName.Component;
54-
if (component.Type == ComponentType.Document)
54+
try
5555
{
56-
try
56+
if (component.Type == ComponentType.Document)
5757
{
5858
var parenthesizedName = component.Properties["Name"].Value.ToString();
5959

@@ -72,10 +72,10 @@ public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declarat
7272
_name += " (" + parenthesizedName + ")";
7373
}
7474
}
75-
catch
76-
{
77-
// gotcha! (this means that the property either doesn't exist or we weren't able to get it for some reason)
78-
}
75+
}
76+
catch
77+
{
78+
// gotcha! (this means that the property either doesn't exist or we weren't able to get it for some reason)
7979
}
8080
}
8181

RetailCoder.VBE/UI/SourceControl/SourceControlProviderFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ public interface ISourceControlProviderFactory
77
{
88
ISourceControlProvider CreateProvider(IVBProject project);
99
ISourceControlProvider CreateProvider(IVBProject project, IRepository repository);
10-
ISourceControlProvider CreateProvider(IVBProject isAny, IRepository repository, SecureCredentials secureCredentials);
10+
ISourceControlProvider CreateProvider(IVBProject project, IRepository repository, SecureCredentials secureCredentials);
1111
}
1212
}

Rubberduck.Inspections/Concrete/EmptyConditionBlockInspection.cs

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,11 @@
1313

1414
namespace Rubberduck.Inspections.Concrete
1515
{
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-
}
2516

2617
internal class EmptyConditionBlockInspection : ParseTreeInspectionBase
2718
{
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; }
19+
public EmptyConditionBlockInspection(RubberduckParserState state)
20+
: base(state, CodeInspectionSeverity.Suggestion) { }
3721

3822
public override Type Type => typeof(EmptyConditionBlockInspection);
3923

@@ -46,48 +30,29 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
4630
result));
4731
}
4832

49-
private IInspectionListener _listener;
50-
public override IInspectionListener Listener { get { return _listener; } }
33+
public override IInspectionListener Listener { get; } =
34+
new EmptyConditionBlockListener();
5135

5236
public class EmptyConditionBlockListener : EmptyBlockInspectionListenerBase
5337
{
54-
ConditionBlockToInspect _blockToInspect;
55-
56-
public EmptyConditionBlockListener(ConditionBlockToInspect blockToInspect)
57-
{
58-
_blockToInspect = blockToInspect;
59-
}
60-
6138
public override void EnterIfStmt([NotNull] VBAParser.IfStmtContext context)
6239
{
63-
if (_blockToInspect.HasFlag(ConditionBlockToInspect.If))
64-
{
65-
InspectBlockForExecutableStatements(context.block(), context);
66-
}
40+
InspectBlockForExecutableStatements(context.block(), context);
6741
}
6842

6943
public override void EnterElseIfBlock([NotNull] VBAParser.ElseIfBlockContext context)
7044
{
71-
if (_blockToInspect.HasFlag(ConditionBlockToInspect.ElseIf))
72-
{
73-
InspectBlockForExecutableStatements(context.block(), context);
74-
}
45+
InspectBlockForExecutableStatements(context.block(), context);
7546
}
7647

7748
public override void EnterSingleLineIfStmt([NotNull] VBAParser.SingleLineIfStmtContext context)
7849
{
79-
if (context.ifWithEmptyThen() != null & _blockToInspect.HasFlag(ConditionBlockToInspect.If))
80-
{
81-
AddResult(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context.ifWithEmptyThen()));
82-
}
50+
AddResult(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context.ifWithEmptyThen()));
8351
}
8452

8553
public override void EnterElseBlock([NotNull] VBAParser.ElseBlockContext context)
8654
{
87-
if (_blockToInspect.HasFlag(ConditionBlockToInspect.Else))
88-
{
89-
InspectBlockForExecutableStatements(context.block(), context);
90-
}
55+
InspectBlockForExecutableStatements(context.block(), context);
9156
}
9257
}
9358
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Antlr4.Runtime.Misc;
2+
using Rubberduck.Inspections.Abstract;
3+
using Rubberduck.Inspections.Results;
4+
using Rubberduck.Parsing.Grammar;
5+
using Rubberduck.Parsing.Inspections.Abstract;
6+
using Rubberduck.Parsing.Inspections.Resources;
7+
using Rubberduck.Parsing.VBA;
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Linq;
11+
12+
namespace Rubberduck.Inspections.Concrete
13+
{
14+
internal class EmptyElseBlockInspection : ParseTreeInspectionBase
15+
{
16+
public EmptyElseBlockInspection(RubberduckParserState state)
17+
: base(state, CodeInspectionSeverity.Suggestion) { }
18+
19+
public override Type Type => typeof(EmptyElseBlockInspection);
20+
21+
public override CodeInspectionType InspectionType => CodeInspectionType.CodeQualityIssues;
22+
23+
public override IEnumerable<IInspectionResult> GetInspectionResults()
24+
{
25+
return Listener.Contexts
26+
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
27+
.Select(result => new QualifiedContextInspectionResult(this,
28+
InspectionsUI.EmptyElseBlockInspectionResultFormat,
29+
result));
30+
}
31+
32+
public override IInspectionListener Listener { get; }
33+
= new EmptyElseBlockListener();
34+
35+
public class EmptyElseBlockListener : EmptyBlockInspectionListenerBase
36+
{
37+
public override void EnterElseBlock([NotNull] VBAParser.ElseBlockContext context)
38+
{
39+
InspectBlockForExecutableStatements(context.block(), context);
40+
}
41+
}
42+
}
43+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Antlr4.Runtime;
2+
using Antlr4.Runtime.Misc;
3+
using Rubberduck.Inspections.Abstract;
4+
using Rubberduck.Inspections.Results;
5+
using Rubberduck.Parsing;
6+
using Rubberduck.Parsing.Grammar;
7+
using Rubberduck.Parsing.Inspections.Abstract;
8+
using Rubberduck.Parsing.Inspections.Resources;
9+
using Rubberduck.Parsing.VBA;
10+
using System;
11+
using System.Collections.Generic;
12+
using System.Linq;
13+
14+
namespace Rubberduck.Inspections.Concrete
15+
{
16+
internal class EmptyIfBlockInspection : ParseTreeInspectionBase
17+
{
18+
public EmptyIfBlockInspection(RubberduckParserState state)
19+
: base(state, CodeInspectionSeverity.Suggestion) { }
20+
21+
public override Type Type => typeof(EmptyIfBlockInspection);
22+
23+
public override CodeInspectionType InspectionType => CodeInspectionType.CodeQualityIssues;
24+
25+
public override IEnumerable<IInspectionResult> GetInspectionResults()
26+
{
27+
return Listener.Contexts
28+
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
29+
.Select(result => new QualifiedContextInspectionResult(this,
30+
InspectionsUI.EmptyIfBlockInspectionResultFormat,
31+
result));
32+
}
33+
34+
public override IInspectionListener Listener { get; } =
35+
new EmptyIfBlockListener();
36+
37+
public class EmptyIfBlockListener : EmptyBlockInspectionListenerBase
38+
{
39+
public override void EnterIfStmt([NotNull] VBAParser.IfStmtContext context)
40+
{
41+
InspectBlockForExecutableStatements(context.block(), context);
42+
}
43+
44+
public override void EnterElseIfBlock([NotNull] VBAParser.ElseIfBlockContext context)
45+
{
46+
InspectBlockForExecutableStatements(context.block(), context);
47+
}
48+
49+
public override void EnterSingleLineIfStmt([NotNull] VBAParser.SingleLineIfStmtContext context)
50+
{
51+
if (context.ifWithEmptyThen() != null)
52+
{
53+
AddResult(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context.ifWithEmptyThen()));
54+
}
55+
}
56+
}
57+
}
58+
}

Rubberduck.Inspections/Concrete/ShadowedDeclarationInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public override void EnterEnumerationStmt_Constant(VBAParser.EnumerationStmt_Con
5656
}
5757
}
5858

59-
public ShadowedDeclarationInspection(RubberduckParserState state) : base(state)
59+
public ShadowedDeclarationInspection(RubberduckParserState state) : base(state, CodeInspectionSeverity.DoNotShow)
6060
{
6161
}
6262

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Rubberduck.Inspections.Abstract;
2+
using Rubberduck.Inspections.Concrete;
3+
using Rubberduck.Parsing.Inspections.Abstract;
4+
using Rubberduck.Parsing.Inspections.Resources;
5+
using Rubberduck.Parsing.Grammar;
6+
using Rubberduck.Parsing.Rewriter;
7+
using Rubberduck.Parsing.VBA;
8+
9+
namespace Rubberduck.Inspections.QuickFixes
10+
{
11+
class RemoveEmptyElseBlockQuickFix : QuickFixBase
12+
{
13+
private readonly RubberduckParserState _state;
14+
15+
public RemoveEmptyElseBlockQuickFix(RubberduckParserState state)
16+
: base(typeof(EmptyElseBlockInspection))
17+
{
18+
_state = state;
19+
}
20+
21+
public override void Fix(IInspectionResult result)
22+
{
23+
IModuleRewriter rewriter = _state.GetRewriter(result.QualifiedSelection.QualifiedName);
24+
25+
//dynamic used since it's not known at run-time
26+
UpdateContext((dynamic)result.Context, rewriter);
27+
}
28+
29+
private void UpdateContext(VBAParser.ElseBlockContext context, IModuleRewriter rewriter)
30+
{
31+
var elseBlock = context.block();
32+
33+
if (elseBlock.ChildCount == 0 )
34+
{
35+
rewriter.Remove(context);
36+
}
37+
}
38+
39+
public override string Description(IInspectionResult result)
40+
{
41+
return InspectionsUI.RemoveEmptyElseBlockQuickFix;
42+
}
43+
44+
public override bool CanFixInProcedure { get; } = false;
45+
public override bool CanFixInModule { get; } = false;
46+
public override bool CanFixInProject { get; } = false;
47+
}
48+
}

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

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Linq;
4+
using Antlr4.Runtime;
5+
using Rubberduck.Inspections.Abstract;
36
using Rubberduck.Inspections.Concrete;
4-
using Rubberduck.Parsing.VBA;
5-
using Rubberduck.Parsing.Inspections.Abstract;
67
using Rubberduck.Parsing.Grammar;
7-
using Rubberduck.Parsing.Rewriter;
8-
using Antlr4.Runtime;
8+
using Rubberduck.Parsing.Inspections.Abstract;
99
using Rubberduck.Parsing.Inspections.Resources;
10-
using System.Diagnostics;
11-
using Rubberduck.Inspections.Abstract;
10+
using Rubberduck.Parsing.Rewriter;
11+
using Rubberduck.Parsing.VBA;
1212

1313
namespace Rubberduck.Inspections.QuickFixes
1414
{
15-
internal sealed class RemoveEmptyConditionBlockQuickFix : QuickFixBase
15+
internal sealed class RemoveEmptyIfBlockQuickFix : QuickFixBase
1616
{
1717
private readonly RubberduckParserState _state;
1818

19-
public RemoveEmptyConditionBlockQuickFix(RubberduckParserState state)
20-
: base(typeof(EmptyConditionBlockInspection))
19+
public RemoveEmptyIfBlockQuickFix(RubberduckParserState state)
20+
: base(typeof(EmptyIfBlockInspection))
2121
{
2222
_state = state;
2323
}
@@ -90,16 +90,6 @@ private void UpdateContext(VBAParser.ElseIfBlockContext context, IModuleRewriter
9090
rewriter.Remove(context);
9191
}
9292

93-
private void UpdateContext(VBAParser.ElseBlockContext context, IModuleRewriter rewriter)
94-
{
95-
var elseBlock = context.block();
96-
97-
if (elseBlock.ChildCount == 0)
98-
{
99-
rewriter.Remove(context);
100-
}
101-
}
102-
10393
private void UpdateCondition(VBAParser.RelationalOpContext condition, IModuleRewriter rewriter)
10494
{
10595
if (condition.EQ() != null)
@@ -186,7 +176,7 @@ private bool FirstBlockStmntHasLabel(VBAParser.BlockContext block)
186176

187177
public override string Description(IInspectionResult result)
188178
{
189-
return InspectionsUI.RemoveEmptyConditionBlockQuickFix;
179+
return InspectionsUI.RemoveEmptyIfBlockQuickFix;
190180
}
191181

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

Rubberduck.Inspections/Rubberduck.Inspections.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
<Compile Include="Concrete\AssignedByValParameterInspection.cs" />
6565
<Compile Include="Concrete\EmptyBlockInspectionListenerBase.cs" />
6666
<Compile Include="Concrete\EmptyCaseBlockInspection.cs" />
67-
<Compile Include="Concrete\EmptyConditionBlockInspection.cs" />
6867
<Compile Include="Concrete\EmptyDoWhileBlockInspection.cs" />
6968
<Compile Include="Concrete\EmptyForEachBlockInspection.cs" />
7069
<Compile Include="Concrete\EmptyForLoopBlockInspection.cs" />
@@ -76,6 +75,7 @@
7675
<Compile Include="ParseTreeListeners\AttributeAnnotationListener.cs" />
7776
<Compile Include="Concrete\ConstantNotUsedInspection.cs" />
7877
<Compile Include="Concrete\DefaultProjectNameInspection.cs" />
78+
<Compile Include="Concrete\EmptyIfBlockInspection.cs" />
7979
<Compile Include="Concrete\EmptyStringLiteralInspection.cs" />
8080
<Compile Include="Concrete\EncapsulatePublicFieldInspection.cs" />
8181
<Compile Include="Concrete\FunctionReturnValueNotUsedInspection.cs" />
@@ -92,6 +92,7 @@
9292
<Compile Include="Concrete\MissingAttributeInspection.cs" />
9393
<Compile Include="Abstract\InspectionResultBase.cs" />
9494
<Compile Include="Concrete\RedundantByRefModifierInspection.cs" />
95+
<Compile Include="Concrete\EmptyElseBlockInspection.cs" />
9596
<Compile Include="Inspector.cs" />
9697
<Compile Include="Concrete\MemberNotOnInterfaceInspection.cs" />
9798
<Compile Include="Concrete\MissingAnnotationArgumentInspection.cs" />
@@ -120,7 +121,6 @@
120121
<Compile Include="QuickFixes\ChangeDimToPrivateQuickFix.cs" />
121122
<Compile Include="QuickFixes\ChangeIntegerToLongQuickFix.cs" />
122123
<Compile Include="Abstract\QuickFixBase.cs" />
123-
<Compile Include="QuickFixes\RemoveEmptyConditionBlockQuickFix.cs" />
124124
<Compile Include="QuickFixes\RemoveStopKeywordQuickFix.cs" />
125125
<Compile Include="QuickFixes\SpecifyExplicitByRefModifierQuickFix.cs" />
126126
<Compile Include="QuickFixes\ChangeProcedureToFunctionQuickFix.cs" />
@@ -135,6 +135,8 @@
135135
<Compile Include="QuickFixes\PassParameterByReferenceQuickFix.cs" />
136136
<Compile Include="QuickFixes\PassParameterByValueQuickFix.cs" />
137137
<Compile Include="QuickFixes\RemoveCommentQuickFix.cs" />
138+
<Compile Include="QuickFixes\RemoveEmptyElseBlockQuickFix.cs" />
139+
<Compile Include="QuickFixes\RemoveEmptyIfBlockQuickFix.cs" />
138140
<Compile Include="QuickFixes\RemoveExplicitCallStatmentQuickFix.cs" />
139141
<Compile Include="QuickFixes\RemoveExplicitLetStatementQuickFix.cs" />
140142
<Compile Include="QuickFixes\RemoveOptionBaseStatementQuickFix.cs" />

0 commit comments

Comments
 (0)