- enhancement: Issue #196 Support C++ using alias in syntax highlighting/code completion/function tips.

This commit is contained in:
Roy Qu 2024-03-07 21:35:53 +08:00
parent 1283609c41
commit c742a8bb29
4 changed files with 22 additions and 10 deletions

View File

@ -36,6 +36,8 @@ Red Panda C++ Version 2.27
- enhancement: Optimization for string/raw string/char literal status check while completing symbols in c/c++ files.
- enhancement: Windows installer Hi-DPI support.
- fix: Delete/Insert in column editing mode.
- enhancement: Issue #196 Support using alias in C++ syntax highlighting/code completion/function tips.
Red Panda C++ Version 2.26

View File

@ -1253,6 +1253,8 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
filename(),
expression,
p.line);
while (statement && statement->kind == StatementKind::skAlias)
statement = mParser->findAliasedStatement(statement);
kind = getKindOfStatement(statement);
mIdentCache.insert(QString("%1 %2").arg(aChar).arg(token),kind);
}
@ -3766,6 +3768,9 @@ void Editor::completionInsert(bool appendFunc)
if (appendFunc) {
if (statement->kind == StatementKind::skAlias) {
PStatement newStatement = mParser->findAliasedStatement(statement);
while (newStatement && newStatement->kind==StatementKind::skAlias) {
newStatement = mParser->findAliasedStatement(newStatement);
}
if (newStatement)
statement = newStatement;
}
@ -4416,6 +4421,8 @@ void Editor::onExportedFormatToken(QSynedit::PSyntaxer syntaxer, int Line, int c
// qDebug()<<s;
PStatement statement = mParser->findStatementOf(mFilename,
s , p.line);
while (statement && statement->kind == StatementKind::skAlias)
statement = mParser->findAliasedStatement(statement);
StatementKind kind = getKindOfStatement(statement);
if (kind == StatementKind::skUnknown) {
if ((pEndPos.line>=1)
@ -4436,7 +4443,6 @@ void Editor::onExportedFormatToken(QSynedit::PSyntaxer syntaxer, int Line, int c
break;
case StatementKind::skClass:
case StatementKind::skTypedef:
case StatementKind::skAlias:
attr = cppSyntaxer->classAttribute();
break;
case StatementKind::skEnumClassType:

View File

@ -4525,8 +4525,8 @@ void CppParser::internalParse(const QString &fileName)
handleInheritances();
// qDebug()<<"parse"<<timer.elapsed();
#ifdef QT_DEBUG
mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
#endif
//reduce memory usage
internalClear();
@ -5360,6 +5360,9 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
if (statement && statement->kind == StatementKind::skConstructor) {
statement = statement->parentScope.lock();
}
while (statement && statement->kind == StatementKind::skAlias) {
statement = doFindAliasedStatement(statement);
}
if (statement) {
switch (statement->kind) {
case StatementKind::skNamespace:
@ -5368,12 +5371,12 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
case StatementKind::skNamespaceAlias:
result = doFindAliasedNamespace(statement);
break;
case StatementKind::skAlias: {
statement = doFindAliasedStatement(statement);
if (statement)
result = doCreateEvalType(fileName,statement);
}
break;
// case StatementKind::skAlias: {
// statement =
// if (statement)
// result = doCreateEvalType(fileName,statement);
// }
// break;
case StatementKind::skVariable:
case StatementKind::skParameter:
result = doCreateEvalVariable(fileName,statement, previousResult?previousResult->templateParams:"",scope);

View File

@ -1254,10 +1254,11 @@ QVariant CodeCompletionListModel::data(const QModelIndex &index, int role) const
PStatement statement = mStatements->at(index.row());
return statement->command;
}
case Qt::DecorationRole:
case Qt::DecorationRole:{
PStatement statement = mStatements->at(index.row());
return pIconsManager->getPixmapForStatement(statement);
}
}
return QVariant();
}