logic: Added compilation database project setup
* Added CDB option to project type selection * show CDB source files in popup * define header paths separately * made generic content summary in wizzard and use it everywhere * fixed file paths not canonical in analysis * refactored wizzard content paths to use summary instead of subpaths * refactored files popup to simpler communication with content bug id = 35
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "clang/Tooling/JSONCompilationDatabase.h"
|
||||
|
||||
#include "data/parser/cxx/CxxParser.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
@@ -19,18 +21,49 @@ TaskParseCxx::TaskParseCxx(
|
||||
, m_parser(std::make_shared<CxxParser>(client, fileManager))
|
||||
, m_arguments(arguments)
|
||||
, m_files(files)
|
||||
, m_isCDB(false)
|
||||
{
|
||||
if (arguments.compilationDatabasePath.exists())
|
||||
{
|
||||
m_isCDB = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FilePath> TaskParseCxx::getSourceFilesFromCDB(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
std::string error;
|
||||
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
|
||||
(clang::tooling::JSONCompilationDatabase::loadFromFile(compilationDatabasePath.str(), error));
|
||||
|
||||
std::vector<std::string> files = cdb->getAllFiles();
|
||||
std::vector<FilePath> filePaths;
|
||||
for (const std::string& file : files)
|
||||
{
|
||||
filePaths.push_back(FilePath(file));
|
||||
}
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
void TaskParseCxx::enter()
|
||||
{
|
||||
m_start = utility::durationStart();
|
||||
|
||||
m_parser->setupParsing(m_files, m_arguments);
|
||||
if (m_isCDB)
|
||||
{
|
||||
std::string error;
|
||||
m_cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
|
||||
(clang::tooling::JSONCompilationDatabase::loadFromFile(m_arguments.compilationDatabasePath.str(), error));
|
||||
|
||||
m_parser->setupParsingCDB(m_files, m_arguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_parser->setupParsing(m_files, m_arguments);
|
||||
}
|
||||
|
||||
for (const FilePath& path : m_parser->getFileRegister()->getUnparsedSourceFilePaths())
|
||||
{
|
||||
m_sourcePaths.push(path.absolute());
|
||||
m_sourcePaths.push_back(path.absolute());
|
||||
}
|
||||
|
||||
m_client->startParsing();
|
||||
@@ -46,10 +79,10 @@ Task::TaskState TaskParseCxx::update()
|
||||
if (m_sourcePaths.size())
|
||||
{
|
||||
sourcePath = m_sourcePaths.front();
|
||||
m_sourcePaths.pop();
|
||||
m_sourcePaths.pop_front();
|
||||
isSource = true;
|
||||
}
|
||||
else
|
||||
else if (!m_isCDB)
|
||||
{
|
||||
std::vector<FilePath> unparsedHeaders = fileRegister->getUnparsedIncludeFilePaths();
|
||||
if (unparsedHeaders.size())
|
||||
@@ -65,14 +98,26 @@ Task::TaskState TaskParseCxx::update()
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "analyzing files (ESC to quit): [";
|
||||
ss << fileRegister->getParsedFilesCount() << "/" << fileRegister->getFilesCount() << "] ";
|
||||
ss << (m_isCDB ? fileRegister->getParsedSourceFilesCount() : fileRegister->getParsedFilesCount()) + 1 << "/";
|
||||
ss << (m_isCDB ? fileRegister->getSourceFilesCount() : fileRegister->getFilesCount()) << "] ";
|
||||
ss << sourcePath.str();
|
||||
|
||||
MessageStatus(ss.str(), false, true).dispatch();
|
||||
|
||||
m_client->startParsingFile(sourcePath);
|
||||
|
||||
m_parser->runTool(std::vector<std::string>(1, sourcePath.str()));
|
||||
if (m_isCDB)
|
||||
{
|
||||
std::vector<clang::tooling::CompileCommand> commands = m_cdb->getCompileCommands(sourcePath.str());
|
||||
if (commands.size() > 0)
|
||||
{
|
||||
m_parser->runTool(commands[0], m_arguments);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_parser->runTool(std::vector<std::string>(1, sourcePath.str()));
|
||||
}
|
||||
|
||||
m_client->finishParsingFile(sourcePath);
|
||||
|
||||
@@ -93,8 +138,8 @@ void TaskParseCxx::exit()
|
||||
FileRegister* fileRegister = m_parser->getFileRegister();
|
||||
|
||||
MessageFinishedParsing(
|
||||
fileRegister->getParsedFilesCount(),
|
||||
fileRegister->getFilesCount(),
|
||||
(m_isCDB ? fileRegister->getParsedSourceFilesCount() : fileRegister->getParsedFilesCount()),
|
||||
(m_isCDB ? fileRegister->getSourceFilesCount() : fileRegister->getFilesCount()),
|
||||
utility::duration(m_start)
|
||||
).dispatch();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user