From 0e5d666c67038a8e6ff8394e2e5dedf2b36a3fd3 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 8 Mar 2024 18:20:49 +0800 Subject: [PATCH] - fix: Full scope typed variables in lambda expressions is not correctly parsed. --- NEWS.md | 4 ++-- RedPandaIDE/parser/cppparser.cpp | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9f794165..b5cff84d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -41,8 +41,8 @@ Red Panda C++ Version 2.27 - fix: Using alias for global symbols are not correctly handled. - enhancement: Support "enum struct" Scoped enumerations. - fix: Function tips contains functions that not in the scope. - - fix: Hint for bold text () are not correctly handled in the function tips. - + - fix: Hint for bold text () 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 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index feea4c49..4beb3e2c 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -2953,15 +2953,25 @@ void CppParser::handleLambda(int index, int endIndex) scanMethodArgs(lambdaBlock,argStart); addSoloScopeLevel(lambdaBlock,mTokenizer[bodyStart]->line); int i=bodyStart+1; // start after '{'; - while (i+2text) + QString sType; + while (itext=="::") { + sType="::"; + i++; + } + while (i+1text) + && mTokenizer[i+1]->text=="::") { + sType+=mTokenizer[i]->text; + sType+="::"; + i+=2; + } + if (i+1text) && !mTokenizer[i]->text.endsWith('.') && !mTokenizer[i]->text.endsWith("->") && (mTokenizer[i+1]->text.startsWith('*') || mTokenizer[i+1]->text.startsWith('&') || tokenIsTypeOrNonKeyword(mTokenizer[i+1]->text))) { - QString sType; QString sName; while (i+1text==':' @@ -2973,7 +2983,7 @@ void CppParser::handleLambda(int index, int endIndex) ) break; else { - if (!sType.isEmpty()) + if (!sType.isEmpty() && !sType.endsWith("::")) sType+=' '; sType+=mTokenizer[i]->text; } @@ -3038,6 +3048,7 @@ void CppParser::handleLambda(int index, int endIndex) } } i=moveToEndOfStatement(i, true, bodyEnd); + sType=""; } removeScopeLevel(mTokenizer[bodyEnd]->line); }