From 8788e950dd08824afef6e98ff45d6ee8df876559 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 25 Nov 2022 10:01:10 +0800 Subject: [PATCH] - enhancement: show completion suggest for "namespace" after "using" - fix: MinGW-w64 gcc displayed as "MinGW GCC" --- NEWS.md | 2 ++ RedPandaIDE/editor.cpp | 10 ++++++++-- RedPandaIDE/settings.cpp | 10 ++++++---- RedPandaIDE/widgets/codecompletionpopup.cpp | 5 ++++- RedPandaIDE/widgets/codecompletionpopup.h | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index fbf2457d..05e71766 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,8 @@ Red Panda C++ Version 2.5 - enhancement: Options -> editor -> custom C/C++ type keywords page - change: Default value of option "Editors share one code analyzer" is ON if available physical memory <= 32G - change: Default value of option "Auto clear symbols in hidden editors" is ON if number of CPU cores > 8 and "Editors share one code analyzer" is on + - enhancement: show completion suggest for "namespace" after "using" + - fix: MinGW-w64 gcc displayed as "MinGW GCC" Red Panda C++ Version 2.4 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index f81adcb6..a58ca217 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -728,8 +728,14 @@ void Editor::keyPressEvent(QKeyEvent *event) return; } else if (mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()){ QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY()); + if (mParser && !lastWord.isEmpty()) { - if (CppTypeKeywords.contains(lastWord)) { + if (lastWord == "using") { + commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword); + handled=true; + return; + } else if (CppTypeKeywords.contains(lastWord)) { PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); while(currentScope && currentScope->kind==StatementKind::skBlock) { currentScope = currentScope->parentScope.lock(); @@ -747,7 +753,7 @@ void Editor::keyPressEvent(QKeyEvent *event) lastWord == "unsigned" ) { commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); - showCompletion(lastWord,false, CodeCompletionType::TypeKeywordComplex); + showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword); handled=true; return; } diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 8066cc7a..b4d0def5 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -2135,13 +2135,15 @@ void Settings::CompilerSet::setProperties(const QString &binDir, const QString& mCompilerType = CompilerType::GCC_UTF8; // Assemble user friendly name if we don't have one yet if (mName == "") { - if (mType.contains("tdm64")) { + if (mType.contains("tdm64",Qt::CaseInsensitive)) { mName = "TDM-GCC " + mVersion; - } else if (mType.contains("tdm")) { + } else if (mType.contains("tdm",Qt::CaseInsensitive)) { mName = "TDM-GCC " + mVersion; - } else if (mType.contains("MSYS2")) { + } else if (mType.contains("MSYS2",Qt::CaseInsensitive)) { mName = "MinGW-w64 GCC " + mVersion; - } else if (mType.contains("GCC")) { + } else if (mType.contains("MinGW-W64",Qt::CaseInsensitive)) { + mName = "MinGW-w64 GCC " + mVersion; + } else if (mType.contains("GCC",Qt::CaseInsensitive)) { #ifdef Q_OS_WIN mName = "MinGW GCC " + mVersion; #else diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index fefd4284..db5b2d97 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -92,7 +92,7 @@ void CodeCompletionPopup::prepareSearch( mMemberPhrase = memberExpression.join(""); mMemberOperator = memberOperator; - if (type == CodeCompletionType::TypeKeywordComplex) { + if (type == CodeCompletionType::ComplexKeyword) { getCompletionListForTypeKeywordComplex(preWord); } else if (type == CodeCompletionType::FunctionWithoutDefinition) { mIncludedFiles = mParser->getFileIncludes(filename); @@ -898,6 +898,9 @@ void CodeCompletionPopup::getCompletionListForTypeKeywordComplex(const QString & addKeyword("short"); addKeyword("int"); addKeyword("char"); + } else if (preWord == "using") { + addKeyword("namespace"); + } } diff --git a/RedPandaIDE/widgets/codecompletionpopup.h b/RedPandaIDE/widgets/codecompletionpopup.h index 7d2fadd7..e70e2e5b 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.h +++ b/RedPandaIDE/widgets/codecompletionpopup.h @@ -39,7 +39,7 @@ private: enum class CodeCompletionType { Normal, - TypeKeywordComplex, + ComplexKeyword, FunctionWithoutDefinition };