public void Creates_computation_chain_with_limited_scope() { var codeAsText = File.ReadAllText(@"SyntaxAnalyserExamples/TestFunctions.cs"); var syntaxTree = SyntaxOperations.Parse(codeAsText); var semanticModel = SemanticOperations.GetSemanticModel(syntaxTree); var methodSyntax = SyntaxOperations .FindMethodsOfClass(syntaxTree, nameof(TestFunctions), nameof(TestFunctions.ProcessInt32Parameter)) .Value .Single(); var methodAnalysis = MethodBlockAnalysis.FromSemanticModel(methodSyntax, semanticModel); var returnSyntax = methodAnalysis.BodyBlock.DescendantNodes().OfType <ReturnStatementSyntax>().Single(); var identSyntax = SyntaxOperations.GetVariable(returnSyntax); var doubleIncrementedIdentSyntax = SyntaxOperations.GetDelarationOfVariable(methodAnalysis.BodyBlock, "doubledIncremented"); var searchSpan = TextSpan.FromBounds(doubleIncrementedIdentSyntax.SpanStart, returnSyntax.Span.End); var chainHead = ComputationGraph.FromReturnStatement(returnSyntax, methodAnalysis, searchSpan).Item1.A; var sqrtDoubledIncrementedInt = _Assert_ReturnStatement(chainHead).A; var localDecl_sqrtDoubledIncrementedInt = _Assert_Identifier(sqrtDoubledIncrementedInt, "sqrtDoubledIncrementedInt").A; var castToInt = _Assert_LocalDeclaration(localDecl_sqrtDoubledIncrementedInt, "sqrtDoubledIncrementedInt").A; var sqrtDoubledIncremented = _Assert_CastExpression(castToInt, typeof(int), methodAnalysis).A; var localDecl_sqrtDoubledIncremented = _Assert_Identifier(sqrtDoubledIncremented, "sqrtDoubledIncremented").A; var sqrt = _Assert_LocalDeclaration(localDecl_sqrtDoubledIncremented, "sqrtDoubledIncremented").A; var(mathSqrt, args_doubledIncremented) = _Assert_Invocation(sqrt, nameof(Math.Sqrt)); var localDecl_doubledIncremented = _Assert_Identifier(args_doubledIncremented.Single().A, "doubledIncremented").A; var parenthesizedExprAdd = _Assert_LocalDeclaration(localDecl_doubledIncremented, "doubledIncremented").A; var binary_add = _Assert_ParenthesizedExpr(parenthesizedExprAdd).A; var(doubled, oneLiteral) = _Assert_BinaryExpression(binary_add, operatorToken: SyntaxKind.PlusToken); _Assert_Literal(oneLiteral.A, 1); var localDecl_doubled = _Assert_Identifier(doubled.A, "doubled"); Assert.IsFalse(localDecl_doubled.IsA); }