Skip to content

Commit c742a8b

Browse files
committed
- enhancement: Issue #196 Support C++ using alias in syntax highlighting/code completion/function tips.
1 parent 1283609 commit c742a8b

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Red Panda C++ Version 2.27
3636
- enhancement: Optimization for string/raw string/char literal status check while completing symbols in c/c++ files.
3737
- enhancement: Windows installer Hi-DPI support.
3838
- fix: Delete/Insert in column editing mode.
39+
- enhancement: Issue #196 Support using alias in C++ syntax highlighting/code completion/function tips.
40+
3941

4042

4143
Red Panda C++ Version 2.26

RedPandaIDE/editor.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,8 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
12531253
filename(),
12541254
expression,
12551255
p.line);
1256+
while (statement && statement->kind == StatementKind::skAlias)
1257+
statement = mParser->findAliasedStatement(statement);
12561258
kind = getKindOfStatement(statement);
12571259
mIdentCache.insert(QString("%1 %2").arg(aChar).arg(token),kind);
12581260
}
@@ -3766,6 +3768,9 @@ void Editor::completionInsert(bool appendFunc)
37663768
if (appendFunc) {
37673769
if (statement->kind == StatementKind::skAlias) {
37683770
PStatement newStatement = mParser->findAliasedStatement(statement);
3771+
while (newStatement && newStatement->kind==StatementKind::skAlias) {
3772+
newStatement = mParser->findAliasedStatement(newStatement);
3773+
}
37693774
if (newStatement)
37703775
statement = newStatement;
37713776
}
@@ -4416,6 +4421,8 @@ void Editor::onExportedFormatToken(QSynedit::PSyntaxer syntaxer, int Line, int c
44164421
// qDebug()<<s;
44174422
PStatement statement = mParser->findStatementOf(mFilename,
44184423
s , p.line);
4424+
while (statement && statement->kind == StatementKind::skAlias)
4425+
statement = mParser->findAliasedStatement(statement);
44194426
StatementKind kind = getKindOfStatement(statement);
44204427
if (kind == StatementKind::skUnknown) {
44214428
if ((pEndPos.line>=1)
@@ -4436,7 +4443,6 @@ void Editor::onExportedFormatToken(QSynedit::PSyntaxer syntaxer, int Line, int c
44364443
break;
44374444
case StatementKind::skClass:
44384445
case StatementKind::skTypedef:
4439-
case StatementKind::skAlias:
44404446
attr = cppSyntaxer->classAttribute();
44414447
break;
44424448
case StatementKind::skEnumClassType:

RedPandaIDE/parser/cppparser.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4525,8 +4525,8 @@ void CppParser::internalParse(const QString &fileName)
45254525
handleInheritances();
45264526
// qDebug()<<"parse"<<timer.elapsed();
45274527
#ifdef QT_DEBUG
4528-
mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
4529-
mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
4528+
// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
4529+
// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
45304530
#endif
45314531
//reduce memory usage
45324532
internalClear();
@@ -5360,6 +5360,9 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
53605360
if (statement && statement->kind == StatementKind::skConstructor) {
53615361
statement = statement->parentScope.lock();
53625362
}
5363+
while (statement && statement->kind == StatementKind::skAlias) {
5364+
statement = doFindAliasedStatement(statement);
5365+
}
53635366
if (statement) {
53645367
switch (statement->kind) {
53655368
case StatementKind::skNamespace:
@@ -5368,12 +5371,12 @@ PEvalStatement CppParser::doEvalTerm(const QString &fileName,
53685371
case StatementKind::skNamespaceAlias:
53695372
result = doFindAliasedNamespace(statement);
53705373
break;
5371-
case StatementKind::skAlias: {
5372-
statement = doFindAliasedStatement(statement);
5373-
if (statement)
5374-
result = doCreateEvalType(fileName,statement);
5375-
}
5376-
break;
5374+
// case StatementKind::skAlias: {
5375+
// statement =
5376+
// if (statement)
5377+
// result = doCreateEvalType(fileName,statement);
5378+
// }
5379+
// break;
53775380
case StatementKind::skVariable:
53785381
case StatementKind::skParameter:
53795382
result = doCreateEvalVariable(fileName,statement, previousResult?previousResult->templateParams:"",scope);

RedPandaIDE/widgets/codecompletionpopup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,10 +1254,11 @@ QVariant CodeCompletionListModel::data(const QModelIndex &index, int role) const
12541254
PStatement statement = mStatements->at(index.row());
12551255
return statement->command;
12561256
}
1257-
case Qt::DecorationRole:
1257+
case Qt::DecorationRole:{
12581258
PStatement statement = mStatements->at(index.row());
12591259
return pIconsManager->getPixmapForStatement(statement);
12601260
}
1261+
}
12611262
return QVariant();
12621263
}
12631264

0 commit comments

Comments
 (0)