Skip to content

Commit 99c2d75

Browse files
authored
Merge pull request #4690 from MDoerner/SomeSmallFixes
Some small fixes from 4686
2 parents 8a1d8bd + 75b5de1 commit 99c2d75

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

Rubberduck.CodeAnalysis/CodePathAnalysis/Walker.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Generic;
66
using System.Collections.Immutable;
77
using System.Linq;
8-
using Antlr4.Runtime;
98

109
namespace Rubberduck.Inspections.CodePathAnalysis
1110
{

Rubberduck.CodeAnalysis/Inspections/Concrete/AssignmentNotUsedInspection.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Rubberduck.Parsing.Symbols;
77
using Rubberduck.Inspections.CodePathAnalysis.Extensions;
88
using System.Linq;
9+
using Rubberduck.Inspections.CodePathAnalysis.Nodes;
910
using Rubberduck.Inspections.Results;
1011
using Rubberduck.Parsing;
1112
using Rubberduck.Parsing.Grammar;
@@ -30,7 +31,15 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
3031
var nodes = new List<IdentifierReference>();
3132
foreach (var variable in variables)
3233
{
33-
var tree = _walker.GenerateTree(variable.ParentScopeDeclaration.Context, variable);
34+
var parentScopeDeclaration = variable.ParentScopeDeclaration;
35+
36+
if (parentScopeDeclaration.DeclarationType.HasFlag(DeclarationType.Module))
37+
{
38+
continue;
39+
}
40+
41+
var tree = _walker.GenerateTree(parentScopeDeclaration.Context, variable);
42+
3443

3544
nodes.AddRange(tree.GetIdentifierReferences());
3645
}

Rubberduck.CodeAnalysis/Inspections/Concrete/ModuleWithoutFolderInspection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ public sealed class ModuleWithoutFolderInspection : InspectionBase
1313
{
1414
public ModuleWithoutFolderInspection(RubberduckParserState state)
1515
: base(state)
16-
{
17-
}
16+
{}
1817

1918
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2019
{
2120
var modulesWithoutFolderAnnotation = State.DeclarationFinder.UserDeclarations(Parsing.Symbols.DeclarationType.Module)
2221
.Where(w => w.Annotations.All(a => a.AnnotationType != AnnotationType.Folder))
2322
.ToList();
2423

25-
return modulesWithoutFolderAnnotation.Select(declaration =>
24+
return modulesWithoutFolderAnnotation
25+
.Where(declaration => !IsIgnoringInspectionResultFor(declaration, AnnotationName))
26+
.Select(declaration =>
2627
new DeclarationInspectionResult(this, string.Format(InspectionResults.ModuleWithoutFolderInspection, declaration.IdentifierName), declaration));
2728
}
2829
}

RubberduckTests/Inspections/ModuleWithoutFolderInspectionTests.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void Module_FolderAnnotation()
4646
[Category("Inspections")]
4747
public void Module_NonFolderAnnotation()
4848
{
49-
const string inputCode = @"'@IgnoreModule
49+
const string inputCode = @"'@PredeclaredId
5050
Option Explicit";
5151

5252
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);
@@ -58,5 +58,22 @@ public void Module_NonFolderAnnotation()
5858
Assert.AreEqual(1, inspectionResults.Count());
5959
}
6060
}
61+
62+
[Test]
63+
[Category("Inspections")]
64+
public void Module_NoFolderAnnotation_IgnoreWorks()
65+
{
66+
const string inputCode = @"'@IgnoreModule ModuleWithoutFolder
67+
Option Explicit";
68+
69+
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);
70+
using (var state = MockParser.CreateAndParse(vbe.Object))
71+
{
72+
var inspection = new ModuleWithoutFolderInspection(state);
73+
var inspectionResults = inspection.GetInspectionResults(CancellationToken.None);
74+
75+
Assert.IsFalse(inspectionResults.Any());
76+
}
77+
}
6178
}
6279
}

0 commit comments

Comments
 (0)