- enhancement: Show "std::function" in the completion list.

This commit is contained in:
Roy Qu 2024-03-22 09:23:49 +08:00
parent ce45cae6ed
commit aad4050c25
4 changed files with 14 additions and 4 deletions

View File

@ -74,6 +74,7 @@ Red Panda C++ Version 2.27
- fix: Filename that contains '&' doesn't correctly displayed in the editor tab. - fix: Filename that contains '&' doesn't correctly displayed in the editor tab.
- enhancement: Type induction for "auto &&" vars. - enhancement: Type induction for "auto &&" vars.
- enhancement: Syntax highlighting for c++ attributes. - enhancement: Syntax highlighting for c++ attributes.
- enhancement: Show "std::function" in the completion list.
Red Panda C++ Version 2.26 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

@ -1397,6 +1397,13 @@ PStatement CppParser::addStatement(const PStatement& parent,
newType += newCommand.front(); newType += newCommand.front();
newCommand.remove(0,1); // remove first 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()<<newCommand<<templateSpecializationParams;
}
newCommand.squeeze(); newCommand.squeeze();
// if (newCommand.startsWith("::") && parent && kind!=StatementKind::skBlock ) { // if (newCommand.startsWith("::") && parent && kind!=StatementKind::skBlock ) {
// qDebug()<<command<<fileName<<line<<kind<<parent->fullName; // qDebug()<<command<<fileName<<line<<kind<<parent->fullName;
@ -1437,6 +1444,7 @@ PStatement CppParser::addStatement(const PStatement& parent,
result->args = args; result->args = args;
result->noNameArgs = noNameArgs; result->noNameArgs = noNameArgs;
result->value = value; result->value = value;
result->templateSpecializationParams = templateSpecializationParams;
result->kind = kind; result->kind = kind;
result->scope = scope; result->scope = scope;
result->accessibility = accessibility; result->accessibility = accessibility;
@ -1457,7 +1465,7 @@ PStatement CppParser::addStatement(const PStatement& parent,
if (scope == StatementScope::Local) if (scope == StatementScope::Local)
result->fullName = newCommand; result->fullName = newCommand;
else else
result->fullName = getFullStatementName(newCommand, parent); result->fullName = getFullStatementName(newCommand + templateSpecializationParams, parent);
result->usageCount = -1; result->usageCount = -1;
result->args.squeeze(); result->args.squeeze();
@ -4560,8 +4568,8 @@ void CppParser::internalParse(const QString &fileName)
handleInheritances(); handleInheritances();
// qDebug()<<"parse"<<timer.elapsed(); // qDebug()<<"parse"<<timer.elapsed();
#ifdef QT_DEBUG #ifdef QT_DEBUG
// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
#endif #endif
//reduce memory usage //reduce memory usage
internalClear(); internalClear();

View File

@ -184,6 +184,7 @@ struct Statement {
QString command; // identifier/name of statement "foo" QString command; // identifier/name of statement "foo"
QString args; // args "(int a,float b)" QString args; // args "(int a,float b)"
QString value; // Used for macro defines/typedef, "100" in "#defin COUNT 100" QString value; // Used for macro defines/typedef, "100" in "#defin COUNT 100"
QString templateSpecializationParams;
StatementKind kind; // kind of statement class/variable/function/etc StatementKind kind; // kind of statement class/variable/function/etc
StatementScope scope; // global/local/classlocal StatementScope scope; // global/local/classlocal
StatementAccessibility accessibility; // protected/private/public StatementAccessibility accessibility; // protected/private/public

View File

@ -296,7 +296,7 @@ void CodeCompletionPopup::addStatement(const PStatement& statement, const QStrin
&& (fileName == statement->fileName)) && (fileName == statement->fileName))
return; return;
mAddedStatements.insert(statement->command); mAddedStatements.insert(statement->command);
if (statement->kind == StatementKind::skUserCodeSnippet || !statement->fullName.contains("<")) if (statement->kind == StatementKind::skUserCodeSnippet || !statement->command.contains("<"))
mFullCompletionStatementList.append(statement); mFullCompletionStatementList.append(statement);
} }