- fix: Full scope typed variables in lambda expressions is not correctly parsed.

This commit is contained in:
Roy Qu 2024-03-08 18:20:49 +08:00
parent ebe64b65b4
commit 0e5d666c67
2 changed files with 17 additions and 6 deletions

View File

@ -41,8 +41,8 @@ Red Panda C++ Version 2.27
- fix: Using alias for global symbols are not correctly handled. - fix: Using alias for global symbols are not correctly handled.
- enhancement: Support "enum struct" Scoped enumerations. - enhancement: Support "enum struct" Scoped enumerations.
- fix: Function tips contains functions that not in the scope. - fix: Function tips contains functions that not in the scope.
- fix: Hint for bold text (<b></b>) are not correctly handled in the function tips. - fix: Hint for bold text (<b></b>) are not correctly handled in the function tips.
- fix: Full scope typed variables in lambda expressions is 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

@ -2953,15 +2953,25 @@ void CppParser::handleLambda(int index, int endIndex)
scanMethodArgs(lambdaBlock,argStart); scanMethodArgs(lambdaBlock,argStart);
addSoloScopeLevel(lambdaBlock,mTokenizer[bodyStart]->line); addSoloScopeLevel(lambdaBlock,mTokenizer[bodyStart]->line);
int i=bodyStart+1; // start after '{'; int i=bodyStart+1; // start after '{';
while (i+2<bodyEnd) { QString sType;
if (tokenIsTypeOrNonKeyword(mTokenizer[i]->text) while (i<bodyEnd) {
if (mTokenizer[i]->text=="::") {
sType="::";
i++;
}
while (i+1<bodyEnd && tokenIsTypeOrNonKeyword(mTokenizer[i]->text)
&& mTokenizer[i+1]->text=="::") {
sType+=mTokenizer[i]->text;
sType+="::";
i+=2;
}
if (i+1<bodyEnd && tokenIsTypeOrNonKeyword(mTokenizer[i]->text)
&& !mTokenizer[i]->text.endsWith('.') && !mTokenizer[i]->text.endsWith('.')
&& !mTokenizer[i]->text.endsWith("->") && !mTokenizer[i]->text.endsWith("->")
&& (mTokenizer[i+1]->text.startsWith('*') && (mTokenizer[i+1]->text.startsWith('*')
|| mTokenizer[i+1]->text.startsWith('&') || mTokenizer[i+1]->text.startsWith('&')
|| tokenIsTypeOrNonKeyword(mTokenizer[i+1]->text))) || tokenIsTypeOrNonKeyword(mTokenizer[i+1]->text)))
{ {
QString sType;
QString sName; QString sName;
while (i+1<bodyEnd) { while (i+1<bodyEnd) {
if (mTokenizer[i+1]->text==':' if (mTokenizer[i+1]->text==':'
@ -2973,7 +2983,7 @@ void CppParser::handleLambda(int index, int endIndex)
) )
break; break;
else { else {
if (!sType.isEmpty()) if (!sType.isEmpty() && !sType.endsWith("::"))
sType+=' '; sType+=' ';
sType+=mTokenizer[i]->text; sType+=mTokenizer[i]->text;
} }
@ -3038,6 +3048,7 @@ void CppParser::handleLambda(int index, int endIndex)
} }
} }
i=moveToEndOfStatement(i, true, bodyEnd); i=moveToEndOfStatement(i, true, bodyEnd);
sType="";
} }
removeScopeLevel(mTokenizer[bodyEnd]->line); removeScopeLevel(mTokenizer[bodyEnd]->line);
} }