Пример #1
0
        private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            ClangTidyProperties Props = (ClangTidyProperties)propertyGrid1.SelectedObject;

            Props.SetHasUnsavedChanges(true);

            // When a CategoryVerb is selected, perform the corresponding action.
            PropertyDescriptor Property = e.ChangedItem.PropertyDescriptor;

            if (!(e.ChangedItem.Value is CategoryVerb))
            {
                return;
            }

            CategoryVerb Action = (CategoryVerb)e.ChangedItem.Value;

            if (Action == CategoryVerb.None)
            {
                return;
            }

            var Category = Property.Attributes.OfType <CategoryAttribute>().FirstOrDefault();

            if (Category == null)
            {
                return;
            }
            var SameCategoryProps = Props.GetProperties(new Attribute[] { Category });

            foreach (PropertyDescriptor P in SameCategoryProps)
            {
                if (P == Property)
                {
                    continue;
                }
                switch (Action)
                {
                case CategoryVerb.Disable:
                    P.SetValue(propertyGrid1.SelectedObject, false);
                    break;

                case CategoryVerb.Enable:
                    P.SetValue(propertyGrid1.SelectedObject, true);
                    break;

                case CategoryVerb.Inherit:
                    P.ResetValue(propertyGrid1.SelectedObject);
                    break;
                }
            }
            Property.ResetValue(propertyGrid1.SelectedObject);
            propertyGrid1.Invalidate();
        }
        public static CheckTree Build(ClangTidyProperties Config)
        {
            // Since some check names contain dashes in them, it doesn't make sense to
            // simply split all check names by dash and construct a huge tree.  For
            // example, in the check called google-runtime-member-string-references,
            // we don't need each of those to be a different subgroup.  So instead we
            // explicitly specify the common breaking points at which a user might want
            // to use a -* and everything else falls as a leaf under one of these
            // categories.
            // FIXME: This should be configurable without recompilation
            CheckTree Root = new CheckTree();

            string[][] Groups = new string[][] {
                new string[] { "boost" },
                new string[] { "cert" },
                new string[] { "clang", "diagnostic" },
                new string[] { "cppcoreguidelines", "interfaces" },
                new string[] { "cppcoreguidelines", "pro", "bounds" },
                new string[] { "cppcoreguidelines", "pro", "type" },
                new string[] { "google", "build" },
                new string[] { "google", "readability" },
                new string[] { "google", "runtime" },
                new string[] { "llvm" },
                new string[] { "misc" },
            };

            foreach (string[] Group in Groups)
            {
                CheckTree Subgroup = Root;
                foreach (string Component in Group)
                {
                    Subgroup = Subgroup.AddOrCreateSubgroup(Component);
                }
            }

            var Props = Config.GetProperties()
                        .Cast <PropertyDescriptor>()
                        .OfType <DynamicPropertyDescriptor <bool> >()
                        .Where(x => x.Attributes.OfType <ClangTidyCheckAttribute>().Count() > 0)
                        .Select(x => new KeyValuePair <DynamicPropertyDescriptor <bool>, string>(
                                    x, x.Attributes.OfType <ClangTidyCheckAttribute>().First().CheckName));
            var PropArray = Props.ToArray();

            foreach (var CheckInfo in PropArray)
            {
                string    LeafName = null;
                CheckTree Tree     = Root.LocateCheckLeafGroup(CheckInfo.Value, out LeafName);
                Tree.AddLeaf(LeafName, CheckInfo.Key);
            }
            return(Root);
        }
Пример #3
0
        public static CheckTree Build(ClangTidyProperties Config)
        {
            // Since some check names contain dashes in them, it doesn't make sense to
            // simply split all check names by dash and construct a huge tree.  For
            // example, in the check called google-runtime-member-string-references,
            // we don't need each of those to be a different subgroup.  So instead we
            // explicitly specify the common breaking points at which a user might want
            // to use a -* and everything else falls as a leaf under one of these
            // categories.
            // FIXME: This should be configurable without recompilation
            CheckTree Root = new CheckTree();
            string[][] Groups = new string[][] {
                new string[] {"boost"},
                new string[] {"cert"},
                new string[] {"clang", "diagnostic"},
                new string[] {"cppcoreguidelines", "interfaces"},
                new string[] {"cppcoreguidelines", "pro", "bounds"},
                new string[] {"cppcoreguidelines", "pro", "type"},
                new string[] {"google", "build"},
                new string[] {"google", "readability"},
                new string[] {"google", "runtime"},
                new string[] {"llvm"},
                new string[] {"misc"},
            };

            foreach (string[] Group in Groups)
            {
                CheckTree Subgroup = Root;
                foreach (string Component in Group)
                    Subgroup = Subgroup.AddOrCreateSubgroup(Component);
            }

            var Props = Config.GetProperties()
                              .Cast<PropertyDescriptor>()
                              .OfType<DynamicPropertyDescriptor<bool>>()
                              .Where(x => x.Attributes.OfType<ClangTidyCheckAttribute>().Count() > 0)
                              .Select(x => new KeyValuePair<DynamicPropertyDescriptor<bool>, string>(
                                            x, x.Attributes.OfType<ClangTidyCheckAttribute>().First().CheckName));
            var PropArray = Props.ToArray();
            foreach (var CheckInfo in PropArray)
            {
                string LeafName = null;
                CheckTree Tree = Root.LocateCheckLeafGroup(CheckInfo.Value, out LeafName);
                Tree.AddLeaf(LeafName, CheckInfo.Key);
            }
            return Root;
        }