- change: just show one function hint for overloaded functions

This commit is contained in:
Roy Qu 2022-06-30 14:39:12 +08:00
parent 6e60738b39
commit 24a4f0e127
2 changed files with 42 additions and 30 deletions

View File

@ -5,6 +5,7 @@ Red Panda C++ Version 1.1.3
- enhancement: copy the whole folded code block - enhancement: copy the whole folded code block
- enhancement: delete the whole folded code block - enhancement: delete the whole folded code block
- fix: correctly update the folding state of code block, when deleted - fix: correctly update the folding state of code block, when deleted
- change: just show one function hint for overloaded functions
Red Panda C++ Version 1.1.2 Red Panda C++ Version 1.1.2
- enhancement: use different color to differenciate folder and headers in completion popup window - enhancement: use different color to differenciate folder and headers in completion popup window

View File

@ -3418,6 +3418,7 @@ QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/
{ {
// This piece of code changes the parser database, possibly making hints and code completion invalid... // This piece of code changes the parser database, possibly making hints and code completion invalid...
QString result; QString result;
// Exit early, don't bother creating a stream (which is slow)
PStatement statement = mParser->findStatementOf( PStatement statement = mParser->findStatementOf(
mFilename,expression, mFilename,expression,
line); line);
@ -3427,21 +3428,27 @@ QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/
|| statement->kind == StatementKind::skConstructor || statement->kind == StatementKind::skConstructor
|| statement->kind == StatementKind::skDestructor) { || statement->kind == StatementKind::skDestructor) {
PStatement parentScope = statement->parentScope.lock(); PStatement parentScope = statement->parentScope.lock();
if (parentScope && parentScope->kind == StatementKind::skNamespace) { // if (parentScope && parentScope->kind == StatementKind::skNamespace) {
PStatementList namespaceStatementsList = // PStatementList namespaceStatementsList =
mParser->findNamespace(parentScope->command); // mParser->findNamespace(parentScope->command);
if (namespaceStatementsList) { // if (namespaceStatementsList) {
foreach (const PStatement& namespaceStatement, *namespaceStatementsList) { // int counts=0;
QString hint = getHintForFunction(statement,namespaceStatement, // foreach (const PStatement& namespaceStatement, *namespaceStatementsList) {
mFilename,line); // QString hint = getHintForFunction(statement,namespaceStatement,
if (!hint.isEmpty()) { // mFilename,line);
if (!result.isEmpty()) // if (!hint.isEmpty()) {
result += "<BR />"; // counts++;
result += hint; // if (!result.isEmpty())
} // result += "\n";
} // if (counts>4) {
} // result += "...";
} else // break;
// }
// result += hint;
// }
// }
// }
// } else
result = getHintForFunction(statement, parentScope, result = getHintForFunction(statement, parentScope,
mFilename,line); mFilename,line);
} else if (statement->line>0) { } else if (statement->line>0) {
@ -3489,22 +3496,26 @@ QString Editor::getErrorHint(const PSyntaxIssue& issue)
QString Editor::getHintForFunction(const PStatement &statement, const PStatement &scopeStatement, const QString& filename, int line) QString Editor::getHintForFunction(const PStatement &statement, const PStatement &scopeStatement, const QString& filename, int line)
{ {
QFileInfo fileInfo(statement->fileName);
QString result; QString result;
const StatementMap& children = mParser->statementList().childrenStatements(scopeStatement); result = mParser->prettyPrintStatement(statement,filename,line) + " - "
foreach (const PStatement& childStatement, children){ + QString("%1(%2) ").arg(fileInfo.fileName()).arg(statement->line)
if (statement->command == childStatement->command + tr("Ctrl+click for more info");
&& statement->kind == childStatement->kind) { // const StatementMap& children = mParser->statementList().childrenStatements(scopeStatement);
if ((line < childStatement->line) && // foreach (const PStatement& childStatement, children){
childStatement->fileName == filename) // if (statement->command == childStatement->command
continue; // && statement->kind == childStatement->kind) {
if (!result.isEmpty()) // if ((line < childStatement->line) &&
result += "<BR />"; // childStatement->fileName == filename)
QFileInfo fileInfo(childStatement->fileName); // continue;
result = mParser->prettyPrintStatement(childStatement,filename,line) + " - " // if (!result.isEmpty())
+ QString("%1(%2) ").arg(fileInfo.fileName()).arg(childStatement->line) // result += "\n";
+ tr("Ctrl+click for more info"); // QFileInfo fileInfo(childStatement->fileName);
} // result = mParser->prettyPrintStatement(childStatement,filename,line) + " - "
} // + QString("%1(%2) ").arg(fileInfo.fileName()).arg(childStatement->line)
// + tr("Ctrl+click for more info");
// }
// }
return result; return result;
} }