logic: Fixes in error management
* Moved error filtering to PersistentStorage * Fixed wrong error count in statusbar and dialog sometimes * Make sure error tab is visible when showing Log View * Don't show error view when no visible errors are added
This commit is contained in:
@@ -20,7 +20,7 @@ void ErrorController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
clear();
|
||||
|
||||
getView()->addErrors(m_storageAccess->getAllErrors(), false);
|
||||
getView()->addErrors(m_storageAccess->getErrors(), false);
|
||||
}
|
||||
|
||||
void ErrorController::handleMessage(MessageNewErrors* message)
|
||||
@@ -42,8 +42,13 @@ void ErrorController::handleMessage(MessageShowErrors* message)
|
||||
|
||||
clear();
|
||||
|
||||
getView()->addErrors(m_storageAccess->getAllErrors(), false);
|
||||
getView()->showDockWidget();
|
||||
std::vector<ErrorInfo> errors = m_storageAccess->getErrors();
|
||||
getView()->addErrors(errors, false);
|
||||
|
||||
if (errors.size())
|
||||
{
|
||||
getView()->showDockWidget();
|
||||
}
|
||||
}
|
||||
|
||||
ErrorView* ErrorController::getView() const
|
||||
|
||||
@@ -42,7 +42,7 @@ void StatusBarController::handleMessage(MessageRefresh* message)
|
||||
|
||||
void StatusBarController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (message->errorId)
|
||||
if (message->errorId || message->isReplayed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ void TabbedView::removeView(View* view)
|
||||
|
||||
void TabbedView::showView(View* view)
|
||||
{
|
||||
getViewLayout()->showView(view);
|
||||
getViewLayout()->showView(this);
|
||||
}
|
||||
|
||||
void TabbedView::hideView(View* view)
|
||||
{
|
||||
getViewLayout()->hideView(view);
|
||||
getViewLayout()->hideView(this);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
#include "utility/Cache.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageClearErrorCount.h"
|
||||
#include "utility/messaging/type/MessageNewErrors.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/TimePoint.h"
|
||||
@@ -234,7 +232,7 @@ void PersistentStorage::forEachError(std::function<void(const StorageError& /*da
|
||||
|
||||
void PersistentStorage::startInjection()
|
||||
{
|
||||
m_preInjectionErrorCount = m_sqliteStorage.getAllErrors().size();
|
||||
m_preInjectionErrorCount = getErrors().size();
|
||||
|
||||
m_sqliteStorage.beginTransaction();
|
||||
}
|
||||
@@ -243,7 +241,7 @@ void PersistentStorage::finishInjection()
|
||||
{
|
||||
m_sqliteStorage.commitTransaction();
|
||||
|
||||
auto errors = m_sqliteStorage.getAllErrors();
|
||||
auto errors = getErrors();
|
||||
|
||||
if (m_preInjectionErrorCount != errors.size())
|
||||
{
|
||||
@@ -1052,19 +1050,36 @@ StorageStats PersistentStorage::getStorageStats() const
|
||||
|
||||
ErrorCountInfo PersistentStorage::getErrorCount() const
|
||||
{
|
||||
LOG_ERROR("This should never be called.");
|
||||
return ErrorCountInfo();
|
||||
ErrorCountInfo info;
|
||||
|
||||
std::vector<ErrorInfo> errors = getErrors();
|
||||
for (const ErrorInfo& error : errors)
|
||||
{
|
||||
info.total++;
|
||||
|
||||
if (error.fatal)
|
||||
{
|
||||
info.fatal++;
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> PersistentStorage::getErrors() const
|
||||
{
|
||||
LOG_ERROR("This should never be called.");
|
||||
return std::vector<ErrorInfo>();
|
||||
}
|
||||
std::vector<ErrorInfo> errors = m_sqliteStorage.getAllErrors();
|
||||
std::vector<ErrorInfo> filteredErrors;
|
||||
|
||||
std::vector<ErrorInfo> PersistentStorage::getAllErrors() const
|
||||
{
|
||||
return m_sqliteStorage.getAllErrors();
|
||||
for (const ErrorInfo& error : errors)
|
||||
{
|
||||
if (m_errorFilter.filter(error))
|
||||
{
|
||||
filteredErrors.push_back(error);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredErrors;
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> PersistentStorage::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
|
||||
@@ -1072,16 +1087,19 @@ std::shared_ptr<TokenLocationCollection> PersistentStorage::getErrorTokenLocatio
|
||||
TRACE();
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> errorCollection = std::make_shared<TokenLocationCollection>();
|
||||
|
||||
*errors = m_sqliteStorage.getAllErrors();
|
||||
for (const ErrorInfo& error : *errors)
|
||||
for (const ErrorInfo& error : m_sqliteStorage.getAllErrors())
|
||||
{
|
||||
// Set first bit to 1 to avoid collisions
|
||||
Id locationId = ~(~size_t(0) >> 1) + error.id;
|
||||
if (m_errorFilter.filter(error))
|
||||
{
|
||||
errors->push_back(error);
|
||||
|
||||
errorCollection->addTokenLocation(
|
||||
locationId, error.id, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber
|
||||
)->setType(LOCATION_ERROR);
|
||||
// Set first bit to 1 to avoid collisions
|
||||
Id locationId = ~(~size_t(0) >> 1) + error.id;
|
||||
|
||||
errorCollection->addTokenLocation(
|
||||
locationId, error.id, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber
|
||||
)->setType(LOCATION_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return errorCollection;
|
||||
|
||||
@@ -119,7 +119,6 @@ public:
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const;
|
||||
virtual std::vector<ErrorInfo> getErrors() const;
|
||||
virtual std::vector<ErrorInfo> getAllErrors() const;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
|
||||
|
||||
|
||||
@@ -3,3 +3,8 @@
|
||||
StorageAccess::~StorageAccess()
|
||||
{
|
||||
}
|
||||
|
||||
void StorageAccess::setErrorFilter(const ErrorFilter& filter)
|
||||
{
|
||||
m_errorFilter = filter;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/search/SearchMatch.h"
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "data/ErrorFilter.h"
|
||||
#include "data/ErrorInfo.h"
|
||||
#include "data/StorageStats.h"
|
||||
|
||||
@@ -70,9 +71,13 @@ public:
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const = 0;
|
||||
virtual std::vector<ErrorInfo> getErrors() const = 0;
|
||||
virtual std::vector<ErrorInfo> getAllErrors() const = 0;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const = 0;
|
||||
|
||||
virtual void setErrorFilter(const ErrorFilter& filter);
|
||||
|
||||
protected:
|
||||
ErrorFilter m_errorFilter;
|
||||
};
|
||||
|
||||
#endif // STORAGE_ACCESS_H
|
||||
|
||||
@@ -32,6 +32,8 @@ bool StorageAccessProxy::hasSubject() const
|
||||
void StorageAccessProxy::setSubject(StorageAccess* subject)
|
||||
{
|
||||
m_subject = subject;
|
||||
|
||||
setErrorFilter(m_errorFilter);
|
||||
}
|
||||
|
||||
Id StorageAccessProxy::getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const
|
||||
@@ -272,48 +274,19 @@ StorageStats StorageAccessProxy::getStorageStats() const
|
||||
|
||||
ErrorCountInfo StorageAccessProxy::getErrorCount() const
|
||||
{
|
||||
ErrorCountInfo info;
|
||||
|
||||
std::vector<ErrorInfo> errors = getErrors();
|
||||
for (const ErrorInfo& error : errors)
|
||||
if (hasSubject())
|
||||
{
|
||||
info.total++;
|
||||
|
||||
if (error.fatal)
|
||||
{
|
||||
info.fatal++;
|
||||
}
|
||||
return m_subject->getErrorCount();
|
||||
}
|
||||
|
||||
return info;
|
||||
return ErrorCountInfo();
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> StorageAccessProxy::getErrors() const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
std::vector<ErrorInfo> errors = m_subject->getAllErrors();;
|
||||
std::vector<ErrorInfo> filteredErrors;
|
||||
|
||||
for (const ErrorInfo& error : errors)
|
||||
{
|
||||
if (m_errorFilter.filter(error))
|
||||
{
|
||||
filteredErrors.push_back(error);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredErrors;
|
||||
}
|
||||
|
||||
return std::vector<ErrorInfo>();
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> StorageAccessProxy::getAllErrors() const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getAllErrors();
|
||||
return m_subject->getErrors();;
|
||||
}
|
||||
|
||||
return std::vector<ErrorInfo>();
|
||||
@@ -323,32 +296,25 @@ std::shared_ptr<TokenLocationCollection> StorageAccessProxy::getErrorTokenLocati
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
std::shared_ptr<TokenLocationCollection> collection = m_subject->getErrorTokenLocations(errors);
|
||||
std::vector<ErrorInfo> unfilteredErrors = *errors;
|
||||
errors->clear();
|
||||
|
||||
for (const ErrorInfo& error : unfilteredErrors)
|
||||
{
|
||||
if (m_errorFilter.filter(error))
|
||||
{
|
||||
errors->push_back(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set first bit to 1 to avoid collisions
|
||||
Id locationId = ~(~size_t(0) >> 1) + error.id;
|
||||
collection->removeTokenLocation(collection->findTokenLocationById(locationId));
|
||||
}
|
||||
}
|
||||
|
||||
return collection;
|
||||
return m_subject->getErrorTokenLocations(errors);
|
||||
}
|
||||
|
||||
return std::make_shared<TokenLocationCollection>();
|
||||
}
|
||||
|
||||
void StorageAccessProxy::setErrorFilter(const ErrorFilter& filter)
|
||||
{
|
||||
StorageAccess::setErrorFilter(filter);
|
||||
|
||||
if (hasSubject())
|
||||
{
|
||||
m_subject->setErrorFilter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
void StorageAccessProxy::handleMessage(MessageErrorFilterChanged* message)
|
||||
{
|
||||
m_errorFilter = message->errorFilter;
|
||||
setErrorFilter(message->errorFilter);
|
||||
|
||||
MessageShowErrors(getErrorCount()).dispatch();
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#include "data/access/StorageAccess.h"
|
||||
|
||||
#include "data/ErrorFilter.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageErrorFilterChanged.h"
|
||||
|
||||
@@ -65,16 +63,16 @@ public:
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const;
|
||||
virtual std::vector<ErrorInfo> getErrors() const;
|
||||
virtual std::vector<ErrorInfo> getAllErrors() const;
|
||||
|
||||
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
|
||||
|
||||
protected:
|
||||
virtual void setErrorFilter(const ErrorFilter& filter);
|
||||
|
||||
private:
|
||||
void handleMessage(MessageErrorFilterChanged* message);
|
||||
|
||||
StorageAccess* m_subject;
|
||||
|
||||
ErrorFilter m_errorFilter;
|
||||
};
|
||||
|
||||
#endif // STORAGE_ACCESS_PROXY_H
|
||||
|
||||
@@ -224,6 +224,11 @@ void QtDialogView::handleMessage(MessageNewErrors* message)
|
||||
|
||||
void QtDialogView::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (message->isReplayed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorCountInfo errorInfo = message->errorCount;
|
||||
|
||||
m_onQtThread2(
|
||||
|
||||
@@ -56,6 +56,13 @@ void QtTabbedView::addViewWidget(View* view)
|
||||
doRefreshView();
|
||||
}
|
||||
|
||||
void QtTabbedView::showView(View* view)
|
||||
{
|
||||
TabbedView::showView(view);
|
||||
|
||||
m_widget->setCurrentWidget(QtViewWidgetWrapper::getWidgetOfView(view));
|
||||
}
|
||||
|
||||
void QtTabbedView::setStyleSheet()
|
||||
{
|
||||
utility::setWidgetBackgroundColor(QtViewWidgetWrapper::getWidgetOfView(this), ColorScheme::getInstance()->getColor("tab/background"));
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
|
||||
// TabbedView implementation
|
||||
virtual void addViewWidget(View* view);
|
||||
virtual void showView(View* view);
|
||||
|
||||
private:
|
||||
void setStyleSheet();
|
||||
|
||||
Reference in New Issue
Block a user