From aad4050c2537bf902fdce0f77fc07946d5b69916 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 22 Mar 2024 09:23:49 +0800 Subject: [PATCH] - enhancement: Show "std::function" in the completion list. --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 14 +++++++++++--- RedPandaIDE/parser/parserutils.h | 1 + RedPandaIDE/widgets/codecompletionpopup.cpp | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 432b0bc4..1a0467dd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -74,6 +74,7 @@ Red Panda C++ Version 2.27 - fix: Filename that contains '&' doesn't correctly displayed in the editor tab. - enhancement: Type induction for "auto &&" vars. - enhancement: Syntax highlighting for c++ attributes. + - enhancement: Show "std::function" in the completion list. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 20545d47..01d575c2 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -1397,6 +1397,13 @@ PStatement CppParser::addStatement(const PStatement& parent, newType += newCommand.front(); newCommand.remove(0,1); // remove first } + QString templateSpecializationParams; + int pos = newCommand.indexOf("<"); + if (pos>0 && !newCommand.startsWith("operator<")) { + templateSpecializationParams = newCommand.mid(pos); + newCommand = newCommand.left(pos); + qDebug()<fullName; @@ -1437,6 +1444,7 @@ PStatement CppParser::addStatement(const PStatement& parent, result->args = args; result->noNameArgs = noNameArgs; result->value = value; + result->templateSpecializationParams = templateSpecializationParams; result->kind = kind; result->scope = scope; result->accessibility = accessibility; @@ -1457,7 +1465,7 @@ PStatement CppParser::addStatement(const PStatement& parent, if (scope == StatementScope::Local) result->fullName = newCommand; else - result->fullName = getFullStatementName(newCommand, parent); + result->fullName = getFullStatementName(newCommand + templateSpecializationParams, parent); result->usageCount = -1; result->args.squeeze(); @@ -4560,8 +4568,8 @@ void CppParser::internalParse(const QString &fileName) handleInheritances(); // qDebug()<<"parse"<fileName)) return; mAddedStatements.insert(statement->command); - if (statement->kind == StatementKind::skUserCodeSnippet || !statement->fullName.contains("<")) + if (statement->kind == StatementKind::skUserCodeSnippet || !statement->command.contains("<")) mFullCompletionStatementList.append(statement); }