ui: display an error when loading a Clang Compilation Database fails

This commit is contained in:
malte_langkabel
2017-05-23 09:35:58 +02:00
parent 082dfc2e1a
commit 9b73d73a85
2 changed files with 17 additions and 0 deletions
@@ -2,6 +2,8 @@
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/JSONCompilationDatabase.h"
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageStatus.h"
std::vector<FilePath> IndexerCommandCxxCdb::getSourceFilesFromCDB(const FilePath& compilationDatabasePath)
{
@@ -9,6 +11,13 @@ std::vector<FilePath> IndexerCommandCxxCdb::getSourceFilesFromCDB(const FilePath
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
(clang::tooling::JSONCompilationDatabase::loadFromFile(compilationDatabasePath.str(), error));
if (!error.empty())
{
const std::string message = "Loading Clang compilation database failed with error: \"" + error + "\"";
LOG_ERROR(message);
MessageStatus(message, true).dispatch();
}
std::vector<FilePath> filePaths;
if (cdb)
{
+8
View File
@@ -135,6 +135,14 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxx::getIndexerCommands(
std::string error;
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
(clang::tooling::JSONCompilationDatabase::loadFromFile(cdbPath.str(), error));
if (!error.empty())
{
const std::string message = "Loading Clang compilation database failed with error: \"" + error + "\"";
LOG_ERROR(message);
MessageStatus(message, true).dispatch();
}
for (clang::tooling::CompileCommand command: cdb->getAllCompileCommands())
{
if (sourceFilePathsToIndex.find(FilePath(command.Filename)) != sourceFilePathsToIndex.end())