* reimplemented interrupting TaskParseCxx by adding a listener for the MessageInterruptTask and returning a failure status code on update. This cancels the parent sequence task which results in the indexed items not getting inserted into the persistent storage * removed the capability for interrupting from TaskScheduler * changed task system to be closer to the standard behavior tree implementation * changed task system to accommodate the 3 status return types: Running, Success and Failure * made TaskGroupSequential fail once a member task fails * made TaskGroupParallel fail once a member task fails * split TaskParse... into one task for indexing and one task for injecting * added TaskRunner that handles updating and resetting the managed task * fixed numbers that are shown as parsed file count in indexing ui * fixed deadlock that originated from interaction between TaskScheduler and MessageQueue (one thread wanted to destroy a message listener on a task while the other one wanted to send as message as a task)
70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#include "data/parser/java/TaskParseJava.h"
|
|
|
|
#include "component/view/DialogView.h"
|
|
#include "data/parser/java/JavaParser.h"
|
|
#include "data/parser/ParserClientImpl.h"
|
|
#include "data/IntermediateStorage.h"
|
|
#include "utility/file/FileRegister.h"
|
|
#include "utility/messaging/type/MessageFinishedParsing.h"
|
|
#include "utility/text/TextAccess.h"
|
|
#include "utility/utility.h"
|
|
|
|
TaskParseJava::TaskParseJava(
|
|
std::shared_ptr<IntermediateStorage> storage,
|
|
std::shared_ptr<FileRegister> fileRegister,
|
|
const Parser::Arguments& arguments,
|
|
DialogView* dialogView
|
|
)
|
|
: m_storage(storage)
|
|
, m_fileRegister(fileRegister)
|
|
, m_arguments(arguments)
|
|
, m_dialogView(dialogView)
|
|
, m_interrupted(false)
|
|
{
|
|
}
|
|
|
|
void TaskParseJava::doEnter()
|
|
{
|
|
}
|
|
|
|
Task::TaskState TaskParseJava::doUpdate()
|
|
{
|
|
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
|
std::shared_ptr<JavaParser> parser = std::make_shared<JavaParser>(parserClient.get());
|
|
|
|
FilePath sourcePath = m_fileRegister->consumeSourceFile();
|
|
|
|
if (!sourcePath.empty())
|
|
{
|
|
m_dialogView->updateIndexingDialog(
|
|
m_fileRegister->getParsedSourceFilesCount(), m_fileRegister->getSourceFilesCount(), sourcePath.str()
|
|
);
|
|
|
|
m_storage->clear();
|
|
parserClient->setStorage(m_storage);
|
|
parserClient->startParsingFile();
|
|
|
|
parser->parseFile(sourcePath, TextAccess::createFromFile(sourcePath.str()), m_arguments);
|
|
|
|
parserClient->finishParsingFile();
|
|
parserClient->resetStorage();
|
|
|
|
m_fileRegister->markThreadFilesParsed(); // todo: rename to markThreadFilesProcessed
|
|
}
|
|
|
|
return (m_interrupted ? STATE_FAILURE : STATE_SUCCESS);
|
|
}
|
|
|
|
void TaskParseJava::doExit()
|
|
{
|
|
}
|
|
|
|
void TaskParseJava::doReset()
|
|
{
|
|
}
|
|
|
|
void TaskParseJava::handleMessage(MessageInterruptTasks* message)
|
|
{
|
|
m_interrupted = true;
|
|
}
|