From 4634c0fbbc6744fa19bdd3f91d7d9196ca4f3b23 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Sun, 26 Sep 2021 22:52:19 +0800 Subject: [PATCH] - change: continue to run / debug if there are compiling warnings (but no errors) --- NEWS.md | 1 + RedPandaIDE/compiler/compilermanager.cpp | 23 +++++++++--- RedPandaIDE/compiler/compilermanager.h | 6 ++++ RedPandaIDE/mainwindow.cpp | 45 ++++++++---------------- 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/NEWS.md b/NEWS.md index f241cd3a..c424e91b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,5 @@ Version 0.2 + - change: continue to run / debug if there are compiling warnings (but no errors) - enhancement: class browser syntax colors and icons - enhancement: function tips - enhancement: project support diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index adb2fc49..f910f363 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -222,9 +222,11 @@ void CompilerManager::onRunnerTerminated() p->deleteLater(); } -void CompilerManager::onCompileIssue(PCompileIssue) +void CompilerManager::onCompileIssue(PCompileIssue issue) { - mCompileErrorCount ++; + if (issue->type == CompileIssueType::Error) + mCompileErrorCount++; + mCompileIssueCount++; } void CompilerManager::onSyntaxCheckFinished() @@ -234,9 +236,22 @@ void CompilerManager::onSyntaxCheckFinished() mBackgroundSyntaxChecker=nullptr; } -void CompilerManager::onSyntaxCheckIssue(PCompileIssue) +void CompilerManager::onSyntaxCheckIssue(PCompileIssue issue) { - mSyntaxCheckErrorCount++; + if (issue->type == CompileIssueType::Error) + mSyntaxCheckErrorCount++; + mSyntaxCheckIssueCount++; + +} + +int CompilerManager::syntaxCheckIssueCount() const +{ + return mSyntaxCheckIssueCount; +} + +int CompilerManager::compileIssueCount() const +{ + return mCompileIssueCount; } int CompilerManager::syntaxCheckErrorCount() const diff --git a/RedPandaIDE/compiler/compilermanager.h b/RedPandaIDE/compiler/compilermanager.h index 5a01eaad..2c8ec63c 100644 --- a/RedPandaIDE/compiler/compilermanager.h +++ b/RedPandaIDE/compiler/compilermanager.h @@ -33,6 +33,10 @@ public: int syntaxCheckErrorCount() const; + int compileIssueCount() const; + + int syntaxCheckIssueCount() const; + private slots: void onRunnerTerminated(); void onCompileFinished(); @@ -43,7 +47,9 @@ private slots: private: Compiler* mCompiler; int mCompileErrorCount; + int mCompileIssueCount; int mSyntaxCheckErrorCount; + int mSyntaxCheckIssueCount; Compiler* mBackgroundSyntaxChecker; ExecutableRunner* mRunner; QMutex mCompileMutex; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 24a9e7fa..706431c4 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -293,7 +293,7 @@ void MainWindow::updateCompileActions() if (e) { FileType fileType = getFileType(e->filename()); if (fileType == FileType::CSource - || fileType == FileType::CppSource) + || fileType == FileType::CppSource || e->isNew()) editorCanCompile = true; } if (mCompilerManager->compiling() || mCompilerManager->running() || mDebugger->executing() @@ -2428,8 +2428,19 @@ void MainWindow::onCompileFinished() e->invalidate(); } - // Jump to problem location, sorted by significance - if ((mCompilerManager->compileErrorCount() > 0) && (!mCheckSyntaxInBack)) { + //run succession task if there aren't any errors + if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) { + switch (mCompileSuccessionTask->type) { + case MainWindow::CompileSuccessionTaskType::Run: + runExecutable(mCompileSuccessionTask->filename); + break; + case MainWindow::CompileSuccessionTaskType::Debug: + debug(); + break; + } + mCompileSuccessionTask.reset(); + // Jump to problem location, sorted by significance + } else if ((mCompilerManager->compileIssueCount() > 0) && (!mCheckSyntaxInBack)) { // First try to find errors for (int i=0;itableIssues->count();i++) { PCompileIssue issue = ui->tableIssues->issue(i); @@ -2454,34 +2465,6 @@ void MainWindow::onCompileFinished() emit ui->tableIssues->doubleClicked(index); } } - // Then try to find anything with a line number... -// for I := 0 to CompilerOutput.Items.Count - 1 do begin -// if not SameStr(CompilerOutput.Items[I].Caption, '') then begin -// CompilerOutput.Selected := CompilerOutput.Items[I]; -// CompilerOutput.Selected.MakeVisible(False); -// CompilerOutputDblClick(CompilerOutput); -// Exit; -// end; -// end; - - // Then try to find a resource error -// if ResourceOutput.Items.Count > 0 then begin -// ResourceOutput.Selected := ResourceOutput.Items[0]; -// ResourceOutput.Selected.MakeVisible(False); -// CompilerOutputDblClick(ResourceOutput); -// end; - } else { - if (mCompileSuccessionTask) { - switch (mCompileSuccessionTask->type) { - case MainWindow::CompileSuccessionTaskType::Run: - runExecutable(mCompileSuccessionTask->filename); - break; - case MainWindow::CompileSuccessionTaskType::Debug: - debug(); - break; - } - mCompileSuccessionTask.reset(); - } } mCheckSyntaxInBack=false; updateCompileActions();