in DataExtraction/SourceGraphExtractionUtils/GraphDataExtractor.cs [1250:1278]
public static IEnumerable<ExpressionSyntax> GetSimpleExpressions(SemanticModel semanticModel)
{
var visitor = new SimpleExpressionIdentifier(semanticModel);
visitor.Visit(semanticModel.SyntaxTree.GetRoot());
foreach (var (node, nodeIsSimple) in visitor.IsSimpleNode)
{
//Only return the topmost simple expression:
if (nodeIsSimple && !visitor.IsSimpleNode[node.Parent] && !(node is ArgumentListSyntax))
{
//Special case 1: If we are an argument, the argument list is not simple (checked above), skip this one (instead, exports the encapsulated expression):
if (node is ArgumentSyntax && node.Parent is ArgumentListSyntax && !visitor.IsSimpleNode[node.Parent.Parent])
{
continue;
}
//Special case 2: If we are a member access in an Invocation, and our parent is /not/ simple, then one of the arguments isn't simple, so skip the member access:
if (node is MemberAccessExpressionSyntax && node.Parent is InvocationExpressionSyntax)
{
continue;
}
//Also filter out AST leafs:
if (node.ChildNodes().Any() && node is ExpressionSyntax expressionNode)
{
yield return expressionNode;
}
}
}
}