From 4f23c3580871d05b24df1477d6c8c145253a7e03 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 6 Jul 2023 20:41:54 +0800 Subject: [PATCH] - enhancement: Correctly reformat C++ three-way comparision operator "<=>" --- NEWS.md | 1 + RedPandaIDE/autolinkmanager.cpp | 1 - libs/qsynedit/qsynedit/syntaxer/cpp.cpp | 6 ++++-- tools/astyle/ASResource.cpp | 10 +++++++--- tools/astyle/astyle.h | 1 + 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index c9942a37..09019e24 100644 --- a/NEWS.md +++ b/NEWS.md @@ -32,6 +32,7 @@ Red Panda C++ Version 2.23 - fix: Tips for problem is not correctly displayed. - enhancement: Folder mode in "File in files" dialog. - enhancement: When open a file, test if it contains binary contains. + - enhancement: Correctly reformat C++ three-way comparision operator "<=>" Red Panda C++ Version 2.22 diff --git a/RedPandaIDE/autolinkmanager.cpp b/RedPandaIDE/autolinkmanager.cpp index 1223bfc6..1fc531d7 100644 --- a/RedPandaIDE/autolinkmanager.cpp +++ b/RedPandaIDE/autolinkmanager.cpp @@ -27,7 +27,6 @@ AutolinkManager* pAutolinkManager; AutolinkManager::AutolinkManager() { - } PAutolink AutolinkManager::getLink(const QString &header) const diff --git a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp index a89e644d..9881fae8 100644 --- a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp @@ -558,12 +558,14 @@ void CppSyntaxer::procGreater() switch (mLine[mRun+1].unicode()) { case '=': mRun += 2; + if (mRun') // C++20 <=> + mRun++; return; case '>': - if (mRun+2>= mRun+=3; } else { - mRun += 2; + mRun += 2; // >> } return; } diff --git a/tools/astyle/ASResource.cpp b/tools/astyle/ASResource.cpp index 4ad44f3f..0888b599 100644 --- a/tools/astyle/ASResource.cpp +++ b/tools/astyle/ASResource.cpp @@ -131,6 +131,7 @@ const string ASResource::AS_GR_GR_GR = string(">>>"); const string ASResource::AS_LS_EQUAL = string("<="); const string ASResource::AS_LS_LS = string("<<"); const string ASResource::AS_LS_LS_LS = string("<<<"); +const string ASResource::AS_THREEWAY_COMPARISION = string("<=>"); const string ASResource::AS_QUESTION_QUESTION = string("??"); const string ASResource::AS_LAMBDA = string("=>"); // C# lambda expression arrow const string ASResource::AS_ARROW = string("->"); @@ -350,8 +351,8 @@ void ASResource::buildIndentableMacros(vector* nonAssignmentOperators) { - const size_t elements = 15; - nonAssignmentOperators->reserve(elements); +// const size_t elements = 16; +// nonAssignmentOperators->reserve(elements); nonAssignmentOperators->emplace_back(&AS_EQUAL); nonAssignmentOperators->emplace_back(&AS_PLUS_PLUS); @@ -367,8 +368,9 @@ void ASResource::buildNonAssignmentOperators(vector* nonAssignmen nonAssignmentOperators->emplace_back(&AS_AND); nonAssignmentOperators->emplace_back(&AS_OR); nonAssignmentOperators->emplace_back(&AS_LAMBDA); + nonAssignmentOperators->emplace_back(&AS_THREEWAY_COMPARISION); - assert(nonAssignmentOperators->size() < elements); +// assert(nonAssignmentOperators->size() < elements); sort(nonAssignmentOperators->begin(), nonAssignmentOperators->end(), sortOnLength); } @@ -463,6 +465,8 @@ void ASResource::buildOperators(vector* operators, int fileType) operators->emplace_back(&AS_LS_LS); operators->emplace_back(&AS_QUESTION_QUESTION); operators->emplace_back(&AS_LAMBDA); + operators->emplace_back(&AS_THREEWAY_COMPARISION); + operators->emplace_back(&AS_ARROW); operators->emplace_back(&AS_AND); operators->emplace_back(&AS_OR); diff --git a/tools/astyle/astyle.h b/tools/astyle/astyle.h index 52ca6d4d..91185fe7 100644 --- a/tools/astyle/astyle.h +++ b/tools/astyle/astyle.h @@ -273,6 +273,7 @@ public: static const string AS_GCC_MIN_ASSIGN, AS_GCC_MAX_ASSIGN; static const string AS_EQUAL, AS_PLUS_PLUS, AS_MINUS_MINUS, AS_NOT_EQUAL, AS_GR_EQUAL; static const string AS_LS_EQUAL, AS_LS_LS_LS, AS_LS_LS, AS_GR_GR_GR, AS_GR_GR; + static const string AS_THREEWAY_COMPARISION; static const string AS_QUESTION_QUESTION, AS_LAMBDA; static const string AS_ARROW, AS_AND, AS_OR; static const string AS_SCOPE_RESOLUTION;