-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5561 from rubberduck-vba/next
2.5.1 release
- Loading branch information
Showing
1,021 changed files
with
46,378 additions
and
17,250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Rubberduck.CodeAnalysis/CodePathAnalysis/Nodes/Implementations/AssignmentExpressionNode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Antlr4.Runtime.Tree; | ||
|
||
namespace Rubberduck.Inspections.CodePathAnalysis.Nodes | ||
{ | ||
public class AssignmentExpressionNode : NodeBase | ||
{ | ||
public AssignmentExpressionNode(IParseTree tree) : base(tree) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...duck.CodeAnalysis/Inspections/Abstract/ArgumentReferenceInspectionFromDeclarationsBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Rubberduck.Parsing.Symbols; | ||
using Rubberduck.Parsing.VBA; | ||
using Rubberduck.Parsing.VBA.DeclarationCaching; | ||
|
||
namespace Rubberduck.CodeAnalysis.Inspections.Abstract | ||
{ | ||
internal abstract class ArgumentReferenceInspectionFromDeclarationsBase : IdentifierReferenceInspectionFromDeclarationsBase | ||
{ | ||
protected ArgumentReferenceInspectionFromDeclarationsBase(RubberduckParserState state) | ||
: base(state) { } | ||
|
||
protected abstract bool IsUnsuitableArgument(ArgumentReference reference, DeclarationFinder finder); | ||
|
||
protected override IEnumerable<IdentifierReference> ObjectionableReferences(DeclarationFinder finder) | ||
{ | ||
return ObjectionableDeclarations(finder) | ||
.OfType<ParameterDeclaration>() | ||
.SelectMany(parameter => parameter.ArgumentReferences); | ||
} | ||
|
||
protected override bool IsResultReference(IdentifierReference reference, DeclarationFinder finder) | ||
{ | ||
if (!(reference is ArgumentReference argumentReference)) | ||
{ | ||
return false; | ||
} | ||
|
||
return IsUnsuitableArgument(argumentReference, finder); | ||
} | ||
} | ||
|
||
internal abstract class ArgumentReferenceInspectionFromDeclarationsBase<T> : IdentifierReferenceInspectionFromDeclarationsBase<T> | ||
{ | ||
protected ArgumentReferenceInspectionFromDeclarationsBase(IDeclarationFinderProvider declarationFinderProvider) | ||
: base(declarationFinderProvider) | ||
{} | ||
|
||
protected abstract (bool isResult, T properties) IsUnsuitableArgumentWithAdditionalProperties(ArgumentReference reference, DeclarationFinder finder); | ||
|
||
protected override IEnumerable<IdentifierReference> ObjectionableReferences(DeclarationFinder finder) | ||
{ | ||
return ObjectionableDeclarations(finder) | ||
.OfType<ParameterDeclaration>() | ||
.SelectMany(parameter => parameter.ArgumentReferences); | ||
} | ||
|
||
protected override (bool isResult, T properties) IsResultReferenceWithAdditionalProperties(IdentifierReference reference, DeclarationFinder finder) | ||
{ | ||
if (!(reference is ArgumentReference argumentReference)) | ||
{ | ||
return (false, default); | ||
} | ||
|
||
return IsUnsuitableArgumentWithAdditionalProperties(argumentReference, finder); | ||
} | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
Rubberduck.CodeAnalysis/Inspections/Abstract/DeclarationInspectionBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Rubberduck.CodeAnalysis.Inspections.Results; | ||
using Rubberduck.Parsing.Symbols; | ||
using Rubberduck.Parsing.VBA; | ||
using Rubberduck.Parsing.VBA.DeclarationCaching; | ||
using Rubberduck.VBEditor; | ||
|
||
namespace Rubberduck.CodeAnalysis.Inspections.Abstract | ||
{ | ||
internal abstract class DeclarationInspectionBase : DeclarationInspectionBaseBase | ||
{ | ||
protected DeclarationInspectionBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes) | ||
: base(declarationFinderProvider, relevantDeclarationTypes) | ||
{} | ||
|
||
protected DeclarationInspectionBase(IDeclarationFinderProvider declarationFinderProvider, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes) | ||
: base(declarationFinderProvider, relevantDeclarationTypes, excludeDeclarationTypes) | ||
{} | ||
|
||
protected abstract bool IsResultDeclaration(Declaration declaration, DeclarationFinder finder); | ||
protected abstract string ResultDescription(Declaration declaration); | ||
|
||
protected virtual ICollection<string> DisabledQuickFixes(Declaration declaration) => new List<string>(); | ||
|
||
protected override IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder) | ||
{ | ||
var objectionableDeclarations = RelevantDeclarationsInModule(module, finder) | ||
.Where(declaration => IsResultDeclaration(declaration, finder)); | ||
|
||
return objectionableDeclarations | ||
.Select(InspectionResult) | ||
.ToList(); | ||
} | ||
|
||
protected virtual IInspectionResult InspectionResult(Declaration declaration) | ||
{ | ||
return new DeclarationInspectionResult( | ||
this, | ||
ResultDescription(declaration), | ||
declaration, | ||
disabledQuickFixes: DisabledQuickFixes(declaration)); | ||
} | ||
} | ||
|
||
internal abstract class DeclarationInspectionBase<T> : DeclarationInspectionBaseBase | ||
{ | ||
protected DeclarationInspectionBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes) | ||
: base(declarationFinderProvider, relevantDeclarationTypes) | ||
{} | ||
|
||
protected DeclarationInspectionBase(IDeclarationFinderProvider declarationFinderProvider , DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes) | ||
: base(declarationFinderProvider, relevantDeclarationTypes, excludeDeclarationTypes) | ||
{} | ||
|
||
protected abstract (bool isResult, T properties) IsResultDeclarationWithAdditionalProperties(Declaration declaration, DeclarationFinder finder); | ||
protected abstract string ResultDescription(Declaration declaration, T properties); | ||
|
||
protected virtual ICollection<string> DisabledQuickFixes(Declaration declaration, T properties) => new List<string>(); | ||
|
||
protected override IEnumerable<IInspectionResult> DoGetInspectionResults(QualifiedModuleName module, DeclarationFinder finder) | ||
{ | ||
var objectionableDeclarationsWithAdditionalProperties = RelevantDeclarationsInModule(module, finder) | ||
.Select(declaration => DeclarationWithResultProperties(declaration, finder)) | ||
.Where(result => result.HasValue) | ||
.Select(result => result.Value); | ||
|
||
return objectionableDeclarationsWithAdditionalProperties | ||
.Select(tpl => InspectionResult(tpl.declaration, tpl.properties)) | ||
.ToList(); | ||
} | ||
|
||
private (Declaration declaration, T properties)? DeclarationWithResultProperties(Declaration declaration, DeclarationFinder finder) | ||
{ | ||
var (isResult, properties) = IsResultDeclarationWithAdditionalProperties(declaration, finder); | ||
return isResult | ||
? (declaration, properties) | ||
: ((Declaration declaration, T properties)?) null; | ||
} | ||
|
||
protected virtual IInspectionResult InspectionResult(Declaration declaration, T properties) | ||
{ | ||
return new DeclarationInspectionResult<T>( | ||
this, | ||
ResultDescription(declaration, properties), | ||
declaration, | ||
properties: properties, | ||
disabledQuickFixes: DisabledQuickFixes(declaration, properties)); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
Rubberduck.CodeAnalysis/Inspections/Abstract/DeclarationInspectionBaseBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Rubberduck.Parsing.Symbols; | ||
using Rubberduck.Parsing.VBA; | ||
using Rubberduck.Parsing.VBA.DeclarationCaching; | ||
using Rubberduck.VBEditor; | ||
|
||
namespace Rubberduck.CodeAnalysis.Inspections.Abstract | ||
{ | ||
/// <summary> | ||
/// This is a base class for the other declaration inspection base classes. It should not be implemented directly by concrete inspections. | ||
/// </summary> | ||
internal abstract class DeclarationInspectionBaseBase : InspectionBase | ||
{ | ||
private readonly DeclarationType[] _relevantDeclarationTypes; | ||
private readonly DeclarationType[] _excludeDeclarationTypes; | ||
|
||
protected DeclarationInspectionBaseBase(IDeclarationFinderProvider declarationFinderProvider, params DeclarationType[] relevantDeclarationTypes) | ||
: base(declarationFinderProvider) | ||
{ | ||
_relevantDeclarationTypes = relevantDeclarationTypes; | ||
_excludeDeclarationTypes = new DeclarationType[0]; | ||
} | ||
|
||
protected DeclarationInspectionBaseBase(IDeclarationFinderProvider declarationFinderProvider, DeclarationType[] relevantDeclarationTypes, DeclarationType[] excludeDeclarationTypes) | ||
: base(declarationFinderProvider) | ||
{ | ||
_relevantDeclarationTypes = relevantDeclarationTypes; | ||
_excludeDeclarationTypes = excludeDeclarationTypes; | ||
} | ||
|
||
protected override IEnumerable<IInspectionResult> DoGetInspectionResults(DeclarationFinder finder) | ||
{ | ||
return finder.UserDeclarations(DeclarationType.Module) | ||
.Concat(finder.UserDeclarations(DeclarationType.Project)) | ||
.Where(declaration => declaration != null) | ||
.SelectMany(declaration => DoGetInspectionResults(declaration.QualifiedModuleName, finder)) | ||
.ToList(); | ||
} | ||
|
||
protected virtual IEnumerable<Declaration> RelevantDeclarationsInModule(QualifiedModuleName module, DeclarationFinder finder) | ||
{ | ||
var potentiallyRelevantDeclarations = _relevantDeclarationTypes.Length == 0 | ||
? finder.Members(module) | ||
: _relevantDeclarationTypes | ||
.SelectMany(declarationType => finder.Members(module, declarationType)) | ||
.Distinct(); | ||
return potentiallyRelevantDeclarations | ||
.Where(declaration => !_excludeDeclarationTypes.Contains(declaration.DeclarationType)); | ||
} | ||
} | ||
} |
Oops, something went wrong.