public CodeActionEdit GetEdit(CancellationToken cancellationToken = new CancellationToken()) { // The updated solution, originally identical to the given solution instance. ISolution updatedSolution = solution; // Get all the documents var solutionAnalyzer = AnalyzerFactory.GetSolutionAnalyzer(); solutionAnalyzer.SetSolution(solution); var documents = solutionAnalyzer.GetAllDocuments(); // For each document foreach (var document in documents) { // Get an invocation retriever and set the declaration and document. var retriever = RetrieverFactory.GetMethodInvocationRetriever(); retriever.SetMethodDeclaration(declaration); retriever.SetDocument(document); // Get all the invocations in the document. var invocations = retriever.GetInvocations(); // If there is some invocations of the given declaration in the specfic document if (invocations.Any()) { var rewriter = new MultipleInvocationsRewriter(invocations, mappings); var updatedRoot = rewriter.Visit((SyntaxNode) document.GetSyntaxRoot()); updatedSolution = updatedSolution.UpdateDocument(document.Id, updatedRoot); } } return new CodeActionEdit(updatedSolution); }
public CodeActionEdit GetEdit(CancellationToken cancellationToken = new CancellationToken()) { // Get an invocation retriever and set the declaration and document. var retriever = RetrieverFactory.GetMethodInvocationRetriever(); retriever.SetMethodDeclaration(declaration); retriever.SetDocument(document); // Get all the invocations in the document. var invocations = retriever.GetInvocations(); // If there is some invocations of the given declaration in the specfic document if (invocations.Any()) { var rewriter = new MultipleInvocationsRewriter(invocations, mappings); var updatedRoot = rewriter.Visit((SyntaxNode) document.GetSyntaxRoot()); var updatedSolution = document.Project.Solution.UpdateDocument(document.Id, updatedRoot); return new CodeActionEdit(null, updatedSolution, ConditionCheckersUtils. GetRemoveCodeIssueComputerOperation(computer)); } return null; }