Exemplo n.º 1
0
                    /* Update all the method invocations in the solution. */
                    private ISolution updateMethodInvocations(ISolution solution)
                    {
                        // Get all the documents in the solution.
                        var solutionAnalyzer = AnalyzerFactory.GetSolutionAnalyzer();
                        solutionAnalyzer.SetSolution(solution);
                        var documents = solutionAnalyzer.GetAllDocuments();

                        // Get the retriever for method invocations.
                        var retriever = RetrieverFactory.GetMethodInvocationRetriever();
                        retriever.SetMethodDeclaration(declaration);

                        // For each document
                        foreach (var document in documents)
                        {
                            // Get all the invocations in the document for the given method
                            // declaration.
                            retriever.SetDocument(document);
                            var invocations = retriever.GetInvocations();

                            // If there are invocations in the document.
                            if (invocations.Any())
                            {
                                // Update root
                                var root = (SyntaxNode) document.GetSyntaxRoot();
                                var updatedRoot = new InvocationsAddArgumentsRewriter(invocations, typeNameTuples.Select(t => t.Item2)).
                                    Visit(root);

                                // Update solution by update the document.
                                solution = solution.UpdateDocument(document.Id, updatedRoot);
                            }
                        }
                        return solution;
                    }
Exemplo n.º 2
0
                    /// <summary>
                    /// Update all the method invocations in the solution. 
                    /// </summary>
                    /// <param name="document"></param>
                    /// <returns></returns>
                    private IDocument updateMethodInvocations(IDocument document)
                    {
                        // Get the retriever for method invocations.
                        var retriever = RetrieverFactory.GetMethodInvocationRetriever();
                        retriever.SetMethodDeclaration(declaration);

                        // Get all the invocations in the document for the given method
                        // declaration.
                        retriever.SetDocument(document);
                        var invocations = retriever.GetInvocations();

                        // If there are invocations in the document.
                        if (invocations.Any())
                        {
                            // Update root
                            var root = (SyntaxNode) document.GetSyntaxRoot();
                            var updatedRoot = new InvocationsAddArgumentsRewriter(invocations,
                                typeNameTuple.Item2).Visit(root);

                            // Update solution by update the document.
                            document = document.UpdateSyntaxRoot(updatedRoot);
                        }
                        return document;
                    }