- enhancment: Code suggestion for embedded std::vectors.

This commit is contained in:
Roy Qu 2023-10-19 19:32:08 +08:00
parent fd95b49270
commit 8fe15dab8a
3 changed files with 24 additions and 30 deletions

View File

@ -1,3 +1,6 @@
Red Panda C++ Version 2.26
- enhancment: Code suggestion for embedded std::vectors.
Red Panda C++ Version 2.25 Red Panda C++ Version 2.25
- fix: Symbol completion of '(' before selection may fail, if cursor is at the beginning of the selection. - fix: Symbol completion of '(' before selection may fail, if cursor is at the beginning of the selection.

View File

@ -4749,9 +4749,7 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName,
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command; // qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope); PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope, result->baseStatement);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
} else { } else {
result = PEvalStatement(); result = PEvalStatement();
} }
@ -4760,9 +4758,7 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName,
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command; // qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope); PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
} else { } else {
result = PEvalStatement(); result = PEvalStatement();
} }
@ -4784,9 +4780,7 @@ PEvalStatement CppParser::doEvalCCast(const QString &fileName,
// qDebug()<<"typeName"<<typeName; // qDebug()<<"typeName"<<typeName;
typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope); typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
} else { } else {
result = PEvalStatement(); result = PEvalStatement();
} }
@ -4931,9 +4925,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
if (!typeName.isEmpty()) if (!typeName.isEmpty())
typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope); typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString = typeName;
result->kind = EvalStatementKind::Variable;
lastResult = result; lastResult = result;
} else { } else {
return PEvalStatement(); return PEvalStatement();
@ -4950,9 +4942,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
if (!typeName.isEmpty()) if (!typeName.isEmpty())
typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope); typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString = typeName;
result->kind = EvalStatementKind::Variable;
lastResult = result; lastResult = result;
} else { } else {
return PEvalStatement(); return PEvalStatement();
@ -4984,9 +4974,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
typeStatement = doFindTypeDefinitionOf(fileName, typeName, typeStatement = doFindTypeDefinitionOf(fileName, typeName,
parentScope); parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
lastResult = result; lastResult = result;
} else { } else {
return PEvalStatement(); return PEvalStatement();
@ -5001,9 +4989,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
typeStatement = doFindTypeDefinitionOf(fileName, typeName, typeStatement = doFindTypeDefinitionOf(fileName, typeName,
parentScope); parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
lastResult = result; lastResult = result;
} else { } else {
return PEvalStatement(); return PEvalStatement();
@ -5037,9 +5023,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command; // qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope); PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
} else { } else {
result = PEvalStatement(); result = PEvalStatement();
} }
@ -5048,9 +5032,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command; // qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope); PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
} else { } else {
result = PEvalStatement(); result = PEvalStatement();
} }
@ -5071,9 +5053,7 @@ PEvalStatement CppParser::doEvalMemberAccess(const QString &fileName,
// qDebug()<<"typeName"<<typeName; // qDebug()<<"typeName"<<typeName;
typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope); typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) { if (typeStatement) {
result = doCreateEvalType(fileName,typeName,parentScope); result = doCreateTypedEvalVar(fileName,typeName,parentScope,result->baseStatement);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
} else { } else {
return PEvalStatement(); return PEvalStatement();
} }
@ -5512,6 +5492,15 @@ PEvalStatement CppParser::doCreateEvalType(const QString &primitiveType) const
PStatement()); PStatement());
} }
PEvalStatement CppParser::doCreateTypedEvalVar(const QString &fileName, const QString &typeName, const PStatement &parentScope, const PStatement &baseStatement) const
{
PEvalStatement result = doCreateEvalType(fileName,typeName,parentScope);
result->definitionString=typeName;
result->kind = EvalStatementKind::Variable;
result->baseStatement = baseStatement;
return result;
}
PEvalStatement CppParser::doCreateEvalVariable( PEvalStatement CppParser::doCreateEvalVariable(
const QString &fileName, const QString &fileName,
const PStatement& varStatement, const PStatement& varStatement,

View File

@ -375,6 +375,8 @@ private:
PEvalStatement doCreateEvalType(const QString& fileName,const PStatement& typeStatement) const; PEvalStatement doCreateEvalType(const QString& fileName,const PStatement& typeStatement) const;
PEvalStatement doCreateEvalType(const QString& primitiveType) const; PEvalStatement doCreateEvalType(const QString& primitiveType) const;
PEvalStatement doCreateTypedEvalVar(const QString& fileName,const QString& typeName, const PStatement& parentScope, const PStatement &baseStatement) const;
PEvalStatement doCreateEvalVariable( PEvalStatement doCreateEvalVariable(
const QString& fileName, const QString& fileName,
const PStatement& varStatement, const PStatement& varStatement,