ui: display an error when loading a Clang Compilation Database fails
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "clang/Tooling/CompilationDatabase.h"
|
#include "clang/Tooling/CompilationDatabase.h"
|
||||||
#include "clang/Tooling/JSONCompilationDatabase.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)
|
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>
|
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
|
||||||
(clang::tooling::JSONCompilationDatabase::loadFromFile(compilationDatabasePath.str(), error));
|
(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;
|
std::vector<FilePath> filePaths;
|
||||||
if (cdb)
|
if (cdb)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -135,6 +135,14 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxx::getIndexerCommands(
|
|||||||
std::string error;
|
std::string error;
|
||||||
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
|
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
|
||||||
(clang::tooling::JSONCompilationDatabase::loadFromFile(cdbPath.str(), error));
|
(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())
|
for (clang::tooling::CompileCommand command: cdb->getAllCompileCommands())
|
||||||
{
|
{
|
||||||
if (sourceFilePathsToIndex.find(FilePath(command.Filename)) != sourceFilePathsToIndex.end())
|
if (sourceFilePathsToIndex.find(FilePath(command.Filename)) != sourceFilePathsToIndex.end())
|
||||||
|
|||||||
Reference in New Issue
Block a user