logic: indexer commands

* replaced parser arguments by project specific IndexerCommands that know everything the indexer needs to know to do its job
* added different language and project specific indexers that know how to handle a certain kind of indexer command
* refactored FileManager and FileRegister to have less overhead
* removed no-rtti restriction for clang files in lib cxx
* uncommented deprecated interprocess code.

fortune cookie message = Happiness will bring you good luck.
This commit is contained in:
malte_langkabel
2017-02-22 16:42:20 +01:00
parent 650cd8101e
commit 4563cbe90a
101 changed files with 1908 additions and 1120 deletions
+19 -28
View File
@@ -11,7 +11,7 @@
#include "utility/text/TextAccess.h"
#include "utility/utilityString.h"
JavaParser::JavaParser(ParserClient* client)
JavaParser::JavaParser(std::shared_ptr<ParserClient> client)
: Parser(client)
, m_id(s_nextParserId++)
, m_currentFilePath("")
@@ -47,32 +47,30 @@ JavaParser::~JavaParser()
s_parsers.erase(m_id);
}
void JavaParser::parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments)
void JavaParser::buildIndex(std::shared_ptr<IndexerCommandJava> indexerCommand)
{
//m_fileRegister->setFilePaths(filePaths);
//setupParsing(arguments);
std::string classPath = "";
for (const FilePath& path: indexerCommand->getClassPath())
{
// the separator used here should be the same as the one used in JavaIndexer.java
classPath += path.str() + ";";
}
//std::vector<std::string> sourcePaths;
//for (const FilePath& path : m_fileRegister->getUnparsedSourceFilePaths()) // filter headers
//{
// sourcePaths.push_back(path.absolute().str());
//}
//runTool(sourcePaths);
buildIndex(indexerCommand->getSourceFilePath(), classPath, TextAccess::createFromFile(indexerCommand->getSourceFilePath().str()));
}
void JavaParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess, const Arguments& arguments)
void JavaParser::buildIndex(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess)
{
buildIndex(filePath, "", textAccess);
}
void JavaParser::buildIndex(const FilePath& sourceFilePath, const std::string& classPath, std::shared_ptr<TextAccess> textAccess)
{
if (m_javaEnvironment)
{
m_currentFilePath = filePath.str();
m_client->onFileParsed(FileSystem::getFileInfoForPath(filePath));
std::string classPath = "";
for (const FilePath& path: arguments.javaClassPaths)
{
// the separator used here should be the same as the one used in JavaIndexer.java
classPath += path.str() + ";";
}
m_currentFilePath = sourceFilePath.str();
m_client->onFileParsed(FileSystem::getFileInfoForPath(sourceFilePath));
// remove tabs because they screw with javaparser's location resolver
std::string fileContent = utility::replace(textAccess->getText(), "\t", " ");
@@ -84,7 +82,7 @@ void JavaParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess>
"io/coati/JavaIndexer",
"processFile",
m_id,
filePath.str(),
m_currentFilePath,
fileContent,
classPath,
verbose
@@ -92,13 +90,6 @@ void JavaParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess>
}
}
int JavaParser::s_nextParserId = 0;
std::map<int, JavaParser*> JavaParser::s_parsers;
+5 -5
View File
@@ -4,6 +4,7 @@
#include <map>
#include <mutex>
#include "data/indexer/IndexerCommandJava.h"
#include "data/parser/Parser.h"
#include "data/parser/java/JavaEnvironment.h"
#include "utility/logging/logging.h"
@@ -28,15 +29,14 @@ class FileRegister;
class JavaParser: public Parser
{
public:
JavaParser(ParserClient* client);
JavaParser(std::shared_ptr<ParserClient> client);
~JavaParser();
// ParserClient implementation
virtual void parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments);
virtual void parseFile(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess, const Arguments& arguments);
void buildIndex(std::shared_ptr<IndexerCommandJava> indexerCommand);
void buildIndex(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess);
private:
void buildIndex(const FilePath& sourceFilePath, const std::string& classPath, std::shared_ptr<TextAccess> textAccess);
// This macro makes available a variable T, the passed-in t. blablabla TODO: write somethign real here
#define MAKE_PARAMS_0()
@@ -1,39 +0,0 @@
#include "data/parser/java/TaskParseJava.h"
#include "component/view/DialogView.h"
#include "data/parser/java/JavaParser.h"
#include "data/parser/ParserClientImpl.h"
#include "data/StorageProvider.h"
#include "utility/file/FileRegister.h"
#include "utility/text/TextAccess.h"
TaskParseJava::TaskParseJava(
std::shared_ptr<StorageProvider> storageProvider,
std::shared_ptr<FileRegister> fileRegister,
const Parser::Arguments& arguments,
DialogView* dialogView
)
: TaskParse(storageProvider, fileRegister, arguments, dialogView)
{
}
void TaskParseJava::indexFile(FilePath sourcePath)
{
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
std::shared_ptr<JavaParser> parser = std::make_shared<JavaParser>(parserClient.get());
std::shared_ptr<IntermediateStorage> storage = m_storageProvider->popIndexerTarget();
parserClient->setStorage(storage);
parserClient->startParsingFile();
parser->parseFile(sourcePath, TextAccess::createFromFile(sourcePath.str()), m_arguments);
parserClient->finishParsingFile();
parserClient->resetStorage();
if (!m_interrupted)
{
m_fileRegister->markThreadFilesParsed(); // todo: rename to markThreadFilesProcessed
m_storageProvider->pushIndexerTarget(storage);
}
}
@@ -1,21 +0,0 @@
#ifndef TASK_PARSE_JAVA_H
#define TASK_PARSE_JAVA_H
#include "data/parser/TaskParse.h"
class TaskParseJava
: public TaskParse
{
public:
TaskParseJava(
std::shared_ptr<StorageProvider> storageProvider,
std::shared_ptr<FileRegister> fileRegister,
const Parser::Arguments& arguments,
DialogView* dialogView
);
private:
void indexFile(FilePath sourcePath);
};
#endif // TASK_PARSE_JAVA_H