logic: Hide non-fatal errors in unindexed files

* added database field indexed to error to tell if the error occured within an indexed file
* added checkbox to Preferences for showing them
This commit is contained in:
Eberhard Graether
2016-07-20 12:24:46 +02:00
parent f93b31a942
commit ad3f7ede2f
26 changed files with 122 additions and 47 deletions
@@ -30,6 +30,7 @@
<font_size_min><!-- INTEGER: minimum font size in pt --></font_size_min> <font_size_min><!-- INTEGER: minimum font size in pt --></font_size_min>
<font_size_std><!-- INTEGER: standard font size in pt --></font_size_std> <font_size_std><!-- INTEGER: standard font size in pt --></font_size_std>
<indexer_thread_count><!-- INTEGER: number of threads indexing the source code --></indexer_thread_count> <indexer_thread_count><!-- INTEGER: number of threads indexing the source code --></indexer_thread_count>
<show_external_non_fatal_errors><!-- BOOL: show non-fatal errors in unindexed files --></show_external_non_fatal_errors>
<window_base_width><!-- INTEGER: initial width of an overlay window --></window_base_width> <window_base_width><!-- INTEGER: initial width of an overlay window --></window_base_width>
<window_base_height><!-- INTEGER: initial height of an overlay window --></window_base_height> <window_base_height><!-- INTEGER: initial height of an overlay window --></window_base_height>
</application> </application>
@@ -131,7 +131,7 @@ void FeatureController::handleMessage(MessageSearch* message)
case SearchMatch::COMMAND_ERROR: case SearchMatch::COMMAND_ERROR:
{ {
MessageShowErrors msg(ErrorCountInfo(-1, 0)); MessageShowErrors msg(m_storageAccess->getErrorCount());
msg.setIsReplayed(message->isReplayed()); msg.setIsReplayed(message->isReplayed());
msg.dispatchImmediately(); msg.dispatchImmediately();
return; return;
@@ -43,12 +43,14 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message)
MessageStatus(status, false).dispatch(); MessageStatus(status, false).dispatch();
} }
void StatusBarController::handleMessage(MessageRefresh* message)
{
getView()->setErrorCount(m_storageAccess->getErrorCount());
}
void StatusBarController::handleMessage(MessageShowErrors* message) void StatusBarController::handleMessage(MessageShowErrors* message)
{ {
if (message->errorCount.total >= 0) getView()->setErrorCount(message->errorCount);
{
getView()->setErrorCount(message->errorCount);
}
} }
void StatusBarController::handleMessage(MessageStatus* message) void StatusBarController::handleMessage(MessageStatus* message)
@@ -8,6 +8,7 @@
#include "utility/messaging/MessageListener.h" #include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageClearErrorCount.h" #include "utility/messaging/type/MessageClearErrorCount.h"
#include "utility/messaging/type/MessageFinishedParsing.h" #include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageShowErrors.h" #include "utility/messaging/type/MessageShowErrors.h"
#include "utility/messaging/type/MessageStatus.h" #include "utility/messaging/type/MessageStatus.h"
@@ -18,6 +19,7 @@ class StatusBarController
: public Controller : public Controller
, public MessageListener<MessageClearErrorCount> , public MessageListener<MessageClearErrorCount>
, public MessageListener<MessageFinishedParsing> , public MessageListener<MessageFinishedParsing>
, public MessageListener<MessageRefresh>
, public MessageListener<MessageShowErrors> , public MessageListener<MessageShowErrors>
, public MessageListener<MessageStatus> , public MessageListener<MessageStatus>
{ {
@@ -32,6 +34,7 @@ public:
private: private:
virtual void handleMessage(MessageClearErrorCount* message); virtual void handleMessage(MessageClearErrorCount* message);
virtual void handleMessage(MessageFinishedParsing* message); virtual void handleMessage(MessageFinishedParsing* message);
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageShowErrors* message); virtual void handleMessage(MessageShowErrors* message);
virtual void handleMessage(MessageStatus* message); virtual void handleMessage(MessageStatus* message);
+2 -2
View File
@@ -8,12 +8,12 @@ struct ErrorCountInfo
, fatal(0) , fatal(0)
{} {}
ErrorCountInfo(int total, size_t fatal) ErrorCountInfo(size_t total, size_t fatal)
: total(total) : total(total)
, fatal(fatal) , fatal(fatal)
{} {}
int total; size_t total;
size_t fatal; size_t fatal;
}; };
+2 -1
View File
@@ -138,11 +138,12 @@ void IntermediateStorage::addCommentLocation(Id fileNodeId, uint startLine, uint
)); ));
} }
void IntermediateStorage::addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol) void IntermediateStorage::addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol)
{ {
m_errors.push_back(StorageError( m_errors.push_back(StorageError(
message, message,
fatal, fatal,
indexed,
filePath, filePath,
startLine, startLine,
startCol startCol
+1 -1
View File
@@ -21,7 +21,7 @@ public:
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type); virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
virtual void addComponentAccess(Id edgeId , int type); virtual void addComponentAccess(Id edgeId , int type);
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol); virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
virtual void addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol); virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol);
virtual void forEachFile(std::function<void(const Id /*id*/, const StorageFile& /*data*/)> callback) const; virtual void forEachFile(std::function<void(const Id /*id*/, const StorageFile& /*data*/)> callback) const;
virtual void forEachNode(std::function<void(const Id /*id*/, const StorageNode& /*data*/)> callback) const; virtual void forEachNode(std::function<void(const Id /*id*/, const StorageNode& /*data*/)> callback) const;
+31 -9
View File
@@ -136,11 +136,12 @@ void PersistentStorage::addCommentLocation(Id fileNodeId, uint startLine, uint s
} }
void PersistentStorage::addError( void PersistentStorage::addError(
const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol) const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol)
{ {
m_sqliteStorage.addError( m_sqliteStorage.addError(
message, message,
fatal, fatal,
indexed,
filePath, filePath,
startLine, startLine,
startCol startCol
@@ -224,14 +225,12 @@ void PersistentStorage::finishInjection()
m_sqliteStorage.commitTransaction(); m_sqliteStorage.commitTransaction();
ErrorCountInfo errorCount = getErrorCount(); ErrorCountInfo errorCount = getErrorCount();
if (m_preInjectionErrorCount != -1 && if (m_preInjectionErrorCount != errorCount.total)
m_preInjectionErrorCount != errorCount.total)
{ {
MessageShowErrors msg(errorCount); MessageShowErrors msg(errorCount);
msg.setSendAsTask(false); msg.setSendAsTask(false);
msg.dispatchImmediately(); msg.dispatchImmediately();
} }
m_preInjectionErrorCount = -1;
} }
FilePath PersistentStorage::getDbFilePath() const FilePath PersistentStorage::getDbFilePath() const
@@ -988,14 +987,19 @@ std::shared_ptr<TokenLocationCollection> PersistentStorage::getErrorTokenLocatio
std::shared_ptr<TokenLocationCollection> errorCollection = std::make_shared<TokenLocationCollection>(); std::shared_ptr<TokenLocationCollection> errorCollection = std::make_shared<TokenLocationCollection>();
bool showExternalNonFatalErrors = ApplicationSettings::getInstance()->getShowExternalNonFatalErrors();
std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors(); std::vector<StorageError> storageErrors = m_sqliteStorage.getAllErrors();
for (size_t i = 0; i < storageErrors.size(); i++) for (size_t i = 0; i < storageErrors.size(); i++)
{ {
const StorageError& error = storageErrors[i]; const StorageError& error = storageErrors[i];
errorCollection->addTokenLocation( if (error.fatal || error.indexed || showExternalNonFatalErrors)
i, i, error.filePath, error.lineNumber, error.columnNumber, error.lineNumber, error.columnNumber {
)->setType(LOCATION_ERROR); errorCollection->addTokenLocation(
errors->push_back(ErrorInfo(error.message, error.filePath, i, error.fatal)); i, 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; return errorCollection;
@@ -1048,7 +1052,25 @@ std::vector<FileInfo> PersistentStorage::getFileInfosForFilePaths(const std::vec
ErrorCountInfo PersistentStorage::getErrorCount() const ErrorCountInfo PersistentStorage::getErrorCount() const
{ {
return ErrorCountInfo(m_sqliteStorage.getAllErrors().size(), m_sqliteStorage.getFatalErrors().size()); 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 StorageStats PersistentStorage::getStorageStats() const
+2 -2
View File
@@ -34,7 +34,7 @@ public:
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type); virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
virtual void addComponentAccess(Id edgeId , int type); virtual void addComponentAccess(Id edgeId , int type);
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol); virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
virtual void addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol); virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol);
virtual void forEachFile(std::function<void(const Id /*id*/, const StorageFile& /*data*/)> callback) const; virtual void forEachFile(std::function<void(const Id /*id*/, const StorageFile& /*data*/)> callback) const;
virtual void forEachNode(std::function<void(const Id /*id*/, const StorageNode& /*data*/)> callback) const; virtual void forEachNode(std::function<void(const Id /*id*/, const StorageNode& /*data*/)> callback) const;
@@ -139,7 +139,7 @@ private:
void log(std::string type, std::string str, const ParseLocation& location) const; void log(std::string type, std::string str, const ParseLocation& location) const;
int m_preInjectionErrorCount; size_t m_preInjectionErrorCount;
SearchIndex m_commandIndex; SearchIndex m_commandIndex;
SearchIndex m_elementIndex; SearchIndex m_elementIndex;
+10 -13
View File
@@ -200,7 +200,7 @@ Id SqliteStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCo
return m_database.lastRowId(); return m_database.lastRowId();
} }
Id SqliteStorage::addError(const std::string& message, bool fatal, const std::string& filePath, uint lineNumber, uint columnNumber) 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((fatal ? "Fatal: " : "Error: ") + message, "'", "''");
@@ -226,8 +226,8 @@ Id SqliteStorage::addError(const std::string& message, bool fatal, const std::st
stmt.finalize(); stmt.finalize();
stmt = m_database.compileStatement(( stmt = m_database.compileStatement((
"INSERT INTO error(message, fatal, file_path, line_number, column_number) " "INSERT INTO error(message, fatal, indexed, file_path, line_number, column_number) "
"VALUES (?, " + std::to_string(fatal) + ", '" + filePath + "VALUES (?, " + std::to_string(fatal) + ", " + std::to_string(indexed) + ", '" + filePath +
"', " + std::to_string(lineNumber) + ", " + std::to_string(columnNumber) + ");" "', " + std::to_string(lineNumber) + ", " + std::to_string(columnNumber) + ");"
).c_str()); ).c_str());
@@ -550,11 +550,6 @@ std::vector<StorageCommentLocation> SqliteStorage::getCommentLocationsInFile(con
return getAll<StorageCommentLocation>("WHERE file_node_id == " + std::to_string(fileNodeId)); return getAll<StorageCommentLocation>("WHERE file_node_id == " + std::to_string(fileNodeId));
} }
std::vector<StorageError> SqliteStorage::getFatalErrors() const
{
return getAll<StorageError>("WHERE fatal == 1");
}
std::vector<StorageFile> SqliteStorage::getAllFiles() const std::vector<StorageFile> SqliteStorage::getAllFiles() const
{ {
return getAll<StorageFile>(""); return getAll<StorageFile>("");
@@ -752,6 +747,7 @@ void SqliteStorage::setupTables()
"id INTEGER NOT NULL, " "id INTEGER NOT NULL, "
"message TEXT, " "message TEXT, "
"fatal INTEGER NOT NULL, " "fatal INTEGER NOT NULL, "
"indexed INTEGER NOT NULL, "
"file_path TEXT, " "file_path TEXT, "
"line_number INTEGER, " "line_number INTEGER, "
"column_number INTEGER, " "column_number INTEGER, "
@@ -990,7 +986,7 @@ template <>
std::vector<StorageError> SqliteStorage::getAll<StorageError>(const std::string& query) const std::vector<StorageError> SqliteStorage::getAll<StorageError>(const std::string& query) const
{ {
CppSQLite3Query q = m_database.execQuery(( CppSQLite3Query q = m_database.execQuery((
"SELECT message, fatal, file_path, line_number, column_number FROM error " + query + ";" "SELECT message, fatal, indexed, file_path, line_number, column_number FROM error " + query + ";"
).c_str()); ).c_str());
std::vector<StorageError> errors; std::vector<StorageError> errors;
@@ -998,13 +994,14 @@ std::vector<StorageError> SqliteStorage::getAll<StorageError>(const std::string&
{ {
const std::string message = q.getStringField(0, ""); const std::string message = q.getStringField(0, "");
const bool fatal = q.getIntField(1, 0); const bool fatal = q.getIntField(1, 0);
const std::string filePath = q.getStringField(2, ""); const bool indexed = q.getIntField(2, 0);
const int lineNumber = q.getIntField(3, -1); const std::string filePath = q.getStringField(3, "");
const int columnNumber = q.getIntField(4, -1); const int lineNumber = q.getIntField(4, -1);
const int columnNumber = q.getIntField(5, -1);
if (lineNumber != -1 && columnNumber != -1) if (lineNumber != -1 && columnNumber != -1)
{ {
errors.push_back(StorageError(message, fatal, filePath, lineNumber, columnNumber)); errors.push_back(StorageError(message, fatal, indexed, filePath, lineNumber, columnNumber));
} }
q.nextRow(); q.nextRow();
+1 -2
View File
@@ -44,7 +44,7 @@ public:
Id addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type); Id addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
Id addComponentAccess(Id memberEdgeId, int type); Id addComponentAccess(Id memberEdgeId, int type);
Id addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol); Id addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
Id addError(const std::string& message, bool fatal, const std::string& filePath, uint lineNumber, uint columnNumber); Id addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber);
void removeElement(Id id); void removeElement(Id id);
void removeElements(const std::vector<Id>& ids); void removeElements(const std::vector<Id>& ids);
@@ -101,7 +101,6 @@ public:
std::vector<ParseLocation> getFullTextSearch(const std::string& searchTerm) const; std::vector<ParseLocation> getFullTextSearch(const std::string& searchTerm) const;
std::vector<StorageCommentLocation> getCommentLocationsInFile(const FilePath& filePath) const; std::vector<StorageCommentLocation> getCommentLocationsInFile(const FilePath& filePath) const;
std::vector<StorageError> getFatalErrors() const;
std::vector<StorageFile> getAllFiles() const; std::vector<StorageFile> getAllFiles() const;
std::vector<StorageNode> getAllNodes() const; std::vector<StorageNode> getAllNodes() const;
+1
View File
@@ -170,6 +170,7 @@ void Storage::inject(Storage* injected)
addError( addError(
injectedData.message, injectedData.message,
injectedData.fatal, injectedData.fatal,
injectedData.indexed,
injectedData.filePath, injectedData.filePath,
injectedData.lineNumber, injectedData.lineNumber,
injectedData.columnNumber injectedData.columnNumber
+1 -1
View File
@@ -21,7 +21,7 @@ public:
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type) = 0; virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type) = 0;
virtual void addComponentAccess(Id edgeId , int type) = 0; virtual void addComponentAccess(Id edgeId , int type) = 0;
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol) = 0; virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol) = 0;
virtual void addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol) = 0; virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol) = 0;
virtual void forEachFile(std::function<void(const Id /*id*/, const StorageFile& /*data*/)> callback) const = 0; virtual void forEachFile(std::function<void(const Id /*id*/, const StorageFile& /*data*/)> callback) const = 0;
virtual void forEachNode(std::function<void(const Id /*id*/, const StorageNode& /*data*/)> callback) const = 0; virtual void forEachNode(std::function<void(const Id /*id*/, const StorageNode& /*data*/)> callback) const = 0;
+4 -1
View File
@@ -171,14 +171,16 @@ struct StorageError
StorageError() StorageError()
: message("") : message("")
, fatal(0) , fatal(0)
, indexed(0)
, filePath("") , filePath("")
, lineNumber(-1) , lineNumber(-1)
, columnNumber(-1) , columnNumber(-1)
{} {}
StorageError(const std::string& message, bool fatal, const std::string& filePath, uint lineNumber, uint columnNumber) StorageError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber)
: message(message) : message(message)
, fatal(fatal) , fatal(fatal)
, indexed(indexed)
, filePath(filePath) , filePath(filePath)
, lineNumber(lineNumber) , lineNumber(lineNumber)
, columnNumber(columnNumber) , columnNumber(columnNumber)
@@ -186,6 +188,7 @@ struct StorageError
std::string message; std::string message;
bool fatal; bool fatal;
bool indexed;
std::string filePath; std::string filePath;
uint lineNumber; uint lineNumber;
uint columnNumber; uint columnNumber;
+2
View File
@@ -21,7 +21,9 @@ public:
std::vector<FilePath> systemHeaderSearchPaths; std::vector<FilePath> systemHeaderSearchPaths;
std::vector<FilePath> frameworkSearchPaths; std::vector<FilePath> frameworkSearchPaths;
std::vector<std::string> compilerFlags; std::vector<std::string> compilerFlags;
bool logErrors; bool logErrors;
std::string language; std::string language;
std::string languageStandard; std::string languageStandard;
+1 -1
View File
@@ -42,7 +42,7 @@ public:
virtual void startParsingFile() = 0; virtual void startParsingFile() = 0;
virtual void finishParsingFile() = 0; virtual void finishParsingFile() = 0;
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal) = 0; virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) = 0;
virtual void onTypedefParsed( virtual void onTypedefParsed(
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit) = 0; const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit) = 0;
+4 -4
View File
@@ -34,7 +34,7 @@ void ParserClientImpl::finishParsingFile()
{ {
} }
void ParserClientImpl::onError(const ParseLocation& location, const std::string& message, bool fatal) void ParserClientImpl::onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
{ {
log(std::string(fatal ? "FATAL: " : "ERROR: "), message, location); log(std::string(fatal ? "FATAL: " : "ERROR: "), message, location);
@@ -43,7 +43,7 @@ void ParserClientImpl::onError(const ParseLocation& location, const std::string&
return; return;
} }
addError(message, fatal, location); addError(message, fatal, indexed, location);
} }
void ParserClientImpl::onTypedefParsed( void ParserClientImpl::onTypedefParsed(
@@ -576,14 +576,14 @@ void ParserClientImpl::addCommentLocation(const ParseLocation& location)
); );
} }
void ParserClientImpl::addError(const std::string& message, bool fatal, const ParseLocation& location) void ParserClientImpl::addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location)
{ {
if (!m_storage) if (!m_storage)
{ {
return; return;
} }
m_storage->addError(message, fatal, location.filePath.str(), location.startLineNumber, location.startColumnNumber); m_storage->addError(message, fatal, indexed, location.filePath.str(), location.startLineNumber, location.startColumnNumber);
} }
void ParserClientImpl::log(std::string type, std::string str, const ParseLocation& location) const void ParserClientImpl::log(std::string type, std::string str, const ParseLocation& location) const
+2 -2
View File
@@ -21,7 +21,7 @@ public:
virtual void startParsingFile(); virtual void startParsingFile();
virtual void finishParsingFile(); virtual void finishParsingFile();
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal); virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed);
virtual void onTypedefParsed( virtual void onTypedefParsed(
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit); const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit);
@@ -97,7 +97,7 @@ private:
void addSourceLocation(Id elementId, const ParseLocation& location, int type); void addSourceLocation(Id elementId, const ParseLocation& location, int type);
void addComponentAccess(Id nodeId , int type); void addComponentAccess(Id nodeId , int type);
void addCommentLocation(const ParseLocation& location); void addCommentLocation(const ParseLocation& location);
void addError(const std::string& message, bool fatal, const ParseLocation& location); void addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location);
void log(std::string type, std::string str, const ParseLocation& location) const; void log(std::string type, std::string str, const ParseLocation& location) const;
+10
View File
@@ -153,6 +153,16 @@ void ApplicationSettings::setIndexerThreadCount(const int count)
setValue<int>("application/indexer_thread_count", count); setValue<int>("application/indexer_thread_count", count);
} }
bool ApplicationSettings::getShowExternalNonFatalErrors() const
{
return getValue<bool>("application/show_external_non_fatal_errors", false);
}
void ApplicationSettings::setShowExternalNonFatalErrors(const bool show)
{
setValue<bool>("application/show_external_non_fatal_errors", show);
}
int ApplicationSettings::getWindowBaseWidth() const int ApplicationSettings::getWindowBaseWidth() const
{ {
return getValue<int>("application/window_base_width", 500); return getValue<int>("application/window_base_width", 500);
+3
View File
@@ -50,6 +50,9 @@ public:
int getIndexerThreadCount() const; int getIndexerThreadCount() const;
void setIndexerThreadCount(const int count); void setIndexerThreadCount(const int count);
bool getShowExternalNonFatalErrors() const;
void setShowExternalNonFatalErrors(const bool show);
int getWindowBaseWidth() const; int getWindowBaseWidth() const;
int getWindowBaseHeight() const; int getWindowBaseHeight() const;
@@ -84,6 +84,21 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
); );
row++; row++;
// ignore non-fatal errors in non-indexed files
QLabel* errorsLabel = createFormLabel("Non-Fatal Errors");
m_fatalErrors = new QCheckBox("Display non-fatal errors in unindexed files", this);
layout->addWidget(errorsLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_fatalErrors, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
addHelpButton(
"When checked non-fatal errors within included unindexed files are also shown."
, layout, row
);
row++;
} }
void QtProjectWizzardContentPreferences::load() void QtProjectWizzardContentPreferences::load()
@@ -96,6 +111,7 @@ void QtProjectWizzardContentPreferences::load()
m_tabWidth->setCurrentIndex(appSettings->getCodeTabWidth() - 1); m_tabWidth->setCurrentIndex(appSettings->getCodeTabWidth() - 1);
m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1); m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1);
m_fatalErrors->setChecked(appSettings->getShowExternalNonFatalErrors());
} }
void QtProjectWizzardContentPreferences::save() void QtProjectWizzardContentPreferences::save()
@@ -108,6 +124,7 @@ void QtProjectWizzardContentPreferences::save()
appSettings->setCodeTabWidth(m_tabWidth->currentIndex() + 1); appSettings->setCodeTabWidth(m_tabWidth->currentIndex() + 1);
appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1); appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1);
appSettings->setShowExternalNonFatalErrors(m_fatalErrors->isChecked());
} }
bool QtProjectWizzardContentPreferences::check() bool QtProjectWizzardContentPreferences::check()
@@ -1,6 +1,7 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H #ifndef QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
#define QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H #define QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
#include <QCheckBox>
#include <QComboBox> #include <QComboBox>
#include <QLineEdit> #include <QLineEdit>
@@ -27,6 +28,7 @@ private:
QComboBox* m_fontSize; QComboBox* m_fontSize;
QComboBox* m_tabWidth; QComboBox* m_tabWidth;
QComboBox* m_threads; QComboBox* m_threads;
QCheckBox* m_fatalErrors;
}; };
#endif // QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H #endif // QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
@@ -4,15 +4,18 @@
#include "data/parser/ParseLocation.h" #include "data/parser/ParseLocation.h"
#include "data/parser/ParserClient.h" #include "data/parser/ParserClient.h"
#include "utility/file/FileRegister.h"
CxxDiagnosticConsumer::CxxDiagnosticConsumer( CxxDiagnosticConsumer::CxxDiagnosticConsumer(
clang::raw_ostream &os, clang::raw_ostream &os,
clang::DiagnosticOptions *diags, clang::DiagnosticOptions *diags,
ParserClient* client, ParserClient* client,
FileRegister* fileRegister,
bool useLogging bool useLogging
) )
: clang::TextDiagnosticPrinter(os, diags) : clang::TextDiagnosticPrinter(os, diags)
, m_client(client) , m_client(client)
, m_register(fileRegister)
, m_isParsingFile(false) , m_isParsingFile(false)
, m_useLogging(useLogging) , m_useLogging(useLogging)
{ {
@@ -75,6 +78,11 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
column = presumedLocation.getColumn(); column = presumedLocation.getColumn();
} }
m_client->onError(ParseLocation(filePath, line, column), message, (level == clang::DiagnosticsEngine::Fatal)); m_client->onError(
ParseLocation(filePath, line, column),
message,
level == clang::DiagnosticsEngine::Fatal,
m_register->hasFilePath(filePath)
);
} }
} }
@@ -3,6 +3,7 @@
#include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Frontend/TextDiagnosticPrinter.h"
class FileRegister;
class ParserClient; class ParserClient;
class CxxDiagnosticConsumer class CxxDiagnosticConsumer
@@ -13,6 +14,7 @@ public:
clang::raw_ostream &os, clang::raw_ostream &os,
clang::DiagnosticOptions *diags, clang::DiagnosticOptions *diags,
ParserClient* client, ParserClient* client,
FileRegister* fileRegister,
bool useLogging = true bool useLogging = true
); );
@@ -23,6 +25,8 @@ public:
private: private:
ParserClient* m_client; ParserClient* m_client;
FileRegister* m_register;
bool m_isParsingFile; bool m_isParsingFile;
bool m_useLogging; bool m_useLogging;
}; };
+1 -1
View File
@@ -183,7 +183,7 @@ std::shared_ptr<CxxDiagnosticConsumer> CxxParser::getDiagnostics(const Arguments
{ {
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions(); llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
return std::make_shared<CxxDiagnosticConsumer>( return std::make_shared<CxxDiagnosticConsumer>(
llvm::errs(), &*options, m_client, arguments.logErrors); llvm::errs(), &*options, m_client, m_fileRegister.get(), arguments.logErrors);
} }
void CxxParser::setupParsing(const Arguments& arguments) void CxxParser::setupParsing(const Arguments& arguments)
+1 -1
View File
@@ -2948,7 +2948,7 @@ private:
{ {
} }
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal) virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
{ {
errors.push_back(addLocationSuffix(message, location)); errors.push_back(addLocationSuffix(message, location));
} }