Skip to content

Commit 65b93c0

Browse files
authored
Merge pull request #3622 from IvenBach/Issue3485_Inspection_Sorting_Order
Sort inspections in settings dialog
2 parents 008da37 + 5f97d91 commit 65b93c0

File tree

5 files changed

+69
-16
lines changed

5 files changed

+69
-16
lines changed

RetailCoder.VBE/UI/Settings/InspectionSettings.xaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,12 @@
293293
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SettingsCaption_ExportSettings}"/>
294294
</Grid>
295295
</StackPanel>
296-
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right"/>
297-
</DockPanel>
296+
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right">
297+
<Label Content="Description Filter"/>
298+
<TextBox MinWidth="75"
299+
Text="{Binding InspectionSettingsFilter, UpdateSourceTrigger=PropertyChanged}"/>
300+
</StackPanel>
301+
</DockPanel>
298302
</Label>
299303
<Border BorderBrush="DarkGray" BorderThickness="1" CornerRadius="2">
300304
<controls:GroupingGrid ItemsSource="{Binding InspectionSettings}"

RetailCoder.VBE/UI/Settings/InspectionSettingsViewModel.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ public class InspectionSettingsViewModel : SettingsViewModelBase, ISettingsViewM
1515
public InspectionSettingsViewModel(Configuration config)
1616
{
1717
InspectionSettings = new ListCollectionView(
18-
config.UserSettings.CodeInspectionSettings.CodeInspections.ToList());
18+
config.UserSettings.CodeInspectionSettings.CodeInspections
19+
.OrderBy(inspection => inspection.TypeLabel)
20+
.ThenBy(inspection => inspection.Description)
21+
.ToList());
1922

2023
WhitelistedIdentifierSettings = new ObservableCollection<WhitelistedIdentifierSetting>(
2124
config.UserSettings.CodeInspectionSettings.WhitelistedIdentifiers.OrderBy(o => o.Identifier).Distinct());
@@ -39,10 +42,36 @@ public void UpdateCollection(CodeInspectionSeverity severity)
3942
InspectionSettings.CommitEdit();
4043
}
4144

45+
private string _inspectionSettingsFilter;
46+
public string InspectionSettingsFilter
47+
{
48+
get => _inspectionSettingsFilter;
49+
set
50+
{
51+
if (_inspectionSettingsFilter != value)
52+
{
53+
_inspectionSettingsFilter = value;
54+
OnPropertyChanged(nameof(InspectionSettings));
55+
}
56+
}
57+
}
58+
4259
private ListCollectionView _inspectionSettings;
4360
public ListCollectionView InspectionSettings
4461
{
45-
get => _inspectionSettings;
62+
get
63+
{
64+
if (string.IsNullOrEmpty(_inspectionSettingsFilter))
65+
{
66+
_inspectionSettings.Filter = null;
67+
}
68+
else
69+
{
70+
_inspectionSettings.Filter = filter => FilterInspectionSettings(filter);
71+
}
72+
return _inspectionSettings;
73+
}
74+
4675
set
4776
{
4877
if (_inspectionSettings != value)
@@ -53,6 +82,12 @@ public ListCollectionView InspectionSettings
5382
}
5483
}
5584

