Exemplo n.º 1
0
        public ComplexityAnalysisOptionPage(Lifetime lifetime, OptionsSettingsSmartContext optionsSettingsSmartContext,
                                            ILanguages languages, ILanguageManager languageManager)
            : base(lifetime, optionsSettingsSmartContext)
        {
            AddText("Specify cyclomatic complexity thresholds:");

            var thresholds = OptionsSettingsSmartContext.Schema.GetIndexedEntry((CyclomaticComplexityAnalysisSettings s) => s.Thresholds);

            var list = new List <LanguageSpecificComplexityProperties>();

            foreach (var languageType in languages.All.Where(languageManager.HasService <IControlFlowBuilder>).OrderBy(GetPresentableName))
            {
                var presentableName = GetPresentableName(languageType);
                var thing           = new LanguageSpecificComplexityProperties(lifetime, optionsSettingsSmartContext, thresholds, languageType.Name, presentableName, CyclomaticComplexityAnalysisSettings.DefaultThreshold);
                list.Add(thing);
            }

            // TODO: Do we want to add any keywords for the list view?
            // We would use OptionEntities.Add if the view model also implements IOptionEntity,
            // or use RegisterWord if we just want to add keyword(s)
            // (But the list view is just language name + threshold, so not very interesting)
            AddCustomOption(new ComplexityAnalysisOptionsViewModel(list));
            OptionEntities.Add(new HyperlinkOptionViewModel(lifetime, "What is a good threshold value?",
                                                            new DelegateCommand(() => Process.Start("https://github.com/JetBrains/resharper-cyclomatic-complexity/blob/master/docs/ThresholdGuidance.md#readme"))));
            FinishPage();
        }
Exemplo n.º 2
0
        private StringOptionViewModel AddStringOption(Property <string> property, string text, string toolTipText = null,
                                                      bool acceptsReturn = false)
        {
            return(Lifetime.Using(tempLifetime =>
            {
                // StringOptionViewModel doesn't allow us to pass a Property, but creates one based on the given scalar
                // entry. We're dealing with a custom object as a custom entry, so this doesn't work for us. Let's hack!
                // Create a StringOptionViewModel, with a binding to a scalar, let it create a property, then overwrite
                // it. The temp lifetime will then clean up the binding.
                // RIDER-8339 is sooo getting fixed in 2019.1
                var stringOptionViewModel = new StringOptionViewModel(tempLifetime,
                                                                      OptionsSettingsSmartContext,
                                                                      OptionsSettingsSmartContext.Schema.GetScalarEntry((CSharpNamingSettings s) => s.ExceptionName),
                                                                      text, toolTipText ?? string.Empty, acceptsReturn)
                {
                    StringProperty = property
                };

                OptionEntities.Add(stringOptionViewModel);
                return stringOptionViewModel;
            }));
        }