|
|
|
|
@ -17,6 +17,7 @@
@@ -17,6 +17,7 @@
|
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Threading; |
|
|
|
|
using ICSharpCode.TreeView; |
|
|
|
|
@ -29,6 +30,8 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
@@ -29,6 +30,8 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
|
|
|
|
|
{ |
|
|
|
|
private readonly MethodDefinition analyzedMethod; |
|
|
|
|
private readonly ThreadingSupport threading; |
|
|
|
|
private Lazy<Hashtable> foundMethods; |
|
|
|
|
private object hashLock = new object(); |
|
|
|
|
|
|
|
|
|
public AnalyzedMethodUsedByTreeNode(MethodDefinition analyzedMethod) |
|
|
|
|
{ |
|
|
|
|
@ -66,10 +69,14 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
@@ -66,10 +69,14 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
|
|
|
|
|
|
|
|
|
|
private IEnumerable<SharpTreeNode> FetchChildren(CancellationToken ct) |
|
|
|
|
{ |
|
|
|
|
ScopedWhereUsedScopeAnalyzer<SharpTreeNode> analyzer; |
|
|
|
|
foundMethods = new Lazy<Hashtable>(LazyThreadSafetyMode.ExecutionAndPublication); |
|
|
|
|
|
|
|
|
|
analyzer = new ScopedWhereUsedScopeAnalyzer<SharpTreeNode>(analyzedMethod, FindReferencesInType); |
|
|
|
|
return analyzer.PerformAnalysis(ct); |
|
|
|
|
var analyzer = new ScopedWhereUsedScopeAnalyzer<SharpTreeNode>(analyzedMethod, FindReferencesInType); |
|
|
|
|
foreach (var child in analyzer.PerformAnalysis(ct)) { |
|
|
|
|
yield return child; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foundMethods = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private IEnumerable<SharpTreeNode> FindReferencesInType(TypeDefinition type) |
|
|
|
|
@ -81,8 +88,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
@@ -81,8 +88,7 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
|
|
|
|
|
continue; |
|
|
|
|
foreach (Instruction instr in method.Body.Instructions) { |
|
|
|
|
MethodReference mr = instr.Operand as MethodReference; |
|
|
|
|
if (mr != null && |
|
|
|
|
mr.Name == name && |
|
|
|
|
if (mr != null && mr.Name == name && |
|
|
|
|
Helpers.IsReferencedBy(analyzedMethod.DeclaringType, mr.DeclaringType) && |
|
|
|
|
mr.Resolve() == analyzedMethod) { |
|
|
|
|
found = true; |
|
|
|
|
@ -92,8 +98,25 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
@@ -92,8 +98,25 @@ namespace ICSharpCode.ILSpy.TreeNodes.Analyzer
|
|
|
|
|
|
|
|
|
|
method.Body = null; |
|
|
|
|
|
|
|
|
|
if (found) |
|
|
|
|
yield return new AnalyzedMethodTreeNode(method); |
|
|
|
|
if (found) { |
|
|
|
|
MethodDefinition codeLocation = this.Language.GetOriginalCodeLocation(method) as MethodDefinition; |
|
|
|
|
if (codeLocation != null && !HasAlreadyBeenFound(codeLocation)) { |
|
|
|
|
yield return new AnalyzedMethodTreeNode(codeLocation); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private bool HasAlreadyBeenFound(MethodDefinition method) |
|
|
|
|
{ |
|
|
|
|
Hashtable hashtable = foundMethods.Value; |
|
|
|
|
lock (hashLock) { |
|
|
|
|
if (hashtable.Contains(method)) { |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
hashtable.Add(method, null); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|