- Enhancement: Better type induction for auto in foreach loop of maps.

This commit is contained in:
Roy Qu 2023-11-26 16:30:22 +08:00
parent 5516065fb3
commit ce678c64e8
2 changed files with 4 additions and 4 deletions

View File

@ -4113,8 +4113,8 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
// as // as
// unsigned short bAppReturnCode,reserved,fBusy,fAck // unsigned short bAppReturnCode,reserved,fBusy,fAck
if (mIndex+1<tokenCount if (mIndex+1<tokenCount
&& isIdentifier(mTokenizer[mIndex+1]->text) && isIdentChar(mTokenizer[mIndex+1]->text.front())
&& isIdentChar(mTokenizer[mIndex+1]->text.back()) && (isIdentChar(mTokenizer[mIndex+1]->text.back()) || isDigitChar(mTokenizer[mIndex+1]->text.back()))
&& addedVar && addedVar
&& !(addedVar->properties & StatementProperty::spFunctionPointer) && !(addedVar->properties & StatementProperty::spFunctionPointer)
&& AutoTypes.contains(addedVar->type)) { && AutoTypes.contains(addedVar->type)) {
@ -5875,6 +5875,7 @@ PStatement CppParser::doParseEvalTypeInfo(
} else if (token == ">") { } else if (token == ">") {
templateLevel--; templateLevel--;
} }
baseType += token;
} }
syntaxer.next(); syntaxer.next();
} }

View File

@ -781,8 +781,7 @@ void CodeCompletionPopup::getCompletionFor(
if (!classTypeStatement) if (!classTypeStatement)
return; return;
} else if (STLMaps.contains(parentScope->fullName)) { } else if (STLMaps.contains(parentScope->fullName)) {
QString typeName=mParser->findTemplateParamOf(fileName,ownerStatement->templateParams,1,parentScope); QString typeName="std::pair";
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
classTypeStatement=mParser->findTypeDefinitionOf(fileName, typeName,parentScope); classTypeStatement=mParser->findTypeDefinitionOf(fileName, typeName,parentScope);
if (!classTypeStatement) if (!classTypeStatement)
return; return;