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:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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", "");
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user