Skip to content

Commit 3e2a3d5

Browse files
committed
Adjusted formatting
1 parent d320405 commit 3e2a3d5

29 files changed

+213
-206
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ KeepEmptyLinesAtTheStartOfBlocks: 'false'
4242
Language: Cpp
4343
MaxEmptyLinesToKeep: '2'
4444
NamespaceIndentation: All
45-
PointerAlignment: Right
45+
PointerAlignment: Left
4646
ReflowComments: 'true'
4747
SortIncludes: 'false'
4848
SortUsingDeclarations: 'true'

src/NppJsonViewer/AboutDlg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ bool AboutDlg::ShowDlg(bool bShow)
3636

3737
INT_PTR AboutDlg::run_dlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
3838
{
39-
AboutDlg *pSelf = nullptr;
39+
AboutDlg* pSelf = nullptr;
4040
switch (uMsg)
4141
{
4242
case WM_INITDIALOG:
4343
{
4444
::SetWindowLongPtr(_hSelf, DWLP_USER, lParam);
4545

46-
pSelf = reinterpret_cast<AboutDlg *>(static_cast<LONG_PTR>(::GetWindowLongPtr(_hSelf, DWLP_USER)));
46+
pSelf = reinterpret_cast<AboutDlg*>(static_cast<LONG_PTR>(::GetWindowLongPtr(_hSelf, DWLP_USER)));
4747
if (pSelf)
4848
{
4949
pSelf->SetVersion(_hSelf);
@@ -82,7 +82,7 @@ INT_PTR AboutDlg::run_dlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
8282

8383
case WM_COMMAND:
8484
{
85-
pSelf = reinterpret_cast<AboutDlg *>(static_cast<LONG_PTR>(::GetWindowLongPtr(_hSelf, DWLP_USER)));
85+
pSelf = reinterpret_cast<AboutDlg*>(static_cast<LONG_PTR>(::GetWindowLongPtr(_hSelf, DWLP_USER)));
8686
switch (LOWORD(wParam))
8787
{
8888
case IDCANCEL: // Close this dialog when clicking to close button

src/NppJsonViewer/JsonHandler.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
namespace rj = rapidjson;
77

88

9-
JsonHandler::JsonHandler(const ParseOptions &options)
9+
JsonHandler::JsonHandler(const ParseOptions& options)
1010
: m_parseOptions(options)
1111
{
1212
}
1313

14-
auto JsonHandler::GetCompressedJson(const std::string &jsonText) -> const Result
14+
auto JsonHandler::GetCompressedJson(const std::string& jsonText) -> const Result
1515
{
1616
rj::StringBuffer sb;
1717
rj::Writer<rj::StringBuffer, rj::UTF8<>, rj::UTF8<>, rj::CrtAllocator, rj::kWriteNanAndInfFlag> handler(sb);
1818

1919
return ParseJson<flgBaseWriter>(jsonText, sb, handler);
2020
}
2121

22-
auto JsonHandler::FormatJson(const std::string &jsonText, LE le, LF lf, char indentChar, unsigned indentLen) -> const Result
22+
auto JsonHandler::FormatJson(const std::string& jsonText, LE le, LF lf, char indentChar, unsigned indentLen) -> const Result
2323
{
2424
rj::StringBuffer sb;
2525
rj::PrettyWriter<rj::StringBuffer, rj::UTF8<>, rj::UTF8<>, rj::CrtAllocator, rj::kWriteNanAndInfFlag> handler(sb);
@@ -30,7 +30,7 @@ auto JsonHandler::FormatJson(const std::string &jsonText, LE le, LF lf, char ind
3030
return ParseJson<flgBaseWriter>(jsonText, sb, handler);
3131
}
3232

33-
auto JsonHandler::SortJsonByKey(const std::string &jsonText, LE le, LF lf, char indentChar, unsigned indentLen) -> const Result
33+
auto JsonHandler::SortJsonByKey(const std::string& jsonText, LE le, LF lf, char indentChar, unsigned indentLen) -> const Result
3434
{
3535
auto res = ValidateJson(jsonText);
3636
if (res.success)
@@ -42,15 +42,15 @@ auto JsonHandler::SortJsonByKey(const std::string &jsonText, LE le, LF lf, char
4242
return res;
4343
}
4444

45-
auto JsonHandler::ValidateJson(const std::string &jsonText) -> const Result
45+
auto JsonHandler::ValidateJson(const std::string& jsonText) -> const Result
4646
{
4747
rj::StringBuffer sb;
4848
rj::Writer<rj::StringBuffer, rj::UTF8<>, rj::UTF8<>, rj::CrtAllocator, rj::kWriteNanAndInfFlag> handler(sb);
4949

5050
return ParseJson<flgBaseWriter>(jsonText, sb, handler);
5151
}
5252

53-
void JsonHandler::SortJsonObject(rj::Value &jsonObject, rj::Document::AllocatorType &allocator) const
53+
void JsonHandler::SortJsonObject(rj::Value& jsonObject, rj::Document::AllocatorType& allocator) const
5454
{
5555
if (!jsonObject.IsObject())
5656
{
@@ -72,18 +72,18 @@ void JsonHandler::SortJsonObject(rj::Value &jsonObject, rj::Document::AllocatorT
7272
rj::Value sortedObject(rj::kObjectType);
7373

7474
// Add members to the sorted object in sorted order
75-
for (const auto &key : keys)
75+
for (const auto& key : keys)
7676
{
7777
rj::Value name(key.c_str(), allocator); // Create key as a RapidJSON value
78-
rj::Value &value = jsonObject[key.c_str()]; // Get corresponding value
78+
rj::Value& value = jsonObject[key.c_str()]; // Get corresponding value
7979
sortedObject.AddMember(name, value, allocator); // Add key-value pair to sorted object
8080
}
8181

8282
// Replace the original object with the sorted one
8383
jsonObject = std::move(sortedObject);
8484
}
8585

86-
void JsonHandler::SortJsonRecursively(rj::Value &jsonValue, rj::Document::AllocatorType &allocator) const
86+
void JsonHandler::SortJsonRecursively(rj::Value& jsonValue, rj::Document::AllocatorType& allocator) const
8787
{
8888
if (jsonValue.IsObject())
8989
{
@@ -105,7 +105,7 @@ void JsonHandler::SortJsonRecursively(rj::Value &jsonValue, rj::Document::Alloca
105105
}
106106
}
107107

108-
auto JsonHandler::SortJsonText(const std::string &jsonString) const -> std::string
108+
auto JsonHandler::SortJsonText(const std::string& jsonString) const -> std::string
109109
{
110110
rj::Document document;
111111

src/NppJsonViewer/JsonHandler.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@ class JsonHandler
3333
ParseOptions m_parseOptions {};
3434

3535
public:
36-
explicit JsonHandler(const ParseOptions &options);
36+
explicit JsonHandler(const ParseOptions& options);
3737
~JsonHandler() = default;
3838

39-
auto GetCompressedJson(const std::string &jsonText) -> const Result;
40-
auto FormatJson(const std::string &jsonText, LE le, LF lf, char indentChar, unsigned indentLen) -> const Result;
41-
auto SortJsonByKey(const std::string &jsonText, LE le, LF lf, char indentChar, unsigned indentLen) -> const Result;
42-
auto ValidateJson(const std::string &jsonText) -> const Result;
39+
auto GetCompressedJson(const std::string& jsonText) -> const Result;
40+
auto FormatJson(const std::string& jsonText, LE le, LF lf, char indentChar, unsigned indentLen) -> const Result;
41+
auto SortJsonByKey(const std::string& jsonText, LE le, LF lf, char indentChar, unsigned indentLen) -> const Result;
42+
auto ValidateJson(const std::string& jsonText) -> const Result;
4343

4444
template <unsigned format, typename Handler>
45-
auto ParseJson(const std::string &jsonText, rj::StringBuffer &sb, Handler &handler) -> const Result;
45+
auto ParseJson(const std::string& jsonText, rj::StringBuffer& sb, Handler& handler) -> const Result;
4646

4747
private:
48-
void SortJsonObject(rj::Value &jsonObject, rj::Document::AllocatorType &allocator) const;
49-
void SortJsonRecursively(rj::Value &jsonValue, rj::Document::AllocatorType &allocator) const;
50-
auto SortJsonText(const std::string &jsonString) const -> std::string;
48+
void SortJsonObject(rj::Value& jsonObject, rj::Document::AllocatorType& allocator) const;
49+
void SortJsonRecursively(rj::Value& jsonValue, rj::Document::AllocatorType& allocator) const;
50+
auto SortJsonText(const std::string& jsonString) const -> std::string;
5151
};
5252

5353
template <unsigned flgBase, typename Handler>
54-
inline auto JsonHandler::ParseJson(const std::string &jsonText, rj::StringBuffer &sb, Handler &handler) -> const Result
54+
inline auto JsonHandler::ParseJson(const std::string& jsonText, rj::StringBuffer& sb, Handler& handler) -> const Result
5555
{
5656
Result retVal {};
5757

src/NppJsonViewer/JsonViewDlg.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
constexpr int FILENAME_LEN_IN_TITLE = 16;
1212

13-
JsonViewDlg::JsonViewDlg(HINSTANCE hInstance, const NppData &nppData, const bool &isReady, int nCmdId, std::shared_ptr<Setting> &pSetting)
13+
JsonViewDlg::JsonViewDlg(HINSTANCE hInstance, const NppData& nppData, const bool& isReady, int nCmdId, std::shared_ptr<Setting>& pSetting)
1414
: DockingDlgInterface(IDD_TREEDLG)
1515
, m_NppData(nppData)
1616
, m_IsNppReady(isReady)
@@ -52,7 +52,7 @@ void JsonViewDlg::ShowDlg(bool bShow)
5252
// define the default docking behaviour
5353
data.uMask = DWS_DF_CONT_LEFT | DWS_ICONTAB | DWS_ADDINFO;
5454
data.pszModuleName = getPluginFileName();
55-
data.pszName = const_cast<TCHAR *>(TITLE_JSON_PANEL);
55+
data.pszName = const_cast<TCHAR*>(TITLE_JSON_PANEL);
5656
data.hIconTab = static_cast<HICON>(LoadImage(_hInst, MAKEINTRESOURCE(IDI_ICON_TOOLBAR), IMAGE_ICON, 32, 32, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT));
5757
data.pszAddInfo = m_pCurrFileName.get();
5858

@@ -136,7 +136,7 @@ void JsonViewDlg::SortJsonByKey()
136136
{
137137
UpdateTitle();
138138

139-
const auto selectedData = m_pEditor->GetJsonText();
139+
const auto selectedData = m_pEditor->GetJsonText();
140140
const auto selectedText = IsSelectionValidJson(selectedData);
141141

142142
if (!selectedText.has_value() || selectedText.value().empty())
@@ -164,7 +164,7 @@ void JsonViewDlg::SortJsonByKey()
164164
}
165165
}
166166

167-
bool JsonViewDlg::CheckForTokenUndefined(eMethod method, std::string selectedText, Result &res, HTREEITEM tree_root)
167+
bool JsonViewDlg::CheckForTokenUndefined(eMethod method, std::string selectedText, Result& res, HTREEITEM tree_root)
168168
{
169169
auto [le, lf, indentChar, indentLen] = GetFormatSetting();
170170

@@ -221,15 +221,15 @@ bool JsonViewDlg::CheckForTokenUndefined(eMethod method, std::string selectedTex
221221
m_pEditor->RefreshSelectionPos();
222222
}
223223
}
224-
catch (const std::exception &)
224+
catch (const std::exception&)
225225
{
226226
}
227227
}
228228
}
229229
return false;
230230
}
231231

232-
bool JsonViewDlg::IsMultiSelection(const ScintillaData &scintillaData) const
232+
bool JsonViewDlg::IsMultiSelection(const ScintillaData& scintillaData) const
233233
{
234234
std::string text;
235235
ScintillaCode code = ScintillaCode::Unknown;
@@ -240,7 +240,7 @@ bool JsonViewDlg::IsMultiSelection(const ScintillaData &scintillaData) const
240240
return bRetVal;
241241
}
242242

243-
auto JsonViewDlg::IsSelectionValidJson(const ScintillaData &scintillaData) const -> std::optional<std::string>
243+
auto JsonViewDlg::IsSelectionValidJson(const ScintillaData& scintillaData) const -> std::optional<std::string>
244244
{
245245
std::string text;
246246
ScintillaCode code = ScintillaCode::Unknown;
@@ -253,13 +253,13 @@ auto JsonViewDlg::IsSelectionValidJson(const ScintillaData &scintillaData) const
253253
return std::nullopt;
254254
}
255255

256-
void JsonViewDlg::ProcessScintillaData(const ScintillaData &scintillaData, std::string &text, ScintillaCode &code) const
256+
void JsonViewDlg::ProcessScintillaData(const ScintillaData& scintillaData, std::string& text, ScintillaCode& code) const
257257
{
258258
text.clear();
259259
code = ScintillaCode::Unknown;
260260

261261
std::visit(
262-
[&text, &code](auto &&arg)
262+
[&text, &code](auto&& arg)
263263
{
264264
using T = std::decay_t<decltype(arg)>;
265265
if constexpr (std::is_same_v<T, std::string>)
@@ -300,7 +300,7 @@ void JsonViewDlg::ValidateJson()
300300
{
301301
UpdateTitle();
302302

303-
const auto selectedData = m_pEditor->GetJsonText();
303+
const auto selectedData = m_pEditor->GetJsonText();
304304
const auto selectedText = IsSelectionValidJson(selectedData);
305305

306306
if (!selectedText.has_value() || selectedText.value().empty())
@@ -341,7 +341,7 @@ void JsonViewDlg::DrawJsonTree()
341341

342342
// Refresh the view
343343
m_pEditor->RefreshViewHandle();
344-
const auto selectedData = m_pEditor->GetJsonText();
344+
const auto selectedData = m_pEditor->GetJsonText();
345345
const auto selectedText = IsSelectionValidJson(selectedData);
346346

347347
if (!selectedText.has_value() || selectedText.value().empty())
@@ -386,7 +386,7 @@ void JsonViewDlg::HighlightAsJson(bool bForcefully) const
386386
m_pEditor->SetLangAsJson();
387387
}
388388

389-
auto JsonViewDlg::PopulateTreeUsingSax(HTREEITEM tree_root, const std::string &jsonText) -> std::optional<std::wstring>
389+
auto JsonViewDlg::PopulateTreeUsingSax(HTREEITEM tree_root, const std::string& jsonText) -> std::optional<std::wstring>
390390
{
391391
std::optional<std::wstring> retVal = std::nullopt;
392392

@@ -423,7 +423,7 @@ auto JsonViewDlg::PopulateTreeUsingSax(HTREEITEM tree_root, const std::string &j
423423
return retVal;
424424
}
425425

426-
HTREEITEM JsonViewDlg::InsertToTree(HTREEITEM parent, const std::string &text)
426+
HTREEITEM JsonViewDlg::InsertToTree(HTREEITEM parent, const std::string& text)
427427
{
428428
auto wText = StringHelper::ToWstring(text, CP_UTF8);
429429
return m_hTreeView->InsertNode(wText, NULL, parent);
@@ -579,7 +579,7 @@ void JsonViewDlg::PrepareButtons()
579579
SetIconAndTooltip(eButton::eSearch, TOOLTIP_SEARCH);
580580
}
581581

582-
void JsonViewDlg::SetIconAndTooltip(eButton ctrlType, const std::wstring &toolTip)
582+
void JsonViewDlg::SetIconAndTooltip(eButton ctrlType, const std::wstring& toolTip)
583583
{
584584
int nCtrlID = 0;
585585
int iconResID = 0;
@@ -828,12 +828,12 @@ auto JsonViewDlg::CopyPath() const -> std::wstring
828828
return std::wstring();
829829
}
830830

831-
int JsonViewDlg::ShowMessage(const std::wstring &title, const std::wstring &msg, int flag, bool bDontShow)
831+
int JsonViewDlg::ShowMessage(const std::wstring& title, const std::wstring& msg, int flag, bool bDonotShow)
832832
{
833-
return !bDontShow ? ::MessageBox(_hParent, msg.c_str(), title.c_str(), flag) : IDOK;
833+
return !bDonotShow ? ::MessageBox(_hParent, msg.c_str(), title.c_str(), flag) : IDOK;
834834
}
835835

836-
void JsonViewDlg::ReportError(const Result &result)
836+
void JsonViewDlg::ReportError(const Result& result)
837837
{
838838
// Mark the error position
839839
size_t start = m_pEditor->GetSelectionStart() + result.error_pos;
@@ -851,13 +851,13 @@ void JsonViewDlg::ToggleMenuItemState(bool bVisible)
851851
::SendMessage(_hParent, NPPM_SETMENUITEMCHECK, static_cast<WPARAM>(m_nDlgId), bVisible);
852852
}
853853

854-
void JsonViewDlg::ShowControls(const std::vector<DWORD> &ids, bool show)
854+
void JsonViewDlg::ShowControls(const std::vector<DWORD>& ids, bool show)
855855
{
856856
for (auto id : ids)
857857
ShowWindow(GetDlgItem(getHSelf(), id), show ? SW_SHOW : SW_HIDE);
858858
}
859859

860-
void JsonViewDlg::EnableControls(const std::vector<DWORD> &ids, bool enable)
860+
void JsonViewDlg::EnableControls(const std::vector<DWORD>& ids, bool enable)
861861
{
862862
for (auto id : ids)
863863
EnableWindow(GetDlgItem(getHSelf(), id), enable ? TRUE : FALSE);
@@ -873,7 +873,7 @@ void JsonViewDlg::HandleTreeEvents(LPARAM lParam)
873873
{
874874
case TVN_SELCHANGED:
875875
{
876-
NMTREEVIEW *pnmtv = reinterpret_cast<LPNMTREEVIEW>(lParam);
876+
NMTREEVIEW* pnmtv = reinterpret_cast<LPNMTREEVIEW>(lParam);
877877
HTREEITEM hItem = pnmtv->itemNew.hItem;
878878
if (hItem && (pnmtv->action == TVC_BYMOUSE || pnmtv->action == TVC_BYKEYBOARD))
879879
{
@@ -960,7 +960,7 @@ INT_PTR JsonViewDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
960960
{
961961
case WM_GETMINMAXINFO:
962962
{
963-
MINMAXINFO *mmi = reinterpret_cast<MINMAXINFO *>(lParam);
963+
MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(lParam);
964964
mmi->ptMinTrackSize.x = m_rcInitialWindowRect.right;
965965
return 0;
966966
}
@@ -976,7 +976,7 @@ INT_PTR JsonViewDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
976976

977977
case WM_INITDIALOG:
978978
{
979-
// Save ourself in GWLP_USERDATA.
979+
// Save ourselves in GWLP_USERDATA.
980980
::SetWindowLongPtr(getHSelf(), GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
981981

982982
m_hTreeView->OnInit(getHSelf());

0 commit comments

Comments
 (0)