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:
@@ -2,14 +2,19 @@
|
||||
add_files(
|
||||
LIB_JAVA_FILES
|
||||
|
||||
data/indexer/IndexerCommandJava.cpp
|
||||
data/indexer/IndexerCommandJava.h
|
||||
data/indexer/IndexerFactoryModuleJava.cpp
|
||||
data/indexer/IndexerFactoryModuleJava.h
|
||||
data/indexer/IndexerJava.cpp
|
||||
data/indexer/IndexerJava.h
|
||||
|
||||
data/parser/java/JavaParser.cpp
|
||||
data/parser/java/JavaParser.h
|
||||
data/parser/java/JavaEnvironment.cpp
|
||||
data/parser/java/JavaEnvironment.h
|
||||
data/parser/java/JavaEnvironmentFactory.cpp
|
||||
data/parser/java/JavaEnvironmentFactory.h
|
||||
data/parser/java/TaskParseJava.cpp
|
||||
data/parser/java/TaskParseJava.h
|
||||
|
||||
JavaProject.cpp
|
||||
JavaProject.h
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "JavaProject.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/indexer/IndexerCommandJava.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "data/parser/java/TaskParseJava.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
@@ -81,17 +81,15 @@ bool JavaProject::prepareIndexing()
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> JavaProject::createIndexerTask(
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
std::shared_ptr<FileRegister> fileRegister)
|
||||
std::vector<std::shared_ptr<IndexerCommand>> JavaProject::getIndexerCommands()
|
||||
{
|
||||
Parser::Arguments arguments;
|
||||
std::vector<FilePath> classPath;
|
||||
|
||||
for (FilePath classpath: m_projectSettings->getAbsoluteClasspaths())
|
||||
for (FilePath p: m_projectSettings->getAbsoluteClasspaths())
|
||||
{
|
||||
if (classpath.exists())
|
||||
if (p.exists())
|
||||
{
|
||||
arguments.javaClassPaths.push_back(classpath.str());
|
||||
classPath.push_back(p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,18 +104,38 @@ std::shared_ptr<Task> JavaProject::createIndexerTask(
|
||||
{
|
||||
if (rootDirectory.exists())
|
||||
{
|
||||
arguments.javaClassPaths.push_back(rootDirectory.str());
|
||||
classPath.push_back(rootDirectory.str());
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_shared<TaskParseJava>(
|
||||
storageProvider,
|
||||
fileRegister,
|
||||
arguments,
|
||||
getDialogView()
|
||||
);
|
||||
std::set<FilePath> indexedPaths;
|
||||
for (FilePath p: m_projectSettings->getAbsoluteSourcePaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
indexedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> excludedPaths;
|
||||
for (FilePath p: m_projectSettings->getAbsoluteExcludePaths())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
excludedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
for (const FilePath& sourcePath: getSourceFilePaths())
|
||||
{
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandJava>(sourcePath, indexedPaths, excludedPaths, classPath));
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
}
|
||||
|
||||
|
||||
void JavaProject::updateFileManager(FileManager& fileManager)
|
||||
{
|
||||
std::vector<FilePath> sourcePaths = m_projectSettings->getAbsoluteSourcePaths();
|
||||
|
||||
@@ -25,12 +25,10 @@ private:
|
||||
|
||||
virtual bool prepareIndexing();
|
||||
|
||||
virtual std::shared_ptr<Task> createIndexerTask(
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
std::shared_ptr<FileRegister> fileRegister);
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands();
|
||||
|
||||
virtual void updateFileManager(FileManager& fileManager);
|
||||
|
||||
|
||||
void fetchRootDirectories();
|
||||
|
||||
std::shared_ptr<JavaProjectSettings> m_projectSettings;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "data/indexer/IndexerCommandJava.h"
|
||||
|
||||
std::string IndexerCommandJava::getIndexerKindString()
|
||||
{
|
||||
return "Java";
|
||||
}
|
||||
|
||||
IndexerCommandJava::IndexerCommandJava(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::vector<FilePath>& classPath
|
||||
)
|
||||
: IndexerCommand(sourceFilePath, indexedPaths, excludedPaths)
|
||||
, m_classPath(classPath)
|
||||
{
|
||||
}
|
||||
|
||||
IndexerCommandJava::~IndexerCommandJava()
|
||||
{
|
||||
}
|
||||
|
||||
std::string IndexerCommandJava::getKindString() const
|
||||
{
|
||||
return getIndexerKindString();
|
||||
}
|
||||
|
||||
std::vector<FilePath> IndexerCommandJava::getClassPath() const
|
||||
{
|
||||
return m_classPath;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef INDEXER_COMMAND_JAVA_H
|
||||
#define INDEXER_COMMAND_JAVA_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "data/indexer/IndexerCommand.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
class IndexerCommandJava: public IndexerCommand
|
||||
{
|
||||
public:
|
||||
static std::string getIndexerKindString();
|
||||
|
||||
IndexerCommandJava(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::vector<FilePath>& classPath);
|
||||
virtual ~IndexerCommandJava();
|
||||
|
||||
virtual std::string getKindString() const;
|
||||
|
||||
std::vector<FilePath> getClassPath() const;
|
||||
|
||||
private:
|
||||
std::vector<FilePath> m_classPath;
|
||||
};
|
||||
|
||||
#endif // INDEXER_COMMAND_JAVA_H
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "data/indexer/IndexerFactoryModuleJava.h"
|
||||
|
||||
#include "data/indexer/IndexerJava.h"
|
||||
|
||||
IndexerFactoryModuleJava::~IndexerFactoryModuleJava()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<IndexerBase> IndexerFactoryModuleJava::createIndexer()
|
||||
{
|
||||
return std::make_shared<IndexerJava>();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef INDEXER_FACTORY_MODULE_JAVA_H
|
||||
#define INDEXER_FACTORY_MODULE_JAVA_H
|
||||
|
||||
#include "data/indexer/IndexerFactoryModule.h"
|
||||
|
||||
class IndexerFactoryModuleJava: public IndexerFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~IndexerFactoryModuleJava();
|
||||
virtual std::shared_ptr<IndexerBase> createIndexer();
|
||||
};
|
||||
|
||||
#endif // INDEXER_FACTORY_MODULE_JAVA_H
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "data/indexer/IndexerJava.h"
|
||||
|
||||
#include "data/parser/ParserClientImpl.h"
|
||||
#include "data/parser/java/JavaParser.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
|
||||
IndexerJava::IndexerJava()
|
||||
{
|
||||
}
|
||||
|
||||
IndexerJava::~IndexerJava()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<IntermediateStorage> IndexerJava::index(std::shared_ptr<IndexerCommandJava> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
|
||||
{
|
||||
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
||||
std::shared_ptr<JavaParser> parser = std::make_shared<JavaParser>(parserClient);
|
||||
|
||||
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
||||
parserClient->setStorage(storage);
|
||||
parserClient->startParsingFile();
|
||||
|
||||
fileRegister->markFileIndexing(indexerCommand->getSourceFilePath());
|
||||
parser->buildIndex(indexerCommand);
|
||||
fileRegister->markIndexingFilesIndexed();
|
||||
|
||||
parserClient->finishParsingFile();
|
||||
parserClient->resetStorage();
|
||||
|
||||
if (interrupted())
|
||||
{
|
||||
return std::shared_ptr<IntermediateStorage>();
|
||||
}
|
||||
|
||||
return storage;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef INDEXER_JAVA_H
|
||||
#define INDEXER_JAVA_H
|
||||
|
||||
#include "data/indexer/Indexer.h"
|
||||
#include "data/indexer/IndexerCommandJava.h"
|
||||
|
||||
class IndexerJava: public Indexer<IndexerCommandJava>
|
||||
{
|
||||
public:
|
||||
IndexerJava();
|
||||
virtual ~IndexerJava();
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommandJava> indexerCommand, std::shared_ptr<FileRegister> fileRegister);
|
||||
};
|
||||
|
||||
#endif // INDEXER_JAVA_H
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user