|
|
@ -42,12 +42,12 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring |
|
|
|
var unit = context.RootNode as SyntaxTree; |
|
|
|
var unit = context.RootNode as SyntaxTree; |
|
|
|
if (unit == null) |
|
|
|
if (unit == null) |
|
|
|
return Enumerable.Empty<CodeIssue> (); |
|
|
|
return Enumerable.Empty<CodeIssue> (); |
|
|
|
return new GatherVisitor (context, unit).GetIssues (); |
|
|
|
return new GatherVisitor (context).GetIssues (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class GatherVisitor : GatherVisitorBase |
|
|
|
class GatherVisitor : GatherVisitorBase |
|
|
|
{ |
|
|
|
{ |
|
|
|
public GatherVisitor (BaseRefactoringContext ctx, SyntaxTree unit) |
|
|
|
public GatherVisitor (BaseRefactoringContext ctx) |
|
|
|
: base (ctx) |
|
|
|
: base (ctx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
@ -170,6 +170,14 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool IsInsideTryBlock (AstNode node) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var tryCatchStatement = node.GetParent<TryCatchStatement> (); |
|
|
|
|
|
|
|
if (tryCatchStatement == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
return tryCatchStatement.TryBlock.Contains (node.StartLocation.Line,node.StartLocation.Column); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum NodeState |
|
|
|
enum NodeState |
|
|
|
{ |
|
|
|
{ |
|
|
|
None, |
|
|
|
None, |
|
|
@ -222,8 +230,12 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (var node in assignments) |
|
|
|
foreach (var node in assignments) { |
|
|
|
ProcessNode (node, true, nodeStates); |
|
|
|
// we do not analyze an assignment inside a try block as it can jump to any catch block or finally block
|
|
|
|
|
|
|
|
if (IsInsideTryBlock(node.References[0])) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
ProcessNode(node, true, nodeStates); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ProcessNode (VariableReferenceNode node, bool addIssue, |
|
|
|
void ProcessNode (VariableReferenceNode node, bool addIssue, |
|
|
|