diff --git a/bin/test/data/log/test_log.txt b/bin/test/data/log/test_log.txt index 951a83d6..3ef756d5 100644 --- a/bin/test/data/log/test_log.txt +++ b/bin/test/data/log/test_log.txt @@ -1,189 +1,22 @@ -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml ConfigManager.cpp WARNING: value source/header_search_paths/header_search_path is not present in config. -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:1:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:1:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:1:11 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:1:13 CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:7:15 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:5:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:48 CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:7:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:3:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml CxxDeclNameResolver.cpp ERROR: could not resolve name of decl at: input.cc:4:20 -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml -Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml Token.cpp ERROR: Location Id was not referenced by this Token. Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class Edge.cpp ERROR: Nodes are not plain copies. diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 36fd8cdb..5e963946 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -158,6 +158,7 @@ add_files( data/type/ReferenceModifiedDataType.cpp data/type/ReferenceModifiedDataType.h + data/ErrorCountInfo.h data/HierarchyCache.cpp data/HierarchyCache.h data/SqliteStorage.cpp diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index c31c9a4b..78fd2dd2 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -65,12 +65,12 @@ void CodeController::handleMessage(MessageActivateAll* message) ss << "\t" + std::to_string(stats.nodeCount) + " symbols\n"; ss << "\t" + std::to_string(stats.edgeCount) + " relations\n"; ss << "\n"; - ss << "\t" + std::to_string(stats.errorCount) + " errors\n"; + ss << "\t" + std::to_string(stats.errorCount.total) + " errors (" + std::to_string(stats.errorCount.fatal) + " fatal)\n"; ss << "\n"; - if (stats.errorCount > 0) + if (stats.errorCount.total > 0) { - ss << "\tWarning: The analysis may be incomplete as long as it yields errors.\n"; + ss << "\tWarning: The analysis may be incomplete as long as it yields fatal errors.\n"; ss << "\tTry resolving them and refresh the project.\n"; ss << "\n"; } diff --git a/src/lib/component/controller/StatusBarController.cpp b/src/lib/component/controller/StatusBarController.cpp index a6ba5bf1..3fdfc676 100644 --- a/src/lib/component/controller/StatusBarController.cpp +++ b/src/lib/component/controller/StatusBarController.cpp @@ -19,7 +19,7 @@ StatusBarView* StatusBarController::getView() void StatusBarController::handleMessage(MessageClearErrorCount* message) { - getView()->setErrorCount(0); + getView()->setErrorCount(ErrorCountInfo()); } void StatusBarController::handleMessage(MessageFinishedParsing* message) @@ -29,7 +29,7 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message) void StatusBarController::handleMessage(MessageShowErrors* message) { - if (message->errorCount >= 0) + if (message->errorCount.total >= 0) { getView()->setErrorCount(message->errorCount); } diff --git a/src/lib/component/controller/helper/ActivationTranslator.cpp b/src/lib/component/controller/helper/ActivationTranslator.cpp index be90c6d3..3458a988 100644 --- a/src/lib/component/controller/helper/ActivationTranslator.cpp +++ b/src/lib/component/controller/helper/ActivationTranslator.cpp @@ -126,7 +126,7 @@ std::shared_ptr ActivationTranslator::translateMessage(co else if (match.searchType == SearchMatch::SEARCH_COMMAND && match.getFullName() == SearchMatch::getCommandName(SearchMatch::COMMAND_ERROR)) { - MessageShowErrors msg(-1); + MessageShowErrors msg(ErrorCountInfo(-1, 0)); msg.undoRedoType = message->undoRedoType; msg.dispatchImmediately(); return nullptr; diff --git a/src/lib/component/view/StatusBarView.h b/src/lib/component/view/StatusBarView.h index 7c2140c0..7a57e3ca 100644 --- a/src/lib/component/view/StatusBarView.h +++ b/src/lib/component/view/StatusBarView.h @@ -2,6 +2,7 @@ #define STATUS_BAR_VIEW_H #include "component/view/View.h" +#include "data/ErrorCountInfo.h" class StatusBarController; @@ -13,7 +14,7 @@ public: virtual std::string getName() const; virtual void showMessage(const std::string& message, bool isError, bool showLoader) = 0; - virtual void setErrorCount(size_t count) = 0; + virtual void setErrorCount(ErrorCountInfo errorCount) = 0; protected: StatusBarController* getController(); diff --git a/src/lib/data/ErrorCountInfo.h b/src/lib/data/ErrorCountInfo.h new file mode 100644 index 00000000..f9a940aa --- /dev/null +++ b/src/lib/data/ErrorCountInfo.h @@ -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 diff --git a/src/lib/data/SqliteStorage.cpp b/src/lib/data/SqliteStorage.cpp index b23ac311..21118366 100644 --- a/src/lib/data/SqliteStorage.cpp +++ b/src/lib/data/SqliteStorage.cpp @@ -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 SqliteStorage::getAllErrors() const { CppSQLite3Query q = m_database.execQuery( "SELECT message, file_path, line_number, column_number FROM error;" - ); + ); + + std::vector 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 SqliteStorage::getFatalErrors() const +{ + CppSQLite3Query q = m_database.execQuery( + "SELECT message, file_path, line_number, column_number FROM error WHERE message LIKE 'Fatal: %';" + ); std::vector errors; while (!q.eof()) diff --git a/src/lib/data/SqliteStorage.h b/src/lib/data/SqliteStorage.h index eda9bb42..eab308cb 100644 --- a/src/lib/data/SqliteStorage.h +++ b/src/lib/data/SqliteStorage.h @@ -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& ids); @@ -95,6 +95,7 @@ public: std::vector getCommentLocationsInFile(const FilePath& filePath) const; std::vector getAllErrors() const; + std::vector getFatalErrors() const; int getNodeCount() const; int getEdgeCount() const; diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index a7f49ec5..9c874e81 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -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( diff --git a/src/lib/data/Storage.h b/src/lib/data/Storage.h index d599bddb..c9000e51 100644 --- a/src/lib/data/Storage.h +++ b/src/lib/data/Storage.h @@ -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); diff --git a/src/lib/data/StorageStats.h b/src/lib/data/StorageStats.h index 2aa11035..81592759 100644 --- a/src/lib/data/StorageStats.h +++ b/src/lib/data/StorageStats.h @@ -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 diff --git a/src/lib/data/parser/ParserClient.h b/src/lib/data/parser/ParserClient.h index bdee54c0..5ab4dd6a 100644 --- a/src/lib/data/parser/ParserClient.h +++ b/src/lib/data/parser/ParserClient.h @@ -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; diff --git a/src/lib/utility/messaging/type/MessageFinishedParsing.h b/src/lib/utility/messaging/type/MessageFinishedParsing.h index 49087bc2..fd0c8fc8 100644 --- a/src/lib/utility/messaging/type/MessageFinishedParsing.h +++ b/src/lib/utility/messaging/type/MessageFinishedParsing.h @@ -4,6 +4,7 @@ #include #include +#include "data/ErrorCountInfo.h" #include "utility/messaging/Message.h" #include "utility/messaging/type/MessageStatus.h" @@ -11,7 +12,7 @@ class MessageFinishedParsing : public Message { public: - MessageFinishedParsing(size_t fileCount, size_t totalFileCount, float parseTime, size_t errorCount) + MessageFinishedParsing(size_t fileCount, size_t totalFileCount, float parseTime, ErrorCountInfo errorCount) : fileCount(fileCount) , totalFileCount(totalFileCount) , parseTime(parseTime) @@ -26,7 +27,7 @@ public: virtual void dispatch() { - MessageStatus(getStatusStr(), errorCount > 0).dispatch(); + MessageStatus(getStatusStr(), errorCount.total > 0).dispatch(); Message::dispatch(); } @@ -37,7 +38,11 @@ public: ss << "Finished analysis: "; ss << fileCount << "/" << totalFileCount << " files, "; ss << std::setprecision(2) << std::fixed << parseTime << " seconds, "; - ss << errorCount << " error(s)"; + ss << errorCount.total << " error" << (errorCount.total > 1 ? "s" : ""); + if (errorCount.fatal > 0) + { + ss << " (" << errorCount.fatal << " fatal)"; + } return ss.str(); } @@ -49,7 +54,7 @@ public: size_t fileCount; size_t totalFileCount; float parseTime; - size_t errorCount; + ErrorCountInfo errorCount; }; #endif // MESSAGE_FINISHED_PARSING_H diff --git a/src/lib/utility/messaging/type/MessageShowErrors.h b/src/lib/utility/messaging/type/MessageShowErrors.h index e06e192a..80d16bb1 100644 --- a/src/lib/utility/messaging/type/MessageShowErrors.h +++ b/src/lib/utility/messaging/type/MessageShowErrors.h @@ -1,13 +1,14 @@ #ifndef MESSAGE_SHOW_ERRORS_H #define MESSAGE_SHOW_ERRORS_H +#include "data/ErrorCountInfo.h" #include "utility/messaging/Message.h" class MessageShowErrors : public Message { public: - MessageShowErrors(int errorCount) + MessageShowErrors(ErrorCountInfo errorCount) : errorCount(errorCount) { } @@ -17,7 +18,7 @@ public: return "MessageShowErrors"; } - int errorCount; + ErrorCountInfo errorCount; }; #endif // MESSAGE_SHOW_ERRORS_H diff --git a/src/lib_gui/qt/element/QtStatusBar.cpp b/src/lib_gui/qt/element/QtStatusBar.cpp index 61f239f5..0de93913 100644 --- a/src/lib_gui/qt/element/QtStatusBar.cpp +++ b/src/lib_gui/qt/element/QtStatusBar.cpp @@ -64,11 +64,13 @@ void QtStatusBar::setText(const std::string& text, bool isError, bool showLoader m_text.setText(text.c_str()); } -void QtStatusBar::setErrorCount(size_t count) +void QtStatusBar::setErrorCount(ErrorCountInfo errorCount) { - if (count > 0) + if (errorCount.total > 0) { - m_errorButton.setText(QString::number(count) + " error(s)"); + m_errorButton.setText( + QString::number(errorCount.total) + " error" + (errorCount.total > 1 ? "s" : "") + + (errorCount.fatal > 0 ? "(" + QString::number(errorCount.fatal) + " fatal)" : "")); m_errorButton.show(); } else diff --git a/src/lib_gui/qt/element/QtStatusBar.h b/src/lib_gui/qt/element/QtStatusBar.h index edbcafeb..9b6d27c5 100644 --- a/src/lib_gui/qt/element/QtStatusBar.h +++ b/src/lib_gui/qt/element/QtStatusBar.h @@ -7,6 +7,8 @@ #include #include +#include "data/ErrorCountInfo.h" + class QtStatusBar : public QStatusBar { @@ -17,7 +19,7 @@ public: virtual ~QtStatusBar(void); void setText(const std::string& text, bool isError, bool showLoader); - void setErrorCount(size_t count); + void setErrorCount(ErrorCountInfo errorCount); private slots: void showErrors(); diff --git a/src/lib_gui/qt/view/QtStatusBarView.cpp b/src/lib_gui/qt/view/QtStatusBarView.cpp index 89e0d45d..44b3bcbd 100644 --- a/src/lib_gui/qt/view/QtStatusBarView.cpp +++ b/src/lib_gui/qt/view/QtStatusBarView.cpp @@ -40,9 +40,9 @@ void QtStatusBarView::showMessage(const std::string& message, bool isError, bool m_showMessageFunctor(message, isError, showLoader); } -void QtStatusBarView::setErrorCount(size_t count) +void QtStatusBarView::setErrorCount(ErrorCountInfo errorCount) { - m_setErrorCountFunctor(count); + m_setErrorCountFunctor(errorCount); } void QtStatusBarView::doShowMessage(const std::string& message, bool isError, bool showLoader) @@ -50,7 +50,7 @@ void QtStatusBarView::doShowMessage(const std::string& message, bool isError, bo m_widget->setText(message, isError, showLoader); } -void QtStatusBarView::doSetErrorCount(size_t count) +void QtStatusBarView::doSetErrorCount(ErrorCountInfo errorCount) { - m_widget->setErrorCount(count); + m_widget->setErrorCount(errorCount); } diff --git a/src/lib_gui/qt/view/QtStatusBarView.h b/src/lib_gui/qt/view/QtStatusBarView.h index da9ada35..8fa5ab9d 100644 --- a/src/lib_gui/qt/view/QtStatusBarView.h +++ b/src/lib_gui/qt/view/QtStatusBarView.h @@ -5,6 +5,7 @@ #include #include "component/view/StatusBarView.h" +#include "data/ErrorCountInfo.h" #include "qt/element/QtStatusBar.h" #include "qt/utility/QtThreadedFunctor.h" @@ -22,14 +23,14 @@ public: // StatusBar view implementation virtual void showMessage(const std::string& message, bool isError, bool showLoader); - virtual void setErrorCount(size_t count); + virtual void setErrorCount(ErrorCountInfo errorCount); private: void doShowMessage(const std::string& message, bool isError, bool showLoader); - void doSetErrorCount(size_t count); + void doSetErrorCount(ErrorCountInfo errorCount); QtThreadedFunctor m_showMessageFunctor; - QtThreadedFunctor m_setErrorCountFunctor; + QtThreadedFunctor m_setErrorCountFunctor; std::shared_ptr m_widget; }; diff --git a/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.cpp b/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.cpp index 9fd12146..65fcaf4f 100644 --- a/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.cpp +++ b/src/lib_parser/data/parser/cxx/CxxDiagnosticConsumer.cpp @@ -54,7 +54,7 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev return; } - if (level == clang::DiagnosticsEngine::Error || level == clang::DiagnosticsEngine::Fatal) + if (level >= clang::DiagnosticsEngine::Error) { llvm::SmallString<100> messageStr; info.FormatDiagnostic(messageStr); @@ -82,7 +82,7 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev // if (m_fileManager->hasFilePath(filePath)) if (m_fileManager) { - m_client->onError(ParseLocation(filePath, line, column), message); + m_client->onError(ParseLocation(filePath, line, column), message, (level == clang::DiagnosticsEngine::Fatal)); } } } diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index 2684b9af..55beda5e 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -2794,14 +2794,14 @@ private: { } - virtual void onError(const ParseLocation& location, const std::string& message) + virtual void onError(const ParseLocation& location, const std::string& message, bool fatal) { errors.push_back(addLocationSuffix(message, location)); } - virtual size_t getErrorCount() const + virtual ErrorCountInfo getErrorCount() const { - return 0; + return ErrorCountInfo(); } virtual Id onTypedefParsed(