ui: display fatal errors

* added ErrorCountInfo to incorporate reporting of fatal errors during code analysis.
This commit is contained in:
malte_langkabel
2016-03-02 10:53:04 +01:00
parent 4425b39ea1
commit 2ebfbbf88e
21 changed files with 105 additions and 213 deletions
+20
View File
@@ -0,0 +1,20 @@
#ifndef ERROR_COUNT_INFO_H
#define ERROR_COUNT_INFO_H
struct ErrorCountInfo
{
ErrorCountInfo()
: total(0)
, fatal(0)
{}
ErrorCountInfo(int total, size_t fatal)
: total(total)
, fatal(fatal)
{}
int total;
size_t fatal;
};
#endif // ERROR_COUNT_INFO_H
+25 -3
View File
@@ -169,9 +169,9 @@ Id SqliteStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCo
return m_database.lastRowId();
}
Id SqliteStorage::addError(const std::string& message, const std::string& filePath, uint lineNumber, uint columnNumber)
Id SqliteStorage::addError(const std::string& message, bool fatal, const std::string& filePath, uint lineNumber, uint columnNumber)
{
std::string sanitizedMessage = utility::replace(message, "'", "''");
std::string sanitizedMessage = utility::replace((fatal ? "Fatal: " : "") + message, "'", "''");
// check for duplicate
CppSQLite3Query q = m_database.execQuery((
@@ -630,7 +630,29 @@ std::vector<StorageError> SqliteStorage::getAllErrors() const
{
CppSQLite3Query q = m_database.execQuery(
"SELECT message, file_path, line_number, column_number FROM error;"
);
);
std::vector<StorageError> errors;
while (!q.eof())
{
const std::string message = q.getStringField(0, "");
const std::string filePath = q.getStringField(1, "");
const uint lineNumber = q.getIntField(2, 0);
const uint columnNumber = q.getIntField(3, 0);
errors.push_back(StorageError(message, filePath, lineNumber, columnNumber));
q.nextRow();
}
return errors;
}
std::vector<StorageError> SqliteStorage::getFatalErrors() const
{
CppSQLite3Query q = m_database.execQuery(
"SELECT message, file_path, line_number, column_number FROM error WHERE message LIKE 'Fatal: %';"
);
std::vector<StorageError> errors;
while (!q.eof())
+2 -1
View File
@@ -42,7 +42,7 @@ public:
Id addComponentAccess(Id memberEdgeId, int type);
Id addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
Id addError(const std::string& message, const std::string& filePath, uint lineNumber, uint columnNumber);
Id addError(const std::string& message, bool fatal, const std::string& filePath, uint lineNumber, uint columnNumber);
void removeElement(Id id);
void removeElements(const std::vector<Id>& ids);
@@ -95,6 +95,7 @@ public:
std::vector<StorageCommentLocation> getCommentLocationsInFile(const FilePath& filePath) const;
std::vector<StorageError> getAllErrors() const;
std::vector<StorageError> getFatalErrors() const;
int getNodeCount() const;
int getEdgeCount() const;
+7 -7
View File
@@ -188,20 +188,20 @@ void Storage::finishParsingFile(const FilePath& filePath)
m_sqliteStorage.commitTransaction();
}
void Storage::onError(const ParseLocation& location, const std::string& message)
void Storage::onError(const ParseLocation& location, const std::string& message, bool fatal)
{
log("ERROR", message, location);
log(std::string(fatal ? "FATAL " : "") + "ERROR", message, location);
if (!location.isValid())
{
return;
}
size_t errorCount = getErrorCount();
size_t totalErrorCount = getErrorCount().total;
m_sqliteStorage.addError(message, location.filePath.str(), location.startLineNumber, location.startColumnNumber);
m_sqliteStorage.addError(message, fatal, location.filePath.str(), location.startLineNumber, location.startColumnNumber);
if (errorCount != getErrorCount())
if (totalErrorCount != getErrorCount().total)
{
MessageShowErrors msg(getErrorCount());
msg.setSendAsTask(false);
@@ -209,9 +209,9 @@ void Storage::onError(const ParseLocation& location, const std::string& message)
}
}
size_t Storage::getErrorCount() const
ErrorCountInfo Storage::getErrorCount() const
{
return m_sqliteStorage.getAllErrors().size();
return ErrorCountInfo(m_sqliteStorage.getAllErrors().size(), m_sqliteStorage.getFatalErrors().size());
}
Id Storage::onTypedefParsed(
+2 -2
View File
@@ -46,8 +46,8 @@ public:
virtual void startParsingFile(const FilePath& filePath);
virtual void finishParsingFile(const FilePath& filePath);
virtual void onError(const ParseLocation& location, const std::string& message);
virtual size_t getErrorCount() const;
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal);
virtual ErrorCountInfo getErrorCount() const;
virtual Id onTypedefParsed(
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access);
+4 -2
View File
@@ -1,6 +1,8 @@
#ifndef STORAGE_STATS_H
#define STORAGE_STATS_H
#include "data/ErrorCountInfo.h"
struct StorageStats
{
StorageStats()
@@ -12,7 +14,7 @@ struct StorageStats
, fileCount(0)
, fileLOCCount(0)
, sourceLocationCount(0)
, errorCount(0)
, errorCount(ErrorCountInfo())
{}
size_t nodeCount;
@@ -26,7 +28,7 @@ struct StorageStats
size_t fileLOCCount;
size_t sourceLocationCount;
size_t errorCount;
ErrorCountInfo errorCount;
};
#endif // STORAGE_STATS_H
+3 -2
View File
@@ -6,6 +6,7 @@
#include "utility/types.h"
#include "data/name/NameHierarchy.h"
#include "data/ErrorCountInfo.h"
#include "utility/file/FileInfo.h"
@@ -61,8 +62,8 @@ public:
virtual void startParsingFile(const FilePath& filePath) = 0;
virtual void finishParsingFile(const FilePath& filePath) = 0;
virtual void onError(const ParseLocation& location, const std::string& message) = 0;
virtual size_t getErrorCount() const = 0;
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal) = 0;
virtual ErrorCountInfo getErrorCount() const = 0;
virtual Id onTypedefParsed(
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access) = 0;