logic: Fixed old ErrorInfos on UndoRedoStack showed non-existing errors
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -301,12 +301,7 @@ void CodeController::handleMessage(MessageShowErrors* message)
|
||||
CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION);
|
||||
view->scrollTo(scrollParams);
|
||||
|
||||
std::vector<ErrorInfo> errors = message->errors;
|
||||
if (!errors.size())
|
||||
{
|
||||
errors = m_storageAccess->getErrorsLimited();
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> errors = m_storageAccess->getErrorsLimited(message->errorIds);
|
||||
m_collection = m_storageAccess->getErrorSourceLocations(errors);
|
||||
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
|
||||
|
||||
|
||||
@@ -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<ErrorInfo> errors = message->errors;
|
||||
if (!errors.size())
|
||||
{
|
||||
errors = m_storageAccess->getErrorsLimited();
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> errors = m_storageAccess->getErrorsLimited(message->errorIds);
|
||||
if (errors.size())
|
||||
{
|
||||
getView()->showDockWidget();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ void UndoRedoController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) &&
|
||||
static_cast<MessageShowErrors*>(lastMessage())->errorId == message->errorId &&
|
||||
static_cast<MessageShowErrors*>(lastMessage())->errors.size() == message->errors.size())
|
||||
static_cast<MessageShowErrors*>(lastMessage())->errorIds.size() == message->errorIds.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,8 +85,9 @@ public:
|
||||
virtual StorageStats getStorageStats() const = 0;
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const = 0;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const = 0;
|
||||
virtual std::vector<ErrorInfo> getErrorsForFileLimited(const FilePath& filePath) const = 0;
|
||||
// returns all errors if errorIds is empty
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited(const std::vector<Id>& errorIds) const = 0;
|
||||
virtual std::vector<Id> getErrorIdsForFile(const FilePath& filePath) const = 0;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(
|
||||
const std::vector<ErrorInfo>& errors) const = 0;
|
||||
|
||||
|
||||
@@ -344,24 +344,24 @@ ErrorCountInfo StorageAccessProxy::getErrorCount() const
|
||||
return ErrorCountInfo();
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> StorageAccessProxy::getErrorsLimited() const
|
||||
std::vector<ErrorInfo> StorageAccessProxy::getErrorsLimited(const std::vector<Id>& errorIds) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getErrorsLimited();
|
||||
return m_subject->getErrorsLimited(errorIds);
|
||||
}
|
||||
|
||||
return std::vector<ErrorInfo>();
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> StorageAccessProxy::getErrorsForFileLimited(const FilePath& filePath) const
|
||||
std::vector<Id> StorageAccessProxy::getErrorIdsForFile(const FilePath& filePath) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getErrorsForFileLimited(filePath);
|
||||
return m_subject->getErrorIdsForFile(filePath);
|
||||
}
|
||||
|
||||
return std::vector<ErrorInfo>();
|
||||
return std::vector<Id>();
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> StorageAccessProxy::getErrorSourceLocations(
|
||||
|
||||
@@ -70,8 +70,8 @@ public:
|
||||
virtual StorageStats getStorageStats() const override;
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const override;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const override;
|
||||
virtual std::vector<ErrorInfo> getErrorsForFileLimited(const FilePath& filePath) const override;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited(const std::vector<Id>& errorIds) const override;
|
||||
virtual std::vector<Id> getErrorIdsForFile(const FilePath& filePath) const override;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(
|
||||
const std::vector<ErrorInfo>& errors) const override;
|
||||
|
||||
|
||||
@@ -1519,13 +1519,14 @@ std::vector<ErrorInfo> PersistentStorage::getErrors() const
|
||||
return errors;
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> PersistentStorage::getErrorsLimited() const
|
||||
std::vector<ErrorInfo> PersistentStorage::getErrorsLimited(const std::vector<Id>& errorIds) const
|
||||
{
|
||||
std::vector<ErrorInfo> errors;
|
||||
std::set<Id> ids(errorIds.begin(), errorIds.end());
|
||||
|
||||
for (const ErrorInfo& error : m_sqliteIndexStorage.getAll<StorageError>())
|
||||
{
|
||||
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<ErrorInfo> PersistentStorage::getErrorsLimited() const
|
||||
return errors;
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> PersistentStorage::getErrorsForFileLimited(const FilePath& filePath) const
|
||||
std::vector<Id> PersistentStorage::getErrorIdsForFile(const FilePath& filePath) const
|
||||
{
|
||||
std::unordered_map<Id, std::set<Id>> includingMap = getFileIdToIncludedFileIdMap();
|
||||
|
||||
@@ -1561,22 +1562,17 @@ std::vector<ErrorInfo> PersistentStorage::getErrorsForFileLimited(const FilePath
|
||||
fileIdsToProcess = nextFileIdsToProcess;
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> errors;
|
||||
std::vector<Id> errorIds;
|
||||
|
||||
for (const ErrorInfo& error : m_sqliteIndexStorage.getAll<StorageError>())
|
||||
{
|
||||
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<SourceLocationCollection> PersistentStorage::getErrorSourceLocations(
|
||||
|
||||
@@ -126,8 +126,8 @@ public:
|
||||
virtual ErrorCountInfo getErrorCount() const override;
|
||||
virtual ErrorCountInfo getErrorCount(const std::vector<ErrorInfo>& errors) const;
|
||||
virtual std::vector<ErrorInfo> getErrors() const;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const override;
|
||||
virtual std::vector<ErrorInfo> getErrorsForFileLimited(const FilePath& filePath) const override;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited(const std::vector<Id>& errorIds) const override;
|
||||
virtual std::vector<Id> getErrorIdsForFile(const FilePath& filePath) const override;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(
|
||||
const std::vector<ErrorInfo>& errors) const override;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "data/ErrorInfo.h"
|
||||
|
||||
class MessageShowErrors
|
||||
: public Message<MessageShowErrors>
|
||||
@@ -16,8 +15,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
MessageShowErrors(const std::vector<ErrorInfo>& errors)
|
||||
: errors(errors)
|
||||
MessageShowErrors(const std::vector<Id>& errorIds)
|
||||
: errorIds(errorIds)
|
||||
, errorId(0)
|
||||
{
|
||||
}
|
||||
@@ -33,7 +32,7 @@ public:
|
||||
}
|
||||
|
||||
const ErrorCountInfo errorCount;
|
||||
const std::vector<ErrorInfo> errors;
|
||||
const std::vector<Id> errorIds;
|
||||
const Id errorId;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user