- enhancement: improve the matching of function declaration and definitions

- fix: research button doesn't show find in files dialog
This commit is contained in:
Roy Qu 2022-04-19 19:17:49 +08:00
parent 434d46ef80
commit 354f375f67
4 changed files with 47 additions and 10 deletions

View File

@ -1,5 +1,7 @@
Red Panda C++ Version 1.0.5
- enhancement: add autolink and project template for sqlite3
- enhancement: improve the matching of function declaration and definitions
- fix: research button doesn't show find in files dialog
Red Panda C++ Version 1.0.4
- fix: hide function tips, when move or resize the main window

View File

@ -542,7 +542,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>6</number>
<number>3</number>
</property>
<property name="iconSize">
<size>

View File

@ -4445,6 +4445,25 @@ QString CppParser::splitPhrase(const QString &phrase, QString &sClazz,
return result;
}
static bool isIdentChar(const QChar& ch) {
return ch.isLetter()
|| ch == '_'
|| ch.isDigit();
}
static void appendArgWord(QString& args, const QString& word) {
QString s=word.trimmed();
if (s.isEmpty())
return;
if (args.isEmpty())
args.append(s);
else if (isIdentChar(args.back()) && isIdentChar(word.front()) ) {
args+=" ";
args+=s;
} else {
args+=s;
}
}
QString CppParser::removeArgNames(const QString &args)
{
QString result = "";
@ -4463,10 +4482,10 @@ QString CppParser::removeArgNames(const QString &args)
word+=args[i];
} else {
if (!typeGetted) {
currentArg += ' ' + word;
appendArgWord(currentArg,word);
} else {
if (isCppKeyword(word)) {
currentArg += ' ' + word;
appendArgWord(currentArg,word);
}
}
word = "";
@ -4491,29 +4510,45 @@ QString CppParser::removeArgNames(const QString &args)
case '\t':
if ((brackLevel >0) && !isSpaceChar(args[i-1])) {
word+=args[i];
} else if (!word.trimmed().isEmpty()) {
} else if (!word.isEmpty()) {
if (!typeGetted) {
currentArg += ' ' + word;
appendArgWord(currentArg,word);
if (mCppTypeKeywords.contains(word) || !isCppKeyword(word))
typeGetted = true;
} else {
if (isCppKeyword(word))
currentArg += ' ' + word;
appendArgWord(currentArg,word);
}
word = "";
}
break;
case '&':
case '*':
if (!word.isEmpty()) {
if (!typeGetted) {
appendArgWord(currentArg,word);
if (mCppTypeKeywords.contains(word) || !isCppKeyword(word))
typeGetted = true;
} else {
if (isCppKeyword(word))
appendArgWord(currentArg,word);
}
word = "";
}
currentArg+=args[i];
break;
default:
if (isWordChar(args[i]) || isDigitChar(args[i]))
if (isIdentChar(args[i])) {
word+=args[i];
}
}
i++;
}
if (!typeGetted) {
currentArg += ' ' + word;
appendArgWord(currentArg,word);
} else {
if (isCppKeyword(word)) {
currentArg += ' ' + word;
appendArgWord(currentArg,word);
}
}
result += currentArg.trimmed();

View File

@ -89,7 +89,7 @@ void SearchDialog::findInFiles(const QString &text)
void SearchDialog::findInFiles(const QString &keyword, SearchFileScope scope, SynSearchOptions options)
{
mTabBar->setCurrentIndex(1);
mTabBar->setCurrentIndex(2);
ui->cbFind->setCurrentText(keyword);
ui->cbFind->setFocus();