fix: enum values no correctly displayed

This commit is contained in:
royqh1979@gmail.com 2021-09-26 19:40:52 +08:00
parent 1d2357c374
commit 6ec3cfbfca
6 changed files with 38 additions and 11 deletions

View File

@ -195,6 +195,13 @@ void CompilerManager::stopCompile()
mCompiler->stopCompile();
}
void CompilerManager::stopCheckSyntax()
{
QMutexLocker locker(&mCompileMutex);
if (mBackgroundSyntaxChecker!=nullptr)
mBackgroundSyntaxChecker->stopCompile();
}
bool CompilerManager::canCompile(const QString &filename)
{
return !compiling();

View File

@ -27,6 +27,7 @@ public:
void run(const QString& filename, const QString& arguments, const QString& workDir);
void stopRun();
void stopCompile();
void stopCheckSyntax();
bool canCompile(const QString& filename);
int compileErrorCount() const;

View File

@ -173,6 +173,7 @@ MainWindow::MainWindow(QWidget *parent)
MainWindow::~MainWindow()
{
delete mEditorList;
delete ui;
}
@ -2237,8 +2238,9 @@ void MainWindow::closeEvent(QCloseEvent *event) {
if (mProject) {
closeProject(false);
}
mCompilerManager->stopCompile();
mCompilerManager->stopRun();
delete mEditorList;
event->accept();
return;
}

View File

@ -1845,7 +1845,7 @@ void CppParser::handleEnum()
cmd = mTokenizer[mIndex]->text;
args = "";
}
if (!isEnumClass) {
if (isEnumClass) {
if (enumStatement) {
addStatement(
enumStatement,
@ -1864,6 +1864,23 @@ void CppParser::handleEnum()
false);
}
} else {
if (enumStatement) {
addStatement(
enumStatement,
mCurrentFile,
lastType + "::" + mTokenizer[mIndex]->text, // override hint
lastType,
cmd,
args,
"",
//mTokenizer[mIndex]^.Line,
startLine,
StatementKind::skEnum,
getScope(),
mClassScope,
true,
false);
}
addStatement(
getCurrentScope(),
mCurrentFile,
@ -3066,8 +3083,6 @@ void CppParser::internalParse(const QString &fileName)
// mPreprocessor.dumpIncludesListTo("f:\\includes.txt");
// mStatementList.dump("f:\\stats.txt");
// mTokenizer.dumpTokens("f:\\tokens.txt");
#endif
#ifdef QT_DEBUG
// mStatementList.dumpAll("f:\\all-stats.txt");
#endif
}
@ -3411,12 +3426,12 @@ QString CppParser::splitPhrase(const QString &phrase, QString &sClazz, QString &
int firstOpStart = phrase.length() + 1;
int firstOpEnd = phrase.length() + 1;
for (int i = 0; i<phrase.length();i++) {
if ((i+1<phrase.length()) && (phrase[i] == '-') && (phrase[i + 1] == '>') && (bracketLevel=0)) {
if ((i+1<phrase.length()) && (phrase[i] == '-') && (phrase[i + 1] == '>') && (bracketLevel==0)) {
firstOpStart = i;
firstOpEnd = i+2;
sOperator = "->";
break;
} else if ((i+1<phrase.length()) && (phrase[i] == ':') && (phrase[i + 1] == ':') && (bracketLevel=0)) {
} else if ((i+1<phrase.length()) && (phrase[i] == ':') && (phrase[i + 1] == ':') && (bracketLevel==0)) {
firstOpStart = i;
firstOpEnd = i+2;
sOperator = "::";

View File

@ -153,14 +153,14 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const
case StatementKind::skTypedef:
return QIcon(":/icons/images/classparser/type.ico");
case StatementKind::skClass:
case StatementKind::skEnumClassType:
case StatementKind::skEnumType:
return QIcon(":/icons/images/classparser/class.ico");
case StatementKind::skNamespace:
case StatementKind::skNamespaceAlias:
return QIcon(":/icons/images/classparser/namespace.ico");
case StatementKind::skPreprocessor:
return QIcon(":/icons/images/classparser/define.ico");
case StatementKind::skEnumClassType:
case StatementKind::skEnumType:
case StatementKind::skEnum:
return QIcon(":/icons/images/classparser/enum.ico");
case StatementKind::skFunction:
@ -286,7 +286,9 @@ void ClassBrowserModel::addChild(ClassBrowserNode *node, PStatement statement)
// newNode->childrenFetched = false;
node->children.append(newNode.get());
mNodes.append(newNode);
filterChildren(newNode.get(), statement->children);
//don't show enum type's children values (they are displayed in parent scope)
if (statement->kind != StatementKind::skEnumType)
filterChildren(newNode.get(), statement->children);
}
void ClassBrowserModel::addMembers(const QSet<QString> &includedFiles)

View File

@ -646,8 +646,8 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin
}
//todo friend
} else if ((opType == MemberOperatorType::otDColon)
&& (statement->kind == StatementKind::skEnumType)
&& (statement->kind == StatementKind::skEnumClassType)) {
&& ((statement->kind == StatementKind::skEnumType)
|| (statement->kind == StatementKind::skEnumClassType))) {
//we can add all child enum definess
PStatement classTypeStatement = statement;
if (!isIncluded(classTypeStatement->fileName) &&