Browse Source

Replace FindReferences with context.FindReferences in ValueParameterUnusedIssue.

Simon Lindgren 14 years ago
parent
commit
1726ac4fcd
  1. 19
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ValueParameterUnusedIssue.cs

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

@ -45,13 +45,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
class GatherVisitor : GatherVisitorBase class GatherVisitor : GatherVisitorBase
{ {
readonly BaseRefactoringContext context;
readonly FindReferences findRef = new FindReferences();
public GatherVisitor(BaseRefactoringContext context, ValueParameterUnusedIssue inspector) : base (context) public GatherVisitor(BaseRefactoringContext context, ValueParameterUnusedIssue inspector) : base (context)
{ {
this.context = context;
} }
public override void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration) public override void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration)
@ -77,22 +72,22 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
if (!IsEligible(body)) if (!IsEligible(body))
return; return;
var localResolveResult = context.GetResolverStateBefore(body) var localResolveResult = ctx.GetResolverStateBefore(body)
.LookupSimpleNameOrTypeName("value", new List<IType>(), NameLookupMode.Expression) as LocalResolveResult; .LookupSimpleNameOrTypeName("value", new List<IType>(), NameLookupMode.Expression) as LocalResolveResult;
if (localResolveResult == null) if (localResolveResult == null)
return; return;
var variable = localResolveResult.Variable;
bool referenceFound = false; bool referenceFound = false;
var syntaxTree = (SyntaxTree)context.RootNode; foreach (var result in ctx.FindReferences (body, localResolveResult.Variable)) {
findRef.FindLocalReferences(variable, context.UnresolvedFile, syntaxTree, context.Compilation, (n, entity) => { var node = result.Node;
if (n.StartLocation >= body.StartLocation && n.EndLocation <= body.EndLocation) { if (node.StartLocation >= body.StartLocation && node.EndLocation <= body.EndLocation) {
referenceFound = true; referenceFound = true;
break;
} }
}, CancellationToken.None); }
if(!referenceFound) if(!referenceFound)
AddIssue(anchor, context.TranslateString("The " + accessorName + " does not use the 'value' parameter")); AddIssue(anchor, ctx.TranslateString("The " + accessorName + " does not use the 'value' parameter"));
} }
static bool IsEligible(BlockStatement body) static bool IsEligible(BlockStatement body)

Loading…
Cancel
Save