- fix: Function argument infos are not correctly parsed.

This commit is contained in:
Roy Qu 2024-02-28 10:41:03 +08:00
parent f7eacaa048
commit f763cec8f4
3 changed files with 25 additions and 11 deletions

View File

@ -11,7 +11,8 @@ Red Panda C++ Version 2.27
- enhancement: Don't force fixed-width when using non fixed-width fonts. - enhancement: Don't force fixed-width when using non fixed-width fonts.
- change: Replace non-ascii font with fallback font. - change: Replace non-ascii font with fallback font.
- enhancement: Display ascii control chars. - enhancement: Display ascii control chars.
- fix: Parser: invalidating file may break class inheritance infos. - fix: Parser: invalidating file may lost class inheritance infos.
- fix: Function argument infos are not correctly parsed.
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

@ -1460,6 +1460,7 @@ PStatement CppParser::addStatement(const PStatement &parent,
QChar ch=mTokenizer[i]->text[0]; QChar ch=mTokenizer[i]->text[0];
if (this->isIdentChar(ch)) { if (this->isIdentChar(ch)) {
QString spaces=(i>argStart)?" ":""; QString spaces=(i>argStart)?" ":"";
if (args.length()>0 && isWordChar(args.back()))
args+=spaces; args+=spaces;
word += mTokenizer[i]->text; word += mTokenizer[i]->text;
if (!typeGetted) { if (!typeGetted) {
@ -1473,12 +1474,17 @@ PStatement CppParser::addStatement(const PStatement &parent,
} }
word=""; word="";
} else if (this->isDigitChar(ch)) { } else if (this->isDigitChar(ch)) {
args+=" "; } else if (mTokenizer[i]->text=="::") {
if (braceLevel==0) {
noNameArgs+= mTokenizer[i]->text;
}
} else { } else {
switch(ch.unicode()) { switch(ch.unicode()) {
case ',': case ',':
if (braceLevel==0) if (braceLevel==0) {
typeGetted=false; typeGetted=false;
noNameArgs+= mTokenizer[i]->text;
}
break; break;
case '{': case '{':
case '[': case '[':
@ -1495,15 +1501,17 @@ PStatement CppParser::addStatement(const PStatement &parent,
//todo: * and & processing //todo: * and & processing
case '*': case '*':
case '&': case '&':
if (braceLevel==0) if (braceLevel==0) {
word+=ch; noNameArgs+= mTokenizer[i]->text;
}
break; break;
} }
noNameArgs+= mTokenizer[i]->text;
} }
args+=mTokenizer[i]->text; args+=mTokenizer[i]->text;
} }
if (!word.isEmpty()) {
noNameArgs.append(word);
}
args="("+args.trimmed()+")"; args="("+args.trimmed()+")";
noNameArgs="("+noNameArgs.trimmed()+")"; noNameArgs="("+noNameArgs.trimmed()+")";
return addStatement( return addStatement(

View File

@ -415,9 +415,14 @@ QString CppTokenizer::getNumber()
QString result; QString result;
if (offset != mCurrent) { if (offset != mCurrent) {
if (*mCurrent=='.') {
// keep '.' for decimal
mCurrent++;
while (isDigitChar(*mCurrent) || isHexChar(*mCurrent)) {
mCurrent++;
}
}
result = QString(offset,mCurrent-offset); result = QString(offset,mCurrent-offset);
if (*mCurrent=='.') // keep '.' for decimal
result += *mCurrent;
} }
return result; return result;
} }