ui: Errorview

Tabbed view with errorview as tab
This commit is contained in:
Andreas Stallinger
2016-10-13 12:37:10 +02:00
parent 97b151371b
commit dc064e4756
82 changed files with 1641 additions and 197 deletions
+50
View File
@@ -0,0 +1,50 @@
#ifndef ERROR_FILTER_H
#define ERROR_FILTER_H
#include "data/ErrorInfo.h"
#include "data/StorageTypes.h"
struct ErrorFilter
{
ErrorFilter()
: error(true)
, fatal(true)
, unindexedError(false)
, unindexedFatal(true)
{
}
bool filter(const ErrorInfo& info) const
{
if (!error && !info.isFatal && info.isIndexed)
return false;
if (!fatal && info.isFatal && info.isIndexed)
return false;
if (!unindexedError && !info.isFatal && !info.isIndexed)
return false;
if (!unindexedFatal && info.isFatal && !info.isIndexed)
return false;
return true;
}
bool filter(const StorageError& storageError) const
{
if (!error && !storageError.fatal && storageError.indexed)
return false;
if (!fatal && storageError.fatal && storageError.indexed)
return false;
if (!unindexedError && !storageError.fatal && !storageError.indexed)
return false;
if (!unindexedFatal && storageError.fatal && !storageError.indexed)
return false;
return true;
}
bool error;
bool fatal;
bool unindexedError;
bool unindexedFatal;
};
#endif // ERROR_FILTER_H
+4 -1
View File
@@ -9,14 +9,16 @@ struct ErrorInfo
ErrorInfo()
: id(0)
, isFatal(false)
, isIndexed(false)
{
}
ErrorInfo(const std::string& message, const FilePath& filePath, Id id, bool isFatal)
ErrorInfo(const std::string& message, const FilePath& filePath, Id id, bool isFatal, bool isIndexed)
: message(message)
, filePath(filePath)
, id(id)
, isFatal(isFatal)
, isIndexed(isIndexed)
{
}
@@ -24,6 +26,7 @@ struct ErrorInfo
FilePath filePath;
Id id;
bool isFatal;
bool isIndexed;
};
#endif // ERROR_INFO_H
+1
View File
@@ -163,6 +163,7 @@ void IntermediateStorage::addCommentLocation(Id fileNodeId, uint startLine, uint
void IntermediateStorage::addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol)
{
m_errors.push_back(StorageError(
0,
message,
fatal,
indexed,
+51 -57
View File
@@ -6,6 +6,8 @@
#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"
@@ -24,7 +26,6 @@
#include "data/location/TokenLocationLine.h"
#include "data/parser/ParseLocation.h"
#include "data/type/DataType.h"
#include "settings/ApplicationSettings.h"
PersistentStorage::PersistentStorage(const FilePath& dbPath)
: m_sqliteStorage(dbPath)
@@ -217,7 +218,7 @@ void PersistentStorage::forEachError(std::function<void(const StorageError& /*da
void PersistentStorage::startInjection()
{
m_preInjectionErrorCount = getErrorCount().total;
m_preInjectionErrorCount = m_sqliteStorage.getAllErrors().size();
m_sqliteStorage.beginTransaction();
}
@@ -226,12 +227,11 @@ void PersistentStorage::finishInjection()
{
m_sqliteStorage.commitTransaction();
ErrorCountInfo errorCount = getErrorCount();
if (m_preInjectionErrorCount != errorCount.total)
auto errors = m_sqliteStorage.getAllErrors();
if (m_preInjectionErrorCount != errors.size())
{
MessageShowErrors msg(errorCount);
msg.setSendAsTask(false);
msg.dispatchImmediately();
MessageNewErrors(std::vector<StorageError>(errors.begin() + m_preInjectionErrorCount, errors.end())).dispatchImmediately();
}
}
@@ -994,33 +994,6 @@ std::shared_ptr<TokenLocationFile> PersistentStorage::getTokenLocationsForLinesI
return getTokenLocationsForFile(filePath)->getFilteredByLines(firstLineNumber, lastLineNumber);
}
std::shared_ptr<TokenLocationCollection> PersistentStorage::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
{
TRACE();
std::shared_ptr<TokenLocationCollection> errorCollection = std::make_shared<TokenLocationCollection>();
bool showExternalNonFatalErrors = ApplicationSettings::getInstance()->getShowExternalNonFatalErrors();
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
for (size_t i = 0; i < storageErrors.size(); i++)
{
const StorageError& error = storageErrors[i];
if (error.fatal || error.indexed || showExternalNonFatalErrors)
{
// Set first bit to 1 to avoid collisions
Id locationId = ~(~size_t(0) >> 1) + i;
errorCollection->addTokenLocation(
locationId, i, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber
)->setType(LOCATION_ERROR);
errors->push_back(ErrorInfo(error.message, error.filePath, i, error.fatal));
}
}
return errorCollection;
}
std::shared_ptr<TokenLocationFile> PersistentStorage::getCommentLocationsInFile(const FilePath& filePath) const
{
TRACE();
@@ -1066,29 +1039,6 @@ std::vector<FileInfo> PersistentStorage::getFileInfosForFilePaths(const std::vec
return fileInfos;
}
ErrorCountInfo PersistentStorage::getErrorCount() const
{
bool showExternalNonFatalErrors = ApplicationSettings::getInstance()->getShowExternalNonFatalErrors();
ErrorCountInfo info;
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
for (const StorageError& error : storageErrors)
{
if (error.fatal || error.indexed || showExternalNonFatalErrors)
{
info.total++;
}
if (error.fatal)
{
info.fatal++;
}
}
return info;
}
StorageStats PersistentStorage::getStorageStats() const
{
TRACE();
@@ -1104,6 +1054,50 @@ StorageStats PersistentStorage::getStorageStats() const
return stats;
}
ErrorCountInfo PersistentStorage::getErrorCount() const
{
LOG_ERROR("This should never be called.");
return ErrorCountInfo();
}
ErrorCountInfo PersistentStorage::getFilteredErrorCount() const
{
LOG_ERROR("This should never be called.");
return ErrorCountInfo();
}
std::vector<StorageError> PersistentStorage::getAllErrors() const
{
return m_sqliteStorage.getAllErrors();
}
std::vector<StorageError> PersistentStorage::getFilteredErrors() const
{
LOG_ERROR("This should never be called.");
return std::vector<StorageError>();
}
std::shared_ptr<TokenLocationCollection> PersistentStorage::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
{
TRACE();
std::shared_ptr<TokenLocationCollection> errorCollection = std::make_shared<TokenLocationCollection>();
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
for (const StorageError& error : storageErrors)
{
// 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);
errors->push_back(ErrorInfo(error.message, error.filePath, error.id, error.fatal, error.indexed));
}
return errorCollection;
}
Id PersistentStorage::getFileNodeId(const FilePath& filePath) const
{
if (filePath.empty())
+8 -2
View File
@@ -106,7 +106,6 @@ public:
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
) const;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
virtual std::shared_ptr<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const;
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const;
@@ -114,9 +113,16 @@ public:
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const;
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const;
virtual ErrorCountInfo getErrorCount() const;
virtual StorageStats getStorageStats() const;
virtual ErrorCountInfo getErrorCount() const;
virtual ErrorCountInfo getFilteredErrorCount() const;
virtual std::vector<StorageError> getAllErrors() const;
virtual std::vector<StorageError> getFilteredErrors() const;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
private:
Id getFileNodeId(const FilePath& filePath) const;
FilePath getFileNodePath(Id fileId) const;
+4 -2
View File
@@ -217,7 +217,7 @@ Id SqliteStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCo
Id SqliteStorage::addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber)
{
std::string sanitizedMessage = utility::replace((fatal ? "Fatal: " : "Error: ") + message, "'", "''");
std::string sanitizedMessage = utility::replace(message, "'", "''");
// check for duplicate
CppSQLite3Statement stmt = m_database.compileStatement((
@@ -1072,6 +1072,7 @@ std::vector<StorageError> SqliteStorage::getAll<StorageError>(const std::string&
).c_str());
std::vector<StorageError> errors;
Id id = 1;
while (!q.eof())
{
const std::string message = q.getStringField(0, "");
@@ -1083,7 +1084,8 @@ std::vector<StorageError> SqliteStorage::getAll<StorageError>(const std::string&
if (lineNumber != -1 && columnNumber != -1)
{
errors.push_back(StorageError(message, fatal, indexed, filePath, lineNumber, columnNumber));
errors.push_back(StorageError(id, message, fatal, indexed, filePath, lineNumber, columnNumber));
id++;
}
q.nextRow();
+6 -3
View File
@@ -169,7 +169,8 @@ struct StorageCommentLocation
struct StorageError
{
StorageError()
: message("")
: id(0)
, message("")
, fatal(0)
, indexed(0)
, filePath("")
@@ -177,8 +178,9 @@ struct StorageError
, columnNumber(-1)
{}
StorageError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber)
: message(message)
StorageError(Id id, const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber)
: id(id)
, message(message)
, fatal(fatal)
, indexed(indexed)
, filePath(filePath)
@@ -186,6 +188,7 @@ struct StorageError
, columnNumber(columnNumber)
{}
Id id;
std::string message;
bool fatal;
bool indexed;
+3 -1
View File
@@ -9,10 +9,12 @@
TaskFinishParsing::TaskFinishParsing(
PersistentStorage* storage,
StorageAccess* storageAccess,
std::shared_ptr<FileRegister> fileRegister,
DialogView* dialogView
)
: m_storage(storage)
, m_storageAccess(storageAccess)
, m_fileRegister(fileRegister)
, m_dialogView(dialogView)
{
@@ -59,7 +61,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
m_fileRegister->getParsedSourceFilesCount(),
m_fileRegister->getSourceFilesCount(),
time,
m_storage->getErrorCount()
m_storageAccess->getFilteredErrorCount()
);
return STATE_SUCCESS;
+3
View File
@@ -9,6 +9,7 @@
class DialogView;
class FileRegister;
class PersistentStorage;
class StorageAccess;
class TaskFinishParsing
: public Task
@@ -16,6 +17,7 @@ class TaskFinishParsing
public:
TaskFinishParsing(
PersistentStorage* storage,
StorageAccess* storageAccess,
std::shared_ptr<FileRegister> fileRegister,
DialogView* dialogView
);
@@ -29,6 +31,7 @@ private:
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
PersistentStorage* m_storage;
StorageAccess* m_storageAccess;
std::shared_ptr<FileRegister> m_fileRegister;
DialogView* m_dialogView;
};
+9 -2
View File
@@ -15,6 +15,7 @@
#include "data/ErrorCountInfo.h"
#include "data/ErrorInfo.h"
#include "data/StorageStats.h"
#include "data/StorageTypes.h"
class Graph;
class TextAccess;
@@ -59,7 +60,6 @@ public:
virtual std::shared_ptr<TokenLocationFile> getTokenLocationsForLinesInFile(
const std::string& filePath, uint firstLineNumber, uint lastLineNumber) const = 0;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const = 0;
virtual std::shared_ptr<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const = 0;
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const = 0;
@@ -67,8 +67,15 @@ public:
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const = 0;
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const = 0;
virtual ErrorCountInfo getErrorCount() const = 0;
virtual StorageStats getStorageStats() const = 0;
virtual ErrorCountInfo getErrorCount() const = 0;
virtual ErrorCountInfo getFilteredErrorCount() const = 0;
virtual std::vector<StorageError> getAllErrors() const = 0;
virtual std::vector<StorageError> getFilteredErrors() const = 0;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const = 0;
};
#endif // STORAGE_ACCESS_H
+103 -20
View File
@@ -6,6 +6,7 @@
#include "utility/logging/logging.h"
#include "utility/file/FileInfo.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/TimePoint.h"
StorageAccessProxy::StorageAccessProxy()
@@ -218,16 +219,6 @@ std::shared_ptr<TokenLocationFile> StorageAccessProxy::getTokenLocationsForLines
return std::make_shared<TokenLocationFile>("");
}
std::shared_ptr<TokenLocationCollection> StorageAccessProxy::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
{
if (hasSubject())
{
return m_subject->getErrorTokenLocations(errors);
}
return std::make_shared<TokenLocationCollection>();
}
std::shared_ptr<TokenLocationFile> StorageAccessProxy::getCommentLocationsInFile(const FilePath& filePath) const
{
if (hasSubject())
@@ -268,16 +259,6 @@ std::vector<FileInfo> StorageAccessProxy::getFileInfosForFilePaths(const std::ve
return std::vector<FileInfo>();
}
ErrorCountInfo StorageAccessProxy::getErrorCount() const
{
if (hasSubject())
{
return m_subject->getErrorCount();
}
return ErrorCountInfo();
}
StorageStats StorageAccessProxy::getStorageStats() const
{
if (hasSubject())
@@ -287,3 +268,105 @@ StorageStats StorageAccessProxy::getStorageStats() const
return StorageStats();
}
ErrorCountInfo StorageAccessProxy::getErrorCount() const
{
ErrorCountInfo info;
std::vector<StorageError> storageErrors = getAllErrors();
for (const StorageError& error : storageErrors)
{
info.total++;
if (error.fatal)
{
info.fatal++;
}
}
return info;
}
ErrorCountInfo StorageAccessProxy::getFilteredErrorCount() const
{
ErrorCountInfo info;
std::vector<StorageError> storageErrors = getAllErrors();
for (const StorageError& error : storageErrors)
{
if (!m_errorFilter.filter(error))
{
continue;
}
info.total++;
if (error.fatal)
{
info.fatal++;
}
}
return info;
}
std::vector<StorageError> StorageAccessProxy::getAllErrors() const
{
if (hasSubject())
{
return m_subject->getAllErrors();
}
return std::vector<StorageError>();
}
std::vector<StorageError> StorageAccessProxy::getFilteredErrors() const
{
std::vector<StorageError> errors = getAllErrors();
std::vector<StorageError> filteredErrors;
for (const StorageError& error : errors)
{
if (m_errorFilter.filter(error))
{
filteredErrors.push_back(error);
}
}
return filteredErrors;
}
std::shared_ptr<TokenLocationCollection> StorageAccessProxy::getErrorTokenLocations(std::vector<ErrorInfo>* errors) const
{
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 std::make_shared<TokenLocationCollection>();
}
void StorageAccessProxy::handleMessage(MessageErrorFilterChanged* message)
{
m_errorFilter = message->errorFilter;
MessageShowErrors(getFilteredErrorCount()).dispatch();
}
+21 -3
View File
@@ -3,7 +3,15 @@
#include "data/access/StorageAccess.h"
class StorageAccessProxy: public StorageAccess
#include "data/ErrorFilter.h"
#include "data/StorageTypes.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageErrorFilterChanged.h"
class StorageAccessProxy
: public StorageAccess
, public MessageListener<MessageErrorFilterChanged>
{
public:
StorageAccessProxy();
@@ -47,7 +55,6 @@ public:
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
) const;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
virtual std::shared_ptr<TokenLocationFile> getCommentLocationsInFile(const FilePath& filePath) const;
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const;
@@ -55,11 +62,22 @@ public:
virtual FileInfo getFileInfoForFilePath(const FilePath& filePath) const;
virtual std::vector<FileInfo> getFileInfosForFilePaths(const std::vector<FilePath>& filePaths) const;
virtual ErrorCountInfo getErrorCount() const;
virtual StorageStats getStorageStats() const;
virtual ErrorCountInfo getErrorCount() const;
virtual ErrorCountInfo getFilteredErrorCount() const;
virtual std::vector<StorageError> getAllErrors() const;
virtual std::vector<StorageError> getFilteredErrors() const;
virtual std::shared_ptr<TokenLocationCollection> getErrorTokenLocations(std::vector<ErrorInfo>* errors) const;
private:
void handleMessage(MessageErrorFilterChanged* message);
StorageAccess* m_subject;
ErrorFilter m_errorFilter;
};
#endif // STORAGE_ACCESS_PROXY_H
@@ -89,7 +89,7 @@ TokenLocation* TokenLocationCollection::addTokenLocation(
void TokenLocationCollection::removeTokenLocation(TokenLocation* location)
{
if (!findTokenLocationById(location->getId()))
if (!location || !findTokenLocationById(location->getId()))
{
LOG_ERROR("TokenLocation is not part of this TokenLocationCollection.");
return;
+1 -1
View File
@@ -57,7 +57,7 @@ Id ParserClientImpl::recordSymbol(
Id ParserClientImpl::recordSymbol(
const NameHierarchy& symbolName, SymbolKind symbolType,
const ParseLocation& location, const ParseLocation& scopeLocation,
const ParseLocation& location, const ParseLocation& scopeLocation,
AccessKind access, bool isImplicit
)
{