Skip to content

Commit

Permalink
ParameterNotUsedInspection now ignores Event and Declare statements
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Mar 23, 2015
1 parent 1545bc1 commit a2d2e0a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(VBProjectParse

foreach (var issue in declarations)
{
yield return new ParameterCanBeByValInspectionResult(string.Format(Name, issue.Context.GetText()), Severity, issue.Context, issue.QualifiedName);
yield return new ParameterCanBeByValInspectionResult(string.Format(Name, issue.IdentifierName), Severity, issue.Context, issue.QualifiedName);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion RetailCoder.VBE/Inspections/ParameterNotUsedInspection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Symbols;

namespace Rubberduck.Inspections
Expand All @@ -20,11 +21,13 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(VBProjectParse
{
var declarations = parseResult.Declarations.Items.Where(declaration =>
declaration.DeclarationType == DeclarationType.Parameter
&& !(declaration.Context.Parent.Parent is VBAParser.EventStmtContext)
&& !(declaration.Context.Parent.Parent is VBAParser.DeclareStmtContext)
&& !declaration.References.Any());

foreach (var issue in declarations)
{
yield return new ParameterNotUsedInspectionResult(string.Format(Name, issue.Context.GetText()), Severity, issue.Context, issue.QualifiedName);
yield return new ParameterNotUsedInspectionResult(string.Format(Name, issue.IdentifierName), Severity, issue.Context, issue.QualifiedName);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Rubberduck.Parsing/Symbols/Declaration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ public string Scope
{
case DeclarationType.Class:
case DeclarationType.Module:
return _projectName;
return _projectName + "." + _componentName;
case DeclarationType.Procedure:
case DeclarationType.Function:
case DeclarationType.PropertyGet:
case DeclarationType.PropertyLet:
case DeclarationType.PropertySet:
return _projectName + "." + _componentName;
return _projectName + "." + _componentName + "." + _identifierName;
default:
return _parentScope;
}
Expand Down

0 comments on commit a2d2e0a

Please sign in to comment.