Skip to content

Commit 84bdfa2

Browse files
committed
Other: Simplify C/C++ language selection by merging header options.
1 parent df19e79 commit 84bdfa2

File tree

3 files changed

+15
-38
lines changed

3 files changed

+15
-38
lines changed

CodeIngest.Desktop/MainViewModel.cs

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public class MainViewModel : ViewModelBase
2828
private FolderTreeRoot m_root;
2929
private ProgressToken m_backgroundRefreshProgress;
3030
private bool m_isCSharp = Settings.Instance.IsCSharp;
31-
private bool m_isCppNoHeaders = Settings.Instance.IsCppNoHeaders;
32-
private bool m_isCppWithHeaders = Settings.Instance.IsCppWithHeaders;
31+
private bool m_isCpp = Settings.Instance.IsCpp;
3332
private bool m_includeMarkdown = Settings.Instance.IncludeMarkdown;
3433
private bool m_excludeImports = Settings.Instance.ExcludeImports;
3534
private bool m_useFullPaths = Settings.Instance.UseFullPaths;
@@ -66,32 +65,19 @@ public bool IsCSharp
6665
}
6766
}
6867

69-
public bool IsCppNoHeaders
68+
public bool IsCpp
7069
{
71-
get => m_isCppNoHeaders;
70+
get => m_isCpp;
7271
set
7372
{
74-
if (SetField(ref m_isCppNoHeaders, value))
73+
if (SetField(ref m_isCpp, value))
7574
{
76-
Settings.Instance.IsCppNoHeaders = value;
75+
Settings.Instance.IsCpp = value;
7776
InvalidatePreviewStats();
7877
}
7978
}
8079
}
81-
82-
public bool IsCppWithHeaders
83-
{
84-
get => m_isCppWithHeaders;
85-
set
86-
{
87-
if (SetField(ref m_isCppWithHeaders, value))
88-
{
89-
Settings.Instance.IsCppWithHeaders = value;
90-
InvalidatePreviewStats();
91-
}
92-
}
93-
}
94-
80+
9581
public bool IsPython
9682
{
9783
get => m_isPython;
@@ -221,9 +207,9 @@ public async Task RunIngest()
221207
return; // Nothing to do.
222208

223209
string[] filterExtensions;
224-
if (IsCppNoHeaders)
210+
if (IsCpp)
225211
filterExtensions = [".cpp"];
226-
else if (IsCppWithHeaders)
212+
else if (IsCpp)
227213
filterExtensions = [".cpp", ".h"];
228214
else if (IsPython)
229215
filterExtensions = [".py"];
@@ -267,12 +253,10 @@ private IngestOptions GetIngestOptions()
267253
if (IsCSharp)
268254
{
269255
options.FilePatterns.Add("*.cs");
270-
} else if (IsCppNoHeaders)
271-
{
272-
options.FilePatterns.Add("*.cpp");
273-
} else if (IsCppWithHeaders)
256+
} else if (IsCpp)
274257
{
275-
options.FilePatterns.Add("*.h");
258+
if (!ExcludeImports)
259+
options.FilePatterns.Add("*.h");
276260
options.FilePatterns.Add("*.cpp");
277261
}
278262

CodeIngest.Desktop/Settings.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@ public bool IsCSharp
3131
set => Set(value);
3232
}
3333

34-
public bool IsCppNoHeaders
35-
{
36-
get => Get<bool>();
37-
set => Set(value);
38-
}
39-
40-
public bool IsCppWithHeaders
34+
public bool IsCpp
4135
{
4236
get => Get<bool>();
4337
set => Set(value);
@@ -83,8 +77,7 @@ protected override void ApplyDefaults()
8377
{
8478
RootFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToDir();
8579
IsCSharp = true;
86-
IsCppNoHeaders = false;
87-
IsCppWithHeaders = false;
80+
IsCpp = false;
8881
IsPython = false;
8982
IsJavaScript = false;
9083
ExcludeImports = true;

CodeIngest.Desktop/Views/MainWindow.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@
100100
<TextBlock Text="Languages" Classes="Overline" Margin="4"/>
101101
<StackPanel Margin="8,4">
102102
<RadioButton Content="C#" IsChecked="{Binding IsCSharp}"/>
103-
<RadioButton Content="C/C++ (No Headers)" IsChecked="{Binding IsCppNoHeaders}" Margin="0,4,0,0"/>
104-
<RadioButton Content="C/C++ (With Headers)" IsChecked="{Binding IsCppWithHeaders}" Margin="0,4,0,0"/>
103+
<RadioButton Content="C/C++" IsChecked="{Binding IsCpp}" Margin="0,4,0,0"/>
105104
<RadioButton Content="Python" IsChecked="{Binding IsPython}" Margin="0,4,0,0"/>
106105
<RadioButton Content="JavaScript" IsChecked="{Binding IsJavaScript}" Margin="0,4,0,0"/>
107106
</StackPanel>
108107

108+
<!-- ReSharper disable once Xaml.StyleClassNotFound -->
109109
<TextBlock Text="Options" Classes="Overline" Margin="4,16,4,4"/>
110110
<StackPanel Margin="8,4">
111111
<CheckBox Content="Exclude Imports"

0 commit comments

Comments
 (0)