From e845c7474bee35b36a16bc850c77e74188260ea9 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 29 Nov 2022 12:17:41 +0800 Subject: [PATCH] correctly deduce type for stl container iterators --- RedPandaIDE/parser/cppparser.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 50862164..412d62eb 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3689,6 +3689,15 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic) addedVar->type = aliasStatement->effectiveTypeStatement->fullName; if (!addedVar->type.endsWith(">")) addedVar->type += aliasStatement->templateParams; + if (aliasStatement->typeStatement + && STLIterators.contains(aliasStatement->typeStatement->command) + && !aliasStatement->templateParams.isEmpty()) { + PStatement parentStatement = aliasStatement->typeStatement->parentScope.lock(); + if (parentStatement + && STLContainers.contains(parentStatement->fullName)) { + addedVar->type = parentStatement->fullName+aliasStatement->templateParams+"::"+aliasStatement->typeStatement->command; + } + } } else addedVar->type = aliasStatement->baseType; if (aliasStatement->pointerLevel>0) @@ -3734,6 +3743,14 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic) addedVar->type = aliasStatement->effectiveTypeStatement->fullName; if (!addedVar->type.endsWith(">")) addedVar->type += aliasStatement->templateParams; + if (aliasStatement->typeStatement + && STLIterators.contains(aliasStatement->typeStatement->command)) { + PStatement parentStatement = aliasStatement->typeStatement->parentScope.lock(); + if (parentStatement + && STLContainers.contains(parentStatement->fullName)) { + addedVar->type = parentStatement->fullName+aliasStatement->templateParams+"::"+aliasStatement->typeStatement->command; + } + } } else addedVar->type = aliasStatement->baseType; if (aliasStatement->pointerLevel>0) @@ -4505,7 +4522,6 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName, PStatement parentStatement = result->typeStatement->parentScope.lock(); if (parentStatement && STLContainers.contains(parentStatement->fullName)) { -// result->baseType = parentStatement->fullName+previousResult->templateParams+result->typeStatement->command; result->templateParams = previousResult->templateParams; } }