Browse Source

[CodeIssues] Fix ValueParameterUnusedIssue.

newNRvisualizers
Simon Lindgren 14 years ago
parent
commit
ebfd9410fb
  1. 12
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ValueParameterUnusedIssue.cs

12
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ValueParameterUnusedIssue.cs

@ -28,6 +28,7 @@ using System.Linq;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.CSharp.Resolver;
using System.Threading; using System.Threading;
using ICSharpCode.NRefactory.Semantics;
namespace ICSharpCode.NRefactory.CSharp.Refactoring namespace ICSharpCode.NRefactory.CSharp.Refactoring
{ {
@ -81,15 +82,18 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
{ {
if (node == null || node.IsNull) if (node == null || node.IsNull)
return; return;
var variable = context.GetResolverStateBefore(node).LocalVariables var localResolveResult = context.GetResolverStateBefore(node)
.Where(v => v.Name == "value").FirstOrDefault(); .LookupSimpleNameOrTypeName("value", new List<IType>(), NameLookupMode.Expression) as LocalResolveResult;
if (variable == null) if (localResolveResult == null)
return; return;
var variable = localResolveResult.Variable;
bool referenceFound = false; bool referenceFound = false;
var findRef = new FindReferences(); var findRef = new FindReferences();
findRef.FindLocalReferences(variable, context.ParsedFile, compilationUnit, context.Compilation, (n, entity) => { findRef.FindLocalReferences(variable, context.ParsedFile, compilationUnit, context.Compilation, (n, entity) => {
referenceFound = true; if (n.StartLocation >= node.StartLocation && n.EndLocation <= node.EndLocation) {
referenceFound = true;
}
}, CancellationToken.None); }, CancellationToken.None);
if(!referenceFound) if(!referenceFound)

Loading…
Cancel
Save