85+
private bool FilterInspectionSettings(object filter)
86+
{
87+
var cis = filter as CodeInspectionSetting;
88+
return cis.Description.ToUpper().Contains(_inspectionSettingsFilter.ToUpper());
89+
}
90+
5691
private bool _runInspectionsOnSuccessfulParse;
5792
public bool RunInspectionsOnSuccessfulParse
5893
{

Rubberduck.Parsing/Inspections/Resources/InspectionsUI.resx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -59,7 +59,7 @@
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
62-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
6363
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6464
<xsd:element name="root" msdata:IsDataSet="true">
6565
<xsd:complexType>
@@ -887,4 +887,7 @@ If the parameter can be null, ignore this inspection result; passing a null valu
887887
<data name="EmptyModuleInspectionResultFormat" xml:space="preserve">
888888
<value>Module/class {0} is empty.</value>
889889
</data>
890-
</root>
890+
<data name="ObsoleteErrorSyntaxInspectionName" xml:space="preserve">
891+
<value>Use of 'Error' statement</value>
892+
</data>
893+
</root>

Rubberduck.Parsing/Inspections/Resources/InspectionsUI1.Designer.cs

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RubberduckTests/Settings/InspectionSettingsTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ private Configuration GetDefaultConfig()
2020
new CodeInspectionSetting("HintInspection", "I'm a hint", CodeInspectionType.LanguageOpportunities, CodeInspectionSeverity.Hint, CodeInspectionSeverity.Hint),
2121
new CodeInspectionSetting("SuggestionInspection", "I'm a suggestion", CodeInspectionType.MaintainabilityAndReadabilityIssues, CodeInspectionSeverity.Suggestion, CodeInspectionSeverity.Suggestion),
2222
new CodeInspectionSetting("WarningInspection", "I'm a warning", CodeInspectionType.CodeQualityIssues, CodeInspectionSeverity.Warning, CodeInspectionSeverity.Warning),
23-
new CodeInspectionSetting("ErrorInspection", "FIX ME!", CodeInspectionType.CodeQualityIssues, CodeInspectionSeverity.Error, CodeInspectionSeverity.Error),
24-
new CodeInspectionSetting("NondefaultSeverityInspection", "I do not have my original severity", CodeInspectionType.LanguageOpportunities, CodeInspectionSeverity.Warning, CodeInspectionSeverity.DoNotShow)
25-
})
23+
new CodeInspectionSetting("NondefaultSeverityInspection", "I do not have my original severity", CodeInspectionType.LanguageOpportunities, CodeInspectionSeverity.Warning, CodeInspectionSeverity.DoNotShow),
24+
new CodeInspectionSetting("ErrorInspection", "FIX ME!", CodeInspectionType.CodeQualityIssues, CodeInspectionSeverity.Error, CodeInspectionSeverity.Error)
25+
}.OrderBy(cis => cis.TypeLabel)
26+
.ThenBy(cis => cis.Description)) // Explicit sorting is to match InspectionSettingsViewModel.cs
2627
};
2728

2829
var userSettings = new UserSettings(null, null, null, inspectionSettings, null, null, null);
@@ -39,9 +40,10 @@ private Configuration GetNondefaultConfig()
3940
new CodeInspectionSetting("HintInspection", "I'm a hint", CodeInspectionType.LanguageOpportunities, CodeInspectionSeverity.Hint, CodeInspectionSeverity.Suggestion),
4041
new CodeInspectionSetting("SuggestionInspection", "I'm a suggestion", CodeInspectionType.MaintainabilityAndReadabilityIssues, CodeInspectionSeverity.Suggestion, CodeInspectionSeverity.Hint),
4142
new CodeInspectionSetting("WarningInspection", "I'm a warning", CodeInspectionType.CodeQualityIssues, CodeInspectionSeverity.Warning, CodeInspectionSeverity.Error),
42-
new CodeInspectionSetting("ErrorInspection", "FIX ME!", CodeInspectionType.CodeQualityIssues, CodeInspectionSeverity.Error, CodeInspectionSeverity.DoNotShow),
43-
new CodeInspectionSetting("NondefaultSeverityInspection", "I do not have my original severity", CodeInspectionType.LanguageOpportunities, CodeInspectionSeverity.Warning, CodeInspectionSeverity.Error)
44-
})
43+
new CodeInspectionSetting("NondefaultSeverityInspection", "I do not have my original severity", CodeInspectionType.LanguageOpportunities, CodeInspectionSeverity.Warning, CodeInspectionSeverity.Error),
44+
new CodeInspectionSetting("ErrorInspection", "FIX ME!", CodeInspectionType.CodeQualityIssues, CodeInspectionSeverity.Error, CodeInspectionSeverity.DoNotShow)
45+
}.OrderBy(cis => cis.TypeLabel)
46+
.ThenBy(cis => cis.Description)) // Explicit sorting is to match InspectionSettingsViewModel.cs
4547
};
4648

4749
var userSettings = new UserSettings(null, null, null, inspectionSettings, null, null, null);

0 commit comments

Comments
 (0)