- fix: Code completion info for stl::map/std::unordered_map is not correct.
This commit is contained in:
parent
b220df600b
commit
0b0e941155
1
NEWS.md
1
NEWS.md
|
@ -4,6 +4,7 @@ Red Panda C++ Version 2.18
|
|||
- enhancement: Code completion for embedded stl containers.
|
||||
- enhancement: Slightly speed up code parsing.
|
||||
- enhancement: Sort header completion infos by suffix-trimmed filename.
|
||||
- fix: Code completion info for stl::map/std::unordered_map is not correct.
|
||||
|
||||
Red Panda C++ Version 2.17
|
||||
|
||||
|
|
|
@ -399,6 +399,16 @@ PStatement CppParser::doFindStatementOf(const QString &fileName,
|
|||
lastScopeParent );
|
||||
typeStatement=doFindTypeDefinitionOf(fileName, typeName,
|
||||
lastScopeParent );
|
||||
} else if (parentScope
|
||||
&& STLMaps.contains(parentScope->fullName)
|
||||
&& STLElementMethods.contains(statement->command)
|
||||
&& lastScopeStatement) {
|
||||
isSTLContainerFunctions = true;
|
||||
PStatement lastScopeParent = lastScopeStatement->parentScope.lock();
|
||||
typeName=doFindTemplateParamOf(fileName,lastScopeStatement->type,1,
|
||||
lastScopeParent );
|
||||
typeStatement=doFindTypeDefinitionOf(fileName, typeName,
|
||||
lastScopeParent );
|
||||
}
|
||||
}
|
||||
if (!isSTLContainerFunctions)
|
||||
|
@ -420,6 +430,15 @@ PStatement CppParser::doFindStatementOf(const QString &fileName,
|
|||
parentScope);
|
||||
typeStatement = doFindTypeDefinitionOf(fileName, typeName,
|
||||
parentScope);
|
||||
} else if ((typeStatement)
|
||||
&& STLMaps.contains(typeStatement->fullName)
|
||||
&& nextScopeWord.endsWith(']')) {
|
||||
//it's a std container
|
||||
PStatement parentScope = statement->parentScope.lock();
|
||||
typeName = doFindFirstTemplateParamOf(fileName,statement->type,
|
||||
parentScope);
|
||||
typeStatement = doFindTypeDefinitionOf(fileName, typeName,
|
||||
parentScope);
|
||||
}
|
||||
lastScopeStatement = statement;
|
||||
if (typeStatement)
|
||||
|
@ -3645,11 +3664,10 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
|
|||
getCurrentScope(),
|
||||
PEvalStatement(),
|
||||
true);
|
||||
if(aliasStatement && aliasStatement->effectiveTypeStatement
|
||||
&& STLContainers.contains(aliasStatement->effectiveTypeStatement->fullName)) {
|
||||
if(aliasStatement && aliasStatement->effectiveTypeStatement) {
|
||||
if (STLMaps.contains(aliasStatement->effectiveTypeStatement->fullName)) {
|
||||
addedVar->type = "std::pair"+aliasStatement->templateParams;
|
||||
} else {
|
||||
} else if (STLContainers.contains(aliasStatement->effectiveTypeStatement->fullName)){
|
||||
QString type=doFindFirstTemplateParamOf(mCurrentFile,aliasStatement->templateParams,
|
||||
getCurrentScope());
|
||||
if (!type.isEmpty())
|
||||
|
@ -3726,6 +3744,9 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
|
|||
if (parentStatement
|
||||
&& STLContainers.contains(parentStatement->fullName)) {
|
||||
addedVar->type = parentStatement->fullName+aliasStatement->templateParams+"::"+aliasStatement->typeStatement->command;
|
||||
} else if (parentStatement
|
||||
&& STLMaps.contains(parentStatement->fullName)) {
|
||||
addedVar->type = parentStatement->fullName+aliasStatement->templateParams+"::"+aliasStatement->typeStatement->command;
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -3822,6 +3843,9 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
|
|||
if (parentStatement
|
||||
&& STLContainers.contains(parentStatement->fullName)) {
|
||||
addedVar->type = parentStatement->fullName+aliasStatement->templateParams+"::"+aliasStatement->typeStatement->command;
|
||||
} else if (parentStatement
|
||||
&& STLMaps.contains(parentStatement->fullName)) {
|
||||
addedVar->type = parentStatement->fullName+aliasStatement->templateParams+"::"+aliasStatement->typeStatement->command;
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -4259,7 +4283,19 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName,
|
|||
} else {
|
||||
result = PEvalStatement();
|
||||
}
|
||||
} else if (STLMaps.contains(parentScope->fullName)) {
|
||||
QString typeName=doFindTemplateParamOf(fileName,result->templateParams,1,parentScope);
|
||||
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
|
||||
PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
|
||||
if (typeStatement) {
|
||||
result = doCreateEvalType(fileName,typeStatement);
|
||||
result->definitionString=typeName;
|
||||
result->kind = EvalStatementKind::Variable;
|
||||
} else {
|
||||
result = PEvalStatement();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
PStatement typeStatement = result->effectiveTypeStatement;
|
||||
if ((typeStatement)
|
||||
|
@ -4409,9 +4445,9 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
|
|||
if (result->baseStatement && lastResult) {
|
||||
PStatement parentScope = result->baseStatement->parentScope.lock();
|
||||
if (parentScope
|
||||
&& STLContainers.contains(parentScope->fullName)
|
||||
&& STLElementMethods.contains(result->baseStatement->command)
|
||||
) {
|
||||
if (STLContainers.contains(parentScope->fullName)) {
|
||||
//stl container methods
|
||||
PStatement typeStatement = result->effectiveTypeStatement;
|
||||
QString typeName;
|
||||
|
@ -4419,7 +4455,26 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
|
|||
typeName = doFindFirstTemplateParamOf(fileName,lastResult->definitionString,parentScope);
|
||||
else if (lastResult->baseStatement)
|
||||
typeName = doFindFirstTemplateParamOf(fileName,lastResult->baseStatement->type, parentScope);
|
||||
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
|
||||
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
|
||||
if (!typeName.isEmpty())
|
||||
typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
|
||||
if (typeStatement) {
|
||||
result = doCreateEvalType(fileName,typeStatement);
|
||||
result->definitionString = typeName;
|
||||
result->kind = EvalStatementKind::Variable;
|
||||
lastResult = result;
|
||||
} else {
|
||||
return PEvalStatement();
|
||||
}
|
||||
} else if (STLMaps.contains(parentScope->fullName)) {
|
||||
//stl map methods
|
||||
PStatement typeStatement = result->effectiveTypeStatement;
|
||||
QString typeName;
|
||||
if (!lastResult->definitionString.isEmpty())
|
||||
typeName = doFindTemplateParamOf(fileName,lastResult->definitionString,1,parentScope);
|
||||
else if (lastResult->baseStatement)
|
||||
typeName = doFindTemplateParamOf(fileName,lastResult->baseStatement->type,1, parentScope);
|
||||
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
|
||||
if (!typeName.isEmpty())
|
||||
typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
|
||||
if (typeStatement) {
|
||||
|
@ -4432,6 +4487,8 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
result->kind = EvalStatementKind::Variable;
|
||||
} else
|
||||
result = PEvalStatement();
|
||||
|
@ -4443,9 +4500,9 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
|
|||
else {
|
||||
PStatement typeStatement = result->effectiveTypeStatement;
|
||||
if (typeStatement
|
||||
&& STLContainers.contains(typeStatement->fullName)
|
||||
&& result->kind == EvalStatementKind::Variable
|
||||
&& result->baseStatement) {
|
||||
if (STLContainers.contains(typeStatement->fullName)) {
|
||||
PStatement parentScope = result->baseStatement->parentScope.lock();
|
||||
QString typeName;
|
||||
if (!lastResult || lastResult->definitionString.isEmpty())
|
||||
|
@ -4462,6 +4519,25 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
|
|||
} else {
|
||||
return PEvalStatement();
|
||||
}
|
||||
} else if (STLMaps.contains(typeStatement->fullName)) {
|
||||
PStatement parentScope = result->baseStatement->parentScope.lock();
|
||||
QString typeName;
|
||||
if (!lastResult || lastResult->definitionString.isEmpty())
|
||||
typeName = doFindTemplateParamOf(fileName,result->baseStatement->type, 1,parentScope);
|
||||
else
|
||||
typeName = doFindTemplateParamOf(fileName,lastResult->definitionString,1,parentScope);
|
||||
typeStatement = doFindTypeDefinitionOf(fileName, typeName,
|
||||
parentScope);
|
||||
if (typeStatement) {
|
||||
result = doCreateEvalType(fileName,typeStatement);
|
||||
result->definitionString=typeName;
|
||||
result->kind = EvalStatementKind::Variable;
|
||||
lastResult = result;
|
||||
} else {
|
||||
return PEvalStatement();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return PEvalStatement();
|
||||
}
|
||||
|
@ -4690,6 +4766,9 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
|
|||
if (parentStatement
|
||||
&& STLContainers.contains(parentStatement->fullName)) {
|
||||
result->templateParams = previousResult->templateParams;
|
||||
} else if (parentStatement
|
||||
&& STLMaps.contains(parentStatement->fullName)) {
|
||||
result->templateParams = previousResult->templateParams;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,14 +257,14 @@ void initParser()
|
|||
STLContainers.insert("std::list");
|
||||
|
||||
STLContainers.insert("std::set");
|
||||
STLContainers.insert("std::map");
|
||||
STLContainers.insert("std::multilist");
|
||||
STLContainers.insert("std::multimap");
|
||||
// STLContainers.insert("std::map");
|
||||
// STLContainers.insert("std::multilist");
|
||||
// STLContainers.insert("std::multimap");
|
||||
|
||||
STLContainers.insert("std::unordered_set");
|
||||
STLContainers.insert("std::unordered_map");
|
||||
// STLContainers.insert("std::unordered_map");
|
||||
STLContainers.insert("std::unordered_multiset");
|
||||
STLContainers.insert("std::unordered_multimap");
|
||||
// STLContainers.insert("std::unordered_multimap");
|
||||
|
||||
STLContainers.insert("std::stack");
|
||||
STLContainers.insert("std::queue");
|
||||
|
|
Loading…
Reference in New Issue