mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-22 14:22:32 -06:00
is win32 broken?
This commit is contained in:
parent
253b80d33c
commit
142d359a87
2 changed files with 100 additions and 40 deletions
|
|
@ -1,21 +1,26 @@
|
|||
#include "ide.h"
|
||||
|
||||
struct ClangTidyDlg : WithClangTidy<TopWindow> {
|
||||
struct ClangTidyDlg : WithClangTidyLayout<TopWindow> {
|
||||
static String path;
|
||||
static Index<String> options;
|
||||
static Index<String> groups;
|
||||
static Index<String> active_checks;
|
||||
|
||||
static bool HasClangTidy();
|
||||
static bool HasClangTidy();
|
||||
static String ClangTidyConfigPath();
|
||||
static void Load(const char *path);
|
||||
static void Save(const char *path);
|
||||
|
||||
struct OptionWithLink : Option {
|
||||
RichTextCtrl text;
|
||||
};
|
||||
|
||||
ArrayMap<String, OptionWithLink> checks;
|
||||
|
||||
|
||||
void SyncGroupCounts();
|
||||
void Group();
|
||||
void Save();
|
||||
void SetOptions();
|
||||
void ReadOptions();
|
||||
|
||||
ClangTidyDlg();
|
||||
};
|
||||
|
|
@ -29,11 +34,12 @@ ClangTidyDlg::ClangTidyDlg()
|
|||
{
|
||||
CtrlLayoutOKCancel(*this, "Clang Tidy");
|
||||
|
||||
group.AddIndex();
|
||||
group.AddColumn("Group");
|
||||
group.NoHeader();
|
||||
group.Add(AttrText("All").Italic().NormalInk(SLtBlue()));
|
||||
group.Add(Null, AttrText("All").Italic().NormalInk(SLtBlue()));
|
||||
for(String s : groups)
|
||||
group.Add(s);
|
||||
group.Add(s, s);
|
||||
|
||||
group.WhenSel = [=] {
|
||||
Group();
|
||||
|
|
@ -44,23 +50,7 @@ ClangTidyDlg::ClangTidyDlg()
|
|||
option.AddColumn();
|
||||
option.NoCursor();
|
||||
|
||||
for(String s : options) {
|
||||
OptionWithLink& opt = checks.Add(s);
|
||||
opt.NoWantFocus();
|
||||
opt << opt.text.NoSb().VCenter().HSizePos(DPI(18), 0).VSizePos();
|
||||
String txt = "[g";
|
||||
String cs;
|
||||
if(cs.TrimStart("clang-analyzer-")) // TODO: Improve
|
||||
txt << "^https://clang.llvm.org/extra/clang-tidy/checks/clang-analyzer/" + cs + "^";
|
||||
else {
|
||||
int q = s.Find('-');
|
||||
if(q >= 0)
|
||||
txt << "^https://clang.llvm.org/extra/clang-tidy/checks/" << s.Mid(0, q) << "/" << s.Mid(q + 1) << ".html^";
|
||||
}
|
||||
txt << " \1" << s;
|
||||
opt.text <<= txt;
|
||||
opt <<= active_checks.Find(s) >= 0;
|
||||
}
|
||||
SetOptions();
|
||||
|
||||
auto Set = [=](bool b) {
|
||||
for(int i = 0; i < option.GetCount(); i++) {
|
||||
|
|
@ -68,10 +58,25 @@ ClangTidyDlg::ClangTidyDlg()
|
|||
if(o)
|
||||
*o <<= b;
|
||||
}
|
||||
SyncGroupCounts();
|
||||
};
|
||||
|
||||
set << [=] { Set(true); };
|
||||
reset << [=] { Set(false); };
|
||||
|
||||
save << [=] {
|
||||
ReadOptions();
|
||||
String p = SelectFileSaveAs("*.json\n*.*");
|
||||
if(!IsNull(p))
|
||||
Save(p);
|
||||
};
|
||||
|
||||
load << [=] {
|
||||
String p = SelectFileOpen("*.json\n*.*");
|
||||
Load(p);
|
||||
SetOptions();
|
||||
Group();
|
||||
};
|
||||
}
|
||||
|
||||
bool ClangTidyDlg::HasClangTidy()
|
||||
|
|
@ -100,11 +105,10 @@ bool ClangTidyDlg::HasClangTidy()
|
|||
s.Trim(q);
|
||||
groups.FindAdd(s);
|
||||
}
|
||||
Load(ClangTidyConfigPath());
|
||||
break;
|
||||
}
|
||||
|
||||
Value json = ParseJSON(LoadFile(ConfigFile("ide-clang-tidy.json")));
|
||||
for(Value v : json["active_checks"])
|
||||
active_checks << ~v;
|
||||
#ifdef PLATFORM_WIN32
|
||||
}
|
||||
#endif
|
||||
|
|
@ -112,32 +116,88 @@ bool ClangTidyDlg::HasClangTidy()
|
|||
return path.GetCount() && options.GetCount();
|
||||
}
|
||||
|
||||
String ClangTidyDlg::ClangTidyConfigPath() {
|
||||
return ConfigFile("ide-clang-tidy.json");
|
||||
}
|
||||
|
||||
void ClangTidyDlg::Group()
|
||||
{
|
||||
String st;
|
||||
if(group.GetCursor() > 0)
|
||||
st = group.GetKey();
|
||||
|
||||
String g = ~group.GetKey();
|
||||
option.Clear();
|
||||
for(auto m : ~checks)
|
||||
if(m.key.StartsWith(st)) {
|
||||
for(auto m : ~checks) {
|
||||
if(m.key.StartsWith(g)) {
|
||||
option.Add(m.key);
|
||||
option.SetCtrl(option.GetCount() - 1, 0, m.value, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClangTidyDlg::Save()
|
||||
void ClangTidyDlg::SyncGroupCounts()
|
||||
{
|
||||
for(int i = 1; i < group.GetCount(); i++) {
|
||||
String g = ~group.Get(i, 0);
|
||||
int count = 0;
|
||||
for(auto m : ~checks)
|
||||
if(m.key.StartsWith(g) && ~m.value)
|
||||
count++;
|
||||
if(count) {
|
||||
g << " (" << count << ")";
|
||||
group.Set(i, 1, AttrText(g).Bold());
|
||||
}
|
||||
else
|
||||
group.Set(i, 1, g);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ClangTidyDlg::Load(const char *path)
|
||||
{
|
||||
Value json = ParseJSON(LoadFile(path));
|
||||
active_checks.Clear();
|
||||
for(Value v : json["active_checks"])
|
||||
active_checks << ~v;
|
||||
}
|
||||
|
||||
void ClangTidyDlg::SetOptions()
|
||||
{
|
||||
checks.Clear();
|
||||
for(String s : options) {
|
||||
OptionWithLink& opt = checks.Add(s);
|
||||
opt.NoWantFocus();
|
||||
opt << opt.text.NoSb().VCenter().HSizePos(DPI(18), 0).VSizePos();
|
||||
opt << [=] { SyncGroupCounts(); };
|
||||
String txt = "[g";
|
||||
String cs;
|
||||
if(cs.TrimStart("clang-analyzer-")) // TODO: Improve
|
||||
txt << "^https://clang.llvm.org/extra/clang-tidy/checks/clang-analyzer/" + cs + "^";
|
||||
else {
|
||||
int q = s.Find('-');
|
||||
if(q >= 0)
|
||||
txt << "^https://clang.llvm.org/extra/clang-tidy/checks/" << s.Mid(0, q) << "/" << s.Mid(q + 1) << ".html^";
|
||||
}
|
||||
txt << " \1" << s;
|
||||
opt.text <<= txt;
|
||||
opt <<= active_checks.Find(s) >= 0;
|
||||
}
|
||||
SyncGroupCounts();
|
||||
}
|
||||
|
||||
void ClangTidyDlg::ReadOptions()
|
||||
{
|
||||
active_checks.Clear();
|
||||
for(auto m : ~checks)
|
||||
if(m.value)
|
||||
active_checks.FindAdd(m.key);
|
||||
}
|
||||
|
||||
void ClangTidyDlg::Save(const char *path)
|
||||
{
|
||||
Value json;
|
||||
ValueArray va;
|
||||
for(String s : active_checks)
|
||||
va << s;
|
||||
json("active_checks") = va;
|
||||
SaveFile(ConfigFile("ide-clang-tidy.json"), AsJSON(json, true));
|
||||
SaveFile(path, AsJSON(json, true));
|
||||
}
|
||||
|
||||
bool Ide::HasClangTidy()
|
||||
|
|
@ -156,7 +216,8 @@ void Ide::ClangTidy()
|
|||
|
||||
dlg.Execute();
|
||||
|
||||
dlg.Save();
|
||||
dlg.ReadOptions();
|
||||
dlg.Save(dlg.ClangTidyConfigPath());
|
||||
|
||||
MakeBuild *mb = dynamic_cast<MakeBuild *>(TheIdeContext()); // TODO: Move to Builders/umk
|
||||
|
||||
|
|
@ -180,9 +241,6 @@ void Ide::ClangTidy()
|
|||
RealizePath(cc_path);
|
||||
Upp::SaveFile(cc_path, ccj.ToString());
|
||||
|
||||
DDUMP(cc_path);
|
||||
DDUMP(ccj.ToString());
|
||||
|
||||
cmdline << " -checks=" << Join(ClangTidyDlg::active_checks.GetKeys(), ",")
|
||||
<< " -p " << cc_path;
|
||||
|
||||
|
|
|
|||
|
|
@ -1028,12 +1028,14 @@ LAYOUT(SeqLayout, 764, 544)
|
|||
ITEM(Upp::EditString, postfix, LeftPosZ(708, 48).TopPosZ(8, 19))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(ClangTidy, 624, 580)
|
||||
LAYOUT(ClangTidyLayout, 624, 580)
|
||||
ITEM(Upp::ArrayCtrl, group, LeftPosZ(8, 184).TopPosZ(8, 532))
|
||||
ITEM(Upp::ArrayCtrl, option, LeftPosZ(196, 420).TopPosZ(8, 532))
|
||||
ITEM(Upp::Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(8, 24))
|
||||
ITEM(Upp::Button, save, SetLabel(t_("Save..")).RightPosZ(568, 48).BottomPosZ(8, 24))
|
||||
ITEM(Upp::Button, load, SetLabel(t_("Load..")).RightPosZ(516, 48).BottomPosZ(8, 24))
|
||||
ITEM(Upp::Button, set, SetLabel(t_("Set All")).RightPosZ(380, 48).BottomPosZ(8, 24))
|
||||
ITEM(Upp::Button, reset, SetLabel(t_("Reset All")).RightPosZ(320, 56).BottomPosZ(8, 24))
|
||||
ITEM(Upp::Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(8, 24))
|
||||
ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(8, 24))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue