Skip to content

Commit 4bbb58e

Browse files
committed
Merge remote-tracking branch 'upstream/next' into rkapka-master
2 parents 06e96bb + 48b02db commit 4bbb58e

File tree

146 files changed

+3192
-1890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+3192
-1890
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/Rubberduck.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<NoWarn>1591</NoWarn>
3030
<PlatformTarget>AnyCPU</PlatformTarget>
3131
<UseVSHostingProcess>true</UseVSHostingProcess>
32+
<LangVersion>7.1</LangVersion>
3233
</PropertyGroup>
3334
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3435
<DebugType>full</DebugType>
@@ -41,6 +42,7 @@
4142
<DocumentationFile>bin\Release\Rubberduck.XML</DocumentationFile>
4243
<DebugSymbols>true</DebugSymbols>
4344
<NoWarn>1591</NoWarn>
45+
<LangVersion>7.1</LangVersion>
4446
</PropertyGroup>
4547
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugAccess|AnyCPU'">
4648
<DebugSymbols>true</DebugSymbols>
@@ -54,6 +56,7 @@
5456
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
5557
<WarningLevel>4</WarningLevel>
5658
<Optimize>false</Optimize>
59+
<LangVersion>7.1</LangVersion>
5760
</PropertyGroup>
5861
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
5962
<DebugSymbols>true</DebugSymbols>
@@ -151,6 +154,7 @@
151154
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
152155
<WarningLevel>4</WarningLevel>
153156
<Optimize>false</Optimize>
157+
<LangVersion>7.1</LangVersion>
154158
</PropertyGroup>
155159
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug64|x64'">
156160
<DebugSymbols>true</DebugSymbols>
@@ -191,6 +195,7 @@
191195
<ErrorReport>prompt</ErrorReport>
192196
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
193197
<WarningLevel>4</WarningLevel>
198+
<LangVersion>7.1</LangVersion>
194199
</PropertyGroup>
195200
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release64|x64'">
196201
<DebugSymbols>true</DebugSymbols>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using NLog;
5+
using Rubberduck.Parsing.Inspections.Abstract;
6+
using Rubberduck.Parsing.VBA;
7+
8+
namespace Rubberduck.Inspections.Abstract
9+
{
10+
public abstract class QuickFixBase : IQuickFix
11+
{
12+
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
13+
private HashSet<Type> _supportedInspections;
14+
public IReadOnlyCollection<Type> SupportedInspections => _supportedInspections.ToList();
15+
16+
protected QuickFixBase(params Type[] inspections)
17+
{
18+
RegisterInspections(inspections);
19+
}
20+
21+
public void RegisterInspections(params Type[] inspections)
22+
{
23+
if (!inspections.All(s => s.GetInterfaces().Any(a => a == typeof(IInspection))))
24+
{
25+
#if DEBUG
26+
throw new ArgumentException($"Parameters must implement {nameof(IInspection)}", nameof(inspections));
27+
#else
28+
inspections.Where(s => s.GetInterfaces().All(i => i != typeof(IInspection))).ToList()
29+
.ForEach(i => _logger.Error($"Type {i.Name} does not implement {nameof(IInspection)}"));
30+
#endif
31+
}
32+
33+
_supportedInspections = inspections.ToHashSet();
34+
}
35+
36+
public void RemoveInspections(params Type[] inspections)
37+
{
38+
_supportedInspections = _supportedInspections.Except(inspections).ToHashSet();
39+
}
40+
41+
public abstract void Fix(IInspectionResult result);
42+
public abstract string Description(IInspectionResult result);
43+
44+
public abstract bool CanFixInProcedure { get; }
45+
public abstract bool CanFixInModule { get; }
46+
public abstract bool CanFixInProject { get; }
47+
}
48+
}

Rubberduck.Inspections/Concrete/EmptyCaseBlockInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Rubberduck.Inspections.Concrete
1414
internal class EmptyCaseBlockInspection : ParseTreeInspectionBase
1515
{
1616
public EmptyCaseBlockInspection(RubberduckParserState state)
17-
: base(state, CodeInspectionSeverity.Suggestion) { }
17+
: base(state, CodeInspectionSeverity.DoNotShow) { }
1818

1919
public override IInspectionListener Listener { get; } =
2020
new EmptyCaseBlockListener();
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/EmptyElseBlockInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Rubberduck.Inspections.Concrete
1414
internal class EmptyElseBlockInspection : ParseTreeInspectionBase
1515
{
1616
public EmptyElseBlockInspection(RubberduckParserState state)
17-
: base(state, CodeInspectionSeverity.Suggestion) { }
17+
: base(state, CodeInspectionSeverity.DoNotShow) { }
1818

1919
public override Type Type => typeof(EmptyElseBlockInspection);
2020

Rubberduck.Inspections/Concrete/EmptyForEachBlockInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Rubberduck.Inspections.Concrete
1414
internal class EmptyForEachBlockInspection : ParseTreeInspectionBase
1515
{
1616
public EmptyForEachBlockInspection(RubberduckParserState state)
17-
: base(state, CodeInspectionSeverity.Suggestion) { }
17+
: base(state, CodeInspectionSeverity.DoNotShow) { }
1818

1919
public override Type Type => typeof(EmptyForEachBlockInspection);
2020

Rubberduck.Inspections/Concrete/EmptyForLoopBlockInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Rubberduck.Inspections.Concrete
1414
internal class EmptyForLoopBlockInspection : ParseTreeInspectionBase
1515
{
1616
public EmptyForLoopBlockInspection(RubberduckParserState state)
17-
: base(state, CodeInspectionSeverity.Suggestion) { }
17+
: base(state, CodeInspectionSeverity.DoNotShow) { }
1818

1919
public override Type Type => typeof(EmptyForLoopBlockInspection);
2020

Rubberduck.Inspections/Concrete/EmptyIfBlockInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Rubberduck.Inspections.Concrete
1616
internal class EmptyIfBlockInspection : ParseTreeInspectionBase
1717
{
1818
public EmptyIfBlockInspection(RubberduckParserState state)
19-
: base(state, CodeInspectionSeverity.Suggestion) { }
19+
: base(state, CodeInspectionSeverity.DoNotShow) { }
2020

2121
public override Type Type => typeof(EmptyIfBlockInspection);
2222

Rubberduck.Inspections/Concrete/EmptyWhileWendBlockInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Rubberduck.Inspections.Concrete
1414
internal class EmptyWhileWendBlockInspection : ParseTreeInspectionBase
1515
{
1616
public EmptyWhileWendBlockInspection(RubberduckParserState state)
17-
: base(state, CodeInspectionSeverity.Suggestion) { }
17+
: base(state, CodeInspectionSeverity.DoNotShow) { }
1818

1919
public override Type Type => typeof(EmptyWhileWendBlockInspection);
2020

0 commit comments

Comments
 (0)