Skip to content

Commit c1a8e9c

Browse files
authored
Merge branch 'next' into next
2 parents da52c6b + b269ca6 commit c1a8e9c

File tree

44 files changed

+1957
-1247
lines changed

Some content is hidden

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

44 files changed

+1957
-1247
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.user
77
*.sln.docstates
88
*.csproj.user
9+
*.csproj.DotSettings
910

1011
# External NuGet Packages
1112
[Pp]ackages/

.nuget/NuGet.exe

2.8 MB
Binary file not shown.

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@
296296
<Reference Include="System.Printing" />
297297
<Reference Include="System.Runtime.Remoting" />
298298
<Reference Include="System.Runtime.Serialization" />
299+
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
300+
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
301+
</Reference>
299302
<Reference Include="System.Windows.Forms" />
300303
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
301304
<HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll</HintPath>
@@ -1388,6 +1391,10 @@
13881391
<SubType>Designer</SubType>
13891392
<Generator>MSBuild:Compile</Generator>
13901393
</Page>
1394+
<Page Include="UI\Controls\ToolBar.xaml">
1395+
<SubType>Designer</SubType>
1396+
<Generator>MSBuild:Compile</Generator>
1397+
</Page>
13911398
<Page Include="UI\Refactorings\EncapsulateField\EncapsulateFieldView.xaml">
13921399
<SubType>Designer</SubType>
13931400
<Generator>MSBuild:Compile</Generator>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp60</s:String>
2+
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp70</s:String>
33
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=ui_005Crefactorings_005Cextractinterface/@EntryIndexedValue">True</s:Boolean>
44
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=unittesting_005Cstubs/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 213 additions & 633 deletions
Large diffs are not rendered by default.

RetailCoder.VBE/UI/Controls/ToolBar.xaml

Lines changed: 433 additions & 0 deletions
Large diffs are not rendered by default.

RetailCoder.VBE/UI/Inspections/InspectionResultsControl.xaml

Lines changed: 28 additions & 438 deletions
Large diffs are not rendered by default.

RetailCoder.VBE/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<package id="Ninject.Extensions.NamedScope" version="3.2.0.0" targetFramework="net45" />
1515
<package id="NLog" version="4.0.1" targetFramework="net45" />
1616
<package id="NLog.Schema" version="4.0.1" targetFramework="net45" />
17+
<package id="System.ValueTuple" version="4.4.0" targetFramework="net45" />
1718
<package id="System.Windows.Interactivity.WPF" version="2.0.20525" targetFramework="net45" />
1819
</packages>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using Antlr4.Runtime;
2+
using Rubberduck.Parsing;
3+
using Rubberduck.Parsing.Grammar;
4+
using Rubberduck.Parsing.Inspections.Abstract;
5+
using Rubberduck.VBEditor;
6+
using System.Collections.Generic;
7+
using System.Diagnostics;
8+
9+
namespace Rubberduck.Inspections.Concrete
10+
{
11+
public class EmptyBlockInspectionListenerBase : VBAParserBaseListener, IInspectionListener
12+
{
13+
private readonly List<QualifiedContext<ParserRuleContext>> _contexts = new List<QualifiedContext<ParserRuleContext>>();
14+
public IReadOnlyList<QualifiedContext<ParserRuleContext>> Contexts => _contexts;
15+
16+
public QualifiedModuleName CurrentModuleName { get; set; }
17+
18+
public void ClearContexts()
19+
{
20+
_contexts.Clear();
21+
}
22+
23+
public void InspectBlockForExecutableStatements<T>(VBAParser.BlockContext block, T context) where T : ParserRuleContext
24+
{
25+
if (!BlockContainsExecutableStatements(block))
26+
{
27+
AddResult(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context));
28+
}
29+
}
30+
31+
public void AddResult(QualifiedContext<ParserRuleContext> qualifiedContext)
32+
{
33+
_contexts.Add(qualifiedContext);
34+
}
35+
36+
private bool BlockContainsExecutableStatements(VBAParser.BlockContext block)
37+
{
38+
return block != null && block.children != null && ContainsExecutableStatements(block);
39+
}
40+
41+
private bool ContainsExecutableStatements(VBAParser.BlockContext block)
42+
{
43+
foreach (var child in block.children)
44+
{
45+
if (child is VBAParser.BlockStmtContext)
46+
{
47+
var blockStmt = (VBAParser.BlockStmtContext)child;
48+
var mainBlockStmt = blockStmt.mainBlockStmt();
49+
50+
if (mainBlockStmt == null)
51+
{
52+
continue; //We have a lone line lable, which is not executable.
53+
}
54+
55+
Debug.Assert(mainBlockStmt.ChildCount == 1);
56+
57+
// exclude variables and consts because they are not executable statements
58+
if (mainBlockStmt.GetChild(0) is VBAParser.VariableStmtContext ||
59+
mainBlockStmt.GetChild(0) is VBAParser.ConstStmtContext)
60+
{
61+
continue;
62+
}
63+
64+
return true;
65+
}
66+
67+
if (child is VBAParser.RemCommentContext ||
68+
child is VBAParser.CommentContext ||
69+
child is VBAParser.CommentOrAnnotationContext ||
70+
child is VBAParser.EndOfStatementContext)
71+
{
72+
continue;
73+
}
74+
75+
return true;
76+
}
77+
78+
return false;
79+
}
80+
}
81+
}
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 EmptyCaseBlockInspection : ParseTreeInspectionBase
15+
{
16+
public EmptyCaseBlockInspection(RubberduckParserState state)
17+
: base(state, CodeInspectionSeverity.Suggestion) { }
18+
19+
public override IInspectionListener Listener { get; } =
20+
new EmptyCaseBlockListener();
21+
22+
public override Type Type => typeof(EmptyCaseBlockInspection);
23+
24+
public override CodeInspectionType InspectionType => CodeInspectionType.CodeQualityIssues;
25+
26+
public override IEnumerable<IInspectionResult> GetInspectionResults()
27+
{
28+
return Listener.Contexts
29+
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
30+
.Select(result => new QualifiedContextInspectionResult(this,
31+
InspectionsUI.EmptyCaseBlockInspectionResultFormat,
32+
result));
33+
}
34+
35+
public class EmptyCaseBlockListener : EmptyBlockInspectionListenerBase
36+
{
37+
public override void EnterCaseClause([NotNull] VBAParser.CaseClauseContext context)
38+
{
39+
InspectBlockForExecutableStatements(context.block(), context);
40+
}
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)