Skip to content

Commit 5d7189e

Browse files
authored
Merge pull request #5404 from MDoerner/RefactorParseTreeInspections
Refactoring of parse tree inspections; empty block inspections no longer experimental, xmldoc analyzers work.
2 parents 09b7209 + 98ea837 commit 5d7189e

File tree

499 files changed

+7001
-5322
lines changed

Some content is hidden

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

499 files changed

+7001
-5322
lines changed

Rubberduck.CodeAnalysis/Inspections/Abstract/ArgumentReferenceInspectionFromDeclarationsBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using Rubberduck.Inspections.Abstract;
43
using Rubberduck.Parsing.Symbols;
54
using Rubberduck.Parsing.VBA;
65
using Rubberduck.Parsing.VBA.DeclarationCaching;
76

8-
namespace Rubberduck.Inspections.Inspections.Abstract
7+
namespace Rubberduck.CodeAnalysis.Inspections.Abstract
98
{
10-
public abstract class ArgumentReferenceInspectionFromDeclarationsBase : IdentifierReferenceInspectionFromDeclarationsBase
9+
internal abstract class ArgumentReferenceInspectionFromDeclarationsBase : IdentifierReferenceInspectionFromDeclarationsBase
1110
{
1211
protected ArgumentReferenceInspectionFromDeclarationsBase(RubberduckParserState state)
1312
: base(state) { }
@@ -32,10 +31,11 @@ protected override bool IsResultReference(IdentifierReference reference, Declara
3231
}
3332
}
3433

35-
public abstract class ArgumentReferenceInspectionFromDeclarationsBase<T> : IdentifierReferenceInspectionFromDeclarationsBase<T>
34+
internal abstract class ArgumentReferenceInspectionFromDeclarationsBase<T> : IdentifierReferenceInspectionFromDeclarationsBase<T>
3635
{
37-
protected ArgumentReferenceInspectionFromDeclarationsBase(RubberduckParserState state)
38-
: base(state) { }
36+
protected ArgumentReferenceInspectionFromDeclarationsBase(IDeclarationFinderProvider declarationFinderProvider)
37+
: base(declarationFinderProvider)
38+
{}
3939

4040
protected abstract (bool isResult, T properties) IsUnsuitableArgumentWithAdditionalProperties(ArgumentReference reference, DeclarationFinder finder);
4141

Rubberduck.CodeAnalysis/Inspections/Abstract/DeclarationInspectionBase.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using Rubberduck.Inspections.Results;
4-
using Rubberduck.Parsing.Inspections.Abstract;
3+
using Rubberduck.CodeAnalysis.Inspections.Results;
54
using Rubberduck.Parsing.Symbols;
65
using Rubberduck.Parsing.VBA;
76
using Rubberduck.Parsing.VBA.DeclarationCaching;
87
using Rubberduck.VBEditor;
98

10-
namespace Rubberduck.Inspections.Abstract
9+
namespace Rubberduck.CodeAnalysis.Inspections.Abstract
1110
{
12-
public abstract class DeclarationInspectionBase : DeclarationInspectionBaseBase
11+
internal abstract class DeclarationInspectionBase : DeclarationInspectionBaseBase
1312
{
14-
protected DeclarationInspectionBase(RubberduckParserState state, params DeclarationType[] relevantDeclarationTypes)
15-
: base(state, relevantDeclarationTypes)
13+
protected DeclarationInspectionBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes)
14+
: base(declarationFinderProvider, relevantDeclarationTypes)
1615
{}
1716

18-
protected DeclarationInspectionBase(RubberduckParserState state, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
19-
: base(state, relevantDeclarationTypes, excludeDeclarationTypes)
17+
protected DeclarationInspectionBase(IDeclarationFinderProvider declarationFinderProvider, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
18+
: base(declarationFinderProvider, relevantDeclarationTypes, excludeDeclarationTypes)
2019
{}
2120

2221
protected abstract bool IsResultDeclaration(Declaration declaration, DeclarationFinder finder);
@@ -44,14 +43,14 @@ protected virtual IInspectionResult InspectionResult(Declaration declaration)
4443
}
4544
}
4645

47-
public abstract class DeclarationInspectionBase<T> : DeclarationInspectionBaseBase
46+
internal abstract class DeclarationInspectionBase<T> : DeclarationInspectionBaseBase
4847
{
49-
protected DeclarationInspectionBase(RubberduckParserState state, params DeclarationType[] relevantDeclarationTypes)
50-
: base(state, relevantDeclarationTypes)
48+
protected DeclarationInspectionBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes)
49+
: base(declarationFinderProvider, relevantDeclarationTypes)
5150
{}
5251

53-
protected DeclarationInspectionBase(RubberduckParserState state, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
54-
: base(state, relevantDeclarationTypes, excludeDeclarationTypes)
52+
protected DeclarationInspectionBase(IDeclarationFinderProvider declarationFinderProvider , DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
53+
: base(declarationFinderProvider, relevantDeclarationTypes, excludeDeclarationTypes)
5554
{}
5655

5756
protected abstract (bool isResult, T properties) IsResultDeclarationWithAdditionalProperties(Declaration declaration, DeclarationFinder finder);
Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,52 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using Rubberduck.Parsing.Inspections.Abstract;
43
using Rubberduck.Parsing.Symbols;
54
using Rubberduck.Parsing.VBA;
65
using Rubberduck.Parsing.VBA.DeclarationCaching;
76
using Rubberduck.VBEditor;
87

9-
namespace Rubberduck.Inspections.Abstract
8+
namespace Rubberduck.CodeAnalysis.Inspections.Abstract
109
{
11-
public abstract class DeclarationInspectionBaseBase : InspectionBase
10+
/// <summary>
11+
/// This is a base class for the other declaration inspection base classes. It should not be implemented directly by concrete inspections.
12+
/// </summary>
13+
internal abstract class DeclarationInspectionBaseBase : InspectionBase
1214
{
13-
protected readonly DeclarationType[] RelevantDeclarationTypes;
14-
protected readonly DeclarationType[] ExcludeDeclarationTypes;
15+
private readonly DeclarationType[] _relevantDeclarationTypes;
16+
private readonly DeclarationType[] _excludeDeclarationTypes;
1517

16-
protected DeclarationInspectionBaseBase(RubberduckParserState state, params DeclarationType[] relevantDeclarationTypes)
17-
: base(state)
18+
protected DeclarationInspectionBaseBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes)
19+
: base(declarationFinderProvider)
1820
{
19-
RelevantDeclarationTypes = relevantDeclarationTypes;
20-
ExcludeDeclarationTypes = new DeclarationType[0];
21+
_relevantDeclarationTypes = relevantDeclarationTypes;
22+
_excludeDeclarationTypes = new DeclarationType[0];
2123
}
2224

23-
protected DeclarationInspectionBaseBase(RubberduckParserState state, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
24-
: base(state)
25+
protected DeclarationInspectionBaseBase(IDeclarationFinderProvider declarationFinderProvider, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
26+
: base(declarationFinderProvider)
2527
{
26-
RelevantDeclarationTypes = relevantDeclarationTypes;
27-
ExcludeDeclarationTypes = excludeDeclarationTypes;
28+
_relevantDeclarationTypes = relevantDeclarationTypes;
29+
_excludeDeclarationTypes = excludeDeclarationTypes;
2830
}
2931

30-
protected abstract IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder);
31-
32-
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
32+
protected override IEnumerable<IInspectionResult> DoGetInspectionResults(DeclarationFinder finder)
3333
{
34-
var finder = DeclarationFinderProvider.DeclarationFinder;
35-
3634
return finder.UserDeclarations(DeclarationType.Module)
3735
.Concat(finder.UserDeclarations(DeclarationType.Project))
3836
.Where(declaration => declaration != null)
3937
.SelectMany(declaration => DoGetInspectionResults(declaration.QualifiedModuleName, finder))
4038
.ToList();
4139
}
4240

43-
protected virtual IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module)
44-
{
45-
var finder = DeclarationFinderProvider.DeclarationFinder;
46-
return DoGetInspectionResults(module, finder);
47-
}
48-
4941
protected virtual IEnumerable<Declaration> RelevantDeclarationsInModule(QualifiedModuleName module, DeclarationFinder finder)
5042
{
51-
var potentiallyRelevantDeclarations = RelevantDeclarationTypes.Length == 0
43+
var potentiallyRelevantDeclarations = _relevantDeclarationTypes.Length == 0
5244
? finder.Members(module)
53-
: RelevantDeclarationTypes
45+
: _relevantDeclarationTypes
5446
.SelectMany(declarationType => finder.Members(module, declarationType))
5547
.Distinct();
5648
return potentiallyRelevantDeclarations
57-
.Where(declaration => !ExcludeDeclarationTypes.Contains(declaration.DeclarationType));
49+
.Where(declaration => !_excludeDeclarationTypes.Contains(declaration.DeclarationType));
5850
}
5951
}
6052
}

Rubberduck.CodeAnalysis/Inspections/Abstract/DeclarationInspectionMultiResultBase.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using Rubberduck.Inspections.Results;
4-
using Rubberduck.Parsing.Inspections.Abstract;
3+
using Rubberduck.CodeAnalysis.Inspections.Results;
54
using Rubberduck.Parsing.Symbols;
65
using Rubberduck.Parsing.VBA;
76
using Rubberduck.Parsing.VBA.DeclarationCaching;
87
using Rubberduck.VBEditor;
98

10-
namespace Rubberduck.Inspections.Abstract
9+
namespace Rubberduck.CodeAnalysis.Inspections.Abstract
1110
{
12-
public abstract class DeclarationInspectionMultiResultBase<T> : DeclarationInspectionBaseBase
11+
internal abstract class DeclarationInspectionMultiResultBase<T> : DeclarationInspectionBaseBase
1312
{
14-
protected DeclarationInspectionMultiResultBase(RubberduckParserState state, params DeclarationType[] relevantDeclarationTypes)
15-
: base(state, relevantDeclarationTypes)
13+
protected DeclarationInspectionMultiResultBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes)
14+
: base(declarationFinderProvider, relevantDeclarationTypes)
1615
{}
1716

18-
protected DeclarationInspectionMultiResultBase(RubberduckParserState state, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
19-
: base(state, relevantDeclarationTypes, excludeDeclarationTypes)
17+
protected DeclarationInspectionMultiResultBase(IDeclarationFinderProvider declarationFinderProvider, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
18+
: base(declarationFinderProvider, relevantDeclarationTypes, excludeDeclarationTypes)
2019
{}
2120

2221
protected abstract IEnumerable<T> ResultProperties(Declaration declaration, DeclarationFinder finder);

Rubberduck.CodeAnalysis/Inspections/Abstract/DeclarationInspectionUsingGlobalInformationBase.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using Rubberduck.Inspections.Results;
4-
using Rubberduck.Parsing.Inspections.Abstract;
3+
using Rubberduck.CodeAnalysis.Inspections.Results;
54
using Rubberduck.Parsing.Symbols;
65
using Rubberduck.Parsing.VBA;
76
using Rubberduck.Parsing.VBA.DeclarationCaching;
87
using Rubberduck.VBEditor;
98

10-
namespace Rubberduck.Inspections.Abstract
9+
namespace Rubberduck.CodeAnalysis.Inspections.Abstract
1110
{
12-
public abstract class DeclarationInspectionUsingGlobalInformationBase<TGlobalInfo> : DeclarationInspectionUsingGlobalInformationBaseBase<TGlobalInfo>
11+
internal abstract class DeclarationInspectionUsingGlobalInformationBase<TGlobalInfo> : DeclarationInspectionUsingGlobalInformationBaseBase<TGlobalInfo>
1312
{
14-
protected DeclarationInspectionUsingGlobalInformationBase(RubberduckParserState state, params DeclarationType[] relevantDeclarationTypes)
15-
: base(state, relevantDeclarationTypes)
13+
protected DeclarationInspectionUsingGlobalInformationBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes)
14+
: base(declarationFinderProvider, relevantDeclarationTypes)
1615
{}
1716

18-
protected DeclarationInspectionUsingGlobalInformationBase(RubberduckParserState state, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
19-
: base(state, relevantDeclarationTypes, excludeDeclarationTypes)
17+
protected DeclarationInspectionUsingGlobalInformationBase(IDeclarationFinderProvider declarationFinderProvider, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
18+
: base(declarationFinderProvider, relevantDeclarationTypes, excludeDeclarationTypes)
2019
{}
2120

2221
protected abstract bool IsResultDeclaration(Declaration declaration, DeclarationFinder finder, TGlobalInfo globalInfo);
@@ -44,14 +43,14 @@ protected virtual IInspectionResult InspectionResult(Declaration declaration)
4443
}
4544
}
4645

47-
public abstract class DeclarationInspectionUsingGlobalInformationBase<TGlobalInfo,TProperties> : DeclarationInspectionUsingGlobalInformationBaseBase<TGlobalInfo>
46+
internal abstract class DeclarationInspectionUsingGlobalInformationBase<TGlobalInfo,TProperties> : DeclarationInspectionUsingGlobalInformationBaseBase<TGlobalInfo>
4847
{
49-
protected DeclarationInspectionUsingGlobalInformationBase(RubberduckParserState state, params DeclarationType[] relevantDeclarationTypes)
50-
: base(state, relevantDeclarationTypes)
48+
protected DeclarationInspectionUsingGlobalInformationBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes)
49+
: base(declarationFinderProvider, relevantDeclarationTypes)
5150
{}
5251

53-
protected DeclarationInspectionUsingGlobalInformationBase(RubberduckParserState state, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
54-
: base(state, relevantDeclarationTypes, excludeDeclarationTypes)
52+
protected DeclarationInspectionUsingGlobalInformationBase(IDeclarationFinderProvider declarationFinderProvider, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
53+
: base(declarationFinderProvider, relevantDeclarationTypes, excludeDeclarationTypes)
5554
{}
5655

5756
protected abstract (bool isResult, TProperties properties) IsResultDeclarationWithAdditionalProperties(Declaration declaration, DeclarationFinder finder, TGlobalInfo globalInformation);

Rubberduck.CodeAnalysis/Inspections/Abstract/DeclarationInspectionUsingGlobalInformationBaseBase.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using Rubberduck.Parsing.Inspections.Abstract;
43
using Rubberduck.Parsing.Symbols;
54
using Rubberduck.Parsing.VBA;
65
using Rubberduck.Parsing.VBA.DeclarationCaching;
76
using Rubberduck.VBEditor;
87

9-
namespace Rubberduck.Inspections.Abstract
8+
namespace Rubberduck.CodeAnalysis.Inspections.Abstract
109
{
11-
public abstract class DeclarationInspectionUsingGlobalInformationBaseBase<T> : InspectionBase
10+
internal abstract class DeclarationInspectionUsingGlobalInformationBaseBase<T> : InspectionBase
1211
{
1312
protected readonly DeclarationType[] RelevantDeclarationTypes;
1413
protected readonly DeclarationType[] ExcludeDeclarationTypes;
1514

16-
protected DeclarationInspectionUsingGlobalInformationBaseBase(RubberduckParserState state, params DeclarationType[] relevantDeclarationTypes)
17-
: base(state)
15+
protected DeclarationInspectionUsingGlobalInformationBaseBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes)
16+
: base(declarationFinderProvider)
1817
{
1918
RelevantDeclarationTypes = relevantDeclarationTypes;
2019
ExcludeDeclarationTypes = new DeclarationType[0];
2120
}
2221

23-
protected DeclarationInspectionUsingGlobalInformationBaseBase(RubberduckParserState state, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
24-
: base(state)
22+
protected DeclarationInspectionUsingGlobalInformationBaseBase(IDeclarationFinderProvider declarationFinderProvider, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes)
23+
: base(declarationFinderProvider)
2524
{
2625
RelevantDeclarationTypes = relevantDeclarationTypes;
2726
ExcludeDeclarationTypes = excludeDeclarationTypes;
@@ -38,9 +37,8 @@ protected virtual T GlobalInformation(QualifiedModuleName module, DeclarationFin
3837
return GlobalInformation(finder);
3938
}
4039

41-
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
40+
protected override IEnumerable<IInspectionResult> DoGetInspectionResults(DeclarationFinder finder)
4241
{
43-
var finder = DeclarationFinderProvider.DeclarationFinder;
4442
var globalInformation = GlobalInformation(finder);
4543

4644
return finder.UserDeclarations(DeclarationType.Module)
@@ -50,9 +48,8 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
5048
.ToList();
5149
}
5250

53-
protected virtual IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module)
51+
protected override IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder)
5452
{
55-
var finder = DeclarationFinderProvider.DeclarationFinder;
5653
var globalInformation = GlobalInformation(module, finder);
5754
return DoGetInspectionResults(module, finder, globalInformation);
5855
}

0 commit comments

Comments
 (0)