* TaskBuildIndex starts seperate indexer processes and communicates via shared memory * indexer processes get restarted if they fail * indexer processes are killed when the app closes or crashes * added utility class SharedMemory to allocate and access shared memory, providing basic data structures * added SharedMemoryGarbageCollector for keeping track of running instances and cleaning up shared memory in case of a crash * show errors for source files that crashed during indexing * added basic exception handling to task scheduling * added option to turn off processes and use threads in preferences, but still use shared memory fortune cookie message = Good news from someone dear is coming soon.
97 lines
2.1 KiB
C++
97 lines
2.1 KiB
C++
#include "data/parser/ParserClient.h"
|
|
|
|
#include <sstream>
|
|
|
|
#include "data/parser/ParseLocation.h"
|
|
#include "utility/utilityString.h"
|
|
|
|
std::string ParserClient::addAccessPrefix(const std::string& str, AccessKind access)
|
|
{
|
|
switch (access)
|
|
{
|
|
case ACCESS_PUBLIC:
|
|
return "public " + str;
|
|
case ACCESS_PROTECTED:
|
|
return "protected " + str;
|
|
case ACCESS_PRIVATE:
|
|
return "private " + str;
|
|
case ACCESS_DEFAULT:
|
|
return "default " + str;
|
|
default:
|
|
break;
|
|
}
|
|
return str;
|
|
}
|
|
|
|
std::string ParserClient::addStaticPrefix(const std::string& str, bool isStatic)
|
|
{
|
|
if (isStatic)
|
|
{
|
|
return "static " + str;
|
|
}
|
|
return str;
|
|
}
|
|
|
|
std::string ParserClient::addConstPrefix(const std::string& str, bool isConst, bool atFront)
|
|
{
|
|
if (isConst)
|
|
{
|
|
return atFront ? "const " + str : str + " const";
|
|
}
|
|
return str;
|
|
}
|
|
|
|
std::string ParserClient::addLocationSuffix(const std::string& str, const ParseLocation& location)
|
|
{
|
|
std::stringstream ss;
|
|
ss << str;
|
|
ss << " <" << location.startLineNumber << ":" << location.startColumnNumber << " ";
|
|
ss << location.endLineNumber << ":" << location.endColumnNumber << ">";
|
|
return ss.str();
|
|
}
|
|
|
|
std::string ParserClient::addLocationSuffix(
|
|
const std::string& str, const ParseLocation& location, const ParseLocation& scopeLocation
|
|
){
|
|
if (!location.isValid())
|
|
{
|
|
return addLocationSuffix(str, scopeLocation);
|
|
}
|
|
else if (!scopeLocation.isValid())
|
|
{
|
|
return addLocationSuffix(str, location);
|
|
}
|
|
|
|
std::stringstream ss;
|
|
ss << str;
|
|
ss << " <" << scopeLocation.startLineNumber << ":" << scopeLocation.startColumnNumber;
|
|
ss << " <" << location.startLineNumber << ":" << location.startColumnNumber << " ";
|
|
ss << location.endLineNumber << ":" << location.endColumnNumber << "> ";
|
|
ss << scopeLocation.endLineNumber << ":" << scopeLocation.endColumnNumber << ">";
|
|
return ss.str();
|
|
}
|
|
|
|
ParserClient::ParserClient()
|
|
: m_hasFatalErrors(false)
|
|
{
|
|
}
|
|
|
|
ParserClient::~ParserClient()
|
|
{
|
|
}
|
|
|
|
void ParserClient::onErrorParsed(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
|
{
|
|
this->onError(location, message, fatal, indexed);
|
|
|
|
if (fatal)
|
|
{
|
|
m_hasFatalErrors = true;
|
|
}
|
|
}
|
|
|
|
bool ParserClient::hasFatalErrors() const
|
|
{
|
|
return m_hasFatalErrors;
|
|
}
|