From 49049b0884e5a8a8467c4c6a56677f590866cc81 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 4 May 2024 10:31:15 +0800 Subject: [PATCH] refactor: structural binding --- RedPandaIDE/parser/cppparser.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index fa8568e6..b2acfa56 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -2299,9 +2299,6 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType, int maxIndex) mIndex, isStatic, maxIndex); return; - } else if (mTokenizer[mIndex]->text.startsWith("[") && AutoTypes.contains(sType)) { - handleStructredBinding(sType,maxIndex); - return; } else if (mTokenizer[mIndex + 1]->text == '(') { #ifdef ENABLE_SDCC if (mLanguage==ParserLanguage::SDCC && mTokenizer[mIndex]->text=="__at") { @@ -2406,6 +2403,11 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType, int maxIndex) ||mTokenizer[mIndex + 1]->text == ':' ||mTokenizer[mIndex + 1]->text == '{' || mTokenizer[mIndex + 1]->text == '=') { + if (mTokenizer[mIndex]->text.startsWith("[") + && AutoTypes.contains(sType)) { + handleStructredBinding(sType,maxIndex); + return; + } handleVar(sType+" "+sName,isExtern,isStatic, maxIndex); return; } else if ( mTokenizer[mIndex + 1]->text == "::") { @@ -3958,7 +3960,7 @@ void CppParser::handleStructredBinding(const QString &sType, int maxIndex) QStringList lst = s.split(","); if (lst.length()==2) { QString firstVar = lst[0].trimmed(); - QString secondVar = lst[1].trimmed; + QString secondVar = lst[1].trimmed(); bool isConst = sType.startsWith("const"); QString suffix; if (sType.endsWith("&&")) suffix = "&&";