* removed trial target * updated deploy scripts to exclude trial * cleanup CMakeLists * removed Eigen dependencies * split parser lib into lib_cxx and lib_java * added ProjectFactory and ProjectFactoryModules * removed old installer projects * updated wix installer * updated readme for wix setup * updated to use obfuscated exe * added qt.conf * added indexing dialog images * added jars * added coatidb files of sample projects * added source code of javaparser sample * removed auto-refresh image * intermediate files of windows installer are created in build folder * preselected desktop shortcut * build bat is executed from deploy_windows script
139 lines
3.4 KiB
C++
139 lines
3.4 KiB
C++
#include "data/parser/cxx/TaskParseCxx.h"
|
|
|
|
#include <sstream>
|
|
|
|
#include "clang/Tooling/JSONCompilationDatabase.h"
|
|
|
|
#include "component/view/DialogView.h"
|
|
#include "data/parser/cxx/CxxParser.h"
|
|
#include "data/StorageProvider.h"
|
|
#include "utility/file/FileRegister.h"
|
|
#include "utility/scheduling/Blackboard.h"
|
|
#include "utility/utility.h"
|
|
|
|
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<FilePath> filePaths;
|
|
if (cdb)
|
|
{
|
|
std::vector<std::string> files = cdb->getAllFiles();
|
|
for (const std::string& file : files)
|
|
{
|
|
filePaths.push_back(FilePath(file));
|
|
}
|
|
}
|
|
return filePaths;
|
|
}
|
|
|
|
TaskParseCxx::TaskParseCxx(
|
|
std::shared_ptr<StorageProvider> storageProvider,
|
|
std::shared_ptr<FileRegister> fileRegister,
|
|
const Parser::Arguments& arguments,
|
|
DialogView* dialogView
|
|
)
|
|
: m_storageProvider(storageProvider)
|
|
, m_arguments(arguments)
|
|
, m_dialogView(dialogView)
|
|
, m_isCDB(false)
|
|
, m_interrupted(false)
|
|
{
|
|
if (arguments.compilationDatabasePath.exists())
|
|
{
|
|
m_isCDB = true;
|
|
}
|
|
m_parserClient = std::make_shared<ParserClientImpl>(); // todo: create one parserclient per file
|
|
m_parser = std::make_shared<CxxParser>(m_parserClient.get(), fileRegister);
|
|
}
|
|
|
|
void TaskParseCxx::doEnter(std::shared_ptr<Blackboard> blackboard)
|
|
{
|
|
int indexerCount = 0;
|
|
if (blackboard->get("indexer_count", indexerCount))
|
|
{
|
|
indexerCount++;
|
|
blackboard->set("indexer_count", indexerCount);
|
|
}
|
|
|
|
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_arguments);
|
|
}
|
|
else
|
|
{
|
|
m_parser->setupParsing(m_arguments);
|
|
}
|
|
}
|
|
|
|
Task::TaskState TaskParseCxx::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
|
{
|
|
FileRegister* fileRegister = m_parser->getFileRegister();
|
|
|
|
FilePath sourcePath = fileRegister->consumeSourceFile();
|
|
|
|
if (sourcePath.empty())
|
|
{
|
|
return STATE_FAILURE;
|
|
}
|
|
else
|
|
{
|
|
m_dialogView->updateIndexingDialog(
|
|
fileRegister->getParsedSourceFilesCount(), fileRegister->getSourceFilesCount(), sourcePath.str()
|
|
);
|
|
|
|
std::shared_ptr<IntermediateStorage> storage = m_storageProvider->popIndexerTarget();
|
|
m_parserClient->setStorage(storage);
|
|
m_parserClient->startParsingFile();
|
|
|
|
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_parserClient->finishParsingFile();
|
|
m_parserClient->resetStorage();
|
|
|
|
if (!m_interrupted)
|
|
{
|
|
fileRegister->markThreadFilesParsed();
|
|
m_storageProvider->pushIndexerTarget(storage);
|
|
}
|
|
}
|
|
|
|
return (m_interrupted ? STATE_FAILURE : STATE_SUCCESS);
|
|
}
|
|
|
|
void TaskParseCxx::doExit(std::shared_ptr<Blackboard> blackboard)
|
|
{
|
|
int indexerCount = 0;
|
|
if (blackboard->get("indexer_count", indexerCount))
|
|
{
|
|
indexerCount--;
|
|
blackboard->set("indexer_count", indexerCount);
|
|
}
|
|
}
|
|
|
|
void TaskParseCxx::doReset(std::shared_ptr<Blackboard> blackboard)
|
|
{
|
|
}
|
|
|
|
void TaskParseCxx::handleMessage(MessageInterruptTasks* message)
|
|
{
|
|
m_interrupted = true;
|
|
}
|