logic: Fixed issues when indexing via CLI (issue #718)
* show proper error message in console when project configuration has issues * quit when project configuration is wrong * show indexing progress as self-updating percentage
This commit is contained in:
@@ -467,6 +467,11 @@ void Application::refreshProject(RefreshMode refreshMode)
|
||||
if (m_project && checkSharedMemory())
|
||||
{
|
||||
m_project->refresh(refreshMode, getDialogView(DialogView::UseCase::INDEXING));
|
||||
|
||||
if (!m_hasGUI && !m_project->isIndexing())
|
||||
{
|
||||
MessageQuitApplication().dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -516,8 +516,9 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
|
||||
}
|
||||
}
|
||||
|
||||
taskSequential->addTask(std::make_shared<TaskSetValue<int>>(
|
||||
"source_file_count", indexerCommandProvider->size() + customIndexerCommandProvider->size()));
|
||||
size_t sourceFileCount = indexerCommandProvider->size() + customIndexerCommandProvider->size();
|
||||
|
||||
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("source_file_count", sourceFileCount));
|
||||
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("indexed_source_file_count", 0));
|
||||
taskSequential->addTask(std::make_shared<TaskSetValue<bool>>("interrupted_indexing", false));
|
||||
taskSequential->addTask(std::make_shared<TaskSetValue<float>>("index_time", 0.0f));
|
||||
@@ -673,6 +674,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
|
||||
Task::dispatch(TabId::app(), taskSequential);
|
||||
|
||||
m_refreshStage = RefreshStageType::INDEXING;
|
||||
MessageStatus(L"Starting Indexing: " + std::to_wstring(sourceFileCount) + L" source files", false, true).dispatch();
|
||||
MessageIndexingStarted().dispatch();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,18 +26,10 @@ bool SourceGroupCxxCdb::prepareIndexing()
|
||||
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
if (!cdbPath.empty() && !cdbPath.exists())
|
||||
{
|
||||
MessageStatus(L"Can't refresh project").dispatch();
|
||||
|
||||
if (std::shared_ptr<Application> application = Application::getInstance())
|
||||
{
|
||||
if (application->hasGUI())
|
||||
{
|
||||
application->handleDialog(
|
||||
L"Can't refresh. The compilation database of the project does not exist anymore: " + cdbPath.wstr(),
|
||||
{ L"Ok" }
|
||||
);
|
||||
}
|
||||
}
|
||||
std::wstring error = L"Can't refresh project. The compilation database of the project does not exist anymore: "
|
||||
+ cdbPath.wstr();
|
||||
MessageStatus(error, true).dispatch();
|
||||
Application::getInstance()->handleDialog(error, { L"Ok" });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -19,18 +19,10 @@ bool SourceGroupCxxCodeblocks::prepareIndexing()
|
||||
FilePath codeblocksProjectPath = m_settings->getCodeblocksProjectPathExpandedAndAbsolute();
|
||||
if (!codeblocksProjectPath.empty() && !codeblocksProjectPath.exists())
|
||||
{
|
||||
MessageStatus(L"Can't refresh project").dispatch();
|
||||
|
||||
if (std::shared_ptr<Application> application = Application::getInstance())
|
||||
{
|
||||
if (application->hasGUI())
|
||||
{
|
||||
application->handleDialog(
|
||||
L"Can't refresh. The referenced Code::Blocks project does not exist anymore: " + codeblocksProjectPath.wstr(),
|
||||
{ L"Ok" }
|
||||
);
|
||||
}
|
||||
}
|
||||
std::wstring error = L"Can't refresh project. The referenced Code::Blocks project does not exist anymore: " +
|
||||
codeblocksProjectPath.wstr();
|
||||
MessageStatus(error, true).dispatch();
|
||||
Application::getInstance()->handleDialog(error, { L"Ok" });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -19,19 +19,10 @@ bool SourceGroupCxxSonargraph::prepareIndexing()
|
||||
FilePath sonargraphProjectPath = m_settings->getSonargraphProjectPathExpandedAndAbsolute();
|
||||
if (!sonargraphProjectPath.empty() && !sonargraphProjectPath.exists())
|
||||
{
|
||||
MessageStatus(L"Can't refresh project").dispatch();
|
||||
|
||||
if (std::shared_ptr<Application> application = Application::getInstance())
|
||||
{
|
||||
if (application->hasGUI())
|
||||
{
|
||||
application->handleDialog(
|
||||
L"Can't refresh. The referenced Sonargraph project does not exist anymore: " + sonargraphProjectPath.wstr(),
|
||||
{ L"Ok" }
|
||||
);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
std::wstring error = L"Can't refresh project. The referenced Sonargraph project does not exist anymore: "
|
||||
+ sonargraphProjectPath.wstr();
|
||||
MessageStatus(error, true).dispatch();
|
||||
Application::getInstance()->handleDialog(error, { L"Ok" });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,18 +7,27 @@ QtCoreApplication::QtCoreApplication(int argc, char **argv )
|
||||
{
|
||||
}
|
||||
|
||||
QtCoreApplication::~QtCoreApplication()
|
||||
{
|
||||
}
|
||||
|
||||
void QtCoreApplication::handleMessage(MessageQuitApplication* message)
|
||||
{
|
||||
std::cout << "quit" << std::endl;
|
||||
std::cout << "Quitting" << std::endl;
|
||||
emit quit();
|
||||
}
|
||||
|
||||
void QtCoreApplication::handleMessage(MessageIndexingStatus* message)
|
||||
{
|
||||
if (message->showProgress)
|
||||
{
|
||||
std::cout << message->progressPercent << "% " << '\r' << std::flush;
|
||||
}
|
||||
}
|
||||
|
||||
void QtCoreApplication::handleMessage(MessageStatus* message)
|
||||
{
|
||||
if (message->isError)
|
||||
{
|
||||
std::wcout << L"ERROR: ";
|
||||
}
|
||||
|
||||
for (const std::wstring& status : message->stati())
|
||||
{
|
||||
std::wcout << status << std::endl;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "MessageIndexingStatus.h"
|
||||
#include "MessageListener.h"
|
||||
#include "MessageQuitApplication.h"
|
||||
#include "MessageStatus.h"
|
||||
@@ -10,16 +11,18 @@
|
||||
class QtCoreApplication
|
||||
: public QCoreApplication
|
||||
, public MessageListener<MessageQuitApplication>
|
||||
, public MessageListener<MessageIndexingStatus>
|
||||
, public MessageListener<MessageStatus>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtCoreApplication(int argc, char **argv);
|
||||
virtual ~QtCoreApplication();
|
||||
virtual ~QtCoreApplication() = default;
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageQuitApplication* message);
|
||||
virtual void handleMessage(MessageIndexingStatus* message);
|
||||
virtual void handleMessage(MessageStatus* message);
|
||||
};
|
||||
|
||||
|
||||
@@ -23,18 +23,10 @@ bool SourceGroupJavaSonargraph::prepareIndexing()
|
||||
FilePath sonargraphProjectPath = m_settings->getSonargraphProjectPathExpandedAndAbsolute();
|
||||
if (!sonargraphProjectPath.empty() && !sonargraphProjectPath.exists())
|
||||
{
|
||||
MessageStatus(L"Can't refresh project. The referenced Sonargraph project does not exist anymore.").dispatch();
|
||||
|
||||
if (std::shared_ptr<Application> application = Application::getInstance())
|
||||
{
|
||||
if (application->hasGUI())
|
||||
{
|
||||
application->handleDialog(
|
||||
L"Can't refresh project. The referenced Sonargraph project does not exist anymore: " + sonargraphProjectPath.wstr(),
|
||||
{ L"Ok" }
|
||||
);
|
||||
}
|
||||
}
|
||||
std::wstring error = L"Can't refresh project. The referenced Sonargraph project does not exist anymore: "
|
||||
+ sonargraphProjectPath.wstr();
|
||||
MessageStatus(error, true).dispatch();
|
||||
Application::getInstance()->handleDialog(error, { L"Ok" });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user