diff --git a/src/lib/component/controller/ActivationController.cpp b/src/lib/component/controller/ActivationController.cpp index 6dd4c31b..c29ecce7 100644 --- a/src/lib/component/controller/ActivationController.cpp +++ b/src/lib/component/controller/ActivationController.cpp @@ -170,7 +170,7 @@ void ActivationController::handleMessage(MessageSearch* message) void ActivationController::handleMessage(MessageShowErrorsForFile* message) { - MessageShowErrors(m_storageAccess->getErrorsForFileLimited(message->filePath)).dispatch(); + MessageShowErrors(m_storageAccess->getErrorIdsForFile(message->filePath)).dispatch(); } void ActivationController::handleMessage(MessageZoom* message) diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index 6bcb244f..e0364bf9 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -301,12 +301,7 @@ void CodeController::handleMessage(MessageShowErrors* message) CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION); view->scrollTo(scrollParams); - std::vector errors = message->errors; - if (!errors.size()) - { - errors = m_storageAccess->getErrorsLimited(); - } - + std::vector errors = m_storageAccess->getErrorsLimited(message->errorIds); m_collection = m_storageAccess->getErrorSourceLocations(errors); std::vector snippets = getSnippetsForCollection(m_collection); diff --git a/src/lib/component/controller/ErrorController.cpp b/src/lib/component/controller/ErrorController.cpp index b4da7d85..6c5e2f49 100644 --- a/src/lib/component/controller/ErrorController.cpp +++ b/src/lib/component/controller/ErrorController.cpp @@ -24,7 +24,7 @@ void ErrorController::handleMessage(MessageFinishedParsing* message) clear(); getView()->setErrorCount(m_storageAccess->getErrorCount()); - getView()->addErrors(m_storageAccess->getErrorsLimited(), false); + getView()->addErrors(m_storageAccess->getErrorsLimited({ }), false); } void ErrorController::handleMessage(MessageNewErrors* message) @@ -80,12 +80,7 @@ void ErrorController::handleMessage(MessageShowErrors* message) clear(); - std::vector errors = message->errors; - if (!errors.size()) - { - errors = m_storageAccess->getErrorsLimited(); - } - + std::vector errors = m_storageAccess->getErrorsLimited(message->errorIds); if (errors.size()) { getView()->showDockWidget(); diff --git a/src/lib/component/controller/StatusBarController.cpp b/src/lib/component/controller/StatusBarController.cpp index 4b4a2261..24ec9f6b 100644 --- a/src/lib/component/controller/StatusBarController.cpp +++ b/src/lib/component/controller/StatusBarController.cpp @@ -59,7 +59,7 @@ void StatusBarController::handleMessage(MessageRefresh* message) void StatusBarController::handleMessage(MessageShowErrors* message) { - if (message->errorId || message->errors.size() || message->isReplayed()) + if (message->errorId || message->errorIds.size() || message->isReplayed()) { return; } diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index 4d793706..3005889d 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -274,7 +274,7 @@ void UndoRedoController::handleMessage(MessageShowErrors* message) { if (sameMessageTypeAsLast(message) && static_cast(lastMessage())->errorId == message->errorId && - static_cast(lastMessage())->errors.size() == message->errors.size()) + static_cast(lastMessage())->errorIds.size() == message->errorIds.size()) { return; } diff --git a/src/lib/data/access/StorageAccess.h b/src/lib/data/access/StorageAccess.h index 99079280..3fab07b7 100644 --- a/src/lib/data/access/StorageAccess.h +++ b/src/lib/data/access/StorageAccess.h @@ -85,8 +85,9 @@ public: virtual StorageStats getStorageStats() const = 0; virtual ErrorCountInfo getErrorCount() const = 0; - virtual std::vector getErrorsLimited() const = 0; - virtual std::vector getErrorsForFileLimited(const FilePath& filePath) const = 0; + // returns all errors if errorIds is empty + virtual std::vector getErrorsLimited(const std::vector& errorIds) const = 0; + virtual std::vector getErrorIdsForFile(const FilePath& filePath) const = 0; virtual std::shared_ptr getErrorSourceLocations( const std::vector& errors) const = 0; diff --git a/src/lib/data/access/StorageAccessProxy.cpp b/src/lib/data/access/StorageAccessProxy.cpp index 218ec5bd..7da50666 100644 --- a/src/lib/data/access/StorageAccessProxy.cpp +++ b/src/lib/data/access/StorageAccessProxy.cpp @@ -344,24 +344,24 @@ ErrorCountInfo StorageAccessProxy::getErrorCount() const return ErrorCountInfo(); } -std::vector StorageAccessProxy::getErrorsLimited() const +std::vector StorageAccessProxy::getErrorsLimited(const std::vector& errorIds) const { if (hasSubject()) { - return m_subject->getErrorsLimited(); + return m_subject->getErrorsLimited(errorIds); } return std::vector(); } -std::vector StorageAccessProxy::getErrorsForFileLimited(const FilePath& filePath) const +std::vector StorageAccessProxy::getErrorIdsForFile(const FilePath& filePath) const { if (hasSubject()) { - return m_subject->getErrorsForFileLimited(filePath); + return m_subject->getErrorIdsForFile(filePath); } - return std::vector(); + return std::vector(); } std::shared_ptr StorageAccessProxy::getErrorSourceLocations( diff --git a/src/lib/data/access/StorageAccessProxy.h b/src/lib/data/access/StorageAccessProxy.h index bcb1936e..96c1edb1 100644 --- a/src/lib/data/access/StorageAccessProxy.h +++ b/src/lib/data/access/StorageAccessProxy.h @@ -70,8 +70,8 @@ public: virtual StorageStats getStorageStats() const override; virtual ErrorCountInfo getErrorCount() const override; - virtual std::vector getErrorsLimited() const override; - virtual std::vector getErrorsForFileLimited(const FilePath& filePath) const override; + virtual std::vector getErrorsLimited(const std::vector& errorIds) const override; + virtual std::vector getErrorIdsForFile(const FilePath& filePath) const override; virtual std::shared_ptr getErrorSourceLocations( const std::vector& errors) const override; diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 243bc7fb..6de9daac 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -1519,13 +1519,14 @@ std::vector PersistentStorage::getErrors() const return errors; } -std::vector PersistentStorage::getErrorsLimited() const +std::vector PersistentStorage::getErrorsLimited(const std::vector& errorIds) const { std::vector errors; + std::set ids(errorIds.begin(), errorIds.end()); for (const ErrorInfo& error : m_sqliteIndexStorage.getAll()) { - if (m_errorFilter.filter(error)) + if (m_errorFilter.filter(error) && (!ids.size() || ids.find(error.id) != ids.end())) { errors.push_back(error); @@ -1539,7 +1540,7 @@ std::vector PersistentStorage::getErrorsLimited() const return errors; } -std::vector PersistentStorage::getErrorsForFileLimited(const FilePath& filePath) const +std::vector PersistentStorage::getErrorIdsForFile(const FilePath& filePath) const { std::unordered_map> includingMap = getFileIdToIncludedFileIdMap(); @@ -1561,22 +1562,17 @@ std::vector PersistentStorage::getErrorsForFileLimited(const FilePath fileIdsToProcess = nextFileIdsToProcess; } - std::vector errors; + std::vector errorIds; for (const ErrorInfo& error : m_sqliteIndexStorage.getAll()) { if (m_errorFilter.filter(error) && filePaths.find(FilePath(error.filePath)) != filePaths.end()) { - errors.push_back(error); - - if (m_errorFilter.limit > 0 && errors.size() >= m_errorFilter.limit) - { - break; - } + errorIds.push_back(error.id); } } - return errors; + return errorIds; } std::shared_ptr PersistentStorage::getErrorSourceLocations( diff --git a/src/lib/data/storage/PersistentStorage.h b/src/lib/data/storage/PersistentStorage.h index 29008215..e0528740 100644 --- a/src/lib/data/storage/PersistentStorage.h +++ b/src/lib/data/storage/PersistentStorage.h @@ -126,8 +126,8 @@ public: virtual ErrorCountInfo getErrorCount() const override; virtual ErrorCountInfo getErrorCount(const std::vector& errors) const; virtual std::vector getErrors() const; - virtual std::vector getErrorsLimited() const override; - virtual std::vector getErrorsForFileLimited(const FilePath& filePath) const override; + virtual std::vector getErrorsLimited(const std::vector& errorIds) const override; + virtual std::vector getErrorIdsForFile(const FilePath& filePath) const override; virtual std::shared_ptr getErrorSourceLocations( const std::vector& errors) const override; diff --git a/src/lib/utility/messaging/type/MessageShowErrors.h b/src/lib/utility/messaging/type/MessageShowErrors.h index b84673ad..fbe18af9 100644 --- a/src/lib/utility/messaging/type/MessageShowErrors.h +++ b/src/lib/utility/messaging/type/MessageShowErrors.h @@ -4,7 +4,6 @@ #include "utility/messaging/Message.h" #include "data/ErrorCountInfo.h" -#include "data/ErrorInfo.h" class MessageShowErrors : public Message @@ -16,8 +15,8 @@ public: { } - MessageShowErrors(const std::vector& errors) - : errors(errors) + MessageShowErrors(const std::vector& errorIds) + : errorIds(errorIds) , errorId(0) { } @@ -33,7 +32,7 @@ public: } const ErrorCountInfo errorCount; - const std::vector errors; + const std::vector errorIds; const Id errorId; };