Skip to content

Commit cc5b66a

Browse files
authored
Merge branch 'next' into 3389
2 parents 6c17a83 + c40927f commit cc5b66a

File tree

5 files changed

+2180
-7
lines changed

5 files changed

+2180
-7
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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
17+
internal class EmptyConditionBlockInspection : ParseTreeInspectionBase
18+
{
19+
public EmptyConditionBlockInspection(RubberduckParserState state)
20+
: base(state, CodeInspectionSeverity.Suggestion) { }
21+
22+
public override Type Type => typeof(EmptyConditionBlockInspection);
23+
24+
public override IEnumerable<IInspectionResult> GetInspectionResults()
25+
{
26+
return Listener.Contexts
27+
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
28+
.Select(result => new QualifiedContextInspectionResult(this,
29+
InspectionsUI.EmptyConditionBlockInspectionsResultFormat,
30+
result));
31+
}
32+
33+
public override IInspectionListener Listener { get; } =
34+
new EmptyConditionBlockListener();
35+
36+
public class EmptyConditionBlockListener : EmptyBlockInspectionListenerBase
37+
{
38+
public override void EnterIfStmt([NotNull] VBAParser.IfStmtContext context)
39+
{
40+
InspectBlockForExecutableStatements(context.block(), context);
41+
}
42+
43+
public override void EnterElseIfBlock([NotNull] VBAParser.ElseIfBlockContext context)
44+
{
45+
InspectBlockForExecutableStatements(context.block(), context);
46+
}
47+
48+
public override void EnterSingleLineIfStmt([NotNull] VBAParser.SingleLineIfStmtContext context)
49+
{
50+
AddResult(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context.ifWithEmptyThen()));
51+
}
52+
53+
public override void EnterElseBlock([NotNull] VBAParser.ElseBlockContext context)
54+
{
55+
InspectBlockForExecutableStatements(context.block(), context);
56+
}
57+
}
58+
}
59+
}

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

0 commit comments

Comments
 (0)