data: improvements on error management

* mark all files with errors as incomplete
* fix incomplete label in codeview tooltip not updated properly
* added setting for canceling indexing for files with fatal errors
This commit is contained in:
Eberhard Graether
2017-04-15 17:57:20 +02:00
parent 8dc5ac7cbe
commit 6cd6552343
16 changed files with 100 additions and 14 deletions
@@ -30,6 +30,7 @@
<indexing>
<indexer_thread_count><!-- INTEGER: number of threads indexing the source code --></indexer_thread_count>
<cancel_on_fatal_errors><!-- BOOL: cancel indexing in translation units with fatal errors --></cancel_on_fatal_errors>
<cxx>
<compiler_flags>
+22 -3
View File
@@ -1,5 +1,7 @@
#include "data/IntermediateStorage.h"
#include <set>
#include "data/graph/Edge.h"
#include "utility/logging/logging.h"
@@ -31,7 +33,12 @@ void IntermediateStorage::clear()
m_nextId = 1;
}
void IntermediateStorage::setFilesIncomplete()
size_t IntermediateStorage::getSourceLocationCount() const
{
return m_sourceLocationNamesToIds.size();
}
void IntermediateStorage::setAllFilesIncomplete()
{
for (StorageFile& file : m_files)
{
@@ -39,9 +46,21 @@ void IntermediateStorage::setFilesIncomplete()
}
}
size_t IntermediateStorage::getSourceLocationCount() const
void IntermediateStorage::setFilesWithErrorsIncomplete()
{
return m_sourceLocationNamesToIds.size();
std::set<FilePath> errorFiles;
for (StorageError& error : m_errors)
{
errorFiles.insert(error.filePath);
}
for (StorageFile& file : m_files)
{
if (errorFiles.find(file.filePath) != errorFiles.end())
{
file.complete = false;
}
}
}
Id IntermediateStorage::addNode(int type, const std::string& serializedName)
+3 -1
View File
@@ -16,9 +16,11 @@ public:
virtual ~IntermediateStorage();
void clear();
void setFilesIncomplete();
size_t getSourceLocationCount() const;
void setAllFilesIncomplete();
void setFilesWithErrorsIncomplete();
virtual Id addNode(int type, const std::string& serializedName);
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime, bool complete);
virtual void addSymbol(const Id id, int definitionKind);
+11 -4
View File
@@ -17,7 +17,8 @@ public:
virtual std::string getKindString() const;
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister);
virtual std::shared_ptr<IntermediateStorage> index(
std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister);
};
template <typename IndexerCommandType, typename ParserType>
@@ -32,16 +33,21 @@ std::string Indexer<IndexerCommandType, ParserType>::getKindString() const
}
template <typename IndexerCommandType, typename ParserType>
std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::index(std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::index(
std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
{
std::shared_ptr<IndexerCommandType> castedCommand = std::dynamic_pointer_cast<IndexerCommandType>(indexerCommand);
if (!castedCommand)
{
LOG_ERROR("Trying to process " + indexerCommand->getKindString() + " indexer command with " + getKindString() + " indexer.");
LOG_ERROR("Trying to process " + indexerCommand->getKindString() +
" indexer command with " + getKindString() + " indexer.");
return std::shared_ptr<IntermediateStorage>();
}
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
parserClient->setCancelOnFatalErrors(indexerCommand->cancelOnFatalErrors());
std::shared_ptr<ParserType> parser = std::make_shared<ParserType>(parserClient, fileRegister);
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
@@ -53,10 +59,11 @@ std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::in
if (parserClient->hasFatalErrors())
{
storage->setFilesIncomplete();
storage->setAllFilesIncomplete();
}
else
{
storage->setFilesWithErrorsIncomplete();
fileRegister->markIndexingFilesIndexed();
}
+11 -1
View File
@@ -4,10 +4,10 @@ IndexerCommand::IndexerCommand(const FilePath& sourceFilePath, const std::set<Fi
: m_sourceFilePath(sourceFilePath)
, m_indexedPaths(indexedPaths)
, m_excludedPaths(excludedPaths)
, m_cancelOnFatalErrors(false)
{
}
IndexerCommand::~IndexerCommand()
{
}
@@ -26,3 +26,13 @@ std::set<FilePath> IndexerCommand::getExcludedPath() const
{
return m_excludedPaths;
}
bool IndexerCommand::cancelOnFatalErrors() const
{
return m_cancelOnFatalErrors;
}
void IndexerCommand::setCancelOnFatalErrors(bool cancelOnFatalErrors)
{
m_cancelOnFatalErrors = cancelOnFatalErrors;
}
+5
View File
@@ -18,10 +18,15 @@ public:
std::set<FilePath> getIndexedPaths() const;
std::set<FilePath> getExcludedPath() const;
bool cancelOnFatalErrors() const;
void setCancelOnFatalErrors(bool cancelOnFatalErrors);
private:
FilePath m_sourceFilePath;
std::set<FilePath> m_indexedPaths;
std::set<FilePath> m_excludedPaths;
bool m_cancelOnFatalErrors;
};
#endif // INDEXER_COMMAND_H
+11
View File
@@ -73,6 +73,7 @@ std::string ParserClient::addLocationSuffix(
ParserClient::ParserClient()
: m_hasFatalErrors(false)
, m_cancelOnFatalErrors(false)
{
}
@@ -94,3 +95,13 @@ bool ParserClient::hasFatalErrors() const
{
return m_hasFatalErrors;
}
bool ParserClient::cancelOnFatalErrors() const
{
return m_cancelOnFatalErrors;
}
void ParserClient::setCancelOnFatalErrors(bool cancelOnFatalErrors)
{
m_cancelOnFatalErrors = cancelOnFatalErrors;
}
+4
View File
@@ -55,8 +55,12 @@ public:
bool hasFatalErrors() const;
bool cancelOnFatalErrors() const;
void setCancelOnFatalErrors(bool cancelOnFatalErrors);
protected:
bool m_hasFatalErrors;
bool m_cancelOnFatalErrors;
};
#endif // PARSER_CLIENT_H
-4
View File
@@ -18,15 +18,11 @@ ParserClientImpl::~ParserClientImpl()
void ParserClientImpl::setStorage(std::shared_ptr<IntermediateStorage> storage)
{
m_storage = storage;
m_hasFatalErrors = 0;
}
void ParserClientImpl::resetStorage()
{
m_storage.reset();
m_hasFatalErrors = 0;
}
Id ParserClientImpl::recordSymbol(
+3
View File
@@ -404,10 +404,13 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefres
}
std::shared_ptr<IndexerCommandList> indexerCommandList = std::make_shared<IndexerCommandList>();
bool cancelIndexingOnFatalErrors = ApplicationSettings::getInstance()->getCancelIndexingOnFatalErrors();
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
{
for (std::shared_ptr<IndexerCommand> command: sourceGroup->getIndexerCommands(fullRefresh))
{
command->setCancelOnFatalErrors(cancelIndexingOnFatalErrors);
indexerCommandList->addCommand(command);
}
}
+10
View File
@@ -236,6 +236,16 @@ void ApplicationSettings::setIndexerThreadCount(const int count)
setValue<int>("indexing/indexer_thread_count", count);
}
bool ApplicationSettings::getCancelIndexingOnFatalErrors() const
{
return getValue<bool>("indexing/cancel_on_fatal_errors", true);
}
void ApplicationSettings::setCancelIndexingOnFatalErrors(bool enabled)
{
setValue<bool>("indexing/cancel_on_fatal_errors", enabled);
}
std::string ApplicationSettings::getJavaPath() const
{
return getValue<std::string>("indexing/java/java_path", "");
+3
View File
@@ -70,6 +70,9 @@ public:
int getIndexerThreadCount() const;
void setIndexerThreadCount(const int count);
bool getCancelIndexingOnFatalErrors() const;
void setCancelIndexingOnFatalErrors(bool enabled);
std::string getJavaPath() const;
void setJavaPath(const std::string path);
@@ -285,7 +285,7 @@ bool CxxAstVisitor::TraverseTemplateTemplateParmDecl(clang::TemplateTemplateParm
bool CxxAstVisitor::VisitTranslationUnitDecl(clang::TranslationUnitDecl *d)
{
return !m_client->hasFatalErrors();
return !m_client->cancelOnFatalErrors() || !m_client->hasFatalErrors();
}
bool CxxAstVisitor::TraverseNestedNameSpecifierLoc(clang::NestedNameSpecifierLoc loc)
@@ -56,6 +56,11 @@ void QtCodeFileTitleButton::setModificationTime(const TimePoint modificationTime
void QtCodeFileTitleButton::setIsComplete(bool isComplete)
{
if (m_isComplete == isComplete)
{
return;
}
m_isComplete = isComplete;
setProperty("complete", isComplete);
@@ -70,6 +75,8 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete)
{
setStyleSheet("");
}
updateTexts();
}
void QtCodeFileTitleButton::setProject(const std::string& name)
@@ -118,6 +118,10 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
addHelpButton("Number of parallel threads used to index your projects.\nWhen setting this to 0 Sourcetrail tries to use the ideal thread count for your computer.", layout, row);
row++;
// cancel indexing on fatal errors
m_cancelIndexingOnFatalErrors = addCheckBox("Cancel on Fatals", "Cancel indexing on Fatal errors.",
"Cancel indexing of translation units with fatal errors, which result in partly indexed files.", layout, row);
addGap(layout, row);
@@ -256,6 +260,7 @@ void QtProjectWizzardContentPreferences::load()
m_threads->setCurrentIndex(appSettings->getIndexerThreadCount()); // index and value are the same
indexerThreadsChanges(m_threads->currentIndex());
m_cancelIndexingOnFatalErrors->setChecked(appSettings->getCancelIndexingOnFatalErrors());
if (m_javaPath)
{
@@ -299,6 +304,7 @@ void QtProjectWizzardContentPreferences::save()
if (pluginPort) appSettings->setPluginPort(pluginPort);
appSettings->setIndexerThreadCount(m_threads->currentIndex()); // index and value are the same
appSettings->setCancelIndexingOnFatalErrors(m_cancelIndexingOnFatalErrors->isChecked());
if (m_javaPath)
{
@@ -69,6 +69,8 @@ private:
QComboBox* m_threads;
QLabel* m_threadsInfoLabel;
QCheckBox* m_cancelIndexingOnFatalErrors;
std::shared_ptr<CombinedPathDetector> m_javaPathDetector;
std::shared_ptr<CombinedPathDetector> m_mavenPathDetector;