From 797bf2fee5372eb9ec6e71c1c1022fd18d5c8266 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 17 Dec 2018 00:27:16 +0100 Subject: [PATCH] logic: Show error updates during custom command indexing * fixed code view showing all locations when switching view mode while showing errors --- .../component/controller/CodeController.cpp | 2 +- .../indexer/TaskExecuteCustomCommands.cpp | 11 ++++++++- .../data/indexer/TaskExecuteCustomCommands.h | 3 +++ src/lib/data/storage/PersistentStorage.cpp | 24 +++++++++++++------ src/lib/data/storage/PersistentStorage.h | 3 +++ src/lib/project/Project.cpp | 2 +- 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index fe7b1aac..470772bd 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -286,7 +286,7 @@ void CodeController::handleMessage(MessageChangeFileView* message) if (message->needsData && !message->filePath.empty()) { - showCodeSnippets(getSnippetsForFileWithState(message->filePath, state), CodeView::CodeParams()); + showCodeSnippets(getSnippetsForFileWithState(message->filePath, state), CodeView::CodeParams(), !message->showErrors); } view->setFileState(message->filePath, state); diff --git a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp index 4837612c..dbb614bd 100644 --- a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp +++ b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp @@ -7,14 +7,19 @@ #include "MessageIndexingStatus.h" #include "MessageShowStatus.h" #include "MessageStatus.h" +#include "PersistentStorage.h" #include "utility.h" #include "utilityApp.h" #include "utilityString.h" TaskExecuteCustomCommands::TaskExecuteCustomCommands( - std::unique_ptr indexerCommandProvider, std::shared_ptr dialogView, const FilePath& projectDirectory + std::unique_ptr indexerCommandProvider, + std::shared_ptr storage, + std::shared_ptr dialogView, + const FilePath& projectDirectory ) : m_indexerCommandProvider(std::move(indexerCommandProvider)) + , m_storage(storage) , m_dialogView(dialogView) , m_projectDirectory(projectDirectory) { @@ -48,9 +53,13 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr MessageIndexingStatus(true, indexedSourceFileCount * 100 / sourceFileCount).dispatch(); LOG_INFO_STREAM(<< "Execute command \"" << utility::encodeToUtf8(indexerCommand->getCustomCommand()) << "\""); + m_storage->beforeErrorRecording(); + std::wstring processOutput; int result = utility::executeProcessAndGetExitCode(indexerCommand->getCustomCommand(), {}, m_projectDirectory, -1, &processOutput); + m_storage->afterErrorRecording(); + if (processOutput.size() > 3 || result != 0) { if (result == 0) diff --git a/src/lib/data/indexer/TaskExecuteCustomCommands.h b/src/lib/data/indexer/TaskExecuteCustomCommands.h index 29afae38..c338028e 100644 --- a/src/lib/data/indexer/TaskExecuteCustomCommands.h +++ b/src/lib/data/indexer/TaskExecuteCustomCommands.h @@ -11,6 +11,7 @@ class DialogView; class IndexerCommandProvider; +class PersistentStorage; class TaskExecuteCustomCommands : public Task @@ -19,6 +20,7 @@ class TaskExecuteCustomCommands public: TaskExecuteCustomCommands( std::unique_ptr indexerCommandProvider, + std::shared_ptr storage, std::shared_ptr dialogView, const FilePath& projectDirectory); @@ -31,6 +33,7 @@ private: void handleMessage(MessageIndexingInterrupted* message) override; std::unique_ptr m_indexerCommandProvider; + std::shared_ptr m_storage; std::shared_ptr m_dialogView; const FilePath m_projectDirectory; diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index b223d157..6e7e33b8 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -195,13 +195,7 @@ const std::vector& PersistentStorage::getErrors() const void PersistentStorage::startInjection() { - m_preInjectionErrorCount = m_sqliteIndexStorage.getErrorCount(); - - if (!m_preIndexingErrorCountSet) - { - m_preIndexingErrorCount = m_preInjectionErrorCount; - m_preIndexingErrorCountSet = true; - } + beforeErrorRecording(); m_sqliteIndexStorage.beginTransaction(); } @@ -210,6 +204,22 @@ void PersistentStorage::finishInjection() { m_sqliteIndexStorage.commitTransaction(); + afterErrorRecording(); +} + +void PersistentStorage::beforeErrorRecording() +{ + m_preInjectionErrorCount = m_sqliteIndexStorage.getErrorCount(); + + if (!m_preIndexingErrorCountSet) + { + m_preIndexingErrorCount = m_preInjectionErrorCount; + m_preIndexingErrorCountSet = true; + } +} + +void PersistentStorage::afterErrorRecording() +{ std::vector errors = m_sqliteIndexStorage.getAllErrorInfos(); if (m_preInjectionErrorCount < errors.size()) { diff --git a/src/lib/data/storage/PersistentStorage.h b/src/lib/data/storage/PersistentStorage.h index 48b13215..4776ca64 100644 --- a/src/lib/data/storage/PersistentStorage.h +++ b/src/lib/data/storage/PersistentStorage.h @@ -49,6 +49,9 @@ public: void startInjection() override; void finishInjection() override; + void beforeErrorRecording(); + void afterErrorRecording(); + void setMode(const SqliteIndexStorage::StorageModeType mode); FilePath getIndexDbFilePath() const; diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index ecdfcfb8..5dfcb0a6 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -617,7 +617,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr dialogVie { taskSequential->addTask( std::make_shared( - std::move(customIndexerCommandProvider), dialogView, getProjectSettingsFilePath().getParentDirectory()) + std::move(customIndexerCommandProvider), tempStorage, dialogView, getProjectSettingsFilePath().getParentDirectory()) ); }