logic: error limit and better user experience (issue #385)
* only show up to 1000 errors in table and code view * click button in bottom right of error table to show all * same error order in code and table * highlight error line when switching reference in code view * improved error view performance bug id = 385
This commit is contained in:
@@ -388,9 +388,11 @@ void CodeController::handleMessage(MessageShowErrors* message)
|
||||
if (!view->showsErrors() || !message->errorId)
|
||||
{
|
||||
std::vector<ErrorInfo> errors;
|
||||
m_collection = m_storageAccess->getErrorSourceLocations(&errors);
|
||||
m_collection = m_storageAccess->getErrorSourceLocationsLimited(&errors);
|
||||
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
|
||||
|
||||
std::sort(snippets.begin(), snippets.end(), CodeSnippetParams::sortById);
|
||||
|
||||
view->clear();
|
||||
view->setErrorInfos(errors);
|
||||
view->showCodeSnippets(
|
||||
|
||||
@@ -14,19 +14,36 @@ ErrorController::~ErrorController()
|
||||
void ErrorController::handleMessage(MessageClearErrorCount* message)
|
||||
{
|
||||
clear();
|
||||
|
||||
getView()->resetErrorLimit();
|
||||
}
|
||||
|
||||
void ErrorController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
clear();
|
||||
|
||||
getView()->addErrors(m_storageAccess->getErrors(), false);
|
||||
getView()->setErrorCount(m_storageAccess->getErrorCount());
|
||||
getView()->addErrors(m_storageAccess->getErrorsLimited(), false);
|
||||
}
|
||||
|
||||
void ErrorController::handleMessage(MessageNewErrors* message)
|
||||
{
|
||||
getView()->addErrors(message->errors, true);
|
||||
getView()->showDockWidget();
|
||||
ErrorFilter filter;
|
||||
int room = message->errors.size() + filter.limit - message->errorCount.total;
|
||||
if (room > 0)
|
||||
{
|
||||
std::vector<ErrorInfo> errors = message->errors;
|
||||
if (room < int(errors.size()))
|
||||
{
|
||||
errors.resize(room);
|
||||
}
|
||||
|
||||
getView()->addErrors(message->errors, true);
|
||||
getView()->showDockWidget();
|
||||
}
|
||||
|
||||
getView()->setErrorCount(message->errorCount);
|
||||
|
||||
}
|
||||
|
||||
void ErrorController::handleMessage(MessageShowErrors* message)
|
||||
@@ -39,11 +56,13 @@ void ErrorController::handleMessage(MessageShowErrors* message)
|
||||
|
||||
clear();
|
||||
|
||||
std::vector<ErrorInfo> errors = m_storageAccess->getErrors();
|
||||
std::vector<ErrorInfo> errors = m_storageAccess->getErrorsLimited();
|
||||
if (errors.size())
|
||||
{
|
||||
getView()->showDockWidget();
|
||||
}
|
||||
|
||||
getView()->setErrorCount(message->errorCount);
|
||||
getView()->addErrors(errors, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "component/view/View.h"
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "data/ErrorInfo.h"
|
||||
|
||||
class ErrorView
|
||||
@@ -19,6 +20,9 @@ public:
|
||||
|
||||
virtual void addErrors(const std::vector<ErrorInfo>& errors, bool scrollTo) = 0;
|
||||
virtual void setErrorId(Id errorId) = 0;
|
||||
|
||||
virtual void setErrorCount(ErrorCountInfo info) = 0;
|
||||
virtual void resetErrorLimit() = 0;
|
||||
};
|
||||
|
||||
#endif // ERROR_VIEW_H
|
||||
|
||||
@@ -68,3 +68,9 @@ bool CodeSnippetParams::sort(const CodeSnippetParams& a, const CodeSnippetParams
|
||||
|
||||
return a.startLineNumber < b.startLineNumber;
|
||||
}
|
||||
|
||||
bool CodeSnippetParams::sortById(const CodeSnippetParams& a, const CodeSnippetParams& b)
|
||||
{
|
||||
return a.locationFile->getSourceLocations().begin()->get()->getLocationId() <
|
||||
b.locationFile->getSourceLocations().begin()->get()->getLocationId();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ struct CodeSnippetParams
|
||||
|
||||
// comparefunction for snippetsorting
|
||||
static bool sort(const CodeSnippetParams& a, const CodeSnippetParams& b);
|
||||
static bool sortById(const CodeSnippetParams& a, const CodeSnippetParams& b);
|
||||
|
||||
uint startLineNumber;
|
||||
uint endLineNumber;
|
||||
|
||||
@@ -11,6 +11,7 @@ struct ErrorFilter
|
||||
, fatal(true)
|
||||
, unindexedError(false)
|
||||
, unindexedFatal(true)
|
||||
, limit(1000)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,6 +33,8 @@ struct ErrorFilter
|
||||
|
||||
bool unindexedError;
|
||||
bool unindexedFatal;
|
||||
|
||||
size_t limit;
|
||||
};
|
||||
|
||||
#endif // ERROR_FILTER_H
|
||||
|
||||
@@ -417,7 +417,10 @@ void PersistentStorage::finishInjection()
|
||||
|
||||
if (m_preInjectionErrorCount != errors.size())
|
||||
{
|
||||
MessageNewErrors(std::vector<ErrorInfo>(errors.begin() + m_preInjectionErrorCount, errors.end())).dispatchImmediately();
|
||||
MessageNewErrors(
|
||||
std::vector<ErrorInfo>(errors.begin() + m_preInjectionErrorCount, errors.end()),
|
||||
getErrorCount(errors)
|
||||
).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1424,10 +1427,14 @@ StorageStats PersistentStorage::getStorageStats() const
|
||||
}
|
||||
|
||||
ErrorCountInfo PersistentStorage::getErrorCount() const
|
||||
{
|
||||
return getErrorCount(getErrors());
|
||||
}
|
||||
|
||||
ErrorCountInfo PersistentStorage::getErrorCount(const std::vector<ErrorInfo>& errors) const
|
||||
{
|
||||
ErrorCountInfo info;
|
||||
|
||||
std::vector<ErrorInfo> errors = getErrors();
|
||||
for (const ErrorInfo& error : errors)
|
||||
{
|
||||
info.total++;
|
||||
@@ -1443,21 +1450,40 @@ ErrorCountInfo PersistentStorage::getErrorCount() const
|
||||
|
||||
std::vector<ErrorInfo> PersistentStorage::getErrors() const
|
||||
{
|
||||
std::vector<ErrorInfo> errors = m_sqliteIndexStorage.getAll<StorageError>();
|
||||
std::vector<ErrorInfo> filteredErrors;
|
||||
std::vector<ErrorInfo> errors;
|
||||
|
||||
for (const ErrorInfo& error : errors)
|
||||
for (const ErrorInfo& error : m_sqliteIndexStorage.getAll<StorageError>())
|
||||
{
|
||||
if (m_errorFilter.filter(error))
|
||||
{
|
||||
filteredErrors.push_back(error);
|
||||
errors.push_back(error);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredErrors;
|
||||
return errors;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> PersistentStorage::getErrorSourceLocations(std::vector<ErrorInfo>* errors) const
|
||||
std::vector<ErrorInfo> PersistentStorage::getErrorsLimited() const
|
||||
{
|
||||
std::vector<ErrorInfo> errors;
|
||||
|
||||
for (const ErrorInfo& error : m_sqliteIndexStorage.getAll<StorageError>())
|
||||
{
|
||||
if (m_errorFilter.filter(error))
|
||||
{
|
||||
errors.push_back(error);
|
||||
}
|
||||
|
||||
if (m_errorFilter.limit > 0 && errors.size() >= m_errorFilter.limit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> PersistentStorage::getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
@@ -1482,6 +1508,11 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getErrorSourceLocat
|
||||
error.columnNumber
|
||||
);
|
||||
}
|
||||
|
||||
if (m_errorFilter.limit > 0 && errors->size() >= m_errorFilter.limit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addCompleteFlagsToSourceLocationCollection(collection.get());
|
||||
|
||||
@@ -131,9 +131,10 @@ public:
|
||||
virtual StorageStats getStorageStats() const;
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const;
|
||||
virtual ErrorCountInfo getErrorCount(const std::vector<ErrorInfo>& errors) const;
|
||||
virtual std::vector<ErrorInfo> getErrors() const;
|
||||
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(std::vector<ErrorInfo>* errors) const;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const;
|
||||
|
||||
private:
|
||||
Id getFileNodeId(const FilePath& filePath) const;
|
||||
|
||||
@@ -72,9 +72,8 @@ public:
|
||||
virtual StorageStats getStorageStats() const = 0;
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const = 0;
|
||||
virtual std::vector<ErrorInfo> getErrors() const = 0;
|
||||
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(std::vector<ErrorInfo>* errors) const = 0;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const = 0;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const = 0;
|
||||
|
||||
virtual void setErrorFilter(const ErrorFilter& filter);
|
||||
|
||||
|
||||
@@ -300,21 +300,21 @@ ErrorCountInfo StorageAccessProxy::getErrorCount() const
|
||||
return ErrorCountInfo();
|
||||
}
|
||||
|
||||
std::vector<ErrorInfo> StorageAccessProxy::getErrors() const
|
||||
std::vector<ErrorInfo> StorageAccessProxy::getErrorsLimited() const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getErrors();;
|
||||
return m_subject->getErrorsLimited();
|
||||
}
|
||||
|
||||
return std::vector<ErrorInfo>();
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> StorageAccessProxy::getErrorSourceLocations(std::vector<ErrorInfo>* errors) const
|
||||
std::shared_ptr<SourceLocationCollection> StorageAccessProxy::getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getErrorSourceLocations(errors);
|
||||
return m_subject->getErrorSourceLocationsLimited(errors);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationCollection>();
|
||||
|
||||
@@ -64,9 +64,8 @@ public:
|
||||
virtual StorageStats getStorageStats() const;
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const;
|
||||
virtual std::vector<ErrorInfo> getErrors() const;
|
||||
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocations(std::vector<ErrorInfo>* errors) const;
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const;
|
||||
|
||||
virtual Id addNodeBookmark(const NodeBookmark& bookmark);
|
||||
virtual Id addEdgeBookmark(const EdgeBookmark& bookmark);
|
||||
|
||||
@@ -3,14 +3,16 @@
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "data/ErrorInfo.h"
|
||||
|
||||
class MessageNewErrors
|
||||
: public Message<MessageNewErrors>
|
||||
{
|
||||
public:
|
||||
MessageNewErrors(const std::vector<ErrorInfo>& errors)
|
||||
MessageNewErrors(const std::vector<ErrorInfo>& errors, ErrorCountInfo errorCount)
|
||||
: errors(errors)
|
||||
, errorCount(errorCount)
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
@@ -26,6 +28,7 @@ public:
|
||||
}
|
||||
|
||||
const std::vector<ErrorInfo> errors;
|
||||
const ErrorCountInfo errorCount;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_NEW_ERRORS_H
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#ifndef MESSAGE_SHOW_ERRORS_H
|
||||
#define MESSAGE_SHOW_ERRORS_H
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
|
||||
class MessageShowErrors
|
||||
: public Message<MessageShowErrors>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user