in DataExtraction/SourceGraphExtractionUtils/Utils/DataFlowGraph.cs [639:679]
private static bool IsDeclaringNode(SyntaxNode node)
=>
node is FieldDeclarationSyntax || node is VariableDeclaratorSyntax || node is PropertyDeclarationSyntax ||
node is AccessorDeclarationSyntax || node is VariableDesignationSyntax ||
node is ParameterSyntax || node is ForEachStatementSyntax || node is CatchDeclarationSyntax ||
node is UsingStatementSyntax || node is LockStatementSyntax;
private void CheckUseRoots(SyntaxNode node, bool printTrace = false, string prefix = "")
{
if (printTrace)
{
var useType = IsDeclaringNode(node) ? "Declaration" : "Use";
Console.WriteLine("{0}{1}: {2} at {3}", prefix, useType, node, node.SyntaxTree.GetLineSpan(node.Span));
}
var lastUseEdges = _graph.GetOutEdges(node).Where(edge => edge.Label == SourceGraphEdge.LastUse).ToList();
if (lastUseEdges.Count == 0)
{
if (IsDeclaringNode(node))
{
//Everything is fine
}
else
{
Console.WriteLine("Non-Declaration has no outgoing edges: [Type {0}] {1}\n at {2}",
node.GetType().FullName, node, node.SyntaxTree.GetLineSpan(node.Span));
}
}
else
{
if (IsDeclaringNode(node))
{
Console.WriteLine("Declaration has outgoing use edges: [Type {0}] {1}\n at {2}",
node.GetType().FullName, node, node.SyntaxTree.GetLineSpan(node.Span));
}
foreach (var lastUseEdge in lastUseEdges)
{
CheckUseRoots(lastUseEdge.Target.AsNode(), printTrace, prefix + " ");
}
}
}