コード例 #1
0
        /// <summary>
        /// Performs the QuickFix, inserts the configured modifier into the location specified by
        /// the violation.
        /// </summary>
        /// <param name="solution">
        /// Current Solution.
        /// </param>
        /// <param name="textControl">
        /// Current Text Control to modify.
        /// </param>
        public void Execute(ISolution solution, ITextControl textControl)
        {
            using (ChangeSeverityDialog dialog = new ChangeSeverityDialog())
            {
                ////var settings = HighlightingSettingsManager.Instance.Settings.Clone();

                ////var severityItem = HighlightingSettingsManager.Instance.GetSeverityItem(this.HighlightID);

                ////dialog.Severity = settings.GetSeverity(this.HighlightID);
                ////dialog.Text = "Inspection options for \"" + severityItem.Title + "\"";

                ////if (dialog.ShowDialog(Shell.Instance.GetComponent<UIApplication>().MainWindow) == DialogResult.OK)
                ////{
                ////    settings.SetSeverity(this.HighlightID, dialog.Severity);
                ////    HighlightingSettingsManager.Instance.Settings = settings;

                ////    Daemon.GetInstance(solution).Invalidate();
                ////}
                IContextBoundSettingsStore settingsStore             = PsiSourceFileExtensions.GetSettingsStore(null, solution);
                IContextBoundSettingsStore contextBoundSettingsStore =
                    settingsStore.SettingsStore.BindToContextTransient(ContextRange.Smart(textControl.Document.ToDataContext()));
                HighlightingSettingsManager settingsManager = HighlightingSettingsManager.Instance;
                HighlightingSettingsManager.ConfigurableSeverityItem item = settingsManager.GetSeverityItem(this.HighlightID);
                dialog.Severity   = settingsManager.GetConfigurableSeverity(this.HighlightID, solution);
                dialog.Text       = string.Format("Inspection Options for \"{0}\"", item.FullTitle);
                dialog.CanBeError = !item.SolutionAnalysisRequired;
                if (dialog.ShowDialog(Shell.Instance.GetComponent <UIApplication>().MainWindow) == DialogResult.OK)
                {
                    contextBoundSettingsStore.SetIndexedValue(HighlightingSettingsAccessor.InspectionSeverities, this.HighlightID, dialog.Severity);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Registers the rules. Do not put the contents of this method in the constructor.
        /// If you do *sometimes* the StyleCop object won't be loaded be the time you construct it.
        /// </summary>
        private void Init()
        {
            StyleCopCore core = new StyleCopCore();

            core.Initialize(new List <string>(), true);

            Dictionary <SourceAnalyzer, List <StyleCopRule> > analyzerRulesDictionary = StyleCopRule.GetRules(core);

            HighlightingSettingsManager highlightManager = HighlightingSettingsManager.Instance;

            Severity defaultSeverity = highlightManager.GetConfigurableSeverity(DefaultSeverityId, null);

            this.RegisterRuleConfigurations(highlightManager, analyzerRulesDictionary, defaultSeverity);
        }