Exemplo n.º 1
0
        private string ApplyQuickFixToFirstInspectionResult(string inputCode)
        {
            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);

            var(state, rewritingManager) = MockParser.CreateAndParseWithRewritingManager(vbe.Object);
            using (state)
            {
                var inspection        = new MoveFieldCloserToUsageInspection(state);
                var inspectionResults = inspection.GetInspectionResults(CancellationToken.None);
                var resultToFix       = inspectionResults.First();
                var rewriteSession    = rewritingManager.CheckOutCodePaneSession();
                var quickFix          = new MoveFieldCloserToUsageQuickFix(vbe.Object, state, new Mock <IMessageBox>().Object, rewritingManager);

                quickFix.Fix(resultToFix, rewriteSession);

                return(component.CodeModule.Content());
            }
        }
Exemplo n.º 2
0
        private string ApplyQuickFixToFirstInspectionResult(string inputCode)
        {
            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);

            var(state, rewritingManager) = MockParser.CreateAndParseWithRewritingManager(vbe.Object);
            using (state)
            {
                var inspection                  = new MoveFieldCloserToUsageInspection(state);
                var inspectionResults           = inspection.GetInspectionResults(CancellationToken.None);
                var resultToFix                 = inspectionResults.First();
                var rewriteSession              = rewritingManager.CheckOutCodePaneSession();
                var selectionService            = MockedSelectionService();
                var selectedDeclarationProvider = new SelectedDeclarationProvider(selectionService, state);
                var baseRefactoring             = new MoveCloserToUsageRefactoringAction(rewritingManager);
                var refactoring                 = new MoveCloserToUsageRefactoring(baseRefactoring, state, selectionService, selectedDeclarationProvider);
                var quickFix = new MoveFieldCloserToUsageQuickFix(refactoring);

                quickFix.Fix(resultToFix, rewriteSession);

                return(component.CodeModule.Content());
            }
        }