Beispiel #1
0
            public async Task Run()
            {
                var token = default(CancellationToken);

                var oldSolution     = documentContext.AnalysisDocument.Project.Solution;
                var updatedSolution = oldSolution;

                using (var undo = editor.OpenUndoGroup()) {
                    foreach (var operation in await act.GetOperationsAsync(token))
                    {
                        var applyChanges = operation as ApplyChangesOperation;
                        if (applyChanges == null)
                        {
                            operation.TryApply(documentContext.RoslynWorkspace, new RoslynProgressTracker(), token);
                            continue;
                        }
                        if (updatedSolution == oldSolution)
                        {
                            updatedSolution = applyChanges.ChangedSolution;
                        }
                        operation.TryApply(documentContext.RoslynWorkspace, new RoslynProgressTracker(), token);
                    }
                }
                await TryStartRenameSession(documentContext.RoslynWorkspace, oldSolution, updatedSolution, token);
            }
Beispiel #2
0
            public async Task Run()
            {
                var token           = default(CancellationToken);
                var insertionAction = act as InsertionAction;

                if (insertionAction != null)
                {
                    var insertion = await insertionAction.CreateInsertion(token).ConfigureAwait(false);

                    var document = await IdeApp.Workbench.OpenDocument(insertion.Location.SourceTree.FilePath, documentContext.Project);

                    var parsedDocument = await document.UpdateParseDocument();

                    if (parsedDocument != null)
                    {
                        var insertionPoints = InsertionPointService.GetInsertionPoints(
                            document.Editor,
                            parsedDocument,
                            insertion.Type,
                            insertion.Location.SourceSpan.Start
                            );

                        var options = new InsertionModeOptions(
                            insertionAction.Title,
                            insertionPoints,
                            point => {
                            if (!point.Success)
                            {
                                return;
                            }
                            var node = Formatter.Format(insertion.Node, document.RoslynWorkspace, document.GetOptionSet(), token);
                            point.InsertionPoint.Insert(document.Editor, document, node.ToString());
                            // document = await Simplifier.ReduceAsync(document.AnalysisDocument, Simplifier.Annotation, cancellationToken: token).ConfigureAwait(false);
                        }
                            );

                        document.Editor.StartInsertionMode(options);
                        return;
                    }
                }

                var oldSolution     = documentContext.AnalysisDocument.Project.Solution;
                var updatedSolution = oldSolution;

                using (var undo = editor.OpenUndoGroup()) {
                    foreach (var operation in await act.GetOperationsAsync(token))
                    {
                        var applyChanges = operation as ApplyChangesOperation;
                        if (applyChanges == null)
                        {
                            operation.TryApply(documentContext.RoslynWorkspace, new RoslynProgressTracker(), token);
                            continue;
                        }
                        if (updatedSolution == oldSolution)
                        {
                            updatedSolution = applyChanges.ChangedSolution;
                        }
                        operation.TryApply(documentContext.RoslynWorkspace, new RoslynProgressTracker(), token);
                    }
                }
                await TryStartRenameSession(documentContext.RoslynWorkspace, oldSolution, updatedSolution, token);
            }