Exemplo n.º 1
0
 private void ApplyToAllResults(IQuickFix quickFix, IEnumerable <IInspectionResult> inspectionResults, IRewriteSession rewriteSession)
 {
     foreach (var inspectionResult in inspectionResults)
     {
         quickFix.Fix(inspectionResult, rewriteSession);
     }
 }
Exemplo n.º 2
0
        public void Fix(IQuickFix fix, IInspectionResult result)
        {
            if (!CanFix(fix, result))
            {
                return;
            }

            fix.Fix(result);
            _state.RewriteAllModules();
            _state.OnParseRequested(this);
        }
Exemplo n.º 3
0
        public void Fix(IQuickFix fix, IInspectionResult result)
        {
            if (!CanFix(fix, result))
            {
                return;
            }

            var rewriteSession = RewriteSession(fix.TargetCodeKind);

            fix.Fix(result, rewriteSession);
            Apply(rewriteSession);
        }
Exemplo n.º 4
0
        public void Fix(IQuickFix fix, IInspectionResult result)
        {
            if (!CanFix(fix, result))
            {
                return;
            }

            var rewriteSession = RewriteSession(fix.TargetCodeKind);

            try
            {
                fix.Fix(result, rewriteSession);
            }
            catch (RewriteFailedException)
            {
                _failureNotifier.NotifyQuickFixExecutionFailure(rewriteSession.Status);
            }
            Apply(rewriteSession);
        }
Exemplo n.º 5
0
        public void FixInModule(IQuickFix fix, QualifiedSelection selection, Type inspectionType, IEnumerable <IInspectionResult> results)
        {
            var filteredResults = results.Where(result => result.Inspection.GetType() == inspectionType && result.QualifiedSelection.QualifiedName == selection.QualifiedName).ToList();

            foreach (var result in filteredResults)
            {
                if (!CanFix(fix, result))
                {
                    continue;
                }

                fix.Fix(result);
            }

            if (filteredResults.Any())
            {
                _state.RewriteAllModules();
                _state.OnParseRequested(this);
            }
        }
Exemplo n.º 6
0
        public void FixAll(IQuickFix fix, Type inspectionType, IEnumerable <IInspectionResult> results)
        {
            var filteredResults = results.Where(result => result.Inspection.GetType() == inspectionType).ToArray();

            foreach (var result in filteredResults)
            {
                if (!CanFix(fix, result))
                {
                    continue;
                }

                fix.Fix(result);
            }

            if (filteredResults.Any())
            {
                _state.RewriteAllModules();
                _state.OnParseRequested(this);
            }
        }
Exemplo n.º 7
0
        public void FixInProcedure(IQuickFix fix, QualifiedMemberName?qualifiedMember, Type inspectionType, IEnumerable <IInspectionResult> results)
        {
            Debug.Assert(qualifiedMember.HasValue, "Null qualified member.");

            var filteredResults = results.Where(result => result.Inspection.GetType() == inspectionType && result.QualifiedMemberName == qualifiedMember).ToList();

            foreach (var result in filteredResults)
            {
                if (!CanFix(fix, result))
                {
                    continue;
                }

                fix.Fix(result);
            }

            if (filteredResults.Any())
            {
                _state.RewriteAllModules();
                _state.OnParseRequested(this);
            }
        }
Exemplo n.º 8
0
        public void FixAll(IQuickFix fix, Type inspectionType, IEnumerable <IInspectionResult> results)
        {
            var filteredResults = results.Where(result => result.Inspection.GetType() == inspectionType).ToArray();

            if (!filteredResults.Any())
            {
                return;
            }

            var rewriteSession = RewriteSession(fix.TargetCodeKind);

            foreach (var result in filteredResults)
            {
                if (!CanFix(fix, result))
                {
                    continue;
                }

                fix.Fix(result, rewriteSession);
            }
            Apply(rewriteSession);
        }
Exemplo n.º 9
0
        public void FixInProject(IQuickFix fix, QualifiedSelection selection, Type inspectionType, IEnumerable <IInspectionResult> results)
        {
            var filteredResults = results.Where(result => result.Inspection.GetType() == inspectionType && result.QualifiedSelection.QualifiedName.ProjectId == selection.QualifiedName.ProjectId).ToList();

            if (!filteredResults.Any())
            {
                return;
            }

            var rewriteSession = RewriteSession(fix.TargetCodeKind);

            foreach (var result in filteredResults)
            {
                if (!CanFix(fix, result))
                {
                    continue;
                }

                fix.Fix(result, rewriteSession);
            }
            Apply(rewriteSession);
        }
Exemplo n.º 10
0
        public void Fix(IQuickFix fix, IEnumerable <IInspectionResult> resultsToFix)
        {
            var results = resultsToFix.ToList();

            if (!results.Any())
            {
                return;
            }

            var rewriteSession = RewriteSession(fix.TargetCodeKind);

            foreach (var result in results)
            {
                if (!CanFix(fix, result))
                {
                    continue;
                }

                fix.Fix(result, rewriteSession);
            }
            Apply(rewriteSession);
        }
Exemplo n.º 11
0
        public void FixInProcedure(IQuickFix fix, QualifiedMemberName?qualifiedMember, Type inspectionType, IEnumerable <IInspectionResult> results)
        {
            Debug.Assert(qualifiedMember.HasValue, "Null qualified member.");

            var filteredResults = results.Where(result => result.Inspection.GetType() == inspectionType && result.QualifiedMemberName == qualifiedMember).ToList();

            if (!filteredResults.Any())
            {
                return;
            }

            var rewriteSession = RewriteSession(fix.TargetCodeKind);

            foreach (var result in filteredResults)
            {
                if (!CanFix(fix, result))
                {
                    continue;
                }

                fix.Fix(result, rewriteSession);
            }
            Apply(rewriteSession);
        }
Exemplo n.º 12
0
        private void ApplyToFirstResult(IQuickFix quickFix, IEnumerable <IInspectionResult> inspectionResults, IRewriteSession rewriteSession)
        {
            var resultToFix = inspectionResults.First();

            quickFix.Fix(resultToFix, rewriteSession);
        }