data: indexing java
* expanded appsettings to include java specific stuff * added java indexer as separate project that can be build via its build script * added dependencies for java indexer to the setup folder * added license files for these dependencies. * added sample project for java. this is just to test java on other machines and can be removed again in the future. * the java parser test suite is currently uncommented because java is not running on every machine. * added some more node types * removed TokenComponentAccess::AccessType and replaced all its usages by using AccessKind * moved access components from edges to nodes * using recordReference of ParserClient for java * removed recording access specifier of inheritance edges. * added styles for new node types
This commit is contained in:
@@ -3,6 +3,8 @@ add_files(
|
||||
|
||||
data/parser/cxx/TaskParseCxx.cpp
|
||||
data/parser/cxx/TaskParseWrapper.cpp
|
||||
|
||||
data/parser/java/TaskParseJava.cpp
|
||||
|
||||
utility/commandline/CommandLineParser.cpp
|
||||
utility/commandline/CommandLineParser.h
|
||||
|
||||
@@ -7,32 +7,34 @@
|
||||
#include "utility/utility.h"
|
||||
|
||||
TaskParseWrapper::TaskParseWrapper(
|
||||
std::shared_ptr<Task> child,
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<FileRegister> fileRegister
|
||||
)
|
||||
: m_child(child)
|
||||
, m_storage(storage)
|
||||
: m_storage(storage)
|
||||
, m_fileRegister(fileRegister)
|
||||
{
|
||||
}
|
||||
|
||||
TaskParseWrapper::~TaskParseWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseWrapper::enter()
|
||||
{
|
||||
m_start = utility::durationStart();
|
||||
m_storage->startParsing();
|
||||
|
||||
m_child->enter();
|
||||
m_task->enter();
|
||||
}
|
||||
|
||||
Task::TaskState TaskParseWrapper::update()
|
||||
{
|
||||
return m_child->update();
|
||||
return m_task->update();
|
||||
}
|
||||
|
||||
void TaskParseWrapper::exit()
|
||||
{
|
||||
m_child->exit();
|
||||
m_task->exit();
|
||||
|
||||
MessageStatus("optimizing database", false, true).dispatch();
|
||||
|
||||
@@ -52,10 +54,10 @@ void TaskParseWrapper::exit()
|
||||
void TaskParseWrapper::interrupt()
|
||||
{
|
||||
MessageStatus("indexing files interrupted", false, true).dispatch();
|
||||
m_child->interrupt();
|
||||
m_task->interrupt();
|
||||
}
|
||||
|
||||
void TaskParseWrapper::revert()
|
||||
{
|
||||
m_child->revert();
|
||||
m_task->revert();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#include "data/parser/java/TaskParseJava.h"
|
||||
|
||||
#include "data/parser/java/JavaParser.h"
|
||||
#include "data/parser/ParserClientImpl.h"
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
TaskParseJava::TaskParseJava(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
const Parser::Arguments& arguments
|
||||
)
|
||||
: m_storage(storage)
|
||||
, m_storageMutex(storageMutex)
|
||||
, m_fileRegister(fileRegister)
|
||||
, m_arguments(arguments)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseJava::enter()
|
||||
{
|
||||
}
|
||||
|
||||
Task::TaskState TaskParseJava::update()
|
||||
{
|
||||
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())
|
||||
{
|
||||
return Task::STATE_FINISHED;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "indexing files (ESC to quit): [";
|
||||
ss << m_fileRegister->getParsedSourceFilesCount() << "/";
|
||||
ss << m_fileRegister->getSourceFilesCount() << "] ";
|
||||
ss << sourcePath.str();
|
||||
MessageStatus(ss.str(), false, true).dispatch();
|
||||
|
||||
std::shared_ptr<IntermediateStorage> intermediateStorage = std::make_shared<IntermediateStorage>();
|
||||
|
||||
parserClient->setStorage(intermediateStorage);
|
||||
parserClient->startParsingFile();
|
||||
|
||||
parser->parseFile(sourcePath, TextAccess::createFromFile(sourcePath.str()), m_arguments);
|
||||
|
||||
parserClient->finishParsingFile();
|
||||
parserClient->resetStorage();
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(*(m_storageMutex.get()));
|
||||
m_storage->inject(intermediateStorage.get());
|
||||
}
|
||||
|
||||
m_fileRegister->markThreadFilesParsed(); // todo: rename to markThreadFilesProcessed
|
||||
|
||||
return Task::STATE_RUNNING;
|
||||
}
|
||||
|
||||
void TaskParseJava::exit()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseJava::interrupt()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseJava::revert()
|
||||
{
|
||||
}
|
||||
+15
-2
@@ -128,7 +128,15 @@ add_files(
|
||||
|
||||
data/parser/cxx/TaskParseCxx.h
|
||||
data/parser/cxx/TaskParseWrapper.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.h
|
||||
|
||||
data/parser/AccessKind.cpp
|
||||
data/parser/AccessKind.h
|
||||
data/parser/ParseLocation.cpp
|
||||
data/parser/ParseLocation.h
|
||||
data/parser/Parser.cpp
|
||||
@@ -137,7 +145,10 @@ add_files(
|
||||
data/parser/ParserClient.h
|
||||
data/parser/ParserClientImpl.cpp
|
||||
data/parser/ParserClientImpl.h
|
||||
data/parser/SymbolType.h
|
||||
data/parser/ReferenceKind.cpp
|
||||
data/parser/ReferenceKind.h
|
||||
data/parser/SymbolKind.cpp
|
||||
data/parser/SymbolKind.h
|
||||
|
||||
data/search/SearchIndex.cpp
|
||||
data/search/SearchIndex.h
|
||||
@@ -279,6 +290,8 @@ add_files(
|
||||
|
||||
utility/scheduling/Task.cpp
|
||||
utility/scheduling/Task.h
|
||||
utility/scheduling/TaskDecorator.cpp
|
||||
utility/scheduling/TaskDecorator.h
|
||||
utility/scheduling/TaskGroup.cpp
|
||||
utility/scheduling/TaskGroup.h
|
||||
utility/scheduling/TaskGroupParallel.cpp
|
||||
|
||||
+67
-11
@@ -4,6 +4,8 @@
|
||||
#include "data/graph/Token.h"
|
||||
#include "data/parser/cxx/TaskParseCxx.h"
|
||||
#include "data/parser/cxx/TaskParseWrapper.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "data/parser/java/TaskParseJava.h"
|
||||
#include "data/PersistentStorage.h"
|
||||
#include "data/TaskCleanStorage.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
@@ -16,6 +18,7 @@
|
||||
#include "utility/scheduling/TaskGroupSequential.h"
|
||||
#include "utility/scheduling/TaskGroupParallel.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
std::shared_ptr<Project> Project::create(StorageAccessProxy* storageAccessProxy)
|
||||
@@ -144,24 +147,78 @@ void Project::parseCode()
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(&m_fileManager, indexerThreadCount > 1);
|
||||
fileRegister->setFilePaths(filesToParse);
|
||||
|
||||
std::shared_ptr<TaskGroupParallel> taskParallel = std::make_shared<TaskGroupParallel>();
|
||||
if (ProjectSettings::getInstance()->getLanguage() == "Java")
|
||||
{
|
||||
if (!JavaEnvironmentFactory::getInstance())
|
||||
{
|
||||
JavaEnvironmentFactory::createInstance(
|
||||
"data/java/asm-5.0.3.jar;"
|
||||
"data/java/cglib-3.1.jar;"
|
||||
"data/java/easymock-3.3.1.jar;"
|
||||
"data/java/guava-18.0.jar;"
|
||||
"data/java/hamcrest-core-1.3.jar;"
|
||||
"data/java/java-indexer.jar;"
|
||||
"data/java/javaparser-core-2.4.1-SNAPSHOT.jar;"
|
||||
"data/java/javaslang-2.0.0-beta.jar;"
|
||||
"data/java/javassist-3.19.0-GA.jar;"
|
||||
"data/java/java-symbol-solver-core-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/java-symbol-solver-logic-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/java-symbol-solver-model-0.2.0-SNAPSHOT.jar;"
|
||||
"data/java/objenesis-2.1.jar;"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
taskSequential->addTask(std::make_shared<TaskParseWrapper>(
|
||||
taskParallel,
|
||||
std::shared_ptr<TaskParseWrapper> taskParserWrapper = std::make_shared<TaskParseWrapper>(
|
||||
m_storage.get(),
|
||||
fileRegister
|
||||
));
|
||||
);
|
||||
taskSequential->addTask(taskParserWrapper);
|
||||
|
||||
std::shared_ptr<TaskGroupParallel> taskParallelIndexing = std::make_shared<TaskGroupParallel>();
|
||||
taskParserWrapper->setTask(taskParallelIndexing);
|
||||
|
||||
std::shared_ptr<std::mutex> storageMutex = std::make_shared<std::mutex>();
|
||||
|
||||
for (int i = 0; i < indexerThreadCount; i++)
|
||||
{
|
||||
taskParallel->addTask(std::make_shared<TaskParseCxx>(
|
||||
m_storage.get(),
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
getParserArguments()
|
||||
));
|
||||
if (ProjectSettings::getInstance()->getLanguage() == "Java")
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
|
||||
Parser::Arguments arguments;
|
||||
|
||||
for (FilePath classpath: projSettings->getAbsoluteJavaClasspaths())
|
||||
{
|
||||
arguments.javaClassPaths.push_back(classpath.str());
|
||||
}
|
||||
|
||||
for (FilePath sourcePath: projSettings->getAbsoluteSourcePaths())
|
||||
{
|
||||
if (sourcePath.extension().empty())
|
||||
{
|
||||
arguments.javaClassPaths.push_back(sourcePath.str());
|
||||
}
|
||||
}
|
||||
|
||||
taskParallelIndexing->addTask(
|
||||
std::make_shared<TaskParseJava>(
|
||||
m_storage.get(),
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
arguments
|
||||
)
|
||||
);
|
||||
}
|
||||
else // c or cxx
|
||||
{
|
||||
taskParallelIndexing->addTask(std::make_shared<TaskParseCxx>(
|
||||
m_storage.get(),
|
||||
storageMutex,
|
||||
fileRegister,
|
||||
getParserArguments()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Task::dispatch(taskSequential);
|
||||
@@ -247,7 +304,6 @@ Parser::Arguments Project::getParserArguments() const
|
||||
Parser::Arguments args;
|
||||
|
||||
utility::append(args.compilerFlags, projSettings->getCompilerFlags());
|
||||
utility::append(args.compilerFlags, appSettings->getCompilerFlags());
|
||||
|
||||
// Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
|
||||
utility::append(args.systemHeaderSearchPaths, m_fileManager.getSourcePaths());
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "component/view/GraphView.h"
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "data/access/StorageAccess.h"
|
||||
#include "data/parser/AccessKind.h"
|
||||
#include "data/graph/Graph.h"
|
||||
|
||||
GraphController::GraphController(StorageAccess* storageAccess)
|
||||
@@ -278,31 +279,14 @@ std::shared_ptr<DummyNode> GraphController::createDummyNodeTopDown(Node* node, I
|
||||
{
|
||||
DummyNode* parent = nullptr;
|
||||
|
||||
Edge* edge = child->getMemberEdge();
|
||||
TokenComponentAccess* access = edge->getComponent<TokenComponentAccess>();
|
||||
TokenComponentAccess::AccessType accessType = TokenComponentAccess::ACCESS_NONE;
|
||||
TokenComponentAccess* access = child->getComponent<TokenComponentAccess>();
|
||||
|
||||
if (access)
|
||||
{
|
||||
accessType = access->getAccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (node->isType(Node::NODE_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT))
|
||||
{
|
||||
accessType = TokenComponentAccess::ACCESS_PUBLIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = result.get();
|
||||
}
|
||||
}
|
||||
|
||||
if (accessType != TokenComponentAccess::ACCESS_NONE)
|
||||
if (access && access->getAccess() != ACCESS_NONE)
|
||||
{
|
||||
AccessKind accessKind = access->getAccess();
|
||||
for (std::shared_ptr<DummyNode> dummy : result->subNodes)
|
||||
{
|
||||
if (dummy->accessType == accessType)
|
||||
if (dummy->accessKind == accessKind)
|
||||
{
|
||||
parent = dummy.get();
|
||||
break;
|
||||
@@ -312,12 +296,15 @@ std::shared_ptr<DummyNode> GraphController::createDummyNodeTopDown(Node* node, I
|
||||
if (!parent)
|
||||
{
|
||||
std::shared_ptr<DummyNode> accessNode = std::make_shared<DummyNode>();
|
||||
accessNode->accessType = accessType;
|
||||
accessNode->accessKind = accessKind;
|
||||
result->subNodes.push_back(accessNode);
|
||||
parent = accessNode.get();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
parent = result.get();
|
||||
}
|
||||
parent->subNodes.push_back(createDummyNodeTopDown(child, parentId));
|
||||
}
|
||||
);
|
||||
@@ -853,7 +840,10 @@ void GraphController::bundleNodesByType()
|
||||
}
|
||||
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_NAMESPACE, "Namespaces");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_PACKAGE, "Packages");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_BUILTIN_TYPE, "Builtin Types");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_CLASS, "Classes");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_INTERFACE, "Interfaces");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_STRUCT, "Structs");
|
||||
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_FUNCTION, "Functions");
|
||||
@@ -872,6 +862,7 @@ void GraphController::bundleNodesByType()
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_FIELD, "Fields");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_ENUM_CONSTANT, "Enum Constants");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_TEMPLATE_PARAMETER_TYPE, "Template Parameter Types");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_TYPE_PARAMETER, "Type Parameters");
|
||||
BUNDLE_BY_TYPE(nodes, Node::NODE_UNDEFINED, "Undefined Symbols");
|
||||
|
||||
for (std::shared_ptr<DummyNode> node : m_dummyNodes)
|
||||
@@ -918,7 +909,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
|
||||
}
|
||||
else if (node->isAccessNode())
|
||||
{
|
||||
margins = GraphViewStyle::getMarginsOfAccessNode(node->accessType);
|
||||
margins = GraphViewStyle::getMarginsOfAccessNode(node->accessKind);
|
||||
}
|
||||
else if (node->isExpandToggleNode())
|
||||
{
|
||||
@@ -944,7 +935,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
|
||||
|
||||
width = margins.charWidth * node->name.size();
|
||||
|
||||
if (node->data->isType(Node::NODE_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT | Node::NODE_ENUM) &&
|
||||
if (node->data->isType(Node::NODE_TYPE | Node::NODE_BUILTIN_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT | Node::NODE_ENUM) &&
|
||||
node->subNodes.size())
|
||||
{
|
||||
addExpandToggleNode(node);
|
||||
@@ -1178,6 +1169,9 @@ void GraphController::forEachDummyEdge(std::function<void(DummyEdge*)> func)
|
||||
|
||||
void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
{
|
||||
// todo: add nodes: package, interface, type_parameter, builtin_type
|
||||
// todo: add edges: EDGE_TYPE_ARGUMENT, EDGE_IMPORT
|
||||
// todo: add access: TYPE_PARAMETER
|
||||
clear();
|
||||
|
||||
std::shared_ptr<Graph> graph = std::make_shared<Graph>();
|
||||
@@ -1205,15 +1199,15 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
createNodes(60, Node::NODE_FILE);
|
||||
createNodes(70, Node::NODE_MACRO);
|
||||
|
||||
std::function<Node*(Node*, Id, Node::NodeType, std::string, TokenComponentAccess::AccessType)> createChild(
|
||||
[&](Node* parent, Id id, Node::NodeType type, std::string name, TokenComponentAccess::AccessType access)
|
||||
std::function<Node*(Node*, Id, Node::NodeType, std::string, AccessKind)> createChild(
|
||||
[&](Node* parent, Id id, Node::NodeType type, std::string name, AccessKind access)
|
||||
{
|
||||
Node* node = graph->createNode(id + 1000, type, NameHierarchy(name), true);
|
||||
Edge* edge = graph->createEdge(id + 10000, Edge::EDGE_MEMBER, parent, node);
|
||||
|
||||
if (access != TokenComponentAccess::ACCESS_NONE)
|
||||
if (access != ACCESS_NONE)
|
||||
{
|
||||
edge->addComponentAccess(std::make_shared<TokenComponentAccess>(access));
|
||||
node->addComponentAccess(std::make_shared<TokenComponentAccess>(access));
|
||||
}
|
||||
|
||||
return node;
|
||||
@@ -1225,8 +1219,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
{
|
||||
Node* enumNode = graph->createNode(id, Node::NODE_ENUM,
|
||||
NameHierarchy(name + Node::getTypeString(Node::NODE_ENUM)), true);
|
||||
createChild(enumNode, id + 10, Node::NODE_ENUM_CONSTANT, name + Node::getTypeString(Node::NODE_ENUM_CONSTANT),
|
||||
TokenComponentAccess::ACCESS_NONE);
|
||||
createChild(enumNode, id + 10, Node::NODE_ENUM_CONSTANT, name + Node::getTypeString(Node::NODE_ENUM_CONSTANT), ACCESS_NONE);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1245,17 +1238,15 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
|
||||
if (type == Node::NODE_CLASS)
|
||||
{
|
||||
createChild(classNode, id, Node::NODE_TEMPLATE_PARAMETER_TYPE, name + "temp_param",
|
||||
TokenComponentAccess::ACCESS_TEMPLATE);
|
||||
createChild(classNode, id, Node::NODE_TEMPLATE_PARAMETER_TYPE, name + "temp_param", ACCESS_TEMPLATE_PARAMETER);
|
||||
}
|
||||
|
||||
createChild(classNode, id + 10, Node::NODE_METHOD, name + "method", TokenComponentAccess::ACCESS_PUBLIC);
|
||||
createChild(classNode, id + 10, Node::NODE_METHOD, name + "method", ACCESS_PUBLIC);
|
||||
if (type == Node::NODE_CLASS)
|
||||
{
|
||||
createChild(classNode, id + 30, Node::NODE_METHOD, name + "method",
|
||||
TokenComponentAccess::ACCESS_PROTECTED);
|
||||
createChild(classNode, id + 30, Node::NODE_METHOD, name + "method", ACCESS_PROTECTED);
|
||||
}
|
||||
createChild(classNode, id + 60, Node::NODE_FIELD, name + "field", TokenComponentAccess::ACCESS_PRIVATE);
|
||||
createChild(classNode, id + 60, Node::NODE_FIELD, name + "field", ACCESS_PRIVATE);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1284,8 +1275,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
{
|
||||
Node* classNode = graph->createNode(id + 101, Node::NODE_CLASS,
|
||||
NameHierarchy(name + Node::getTypeString(Node::NODE_CLASS)), true);
|
||||
originNode = createChild(classNode, id + 111, Node::NODE_METHOD, name + Edge::getTypeString(type),
|
||||
TokenComponentAccess::ACCESS_PUBLIC);
|
||||
originNode = createChild(classNode, id + 111, Node::NODE_METHOD, name + Edge::getTypeString(type), ACCESS_PUBLIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1297,8 +1287,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
{
|
||||
Node* classNode = graph->createNode(id + 201, Node::NODE_CLASS,
|
||||
NameHierarchy(name + Node::getTypeString(Node::NODE_CLASS)), true);
|
||||
targetNode = createChild(classNode, id + 211, Node::NODE_METHOD, name + Edge::getTypeString(type),
|
||||
TokenComponentAccess::ACCESS_PUBLIC);
|
||||
targetNode = createChild(classNode, id + 211, Node::NODE_METHOD, name + Edge::getTypeString(type), ACCESS_PUBLIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1331,20 +1320,18 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
createEdges( 100000, Edge::EDGE_CALL, Node::NODE_FUNCTION, Node::NODE_FUNCTION);
|
||||
createEdges( 200000, Edge::EDGE_USAGE, Node::NODE_GLOBAL_VARIABLE, Node::NODE_GLOBAL_VARIABLE);
|
||||
createEdges( 300000, Edge::EDGE_TYPE_USAGE, Node::NODE_FUNCTION, Node::NODE_TYPE);
|
||||
createEdges( 400000, Edge::EDGE_TYPE_OF, Node::NODE_GLOBAL_VARIABLE, Node::NODE_TYPE);
|
||||
|
||||
createEdges( 500000, Edge::EDGE_TYPEDEF_OF, Node::NODE_TYPEDEF, Node::NODE_TYPE);
|
||||
createEdges( 600000, Edge::EDGE_AGGREGATION, Node::NODE_TYPE, Node::NODE_TYPE);
|
||||
createEdges( 700000, Edge::EDGE_INCLUDE, Node::NODE_FILE, Node::NODE_FILE);
|
||||
createEdges( 800000, Edge::EDGE_MACRO_USAGE, Node::NODE_MACRO, Node::NODE_MACRO);
|
||||
createEdges( 400000, Edge::EDGE_AGGREGATION, Node::NODE_TYPE, Node::NODE_TYPE);
|
||||
createEdges( 500000, Edge::EDGE_INCLUDE, Node::NODE_FILE, Node::NODE_FILE);
|
||||
createEdges( 600000, Edge::EDGE_MACRO_USAGE, Node::NODE_MACRO, Node::NODE_MACRO);
|
||||
|
||||
createEdges( 900000, Edge::EDGE_INHERITANCE, Node::NODE_CLASS, Node::NODE_CLASS);
|
||||
createEdges(1000000, Edge::EDGE_OVERRIDE, Node::NODE_METHOD, Node::NODE_METHOD);
|
||||
createEdges( 700000, Edge::EDGE_INHERITANCE, Node::NODE_CLASS, Node::NODE_CLASS);
|
||||
createEdges( 800000, Edge::EDGE_OVERRIDE, Node::NODE_METHOD, Node::NODE_METHOD);
|
||||
|
||||
createEdges(1100000, Edge::EDGE_TEMPLATE_ARGUMENT, Node::NODE_TYPE, Node::NODE_TYPE);
|
||||
createEdges(1200000, Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT, Node::NODE_TYPE, Node::NODE_TYPE);
|
||||
createEdges(1300000, Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, Node::NODE_TYPE, Node::NODE_TYPE);
|
||||
createEdges(1400000, Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF, Node::NODE_METHOD, Node::NODE_METHOD);
|
||||
createEdges( 900000, Edge::EDGE_TEMPLATE_ARGUMENT, Node::NODE_TYPE, Node::NODE_TYPE);
|
||||
createEdges(1000000, Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT, Node::NODE_TYPE, Node::NODE_TYPE);
|
||||
createEdges(1100000, Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, Node::NODE_TYPE, Node::NODE_TYPE);
|
||||
createEdges(1200000, Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF, Node::NODE_METHOD, Node::NODE_METHOD);
|
||||
|
||||
std::vector<Id> focusedTokenIds;
|
||||
std::vector<Id> activeTokenIds;
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
, connected(false)
|
||||
, expanded(false)
|
||||
, hasParent(true)
|
||||
, accessType(TokenComponentAccess::ACCESS_NONE)
|
||||
, accessKind(ACCESS_NONE)
|
||||
, invisibleSubNodeCount(0)
|
||||
, layoutBucket(0, 0)
|
||||
, bundledNodeCount(0)
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
bool isAccessNode() const
|
||||
{
|
||||
return accessType != TokenComponentAccess::ACCESS_NONE;
|
||||
return accessKind != ACCESS_NONE;
|
||||
}
|
||||
|
||||
bool isExpandToggleNode() const
|
||||
@@ -223,7 +223,7 @@ public:
|
||||
bool hasParent;
|
||||
|
||||
// AccessNode
|
||||
TokenComponentAccess::AccessType accessType;
|
||||
AccessKind accessKind;
|
||||
|
||||
// ExpandToggleNode
|
||||
size_t invisibleSubNodeCount;
|
||||
|
||||
@@ -130,12 +130,16 @@ size_t GraphViewStyle::getFontSizeForNodeType(Node::NodeType type)
|
||||
{
|
||||
case Node::NODE_UNDEFINED:
|
||||
case Node::NODE_NAMESPACE:
|
||||
case Node::NODE_PACKAGE:
|
||||
case Node::NODE_TYPE:
|
||||
case Node::NODE_BUILTIN_TYPE:
|
||||
case Node::NODE_STRUCT:
|
||||
case Node::NODE_CLASS:
|
||||
case Node::NODE_INTERFACE:
|
||||
case Node::NODE_ENUM:
|
||||
case Node::NODE_TYPEDEF:
|
||||
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
case Node::NODE_TYPE_PARAMETER:
|
||||
case Node::NODE_FILE:
|
||||
case Node::NODE_MACRO:
|
||||
return s_fontSize;
|
||||
@@ -194,10 +198,14 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
|
||||
margins.iconWidth = s_fontSize + 11;
|
||||
case Node::NODE_UNDEFINED:
|
||||
case Node::NODE_NAMESPACE:
|
||||
case Node::NODE_PACKAGE:
|
||||
case Node::NODE_TYPE:
|
||||
case Node::NODE_BUILTIN_TYPE:
|
||||
case Node::NODE_STRUCT:
|
||||
case Node::NODE_CLASS:
|
||||
case Node::NODE_INTERFACE:
|
||||
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
case Node::NODE_TYPE_PARAMETER:
|
||||
if (hasChildren)
|
||||
{
|
||||
margins.left = margins.right = 10;
|
||||
@@ -237,7 +245,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
|
||||
return margins;
|
||||
}
|
||||
|
||||
GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfAccessNode(TokenComponentAccess::AccessType type)
|
||||
GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfAccessNode(AccessKind access)
|
||||
{
|
||||
NodeMargins margins;
|
||||
margins.spacingX = margins.spacingY = 8;
|
||||
@@ -246,21 +254,22 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfAccessNode(TokenComponen
|
||||
margins.top = 40;
|
||||
margins.bottom = 10;
|
||||
|
||||
switch (type)
|
||||
switch (access)
|
||||
{
|
||||
case TokenComponentAccess::ACCESS_NONE:
|
||||
case ACCESS_NONE:
|
||||
margins.minWidth = 30;
|
||||
break;
|
||||
case TokenComponentAccess::ACCESS_PUBLIC:
|
||||
case ACCESS_PUBLIC:
|
||||
margins.minWidth = 56;
|
||||
break;
|
||||
case TokenComponentAccess::ACCESS_PROTECTED:
|
||||
case ACCESS_PROTECTED:
|
||||
margins.minWidth = 72;
|
||||
break;
|
||||
case TokenComponentAccess::ACCESS_PRIVATE:
|
||||
case ACCESS_PRIVATE:
|
||||
margins.minWidth = 58;
|
||||
break;
|
||||
case TokenComponentAccess::ACCESS_TEMPLATE:
|
||||
case ACCESS_TEMPLATE_PARAMETER:
|
||||
case ACCESS_TYPE_PARAMETER:
|
||||
margins.minWidth = 133;
|
||||
break;
|
||||
}
|
||||
@@ -299,12 +308,16 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
style.borderDashed = true;
|
||||
|
||||
case Node::NODE_NAMESPACE:
|
||||
case Node::NODE_PACKAGE:
|
||||
case Node::NODE_TYPE:
|
||||
case Node::NODE_BUILTIN_TYPE:
|
||||
case Node::NODE_STRUCT:
|
||||
case Node::NODE_CLASS:
|
||||
case Node::NODE_INTERFACE:
|
||||
case Node::NODE_ENUM:
|
||||
case Node::NODE_TYPEDEF:
|
||||
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
case Node::NODE_TYPE_PARAMETER:
|
||||
case Node::NODE_FILE:
|
||||
case Node::NODE_MACRO:
|
||||
if (hasChildren)
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
static std::string getFontNameOfExpandToggleNode();
|
||||
|
||||
static NodeMargins getMarginsForNodeType(Node::NodeType type, bool hasChildren);
|
||||
static NodeMargins getMarginsOfAccessNode(TokenComponentAccess::AccessType type);
|
||||
static NodeMargins getMarginsOfAccessNode(AccessKind access);
|
||||
static NodeMargins getMarginsOfExpandToggleNode();
|
||||
static NodeMargins getMarginsOfBundleNode();
|
||||
|
||||
|
||||
@@ -121,9 +121,9 @@ void IntermediateStorage::addSourceLocation(Id elementId, Id fileNodeId, uint st
|
||||
));
|
||||
}
|
||||
|
||||
void IntermediateStorage::addComponentAccess(Id edgeId, int type)
|
||||
void IntermediateStorage::addComponentAccess(Id nodeId, int type)
|
||||
{
|
||||
m_componentAccesses.push_back(StorageComponentAccess(edgeId, type));
|
||||
m_componentAccesses.push_back(StorageComponentAccess(nodeId, type));
|
||||
}
|
||||
|
||||
void IntermediateStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol)
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId);
|
||||
virtual Id addLocalSymbol(const std::string& name);
|
||||
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
|
||||
virtual void addComponentAccess(Id edgeId , int type);
|
||||
virtual void addComponentAccess(Id nodeId , int type);
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol);
|
||||
|
||||
|
||||
@@ -119,9 +119,9 @@ void PersistentStorage::addSourceLocation(
|
||||
);
|
||||
}
|
||||
|
||||
void PersistentStorage::addComponentAccess(Id edgeId , int type)
|
||||
void PersistentStorage::addComponentAccess(Id nodeId , int type)
|
||||
{
|
||||
m_sqliteStorage.addComponentAccess(edgeId, type);
|
||||
m_sqliteStorage.addComponentAccess(nodeId, type);
|
||||
}
|
||||
|
||||
void PersistentStorage::addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol)
|
||||
@@ -668,8 +668,14 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForAll() const
|
||||
for (StorageNode node: m_sqliteStorage.getAllNodes())
|
||||
{
|
||||
if (intToDefinitionType(node.definitionType) == DEFINITION_EXPLICIT &&
|
||||
(!m_hierarchyCache.isChildOfVisibleNodeOrInvisible(node.id) ||
|
||||
Node::intToType(node.type) == Node::NODE_NAMESPACE))
|
||||
(
|
||||
!m_hierarchyCache.isChildOfVisibleNodeOrInvisible(node.id) ||
|
||||
(
|
||||
Node::intToType(node.type) == Node::NODE_NAMESPACE || // TODO: use & here
|
||||
Node::intToType(node.type) == Node::NODE_PACKAGE
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
tokenIds.push_back(node.id);
|
||||
}
|
||||
@@ -701,7 +707,8 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(const std::v
|
||||
|
||||
if (node.id > 0)
|
||||
{
|
||||
if (Node::intToType(node.type) == Node::NODE_NAMESPACE)
|
||||
if (Node::intToType(node.type) == Node::NODE_NAMESPACE || // TODO: use & here
|
||||
Node::intToType(node.type) == Node::NODE_PACKAGE)
|
||||
{
|
||||
ids.clear();
|
||||
m_hierarchyCache.addFirstChildIdsForNodeId(elementId, &ids);
|
||||
@@ -1352,27 +1359,21 @@ void PersistentStorage::addComponentAccessToGraph(Graph* graph) const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::vector<Id> memberEdgeIds;
|
||||
|
||||
graph->forEachEdge(
|
||||
[&memberEdgeIds](Edge* edge)
|
||||
std::vector<Id> nodeIds;
|
||||
graph->forEachNode(
|
||||
[&nodeIds](Node* node)
|
||||
{
|
||||
if (!edge->isType(Edge::EDGE_MEMBER))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memberEdgeIds.push_back(edge->getId());
|
||||
nodeIds.push_back(node->getId());
|
||||
}
|
||||
);
|
||||
|
||||
std::vector<StorageComponentAccess> accesses = m_sqliteStorage.getComponentAccessByMemberEdgeIds(memberEdgeIds);
|
||||
std::vector<StorageComponentAccess> accesses = m_sqliteStorage.getComponentAccessesByNodeIds(nodeIds);
|
||||
for (const StorageComponentAccess& access : accesses)
|
||||
{
|
||||
if (access.memberEdgeId && access.type)
|
||||
if (access.nodeId != 0)
|
||||
{
|
||||
graph->getEdgeById(access.memberEdgeId)->addComponentAccess(
|
||||
std::make_shared<TokenComponentAccess>(TokenComponentAccess::intToType(access.type)));
|
||||
graph->getNodeById(access.nodeId)->addComponentAccess(
|
||||
std::make_shared<TokenComponentAccess>(intToAccessKind(access.type)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId);
|
||||
virtual Id addLocalSymbol(const std::string& name);
|
||||
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
|
||||
virtual void addComponentAccess(Id edgeId , int type);
|
||||
virtual void addComponentAccess(Id nodeId , int type);
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
const size_t SqliteStorage::STORAGE_VERSION = 1;
|
||||
const size_t SqliteStorage::STORAGE_VERSION = 2;
|
||||
|
||||
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
|
||||
: m_dbFilePath(dbFilePath)
|
||||
@@ -178,11 +178,11 @@ Id SqliteStorage::addSourceLocation(
|
||||
return m_database.lastRowId();
|
||||
}
|
||||
|
||||
Id SqliteStorage::addComponentAccess(Id memberEdgeId, int type)
|
||||
Id SqliteStorage::addComponentAccess(Id nodeId, int type)
|
||||
{
|
||||
m_database.execDML((
|
||||
"INSERT INTO component_access(id, edge_id, type) "
|
||||
"VALUES (NULL, " + std::to_string(memberEdgeId) + ", " + std::to_string(type) + ");"
|
||||
"INSERT INTO component_access(id, node_id, type) "
|
||||
"VALUES (NULL, " + std::to_string(nodeId) + ", " + std::to_string(type) + ");"
|
||||
).c_str());
|
||||
|
||||
return m_database.lastRowId();
|
||||
@@ -534,14 +534,14 @@ Id SqliteStorage::getElementIdByLocationId(Id locationId) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
StorageComponentAccess SqliteStorage::getComponentAccessByMemberEdgeId(Id memberEdgeId) const
|
||||
StorageComponentAccess SqliteStorage::getComponentAccessByNodeId(Id nodeId) const
|
||||
{
|
||||
return getFirst<StorageComponentAccess>("WHERE edge_id == " + std::to_string(memberEdgeId));
|
||||
return getFirst<StorageComponentAccess>("WHERE node_id == " + std::to_string(nodeId));
|
||||
}
|
||||
|
||||
std::vector<StorageComponentAccess> SqliteStorage::getComponentAccessByMemberEdgeIds(const std::vector<Id>& memberEdgeIds) const
|
||||
std::vector<StorageComponentAccess> SqliteStorage::getComponentAccessesByNodeIds(const std::vector<Id>& nodeIds) const
|
||||
{
|
||||
return getAll<StorageComponentAccess>("WHERE edge_id IN (" + utility::join(utility::toStrings(memberEdgeIds), ',') + ")");
|
||||
return getAll<StorageComponentAccess>("WHERE node_id IN (" + utility::join(utility::toStrings(nodeIds), ',') + ")");
|
||||
}
|
||||
|
||||
std::vector<StorageCommentLocation> SqliteStorage::getCommentLocationsInFile(const FilePath& filePath) const
|
||||
@@ -722,13 +722,13 @@ void SqliteStorage::setupTables()
|
||||
m_database.execDML(
|
||||
"CREATE TABLE IF NOT EXISTS component_access("
|
||||
"id INTEGER NOT NULL, "
|
||||
"edge_id INTEGER, "
|
||||
"node_id INTEGER, "
|
||||
"type INTEGER NOT NULL, "
|
||||
"PRIMARY KEY(id), "
|
||||
"FOREIGN KEY(edge_id) REFERENCES edge(id) ON DELETE CASCADE);"
|
||||
"FOREIGN KEY(node_id) REFERENCES node(id) ON DELETE CASCADE);"
|
||||
);
|
||||
|
||||
SqliteIndex("component_access_edge_id_index", "component_access(edge_id)").createOnDatabase(m_database);
|
||||
SqliteIndex("component_access_node_id_index", "component_access(node_id)").createOnDatabase(m_database);
|
||||
|
||||
m_database.execDML(
|
||||
"CREATE TABLE IF NOT EXISTS comment_location("
|
||||
@@ -965,7 +965,7 @@ template <>
|
||||
std::vector<StorageComponentAccess> SqliteStorage::getAll<StorageComponentAccess>(const std::string& query) const
|
||||
{
|
||||
CppSQLite3Query q = m_database.execQuery((
|
||||
"SELECT id, edge_id, type FROM component_access " + query + ";"
|
||||
"SELECT id, node_id, type FROM component_access " + query + ";"
|
||||
).c_str());
|
||||
|
||||
std::vector<StorageComponentAccess> componentAccesses;
|
||||
@@ -973,12 +973,12 @@ std::vector<StorageComponentAccess> SqliteStorage::getAll<StorageComponentAccess
|
||||
while (!q.eof())
|
||||
{
|
||||
const Id id = q.getIntField(0, 0);
|
||||
const Id edgeId = q.getIntField(1, 0);
|
||||
const Id nodeId = q.getIntField(1, 0);
|
||||
const int type = q.getIntField(2, -1);
|
||||
|
||||
if (id != 0 && edgeId != 0 && type != -1)
|
||||
if (id != 0 && nodeId != 0 && type != -1)
|
||||
{
|
||||
componentAccesses.push_back(StorageComponentAccess(edgeId, type));
|
||||
componentAccesses.push_back(StorageComponentAccess(nodeId, type));
|
||||
}
|
||||
|
||||
q.nextRow();
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
Id addFile(const std::string& serializedName, const std::string& filePath, const std::string& modificationTime);
|
||||
Id addLocalSymbol(const std::string& name);
|
||||
Id addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
|
||||
Id addComponentAccess(Id memberEdgeId, int type);
|
||||
Id addComponentAccess(Id nodeId, int type);
|
||||
Id addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
Id addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint lineNumber, uint columnNumber);
|
||||
|
||||
@@ -94,8 +94,8 @@ public:
|
||||
|
||||
Id getElementIdByLocationId(Id locationId) const;
|
||||
|
||||
StorageComponentAccess getComponentAccessByMemberEdgeId(Id memberEdgeId) const;
|
||||
std::vector<StorageComponentAccess> getComponentAccessByMemberEdgeIds(const std::vector<Id>& memberEdgeIds) const;
|
||||
StorageComponentAccess getComponentAccessByNodeId(Id memberEdgeId) const;
|
||||
std::vector<StorageComponentAccess> getComponentAccessesByNodeIds(const std::vector<Id>& memberEdgeIds) const;
|
||||
|
||||
void optimizeMemory() const;
|
||||
|
||||
|
||||
@@ -132,14 +132,14 @@ void Storage::inject(Storage* injected)
|
||||
[&](const StorageComponentAccess& injectedData)
|
||||
{
|
||||
std::unordered_map<Id, Id>::const_iterator it;
|
||||
it = injectedIdToOwnId.find(injectedData.memberEdgeId);
|
||||
it = injectedIdToOwnId.find(injectedData.nodeId);
|
||||
if (it == injectedIdToOwnId.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Id ownMemberEdgeId = it->second;
|
||||
Id ownNodeId = it->second;
|
||||
|
||||
addComponentAccess(ownMemberEdgeId, injectedData.type);
|
||||
addComponentAccess(ownNodeId, injectedData.type);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId) = 0;
|
||||
virtual Id addLocalSymbol(const std::string& name) = 0;
|
||||
virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type) = 0;
|
||||
virtual void addComponentAccess(Id edgeId , int type) = 0;
|
||||
virtual void addComponentAccess(Id nodeId , int type) = 0;
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol) = 0;
|
||||
virtual void addError(const std::string& message, bool fatal, bool indexed, const std::string& filePath, uint startLine, uint startCol) = 0;
|
||||
|
||||
|
||||
@@ -125,16 +125,16 @@ struct StorageSourceLocation
|
||||
struct StorageComponentAccess
|
||||
{
|
||||
StorageComponentAccess()
|
||||
: memberEdgeId(0)
|
||||
: nodeId(0)
|
||||
, type(0)
|
||||
{}
|
||||
|
||||
StorageComponentAccess(Id memberEdgeId, int type)
|
||||
: memberEdgeId(memberEdgeId)
|
||||
StorageComponentAccess(Id nodeId, int type)
|
||||
: nodeId(nodeId)
|
||||
, type(type)
|
||||
{}
|
||||
|
||||
Id memberEdgeId;
|
||||
Id nodeId;
|
||||
int type;
|
||||
};
|
||||
|
||||
|
||||
+28
-63
@@ -17,45 +17,39 @@ Edge::EdgeType Edge::intToType(int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0x1:
|
||||
case EDGE_MEMBER:
|
||||
return EDGE_MEMBER;
|
||||
case 0x2:
|
||||
return EDGE_TYPE_OF;
|
||||
case 0x4:
|
||||
return EDGE_RETURN_TYPE_OF;
|
||||
case 0x8:
|
||||
return EDGE_PARAMETER_TYPE_OF;
|
||||
case 0x10:
|
||||
case EDGE_TYPE_USAGE:
|
||||
return EDGE_TYPE_USAGE;
|
||||
case 0x20:
|
||||
case EDGE_USAGE:
|
||||
return EDGE_USAGE;
|
||||
case 0x40:
|
||||
case EDGE_CALL:
|
||||
return EDGE_CALL;
|
||||
case 0x80:
|
||||
case EDGE_INHERITANCE:
|
||||
return EDGE_INHERITANCE;
|
||||
case 0x100:
|
||||
case EDGE_OVERRIDE:
|
||||
return EDGE_OVERRIDE;
|
||||
case 0x200:
|
||||
return EDGE_TYPEDEF_OF;
|
||||
case 0x400:
|
||||
return EDGE_TEMPLATE_PARAMETER;
|
||||
case 0x800:
|
||||
case EDGE_TEMPLATE_ARGUMENT:
|
||||
return EDGE_TEMPLATE_ARGUMENT;
|
||||
case 0x1000:
|
||||
case EDGE_TYPE_ARGUMENT:
|
||||
return EDGE_TYPE_ARGUMENT;
|
||||
case EDGE_TEMPLATE_DEFAULT_ARGUMENT:
|
||||
return EDGE_TEMPLATE_DEFAULT_ARGUMENT;
|
||||
case 0x2000:
|
||||
case EDGE_TEMPLATE_SPECIALIZATION_OF:
|
||||
return EDGE_TEMPLATE_SPECIALIZATION_OF;
|
||||
case 0x4000:
|
||||
case EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF:
|
||||
return EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF;
|
||||
case 0x8000:
|
||||
case EDGE_INCLUDE:
|
||||
return EDGE_INCLUDE;
|
||||
case 0x10000:
|
||||
case EDGE_IMPORT:
|
||||
return EDGE_IMPORT;
|
||||
case EDGE_AGGREGATION:
|
||||
return EDGE_AGGREGATION;
|
||||
case 0x20000:
|
||||
case EDGE_MACRO_USAGE:
|
||||
return EDGE_MACRO_USAGE;
|
||||
}
|
||||
|
||||
return EDGE_NONE;
|
||||
return EDGE_UNDEFINED;
|
||||
}
|
||||
|
||||
Edge::Edge(Id id, EdgeType type, Node* from, Node* to)
|
||||
@@ -141,53 +135,28 @@ void Edge::addComponentAggregation(std::shared_ptr<TokenComponentAggregation> co
|
||||
}
|
||||
}
|
||||
|
||||
void Edge::addComponentAccess(std::shared_ptr<TokenComponentAccess> component)
|
||||
{
|
||||
if (getComponent<TokenComponentAccess>())
|
||||
{
|
||||
// LOG_ERROR("TokenComponentAccess has been set before!");
|
||||
return;
|
||||
}
|
||||
else if (m_type != EDGE_MEMBER && m_type != EDGE_INHERITANCE)
|
||||
{
|
||||
LOG_ERROR("TokenComponentAccess can't be set on edge of type: " + getTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
addComponent(component);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Edge::getTypeString(EdgeType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EDGE_NONE:
|
||||
return "none";
|
||||
case EDGE_UNDEFINED:
|
||||
return "undefined";
|
||||
case EDGE_MEMBER:
|
||||
return "child";
|
||||
case EDGE_TYPE_OF:
|
||||
return "type_of";
|
||||
case EDGE_RETURN_TYPE_OF:
|
||||
return "return_type";
|
||||
case EDGE_PARAMETER_TYPE_OF:
|
||||
return "parameter_type";
|
||||
case EDGE_TYPE_USAGE:
|
||||
return "type_use";
|
||||
case EDGE_USAGE:
|
||||
return "use";
|
||||
case EDGE_CALL:
|
||||
return "call";
|
||||
case EDGE_INHERITANCE:
|
||||
return "inheritance";
|
||||
case EDGE_OVERRIDE:
|
||||
return "override";
|
||||
case EDGE_CALL:
|
||||
return "call";
|
||||
case EDGE_USAGE:
|
||||
return "use";
|
||||
case EDGE_TYPEDEF_OF:
|
||||
return "typedef";
|
||||
case EDGE_TEMPLATE_PARAMETER:
|
||||
return "template_parameter";
|
||||
case EDGE_TEMPLATE_ARGUMENT:
|
||||
return "template_argument";
|
||||
case EDGE_TYPE_ARGUMENT:
|
||||
return "type_argument";
|
||||
case EDGE_TEMPLATE_DEFAULT_ARGUMENT:
|
||||
return "template_default_argument";
|
||||
case EDGE_TEMPLATE_SPECIALIZATION_OF:
|
||||
@@ -196,6 +165,8 @@ std::string Edge::getTypeString(EdgeType type)
|
||||
return "template_member_specialization";
|
||||
case EDGE_INCLUDE:
|
||||
return "include";
|
||||
case EDGE_IMPORT:
|
||||
return "import";
|
||||
case EDGE_AGGREGATION:
|
||||
return "aggregation";
|
||||
case EDGE_MACRO_USAGE:
|
||||
@@ -215,12 +186,6 @@ std::string Edge::getAsString() const
|
||||
std::stringstream str;
|
||||
str << "[" << getId() << "] " << getTypeString() << ": \"" << m_from->getName() << "\" -> \"" + m_to->getName() << "\"";
|
||||
|
||||
TokenComponentAccess* access = getComponent<TokenComponentAccess>();
|
||||
if (access)
|
||||
{
|
||||
str << " " << access->getAccessString();
|
||||
}
|
||||
|
||||
TokenComponentAggregation* aggregation = getComponent<TokenComponentAggregation>();
|
||||
if (aggregation)
|
||||
{
|
||||
|
||||
+15
-21
@@ -18,27 +18,22 @@ public:
|
||||
typedef int EdgeTypeMask;
|
||||
enum EdgeType : EdgeTypeMask
|
||||
{
|
||||
EDGE_NONE = 0x0,
|
||||
EDGE_UNDEFINED = 0x0,
|
||||
EDGE_MEMBER = 0x1,
|
||||
EDGE_TYPE_OF = 0x2,
|
||||
EDGE_RETURN_TYPE_OF = 0x4, // unused: see Storage::addFunctionNode()
|
||||
EDGE_PARAMETER_TYPE_OF = 0x8, // unused: see Storage::addFunctionNode()
|
||||
EDGE_TYPE_USAGE = 0x10,
|
||||
EDGE_USAGE = 0x20,
|
||||
EDGE_CALL = 0x40,
|
||||
EDGE_INHERITANCE = 0x80,
|
||||
EDGE_OVERRIDE = 0x100,
|
||||
EDGE_TYPEDEF_OF = 0x200,
|
||||
EDGE_TEMPLATE_PARAMETER = 0x400, // unused since template parameters are children
|
||||
EDGE_TEMPLATE_ARGUMENT = 0x800,
|
||||
EDGE_TEMPLATE_DEFAULT_ARGUMENT = 0x1000,
|
||||
EDGE_TEMPLATE_SPECIALIZATION_OF = 0x2000,
|
||||
EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF = 0x4000,
|
||||
|
||||
EDGE_INCLUDE = 0x8000,
|
||||
|
||||
EDGE_AGGREGATION = 0x10000,
|
||||
EDGE_MACRO_USAGE = 0x20000,
|
||||
EDGE_TYPE_USAGE = 0x2,
|
||||
EDGE_USAGE = 0x4,
|
||||
EDGE_CALL = 0x8,
|
||||
EDGE_INHERITANCE = 0x10,
|
||||
EDGE_OVERRIDE = 0x20,
|
||||
EDGE_TEMPLATE_ARGUMENT = 0x40,
|
||||
EDGE_TYPE_ARGUMENT = 0x80,
|
||||
EDGE_TEMPLATE_DEFAULT_ARGUMENT = 0x100,
|
||||
EDGE_TEMPLATE_SPECIALIZATION_OF = 0x200,
|
||||
EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF = 0x400,
|
||||
EDGE_INCLUDE = 0x800,
|
||||
EDGE_IMPORT = 0x1000,
|
||||
EDGE_AGGREGATION = 0x2000,
|
||||
EDGE_MACRO_USAGE = 0x4000
|
||||
};
|
||||
|
||||
static int typeToInt(EdgeType type);
|
||||
@@ -62,7 +57,6 @@ public:
|
||||
|
||||
// Component setters
|
||||
void addComponentAggregation(std::shared_ptr<TokenComponentAggregation> component);
|
||||
void addComponentAccess(std::shared_ptr<TokenComponentAccess> component);
|
||||
|
||||
// Logging.
|
||||
static std::string getTypeString(EdgeType type);
|
||||
|
||||
@@ -164,25 +164,6 @@ void Graph::removeEdge(Edge* edge)
|
||||
m_edges.erase(it);
|
||||
}
|
||||
|
||||
bool Graph::removeNodeIfUnreferencedRecursive(Node* node)
|
||||
{
|
||||
if (!node->hasReferences())
|
||||
{
|
||||
Node* parent = node->getParentNode();
|
||||
|
||||
removeNode(node);
|
||||
|
||||
if (parent)
|
||||
{
|
||||
removeNodeIfUnreferencedRecursive(parent);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Node* Graph::findNode(std::function<bool(Node*)> func) const
|
||||
{
|
||||
std::map<Id, std::shared_ptr<Node>>::const_iterator it = find_if(m_nodes.begin(), m_nodes.end(),
|
||||
|
||||
@@ -34,7 +34,6 @@ public:
|
||||
|
||||
void removeNode(Node* node);
|
||||
void removeEdge(Edge* edge);
|
||||
bool removeNodeIfUnreferencedRecursive(Node* node);
|
||||
|
||||
Node* findNode(std::function<bool(Node*)> func) const;
|
||||
Edge* findEdge(std::function<bool(Edge*)> func) const;
|
||||
|
||||
+53
-48
@@ -5,12 +5,13 @@
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "data/graph/token_component/TokenComponentAbstraction.h"
|
||||
#include "data/graph/token_component/TokenComponentAccess.h"
|
||||
#include "data/graph/token_component/TokenComponentConst.h"
|
||||
#include "data/graph/token_component/TokenComponentStatic.h"
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
|
||||
const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_UNDEFINED | Node::NODE_NAMESPACE;
|
||||
const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_UNDEFINED | Node::NODE_NAMESPACE | Node::NODE_PACKAGE;
|
||||
|
||||
std::string Node::getTypeString(NodeType type)
|
||||
{
|
||||
@@ -18,14 +19,20 @@ std::string Node::getTypeString(NodeType type)
|
||||
{
|
||||
case NODE_UNDEFINED:
|
||||
return "undefined";
|
||||
case NODE_BUILTIN_TYPE:
|
||||
return "builtin_type";
|
||||
case NODE_TYPE:
|
||||
return "type";
|
||||
case NODE_NAMESPACE:
|
||||
return "namespace";
|
||||
case NODE_CLASS:
|
||||
return "class";
|
||||
case NODE_PACKAGE:
|
||||
return "package";
|
||||
case NODE_STRUCT:
|
||||
return "struct";
|
||||
case NODE_CLASS:
|
||||
return "class";
|
||||
case NODE_INTERFACE:
|
||||
return "interface";
|
||||
case NODE_GLOBAL_VARIABLE:
|
||||
return "global_variable";
|
||||
case NODE_FIELD:
|
||||
@@ -42,6 +49,8 @@ std::string Node::getTypeString(NodeType type)
|
||||
return "typedef";
|
||||
case NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
return "template_parameter_type";
|
||||
case NODE_TYPE_PARAMETER:
|
||||
return "type_parameter";
|
||||
case NODE_FILE:
|
||||
return "file";
|
||||
case NODE_MACRO:
|
||||
@@ -60,33 +69,41 @@ Node::NodeType Node::intToType(int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0x2:
|
||||
case NODE_TYPE:
|
||||
return NODE_TYPE;
|
||||
case 0x4:
|
||||
case NODE_BUILTIN_TYPE:
|
||||
return NODE_BUILTIN_TYPE;
|
||||
case NODE_NAMESPACE:
|
||||
return NODE_NAMESPACE;
|
||||
case 0x8:
|
||||
case NODE_PACKAGE:
|
||||
return NODE_PACKAGE;
|
||||
case NODE_STRUCT:
|
||||
return NODE_STRUCT;
|
||||
case 0x10:
|
||||
case NODE_CLASS:
|
||||
return NODE_CLASS;
|
||||
case 0x20:
|
||||
case NODE_INTERFACE:
|
||||
return NODE_INTERFACE;
|
||||
case NODE_GLOBAL_VARIABLE:
|
||||
return NODE_GLOBAL_VARIABLE;
|
||||
case 0x40:
|
||||
case NODE_FIELD:
|
||||
return NODE_FIELD;
|
||||
case 0x80:
|
||||
case NODE_FUNCTION:
|
||||
return NODE_FUNCTION;
|
||||
case 0x100:
|
||||
case NODE_METHOD:
|
||||
return NODE_METHOD;
|
||||
case 0x200:
|
||||
case NODE_ENUM:
|
||||
return NODE_ENUM;
|
||||
case 0x400:
|
||||
case NODE_ENUM_CONSTANT:
|
||||
return NODE_ENUM_CONSTANT;
|
||||
case 0x800:
|
||||
case NODE_TYPEDEF:
|
||||
return NODE_TYPEDEF;
|
||||
case 0x1000:
|
||||
case NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
return NODE_TEMPLATE_PARAMETER_TYPE;
|
||||
case 0x2000:
|
||||
case NODE_TYPE_PARAMETER:
|
||||
return NODE_TYPE_PARAMETER;
|
||||
case NODE_FILE:
|
||||
return NODE_FILE;
|
||||
case 0x4000:
|
||||
case NODE_MACRO:
|
||||
return NODE_MACRO;
|
||||
}
|
||||
|
||||
@@ -324,37 +341,6 @@ void Node::forEachNodeRecursive(std::function<void(const Node*)> func) const
|
||||
);
|
||||
}
|
||||
|
||||
bool Node::hasReferences() const
|
||||
{
|
||||
if (getLocationIds().size() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hasChildrenWithReferences = false;
|
||||
size_t childNodeCount = 0;
|
||||
|
||||
forEachEdgeOfType(
|
||||
Edge::EDGE_MEMBER,
|
||||
[&](Edge* edge)
|
||||
{
|
||||
childNodeCount++;
|
||||
|
||||
if (!hasChildrenWithReferences && edge->getTo() != this && edge->getTo()->hasReferences())
|
||||
{
|
||||
hasChildrenWithReferences = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (hasChildrenWithReferences || getEdges().size() > childNodeCount)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Node::isNode() const
|
||||
{
|
||||
return true;
|
||||
@@ -450,6 +436,19 @@ void Node::addComponentSignature(std::shared_ptr<TokenComponentSignature> compon
|
||||
}
|
||||
}
|
||||
|
||||
void Node::addComponentAccess(std::shared_ptr<TokenComponentAccess> component)
|
||||
{
|
||||
if (getComponent<TokenComponentAccess>())
|
||||
{
|
||||
LOG_ERROR("TokenComponentAccess has been set before!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
addComponent(component);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Node::getTypeString() const
|
||||
{
|
||||
return getTypeString(m_type);
|
||||
@@ -460,6 +459,12 @@ std::string Node::getAsString() const
|
||||
std::stringstream str;
|
||||
str << "[" << getId() << "] " << getTypeString() << ": " << "\"" << getName() << "\"";
|
||||
|
||||
TokenComponentAccess* access = getComponent<TokenComponentAccess>();
|
||||
if (access)
|
||||
{
|
||||
str << " " << access->getAccessString();
|
||||
}
|
||||
|
||||
if (getComponent<TokenComponentStatic>())
|
||||
{
|
||||
str << " static";
|
||||
|
||||
+20
-16
@@ -11,6 +11,7 @@
|
||||
#include "data/name/NameHierarchy.h"
|
||||
|
||||
class TokenComponentAbstraction;
|
||||
class TokenComponentAccess;
|
||||
class TokenComponentConst;
|
||||
class TokenComponentStatic;
|
||||
class TokenComponentFilePath;
|
||||
@@ -22,25 +23,29 @@ class Node
|
||||
public:
|
||||
typedef int NodeTypeMask;
|
||||
enum NodeType : NodeTypeMask
|
||||
{
|
||||
{ // make sure that the value of 0x0 is not used here because it doesn't work for bitmasking.
|
||||
NODE_UNDEFINED = 0x1,
|
||||
NODE_TYPE = 0x2,
|
||||
NODE_BUILTIN_TYPE = 0x4,
|
||||
|
||||
NODE_NAMESPACE = 0x4,
|
||||
NODE_STRUCT = 0x8,
|
||||
NODE_CLASS = 0x10,
|
||||
NODE_GLOBAL_VARIABLE = 0x20,
|
||||
NODE_FIELD = 0x40,
|
||||
NODE_FUNCTION = 0x80,
|
||||
NODE_METHOD = 0x100,
|
||||
NODE_NAMESPACE = 0x8,
|
||||
NODE_PACKAGE = 0x10,
|
||||
NODE_STRUCT = 0x20,
|
||||
NODE_CLASS = 0x40,
|
||||
NODE_INTERFACE = 0x80,
|
||||
NODE_GLOBAL_VARIABLE = 0x100,
|
||||
NODE_FIELD = 0x200,
|
||||
NODE_FUNCTION = 0x400,
|
||||
NODE_METHOD = 0x800,
|
||||
|
||||
NODE_ENUM = 0x200,
|
||||
NODE_ENUM_CONSTANT = 0x400,
|
||||
NODE_TYPEDEF = 0x800,
|
||||
NODE_TEMPLATE_PARAMETER_TYPE = 0x1000,
|
||||
NODE_ENUM = 0x1000,
|
||||
NODE_ENUM_CONSTANT = 0x2000,
|
||||
NODE_TYPEDEF = 0x4000,
|
||||
NODE_TEMPLATE_PARAMETER_TYPE = 0x8000,
|
||||
NODE_TYPE_PARAMETER = 0x10000,
|
||||
|
||||
NODE_FILE = 0x2000,
|
||||
NODE_MACRO = 0x4000
|
||||
NODE_FILE = 0x20000,
|
||||
NODE_MACRO = 0x40000
|
||||
};
|
||||
|
||||
static std::string getTypeString(NodeType type);
|
||||
@@ -88,8 +93,6 @@ public:
|
||||
void forEachChildNode(std::function<void(Node*)> func) const;
|
||||
void forEachNodeRecursive(std::function<void(const Node*)> func) const;
|
||||
|
||||
bool hasReferences() const;
|
||||
|
||||
// Token implementation.
|
||||
virtual bool isNode() const;
|
||||
virtual bool isEdge() const;
|
||||
@@ -100,6 +103,7 @@ public:
|
||||
void addComponentStatic(std::shared_ptr<TokenComponentStatic> component);
|
||||
void addComponentFilePath(std::shared_ptr<TokenComponentFilePath> component);
|
||||
void addComponentSignature(std::shared_ptr<TokenComponentSignature> component);
|
||||
void addComponentAccess(std::shared_ptr<TokenComponentAccess> component);
|
||||
|
||||
// Logging.
|
||||
virtual std::string getTypeString() const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "data/graph/token_component/TokenComponentAccess.h"
|
||||
|
||||
std::string TokenComponentAccess::getAccessString(AccessType access)
|
||||
std::string TokenComponentAccess::getAccessString(AccessKind access)
|
||||
{
|
||||
switch (access)
|
||||
{
|
||||
@@ -10,38 +10,18 @@ std::string TokenComponentAccess::getAccessString(AccessType access)
|
||||
return "protected";
|
||||
case ACCESS_PRIVATE:
|
||||
return "private";
|
||||
case ACCESS_TEMPLATE:
|
||||
case ACCESS_DEFAULT:
|
||||
return "default";
|
||||
case ACCESS_TEMPLATE_PARAMETER:
|
||||
return "template parameter";
|
||||
case ACCESS_NONE:
|
||||
return "";
|
||||
case ACCESS_TYPE_PARAMETER:
|
||||
return "type parameter";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
int TokenComponentAccess::typeToInt(AccessType type)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
TokenComponentAccess::AccessType TokenComponentAccess::intToType(int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0x1:
|
||||
return ACCESS_PUBLIC;
|
||||
case 0x2:
|
||||
return ACCESS_PROTECTED;
|
||||
case 0x4:
|
||||
return ACCESS_PRIVATE;
|
||||
case 0x8:
|
||||
return ACCESS_TEMPLATE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ACCESS_NONE;
|
||||
}
|
||||
|
||||
TokenComponentAccess::TokenComponentAccess(AccessType access)
|
||||
TokenComponentAccess::TokenComponentAccess(AccessKind access)
|
||||
: m_access(access)
|
||||
{
|
||||
}
|
||||
@@ -55,7 +35,7 @@ std::shared_ptr<TokenComponent> TokenComponentAccess::copy() const
|
||||
return std::make_shared<TokenComponentAccess>(*this);
|
||||
}
|
||||
|
||||
TokenComponentAccess::AccessType TokenComponentAccess::getAccess() const
|
||||
AccessKind TokenComponentAccess::getAccess() const
|
||||
{
|
||||
return m_access;
|
||||
}
|
||||
|
||||
@@ -4,35 +4,24 @@
|
||||
#include <string>
|
||||
|
||||
#include "data/graph/token_component/TokenComponent.h"
|
||||
#include "data/parser/AccessKind.h"
|
||||
|
||||
class TokenComponentAccess
|
||||
: public TokenComponent
|
||||
{
|
||||
public:
|
||||
enum AccessType : int // todo: use normal numbers here. not 2^x
|
||||
{
|
||||
ACCESS_PUBLIC = 0x1,
|
||||
ACCESS_PROTECTED = 0x2,
|
||||
ACCESS_PRIVATE = 0x4,
|
||||
ACCESS_TEMPLATE = 0x8,
|
||||
ACCESS_NONE = 0x0
|
||||
};
|
||||
static std::string getAccessString(AccessKind access);
|
||||
|
||||
static std::string getAccessString(AccessType access);
|
||||
|
||||
static int typeToInt(AccessType type);
|
||||
static AccessType intToType(int value);
|
||||
|
||||
TokenComponentAccess(AccessType access);
|
||||
TokenComponentAccess(AccessKind access);
|
||||
virtual ~TokenComponentAccess();
|
||||
|
||||
virtual std::shared_ptr<TokenComponent> copy() const;
|
||||
|
||||
AccessType getAccess() const;
|
||||
AccessKind getAccess() const;
|
||||
std::string getAccessString() const;
|
||||
|
||||
private:
|
||||
const AccessType m_access;
|
||||
const AccessKind m_access;
|
||||
};
|
||||
|
||||
#endif // TOKEN_COMPONENT_ACCESS_H
|
||||
|
||||
@@ -38,7 +38,11 @@ std::string NameElement::Signature::qualifyName(const std::string& name) const
|
||||
std::string qualifiedName = m_prefix;
|
||||
if (name.size() > 0)
|
||||
{
|
||||
qualifiedName += " " + name;
|
||||
if (!m_prefix.empty())
|
||||
{
|
||||
qualifiedName += " ";
|
||||
}
|
||||
qualifiedName += name;
|
||||
}
|
||||
qualifiedName += m_postfix;
|
||||
|
||||
|
||||
@@ -87,26 +87,26 @@ size_t NameHierarchy::size() const
|
||||
return m_elements.size();
|
||||
}
|
||||
|
||||
std::string NameHierarchy::getQualifiedName() const
|
||||
std::string NameHierarchy::getQualifiedName(const std::string& delimiter) const
|
||||
{
|
||||
std::string name;
|
||||
for (size_t i = 0; i < m_elements.size(); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
name += "::";
|
||||
name += delimiter;
|
||||
}
|
||||
name += m_elements[i]->getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string NameHierarchy::getQualifiedNameWithSignature() const
|
||||
std::string NameHierarchy::getQualifiedNameWithSignature(const std::string& delimiter) const
|
||||
{
|
||||
std::string name = getQualifiedName();
|
||||
std::string name = getQualifiedName(delimiter);
|
||||
if (m_elements.size())
|
||||
{
|
||||
name = m_elements.back()->getSignature().qualifyName(name);
|
||||
name = m_elements.back()->getSignature().qualifyName(name); // todo: use separator for signature!
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
std::shared_ptr<NameElement> operator[](size_t pos) const;
|
||||
size_t size() const;
|
||||
|
||||
std::string getQualifiedName() const;
|
||||
std::string getQualifiedNameWithSignature() const;
|
||||
std::string getQualifiedName(const std::string& delimiter = "::") const;
|
||||
std::string getQualifiedNameWithSignature(const std::string& delimiter = "::") const;
|
||||
std::string getRawName() const;
|
||||
std::string getRawNameWithSignature() const;
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "data/parser/AccessKind.h"
|
||||
|
||||
AccessKind intToAccessKind(int v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case ACCESS_PUBLIC:
|
||||
return ACCESS_PUBLIC;
|
||||
case ACCESS_PROTECTED:
|
||||
return ACCESS_PROTECTED;
|
||||
case ACCESS_PRIVATE:
|
||||
return ACCESS_PRIVATE;
|
||||
case ACCESS_DEFAULT:
|
||||
return ACCESS_DEFAULT;
|
||||
case ACCESS_TEMPLATE_PARAMETER:
|
||||
return ACCESS_TEMPLATE_PARAMETER;
|
||||
case ACCESS_TYPE_PARAMETER:
|
||||
return ACCESS_TYPE_PARAMETER;
|
||||
}
|
||||
return ACCESS_NONE;
|
||||
}
|
||||
|
||||
int accessKindToInt(AccessKind t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef ACCESS_KIND_H
|
||||
#define ACCESS_KIND_H
|
||||
|
||||
enum AccessKind
|
||||
{ // these values need to be the same as AccessType in Java code
|
||||
ACCESS_NONE = 0,
|
||||
ACCESS_PUBLIC = 1,
|
||||
ACCESS_PROTECTED = 2,
|
||||
ACCESS_PRIVATE = 3,
|
||||
ACCESS_DEFAULT = 4,
|
||||
ACCESS_TEMPLATE_PARAMETER = 5,
|
||||
ACCESS_TYPE_PARAMETER = 6
|
||||
};
|
||||
|
||||
AccessKind intToAccessKind(int v);
|
||||
int accessKindToInt(AccessKind t);
|
||||
|
||||
#endif // ACCESS_KIND_H
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
{
|
||||
Arguments();
|
||||
|
||||
std::vector<FilePath> javaClassPaths;
|
||||
|
||||
std::vector<FilePath> headerSearchPaths;
|
||||
std::vector<FilePath> systemHeaderSearchPaths;
|
||||
std::vector<FilePath> frameworkSearchPaths;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "data/type/DataType.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
std::string ParserClient::addAccessPrefix(const std::string& str, AccessType access)
|
||||
std::string ParserClient::addAccessPrefix(const std::string& str, AccessKind access)
|
||||
{
|
||||
switch (access)
|
||||
{
|
||||
@@ -16,9 +16,10 @@ std::string ParserClient::addAccessPrefix(const std::string& str, AccessType acc
|
||||
return "protected " + str;
|
||||
case ACCESS_PRIVATE:
|
||||
return "private " + str;
|
||||
case ACCESS_NONE:
|
||||
return str;
|
||||
case ACCESS_DEFAULT:
|
||||
return "default " + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string ParserClient::addAbstractionPrefix(const std::string& str, AbstractionType abstraction)
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
#include <vector>
|
||||
|
||||
#include "data/name/NameHierarchy.h"
|
||||
#include "data/parser/SymbolType.h"
|
||||
#include "data/parser/AccessKind.h"
|
||||
#include "data/parser/ReferenceKind.h"
|
||||
#include "data/parser/SymbolKind.h"
|
||||
#include "utility/file/FileInfo.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
@@ -15,20 +17,13 @@ class DataType;
|
||||
class ParserClient
|
||||
{
|
||||
public:
|
||||
enum AccessType {
|
||||
ACCESS_PUBLIC,
|
||||
ACCESS_PROTECTED,
|
||||
ACCESS_PRIVATE,
|
||||
ACCESS_NONE
|
||||
};
|
||||
|
||||
enum AbstractionType {
|
||||
ABSTRACTION_VIRTUAL,
|
||||
ABSTRACTION_PURE_VIRTUAL,
|
||||
ABSTRACTION_NONE
|
||||
};
|
||||
|
||||
static std::string addAccessPrefix(const std::string& str, AccessType access);
|
||||
static std::string addAccessPrefix(const std::string& str, AccessKind access);
|
||||
static std::string addAbstractionPrefix(const std::string& str, AbstractionType abstraction);
|
||||
static std::string addStaticPrefix(const std::string& str, bool isStatic);
|
||||
static std::string addConstPrefix(const std::string& str, bool isConst, bool atFront);
|
||||
@@ -42,28 +37,46 @@ public:
|
||||
virtual void startParsingFile() = 0;
|
||||
virtual void finishParsingFile() = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false) = 0;
|
||||
|
||||
virtual void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location) = 0;
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) = 0;
|
||||
|
||||
virtual void onTypedefParsed(
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit) = 0;
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessKind access, bool isImplicit) = 0;
|
||||
virtual void onClassParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit) = 0;
|
||||
virtual void onStructParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit) = 0;
|
||||
virtual void onGlobalVariableParsed(const ParseLocation& location, const NameHierarchy& variable, bool isImplicit) = 0;
|
||||
virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessType access, bool isImplicit) = 0;
|
||||
virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessKind access, bool isImplicit) = 0;
|
||||
virtual void onFunctionParsed(
|
||||
const ParseLocation& location, const NameHierarchy& function, const ParseLocation& scopeLocation, bool isImplicit) = 0;
|
||||
virtual void onMethodParsed(
|
||||
const ParseLocation& location, const NameHierarchy& method, AccessType access, AbstractionType abstraction,
|
||||
const ParseLocation& location, const NameHierarchy& method, AccessKind access, AbstractionType abstraction,
|
||||
const ParseLocation& scopeLocation, bool isImplicit) = 0;
|
||||
virtual void onNamespaceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy,
|
||||
const ParseLocation& scopeLocation, bool isImplicit) = 0;
|
||||
virtual void onEnumParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit) = 0;
|
||||
virtual void onEnumConstantParsed(const ParseLocation& location, const NameHierarchy& nameHierarchy, bool isImplicit) = 0;
|
||||
virtual void onTemplateParameterTypeParsed(
|
||||
@@ -76,13 +89,13 @@ public:
|
||||
|
||||
virtual void onInheritanceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy,
|
||||
const NameHierarchy& baseNameHierarchy, AccessType access) = 0;
|
||||
const NameHierarchy& baseNameHierarchy) = 0;
|
||||
virtual void onMethodOverrideParsed(
|
||||
const ParseLocation& location, const NameHierarchy& overridden, const NameHierarchy& overrider) = 0;
|
||||
virtual void onCallParsed(
|
||||
const ParseLocation& location, const NameHierarchy& caller, const NameHierarchy& callee) = 0;
|
||||
virtual void onUsageParsed(
|
||||
const ParseLocation& location, const NameHierarchy& userName, SymbolType usedType, const NameHierarchy& usedName) = 0;
|
||||
const ParseLocation& location, const NameHierarchy& userName, SymbolKind usedType, const NameHierarchy& usedName) = 0;
|
||||
virtual void onTypeUsageParsed(const ParseLocation& location, const NameHierarchy& user, const NameHierarchy& used) = 0;
|
||||
|
||||
virtual void onTemplateArgumentTypeParsed(
|
||||
|
||||
@@ -27,13 +27,57 @@ void ParserClientImpl::resetStorage()
|
||||
|
||||
void ParserClientImpl::startParsingFile()
|
||||
{
|
||||
m_nodeIdsToMemberEdgeIds.clear(); // remove this when one parserclient is created per file
|
||||
}
|
||||
|
||||
void ParserClientImpl::finishParsingFile()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access, bool isImplicit
|
||||
)
|
||||
{
|
||||
Id nodeId = addNodeHierarchy(symbolKindToNodeType(symbolType), symbolName, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addAccess(nodeId, access);
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, bool isImplicit
|
||||
)
|
||||
{
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, access, isImplicit);
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, bool isImplicit
|
||||
)
|
||||
{
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, location, access, isImplicit);
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
void ParserClientImpl::recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location)
|
||||
{
|
||||
Id contextNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, contextName, DEFINITION_NONE);
|
||||
Id referencedNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, referencedName, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(referenceKindToEdgeType(referenceKind), contextNodeId, referencedNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ParserClientImpl::onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
||||
{
|
||||
log(std::string(fatal ? "FATAL: " : "ERROR: "), message, location);
|
||||
@@ -47,7 +91,7 @@ void ParserClientImpl::onError(const ParseLocation& location, const std::string&
|
||||
}
|
||||
|
||||
void ParserClientImpl::onTypedefParsed(
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit)
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessKind access, bool isImplicit)
|
||||
{
|
||||
log("typedef", typedefName.getQualifiedName(), location);
|
||||
|
||||
@@ -57,7 +101,7 @@ void ParserClientImpl::onTypedefParsed(
|
||||
}
|
||||
|
||||
void ParserClientImpl::onClassParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("class", nameHierarchy.getQualifiedName(), location);
|
||||
@@ -73,7 +117,7 @@ void ParserClientImpl::onClassParsed(
|
||||
}
|
||||
|
||||
void ParserClientImpl::onStructParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("struct", nameHierarchy.getQualifiedName(), location);
|
||||
@@ -96,7 +140,7 @@ void ParserClientImpl::onGlobalVariableParsed(const ParseLocation& location, con
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessType access, bool isImplicit)
|
||||
void ParserClientImpl::onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessKind access, bool isImplicit)
|
||||
{
|
||||
log("field", field.getQualifiedName(), location);
|
||||
|
||||
@@ -116,7 +160,7 @@ void ParserClientImpl::onFunctionParsed(
|
||||
}
|
||||
|
||||
void ParserClientImpl::onMethodParsed(
|
||||
const ParseLocation& location, const NameHierarchy& method, AccessType access, AbstractionType abstraction,
|
||||
const ParseLocation& location, const NameHierarchy& method, AccessKind access, AbstractionType abstraction, // todo: remove abstractio... better: remove this method!
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("method", method.getQualifiedNameWithSignature(), location);
|
||||
@@ -142,7 +186,7 @@ void ParserClientImpl::onNamespaceParsed(
|
||||
}
|
||||
|
||||
void ParserClientImpl::onEnumParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
log("enum", nameHierarchy.getQualifiedName(), location);
|
||||
@@ -168,7 +212,7 @@ void ParserClientImpl::onTemplateParameterTypeParsed(
|
||||
|
||||
Id nodeId = addNodeHierarchy(Node::NODE_TEMPLATE_PARAMETER_TYPE, templateParameterTypeNameHierarchy, (isImplicit ? DEFINITION_IMPLICIT : DEFINITION_EXPLICIT));
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
addAccess(nodeId, TokenComponentAccess::ACCESS_TEMPLATE);
|
||||
addAccess(nodeId, ACCESS_TEMPLATE_PARAMETER);
|
||||
}
|
||||
|
||||
void ParserClientImpl::onLocalSymbolParsed(const std::string& name, const ParseLocation& location)
|
||||
@@ -214,7 +258,7 @@ void ParserClientImpl::onCommentParsed(const ParseLocation& location)
|
||||
|
||||
void ParserClientImpl::onInheritanceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& childNameHierarchy,
|
||||
const NameHierarchy& parentNameHierarchy, AccessType access)
|
||||
const NameHierarchy& parentNameHierarchy)
|
||||
{
|
||||
log("inheritance", childNameHierarchy.getQualifiedName() + " : " + parentNameHierarchy.getQualifiedName(), location);
|
||||
|
||||
@@ -246,12 +290,12 @@ void ParserClientImpl::onCallParsed(const ParseLocation& location, const NameHie
|
||||
}
|
||||
|
||||
void ParserClientImpl::onUsageParsed(
|
||||
const ParseLocation& location, const NameHierarchy& userName, SymbolType usedType, const NameHierarchy& usedName)
|
||||
const ParseLocation& location, const NameHierarchy& userName, SymbolKind usedType, const NameHierarchy& usedName)
|
||||
{
|
||||
log("usage", userName.getQualifiedNameWithSignature() + " -> " + usedName.getQualifiedName(), location);
|
||||
|
||||
Id userNodeId = addNodeHierarchy(Node::NODE_UNDEFINED, userName, DEFINITION_NONE);
|
||||
Id usedNodeId = addNodeHierarchy(symbolTypeToNodeType(usedType), usedName, DEFINITION_NONE);
|
||||
Id usedNodeId = addNodeHierarchy(symbolKindToNodeType(usedType), usedName, DEFINITION_NONE);
|
||||
Id edgeId = addEdge(Edge::EDGE_USAGE, userNodeId, usedNodeId);
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
@@ -354,10 +398,12 @@ void ParserClientImpl::onMacroExpandParsed(const ParseLocation &location, const
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
Node::NodeType ParserClientImpl::symbolTypeToNodeType(SymbolType symbolType) const
|
||||
Node::NodeType ParserClientImpl::symbolKindToNodeType(SymbolKind symbolType) const
|
||||
{
|
||||
switch (symbolType)
|
||||
{
|
||||
case SYMBOL_BUILTIN_TYPE:
|
||||
return Node::NODE_BUILTIN_TYPE;
|
||||
case SYMBOL_CLASS:
|
||||
return Node::NODE_CLASS;
|
||||
case SYMBOL_ENUM:
|
||||
@@ -370,18 +416,24 @@ Node::NodeType ParserClientImpl::symbolTypeToNodeType(SymbolType symbolType) con
|
||||
return Node::NODE_FUNCTION;
|
||||
case SYMBOL_GLOBAL_VARIABLE:
|
||||
return Node::NODE_GLOBAL_VARIABLE;
|
||||
case SYMBOL_INTERFACE:
|
||||
return Node::NODE_INTERFACE;
|
||||
case SYMBOL_MACRO:
|
||||
return Node::NODE_MACRO;
|
||||
case SYMBOL_METHOD:
|
||||
return Node::NODE_METHOD;
|
||||
case SYMBOL_NAMESPACE:
|
||||
return Node::NODE_NAMESPACE;
|
||||
case SYMBOL_PACKAGE:
|
||||
return Node::NODE_PACKAGE;
|
||||
case SYMBOL_STRUCT:
|
||||
return Node::NODE_STRUCT;
|
||||
case SYMBOL_TYPEDEF:
|
||||
return Node::NODE_TYPEDEF;
|
||||
case SYMBOL_TEMPLATE_PARAMETER:
|
||||
return Node::NODE_TEMPLATE_PARAMETER_TYPE;
|
||||
case SYMBOL_TYPEDEF:
|
||||
return Node::NODE_TYPEDEF;
|
||||
case SYMBOL_TYPE_PARAMETER:
|
||||
return Node::NODE_TYPE_PARAMETER;
|
||||
case SYMBOL_UNION:
|
||||
return Node::NODE_TYPE;
|
||||
default:
|
||||
@@ -390,34 +442,48 @@ Node::NodeType ParserClientImpl::symbolTypeToNodeType(SymbolType symbolType) con
|
||||
return Node::NODE_UNDEFINED;
|
||||
}
|
||||
|
||||
TokenComponentAccess::AccessType ParserClientImpl::convertAccessType(ParserClient::AccessType access) const
|
||||
Edge::EdgeType ParserClientImpl::referenceKindToEdgeType(ReferenceKind referenceKind) const
|
||||
{
|
||||
switch (access)
|
||||
switch (referenceKind)
|
||||
{
|
||||
case ACCESS_PUBLIC:
|
||||
return TokenComponentAccess::ACCESS_PUBLIC;
|
||||
case ACCESS_PROTECTED:
|
||||
return TokenComponentAccess::ACCESS_PROTECTED;
|
||||
case ACCESS_PRIVATE:
|
||||
return TokenComponentAccess::ACCESS_PRIVATE;
|
||||
case ACCESS_NONE:
|
||||
return TokenComponentAccess::ACCESS_NONE;
|
||||
case REFERENCE_TYPE_USAGE:
|
||||
return Edge::EDGE_TYPE_USAGE;
|
||||
case REFERENCE_USAGE:
|
||||
return Edge::EDGE_USAGE;
|
||||
case REFERENCE_CALL:
|
||||
return Edge::EDGE_CALL;
|
||||
case REFERENCE_INHERITANCE:
|
||||
return Edge::EDGE_INHERITANCE;
|
||||
case REFERENCE_OVERRIDE:
|
||||
return Edge::EDGE_OVERRIDE;
|
||||
case REFERENCE_TEMPLATE_ARGUMENT:
|
||||
return Edge::EDGE_TEMPLATE_ARGUMENT;
|
||||
case REFERENCE_TYPE_ARGUMENT:
|
||||
return Edge::EDGE_TYPE_ARGUMENT;
|
||||
case REFERENCE_TEMPLATE_DEFAULT_ARGUMENT:
|
||||
return Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT;
|
||||
case REFERENCE_TEMPLATE_SPECIALIZATION_OF:
|
||||
return Edge::EDGE_TEMPLATE_SPECIALIZATION_OF;
|
||||
case REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF:
|
||||
return Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION_OF;
|
||||
case REFERENCE_INCLUDE:
|
||||
return Edge::EDGE_INCLUDE;
|
||||
case REFERENCE_IMPORT:
|
||||
return Edge::EDGE_IMPORT;
|
||||
case REFERENCE_MACRO_USAGE:
|
||||
return Edge::EDGE_MACRO_USAGE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Edge::EDGE_UNDEFINED;
|
||||
}
|
||||
|
||||
void ParserClientImpl::addAccess(Id nodeId, ParserClient::AccessType access)
|
||||
void ParserClientImpl::addAccess(Id nodeId, AccessKind access)
|
||||
{
|
||||
addAccess(nodeId, convertAccessType(access));
|
||||
}
|
||||
|
||||
void ParserClientImpl::addAccess(Id nodeId, TokenComponentAccess::AccessType access)
|
||||
{
|
||||
if (access == TokenComponentAccess::ACCESS_NONE)
|
||||
if (access != ACCESS_NONE)
|
||||
{
|
||||
return;
|
||||
addComponentAccess(nodeId, accessKindToInt(access));
|
||||
}
|
||||
|
||||
addComponentAccess(nodeId, access);
|
||||
}
|
||||
|
||||
Id ParserClientImpl::addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, DefinitionType definitionType)
|
||||
@@ -493,14 +559,7 @@ Id ParserClientImpl::addEdge(int type, Id sourceId, Id targetId)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Id edgeId = m_storage->addEdge(type, sourceId, targetId);
|
||||
|
||||
if (type == Edge::EDGE_MEMBER)
|
||||
{
|
||||
m_nodeIdsToMemberEdgeIds[targetId] = edgeId;
|
||||
}
|
||||
|
||||
return edgeId;
|
||||
return m_storage->addEdge(type, sourceId, targetId);
|
||||
}
|
||||
|
||||
Id ParserClientImpl::addLocalSymbol(const std::string& name)
|
||||
@@ -549,15 +608,7 @@ void ParserClientImpl::addComponentAccess(Id nodeId , int type)
|
||||
return;
|
||||
}
|
||||
|
||||
std::unordered_map<Id, Id>::const_iterator it = m_nodeIdsToMemberEdgeIds.find(nodeId);
|
||||
if (it != m_nodeIdsToMemberEdgeIds.end())
|
||||
{
|
||||
m_storage->addComponentAccess(it->second, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Cannot assign access" << type << " to node id " << nodeId << " because it's not a child node.");
|
||||
}
|
||||
m_storage->addComponentAccess(nodeId, type);
|
||||
}
|
||||
|
||||
void ParserClientImpl::addCommentLocation(const ParseLocation& location)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef PARSER_CLIENT_IMPL_H
|
||||
#define PARSER_CLIENT_IMPL_H
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "data/IntermediateStorage.h"
|
||||
@@ -21,28 +23,47 @@ public:
|
||||
virtual void startParsingFile();
|
||||
virtual void finishParsingFile();
|
||||
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false);
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false);
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false);
|
||||
|
||||
virtual void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location);
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed);
|
||||
|
||||
virtual void onTypedefParsed(
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit);
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessKind access, bool isImplicit);
|
||||
virtual void onClassParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit);
|
||||
virtual void onStructParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit);
|
||||
virtual void onGlobalVariableParsed(const ParseLocation& location, const NameHierarchy& variable, bool isImplicit);
|
||||
virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessType access, bool isImplicit);
|
||||
virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessKind access, bool isImplicit);
|
||||
virtual void onFunctionParsed(
|
||||
const ParseLocation& location, const NameHierarchy& function, const ParseLocation& scopeLocation, bool isImplicit);
|
||||
virtual void onMethodParsed(
|
||||
const ParseLocation& location, const NameHierarchy& method, AccessType access, AbstractionType abstraction,
|
||||
const ParseLocation& location, const NameHierarchy& method, AccessKind access, AbstractionType abstraction,
|
||||
const ParseLocation& scopeLocation, bool isImplicit);
|
||||
virtual void onNamespaceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy,
|
||||
const ParseLocation& scopeLocation, bool isImplicit);
|
||||
virtual void onEnumParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit);
|
||||
virtual void onEnumConstantParsed(const ParseLocation& location, const NameHierarchy& nameHierarchy, bool isImplicit);
|
||||
virtual void onTemplateParameterTypeParsed(
|
||||
@@ -55,13 +76,13 @@ public:
|
||||
|
||||
virtual void onInheritanceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy,
|
||||
const NameHierarchy& baseNameHierarchy, AccessType access);
|
||||
const NameHierarchy& baseNameHierarchy);
|
||||
virtual void onMethodOverrideParsed(
|
||||
const ParseLocation& location, const NameHierarchy& overridden, const NameHierarchy& overrider);
|
||||
virtual void onCallParsed(
|
||||
const ParseLocation& location, const NameHierarchy& caller, const NameHierarchy& callee);
|
||||
virtual void onUsageParsed(
|
||||
const ParseLocation& location, const NameHierarchy& userName, SymbolType usedType, const NameHierarchy& usedName);
|
||||
const ParseLocation& location, const NameHierarchy& userName, SymbolKind usedType, const NameHierarchy& usedName);
|
||||
virtual void onTypeUsageParsed(const ParseLocation& location, const NameHierarchy& user, const NameHierarchy& used);
|
||||
|
||||
virtual void onTemplateArgumentTypeParsed(
|
||||
@@ -83,10 +104,9 @@ public:
|
||||
const ParseLocation& location, const NameHierarchy& macroNameHierarchy);
|
||||
|
||||
private:
|
||||
Node::NodeType symbolTypeToNodeType(SymbolType symbolType) const;
|
||||
TokenComponentAccess::AccessType convertAccessType(ParserClient::AccessType access) const;
|
||||
void addAccess(Id nodeId, ParserClient::AccessType access);
|
||||
void addAccess(Id nodeId, TokenComponentAccess::AccessType access);
|
||||
Node::NodeType symbolKindToNodeType(SymbolKind symbolType) const;
|
||||
Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const;
|
||||
void addAccess(Id nodeId, AccessKind access);
|
||||
Id addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, DefinitionType definitionType);
|
||||
|
||||
Id addFile(const std::string& name, const std::string& filePath, const std::string& modificationTime);
|
||||
@@ -102,7 +122,6 @@ private:
|
||||
void log(std::string type, std::string str, const ParseLocation& location) const;
|
||||
|
||||
std::shared_ptr<IntermediateStorage> m_storage;
|
||||
std::unordered_map<Id, Id> m_nodeIdsToMemberEdgeIds;
|
||||
};
|
||||
|
||||
#endif // PARSER_CLIENT_IMPL_H
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "data/parser/ReferenceKind.h"
|
||||
|
||||
ReferenceKind intToReferenceKind(int v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case REFERENCE_TYPE_USAGE:
|
||||
return REFERENCE_TYPE_USAGE;
|
||||
case REFERENCE_USAGE:
|
||||
return REFERENCE_USAGE;
|
||||
case REFERENCE_CALL:
|
||||
return REFERENCE_CALL;
|
||||
case REFERENCE_INHERITANCE:
|
||||
return REFERENCE_INHERITANCE;
|
||||
case REFERENCE_OVERRIDE:
|
||||
return REFERENCE_OVERRIDE;
|
||||
case REFERENCE_TEMPLATE_ARGUMENT:
|
||||
return REFERENCE_TEMPLATE_ARGUMENT;
|
||||
case REFERENCE_TYPE_ARGUMENT:
|
||||
return REFERENCE_TYPE_ARGUMENT;
|
||||
case REFERENCE_TEMPLATE_DEFAULT_ARGUMENT:
|
||||
return REFERENCE_TEMPLATE_DEFAULT_ARGUMENT;
|
||||
case REFERENCE_TEMPLATE_SPECIALIZATION_OF:
|
||||
return REFERENCE_TEMPLATE_SPECIALIZATION_OF;
|
||||
case REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF:
|
||||
return REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF;
|
||||
case REFERENCE_INCLUDE:
|
||||
return REFERENCE_INCLUDE;
|
||||
case REFERENCE_IMPORT:
|
||||
return REFERENCE_IMPORT;
|
||||
case REFERENCE_MACRO_USAGE:
|
||||
return REFERENCE_MACRO_USAGE;
|
||||
}
|
||||
return REFERENCE_UNDEFINED;
|
||||
}
|
||||
|
||||
int referenceKindToInt(ReferenceKind t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef REFERENCE_KIND_H
|
||||
#define REFERENCE_KIND_H
|
||||
|
||||
enum ReferenceKind
|
||||
{ // these values need to be the same as ReferenceKind in Java code
|
||||
REFERENCE_UNDEFINED = 0,
|
||||
REFERENCE_TYPE_USAGE = 1,
|
||||
REFERENCE_USAGE = 2,
|
||||
REFERENCE_CALL = 3,
|
||||
REFERENCE_INHERITANCE = 4,
|
||||
REFERENCE_OVERRIDE = 5,
|
||||
REFERENCE_TEMPLATE_ARGUMENT = 6,
|
||||
REFERENCE_TYPE_ARGUMENT = 7,
|
||||
REFERENCE_TEMPLATE_DEFAULT_ARGUMENT = 8,
|
||||
REFERENCE_TEMPLATE_SPECIALIZATION_OF = 9,
|
||||
REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION_OF = 10,
|
||||
REFERENCE_INCLUDE = 11,
|
||||
REFERENCE_IMPORT = 12,
|
||||
REFERENCE_MACRO_USAGE = 13
|
||||
};
|
||||
|
||||
ReferenceKind intToReferenceKind(int v);
|
||||
int referenceKindToInt(ReferenceKind t);
|
||||
|
||||
#endif // REFERENCE_KIND_H
|
||||
@@ -0,0 +1,53 @@
|
||||
#include "data/parser/SymbolKind.h"
|
||||
|
||||
SymbolKind intToSymbolKind(int v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case SYMBOL_BUILTIN_TYPE:
|
||||
return SYMBOL_BUILTIN_TYPE;
|
||||
case SYMBOL_CLASS:
|
||||
return SYMBOL_CLASS;
|
||||
case SYMBOL_ENUM:
|
||||
return SYMBOL_ENUM;
|
||||
case SYMBOL_ENUM_CONSTANT:
|
||||
return SYMBOL_ENUM_CONSTANT;
|
||||
case SYMBOL_FIELD:
|
||||
return SYMBOL_FIELD;
|
||||
case SYMBOL_FUNCTION:
|
||||
return SYMBOL_FUNCTION;
|
||||
case SYMBOL_GLOBAL_VARIABLE:
|
||||
return SYMBOL_GLOBAL_VARIABLE;
|
||||
case SYMBOL_INTERFACE:
|
||||
return SYMBOL_INTERFACE;
|
||||
case SYMBOL_LOCAL_VARIABLE:
|
||||
return SYMBOL_LOCAL_VARIABLE;
|
||||
case SYMBOL_MACRO:
|
||||
return SYMBOL_MACRO;
|
||||
case SYMBOL_METHOD:
|
||||
return SYMBOL_METHOD;
|
||||
case SYMBOL_NAMESPACE:
|
||||
return SYMBOL_NAMESPACE;
|
||||
case SYMBOL_PACKAGE:
|
||||
return SYMBOL_PACKAGE;
|
||||
case SYMBOL_PARAMETER:
|
||||
return SYMBOL_PARAMETER;
|
||||
case SYMBOL_STRUCT:
|
||||
return SYMBOL_STRUCT;
|
||||
case SYMBOL_TEMPLATE_PARAMETER:
|
||||
return SYMBOL_TEMPLATE_PARAMETER;
|
||||
case SYMBOL_TYPEDEF:
|
||||
return SYMBOL_TYPEDEF;
|
||||
case SYMBOL_TYPE_PARAMETER:
|
||||
return SYMBOL_TYPE_PARAMETER;
|
||||
case SYMBOL_UNION:
|
||||
return SYMBOL_UNION;
|
||||
}
|
||||
return SYMBOL_KIND_MAX;
|
||||
}
|
||||
|
||||
int symbolKindToInt(SymbolKind t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef SYMBOL_KIND_H
|
||||
#define SYMBOL_KIND_H
|
||||
|
||||
enum SymbolKind
|
||||
{ // these values need to be the same as SymbolType in Java code
|
||||
SYMBOL_BUILTIN_TYPE = 1,
|
||||
SYMBOL_CLASS = 2,
|
||||
SYMBOL_ENUM = 3,
|
||||
SYMBOL_ENUM_CONSTANT = 4,
|
||||
SYMBOL_FIELD = 5,
|
||||
SYMBOL_FUNCTION = 6,
|
||||
SYMBOL_GLOBAL_VARIABLE = 7,
|
||||
SYMBOL_INTERFACE = 8,
|
||||
SYMBOL_LOCAL_VARIABLE = 9,
|
||||
SYMBOL_MACRO = 10,
|
||||
SYMBOL_METHOD = 11,
|
||||
SYMBOL_NAMESPACE = 12,
|
||||
SYMBOL_PACKAGE = 13,
|
||||
SYMBOL_PARAMETER = 14,
|
||||
SYMBOL_STRUCT = 15,
|
||||
SYMBOL_TEMPLATE_PARAMETER = 16,
|
||||
SYMBOL_TYPEDEF = 17,
|
||||
SYMBOL_TYPE_PARAMETER = 18,
|
||||
SYMBOL_UNION = 19,
|
||||
SYMBOL_KIND_MAX = 20
|
||||
};
|
||||
|
||||
SymbolKind intToSymbolKind(int v);
|
||||
int symbolKindToInt(SymbolKind t);
|
||||
|
||||
#endif // SYMBOL_KIND_H
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef SYMBOL_TYPE_H
|
||||
#define SYMBOL_TYPE_H
|
||||
|
||||
enum SymbolType
|
||||
{
|
||||
SYMBOL_CLASS,
|
||||
SYMBOL_ENUM,
|
||||
SYMBOL_ENUM_CONSTANT,
|
||||
SYMBOL_FIELD,
|
||||
SYMBOL_FUNCTION,
|
||||
SYMBOL_GLOBAL_VARIABLE,
|
||||
SYMBOL_LOCAL_VARIABLE,
|
||||
SYMBOL_MACRO,
|
||||
SYMBOL_METHOD,
|
||||
SYMBOL_NAMESPACE,
|
||||
SYMBOL_PARAMETER,
|
||||
SYMBOL_STRUCT,
|
||||
SYMBOL_TYPEDEF,
|
||||
SYMBOL_TEMPLATE_PARAMETER,
|
||||
SYMBOL_UNION,
|
||||
SYMBOL_TYPE_MAX
|
||||
};
|
||||
|
||||
#endif // SYMBOL_TYPE_H
|
||||
@@ -5,22 +5,21 @@
|
||||
|
||||
#include "data/parser/Parser.h"
|
||||
#include "data/parser/ParserClientImpl.h"
|
||||
#include "utility/scheduling/Task.h"
|
||||
#include "utility/scheduling/TaskDecorator.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
class PersistentStorage;
|
||||
class FileRegister;
|
||||
class CxxParser;
|
||||
|
||||
class TaskParseWrapper
|
||||
: public Task
|
||||
: public TaskDecorator
|
||||
{
|
||||
public:
|
||||
TaskParseWrapper(
|
||||
std::shared_ptr<Task> child,
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<FileRegister> fileRegister
|
||||
);
|
||||
virtual ~TaskParseWrapper();
|
||||
|
||||
virtual void enter();
|
||||
virtual TaskState update();
|
||||
@@ -30,10 +29,8 @@ public:
|
||||
virtual void revert();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Task> m_child;
|
||||
PersistentStorage* m_storage;
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
|
||||
TimePoint m_start;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
|
||||
JavaEnvironment::~JavaEnvironment()
|
||||
{
|
||||
JavaEnvironmentFactory::getInstance()->unregisterEnvironment();
|
||||
}
|
||||
|
||||
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4)
|
||||
{
|
||||
jclass javaClass = m_env->FindClass(className.c_str());
|
||||
if(javaClass == nullptr)
|
||||
{
|
||||
LOG_ERROR("class " + className + " not found in JVM environment");
|
||||
jthrowable exc = m_env->ExceptionOccurred();
|
||||
if(exc)
|
||||
{
|
||||
m_env->ExceptionDescribe();
|
||||
m_env->ExceptionClear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jmethodID javaMethodId = m_env->GetStaticMethodID(javaClass, methodName.c_str(), "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
if(javaMethodId == nullptr)
|
||||
{
|
||||
LOG_ERROR("method void " + methodName + "(int, String, String, String) not found in JVM environment");
|
||||
}
|
||||
else
|
||||
{
|
||||
jint jarg1 = arg1;
|
||||
jstring jarg2 = m_env->NewStringUTF(arg2.c_str());
|
||||
jstring jarg3 = m_env->NewStringUTF(arg3.c_str());
|
||||
jstring jarg4 = m_env->NewStringUTF(arg4.c_str());
|
||||
m_env->CallStaticVoidMethod(javaClass, javaMethodId, jarg1, jarg2, jarg3, jarg4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string JavaEnvironment::toStdString(jstring s)
|
||||
{
|
||||
const char *nativeString = m_env->GetStringUTFChars(s, 0);
|
||||
std::string ret = nativeString;
|
||||
m_env->ReleaseStringUTFChars(s, nativeString);
|
||||
return ret;
|
||||
}
|
||||
|
||||
jstring JavaEnvironment::toJString(std::string s)
|
||||
{
|
||||
return m_env->NewStringUTF(s.c_str());
|
||||
}
|
||||
|
||||
JavaEnvironment::JavaEnvironment(JavaVM* jvm, JNIEnv* env)
|
||||
: m_jvm(jvm)
|
||||
, m_env(env)
|
||||
{
|
||||
JavaEnvironmentFactory::getInstance()->registerEnvironment();
|
||||
}
|
||||
|
||||
void JavaEnvironment::registerNativeMethods(std::string className, std::vector<NativeMethod> methods)
|
||||
{
|
||||
JNINativeMethod* jniMethods = new JNINativeMethod[methods.size()];
|
||||
|
||||
for (int i = 0; i < methods.size(); i++)
|
||||
{
|
||||
jniMethods[i].name = const_cast<char*>(methods[i].name.c_str());
|
||||
jniMethods[i].signature = const_cast<char*>(methods[i].signature.c_str());
|
||||
jniMethods[i].fnPtr = methods[i].function;
|
||||
}
|
||||
|
||||
jclass javaClass = m_env->FindClass(className.c_str());
|
||||
if (javaClass)
|
||||
{
|
||||
if (m_env->RegisterNatives(javaClass, jniMethods, methods.size()) < 0)
|
||||
{
|
||||
LOG_ERROR("RegisterNatives failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("class \"" + className + "\" not found while registering native methods");
|
||||
}
|
||||
|
||||
delete [] jniMethods;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef JAVA_ENVIRONMENT_H
|
||||
#define JAVA_ENVIRONMENT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct JavaVM_;
|
||||
typedef JavaVM_ JavaVM;
|
||||
|
||||
struct JNIEnv_;
|
||||
typedef JNIEnv_ JNIEnv;
|
||||
|
||||
class _jstring;
|
||||
typedef _jstring *jstring;
|
||||
|
||||
class JavaEnvironmentFactory;
|
||||
|
||||
class JavaEnvironment
|
||||
{
|
||||
public:
|
||||
struct NativeMethod
|
||||
{
|
||||
std::string name;
|
||||
std::string signature;
|
||||
void *function;
|
||||
};
|
||||
|
||||
~JavaEnvironment();
|
||||
bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4);
|
||||
|
||||
std::string toStdString(jstring s);
|
||||
jstring toJString(std::string s);
|
||||
|
||||
void registerNativeMethods(std::string className, std::vector<NativeMethod> methods);
|
||||
private:
|
||||
friend class JavaEnvironmentFactory;
|
||||
|
||||
JavaEnvironment(JavaVM* jvm, JNIEnv* env);
|
||||
|
||||
JavaVM* m_jvm;
|
||||
JNIEnv* m_env;
|
||||
};
|
||||
|
||||
#endif // JAVA_ENVIRONMENT_H
|
||||
@@ -0,0 +1,170 @@
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
void JavaEnvironmentFactory::createInstance(std::string classPath)
|
||||
{
|
||||
if (s_instance)
|
||||
{
|
||||
if (classPath == s_classPath)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("java classpath cannot be changed!");
|
||||
// todo: implement destroying the old factory instance and create a new one.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
s_classPath = classPath;
|
||||
|
||||
#ifdef _WIN32
|
||||
{ // todo: make this windows only
|
||||
std::string env1 = getenv("path");
|
||||
|
||||
std::string javapath = ApplicationSettings::getInstance()->getJavaPath() + "/client/";
|
||||
putenv(("path=" + env1 + ";" + javapath).c_str()); // path env is only modified in the scope of this process.
|
||||
}
|
||||
#endif
|
||||
using namespace std;
|
||||
|
||||
JavaVM* jvm; // Pointer to the JVM (Java Virtual Machine)
|
||||
JNIEnv* env; // Pointer to native interface
|
||||
|
||||
JavaVMInitArgs vm_args; // Initialization arguments
|
||||
JavaVMOption* options = new JavaVMOption[3]; // JVM invocation options
|
||||
std::string classPathOption = "-Djava.class.path=" + classPath;
|
||||
options[0].optionString = const_cast<char*>(classPathOption.c_str());
|
||||
options[1].optionString = "-Xms1m";
|
||||
std::string maximumMemoryOprionString = "-Xmx" + std::to_string(ApplicationSettings::getInstance()->getJavaMaximumMemory()) + "m";
|
||||
options[2].optionString = const_cast<char*>(maximumMemoryOprionString.c_str());
|
||||
// options[3].optionString = "-verbose:jni";
|
||||
vm_args.version = JNI_VERSION_1_6; // minimum Java version
|
||||
vm_args.nOptions = 3; // number of options
|
||||
vm_args.options = options;
|
||||
vm_args.ignoreUnrecognized = false; // invalid options make the JVM init fail
|
||||
|
||||
jint rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); // YES !!
|
||||
|
||||
delete options;
|
||||
|
||||
if(rc != JNI_OK)
|
||||
{
|
||||
if(rc == JNI_EVERSION)
|
||||
{
|
||||
LOG_ERROR("JVM is oudated and doesn't meet requirements");
|
||||
}
|
||||
else if(rc == JNI_ENOMEM)
|
||||
{
|
||||
LOG_ERROR("not enough memory for JVM");
|
||||
}
|
||||
else if(rc == JNI_EINVAL)
|
||||
{
|
||||
LOG_ERROR("invalid ragument for launching JVM");
|
||||
}
|
||||
else if(rc == JNI_EEXIST)
|
||||
{
|
||||
LOG_ERROR("the process can only launch one JVM an not more");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "could not create the JVM instance (error code " << rc << ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jvm->DetachCurrentThread();
|
||||
s_instance = std::shared_ptr<JavaEnvironmentFactory>(new JavaEnvironmentFactory(jvm));
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<JavaEnvironmentFactory> JavaEnvironmentFactory::getInstance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
JavaEnvironmentFactory::~JavaEnvironmentFactory()
|
||||
{
|
||||
// todo: what if there are threads running using the jvm?? log something!
|
||||
m_jvm->DestroyJavaVM();
|
||||
}
|
||||
|
||||
std::shared_ptr<JavaEnvironment> JavaEnvironmentFactory::createEnvironment()
|
||||
{
|
||||
std::thread::id currentThreadId = std::this_thread::get_id();
|
||||
|
||||
JNIEnv* env;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadIdToEnvAndUserCountMutex);
|
||||
|
||||
std::map<std::thread::id, std::pair<JNIEnv*, int>>::const_iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
|
||||
if (it != m_threadIdToEnvAndUserCount.end())
|
||||
{
|
||||
env = it->second.first;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_jvm->AttachCurrentThread((void**)&env, NULL);
|
||||
m_threadIdToEnvAndUserCount.insert(std::make_pair(currentThreadId, std::make_pair(env, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
return std::shared_ptr<JavaEnvironment>(new JavaEnvironment(m_jvm, env));
|
||||
}
|
||||
|
||||
std::shared_ptr<JavaEnvironmentFactory> JavaEnvironmentFactory::s_instance;
|
||||
|
||||
std::string JavaEnvironmentFactory::s_classPath;
|
||||
|
||||
JavaEnvironmentFactory::JavaEnvironmentFactory(JavaVM* jvm)
|
||||
: m_jvm(jvm)
|
||||
{
|
||||
}
|
||||
|
||||
void JavaEnvironmentFactory::registerEnvironment()
|
||||
{
|
||||
std::thread::id currentThreadId = std::this_thread::get_id();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadIdToEnvAndUserCountMutex);
|
||||
std::map<std::thread::id, std::pair<JNIEnv*, int>>::iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
|
||||
if (it != m_threadIdToEnvAndUserCount.end())
|
||||
{
|
||||
it->second.second++;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("something went horribly wrong while registering a java environment");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JavaEnvironmentFactory::unregisterEnvironment()
|
||||
{
|
||||
std::thread::id currentThreadId = std::this_thread::get_id();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadIdToEnvAndUserCountMutex);
|
||||
std::map<std::thread::id, std::pair<JNIEnv*, int>>::iterator it = m_threadIdToEnvAndUserCount.find(currentThreadId);
|
||||
if (it != m_threadIdToEnvAndUserCount.end())
|
||||
{
|
||||
it->second.second--;
|
||||
if (it->second.second == 0)
|
||||
{ // TODO: currently this happens quite often. do something about that.
|
||||
m_jvm->DetachCurrentThread();
|
||||
m_threadIdToEnvAndUserCount.erase(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("something went horribly wrong while unregistering a java environment");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef JAVA_ENVIRONMENT_FACTORY_H
|
||||
#define JAVA_ENVIRONMENT_FACTORY_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
struct JavaVM_;
|
||||
typedef JavaVM_ JavaVM;
|
||||
|
||||
struct JNIEnv_;
|
||||
typedef JNIEnv_ JNIEnv;
|
||||
|
||||
class JavaEnvironment;
|
||||
|
||||
class JavaEnvironmentFactory
|
||||
{
|
||||
public:
|
||||
static void createInstance(std::string classPath);
|
||||
static std::shared_ptr<JavaEnvironmentFactory> getInstance();
|
||||
|
||||
~JavaEnvironmentFactory();
|
||||
|
||||
std::shared_ptr<JavaEnvironment> createEnvironment();
|
||||
|
||||
private:
|
||||
friend class JavaEnvironment;
|
||||
|
||||
static std::shared_ptr<JavaEnvironmentFactory> s_instance;
|
||||
static std::string s_classPath;
|
||||
|
||||
JavaEnvironmentFactory(JavaVM* jvm);
|
||||
|
||||
void registerEnvironment();
|
||||
void unregisterEnvironment();
|
||||
|
||||
JavaVM* m_jvm;
|
||||
std::map<std::thread::id, std::pair<JNIEnv*, int>> m_threadIdToEnvAndUserCount;
|
||||
std::mutex m_threadIdToEnvAndUserCountMutex;
|
||||
};
|
||||
|
||||
#endif // JAVA_ENVIRONMENT_FACTORY_H
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef TASK_PARSE_JAVA_H
|
||||
#define TASK_PARSE_JAVA_H
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "data/parser/Parser.h"
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class FileRegister;
|
||||
class PersistentStorage;
|
||||
|
||||
class TaskParseJava
|
||||
: public Task
|
||||
{
|
||||
public:
|
||||
TaskParseJava(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
const Parser::Arguments& arguments
|
||||
);
|
||||
|
||||
virtual void enter();
|
||||
virtual TaskState update();
|
||||
virtual void exit();
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
|
||||
private:
|
||||
PersistentStorage* m_storage;
|
||||
std::shared_ptr<std::mutex> m_storageMutex;
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
Parser::Arguments m_arguments;
|
||||
};
|
||||
|
||||
#endif // TASK_PARSE_JAVA_H
|
||||
@@ -35,46 +35,6 @@ int ApplicationSettings::getMaxRecentProjectsCount() const
|
||||
return 7;
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/header_search_paths/header_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getHeaderSearchPathsExpanded() const
|
||||
{
|
||||
std::vector<FilePath> paths = getPathValues("source/header_search_paths/header_search_path");
|
||||
expandPaths(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ApplicationSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
|
||||
{
|
||||
return setPathValues("source/header_search_paths/header_search_path", headerSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/framework_search_paths/framework_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPathsExpanded() const
|
||||
{
|
||||
std::vector<FilePath> paths = getPathValues("source/framework_search_paths/framework_search_path");
|
||||
expandPaths(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ApplicationSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
|
||||
{
|
||||
return setPathValues("source/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<std::string> ApplicationSettings::getCompilerFlags() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/compiler_flags/compiler_flag", defaultValues);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getFontName() const
|
||||
{
|
||||
return getValue<std::string>("application/font_name", "Source Code Pro");
|
||||
@@ -143,14 +103,24 @@ void ApplicationSettings::setFontSizeStd(const int fontSizeStd)
|
||||
setValue<int>("application/font_size_std", fontSizeStd);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getWindowBaseWidth() const
|
||||
{
|
||||
return getValue<int>("application/window_base_width", 500);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getWindowBaseHeight() const
|
||||
{
|
||||
return getValue<int>("application/window_base_height", 500);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getIndexerThreadCount() const
|
||||
{
|
||||
return getValue<int>("application/indexer_thread_count", 4);
|
||||
return getValue<int>("indexing/indexer_thread_count", 4);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setIndexerThreadCount(const int count)
|
||||
{
|
||||
setValue<int>("application/indexer_thread_count", count);
|
||||
setValue<int>("indexing/indexer_thread_count", count);
|
||||
}
|
||||
|
||||
bool ApplicationSettings::getShowExternalNonFatalErrors() const
|
||||
@@ -163,14 +133,58 @@ void ApplicationSettings::setShowExternalNonFatalErrors(const bool show)
|
||||
setValue<bool>("application/show_external_non_fatal_errors", show);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getWindowBaseWidth() const
|
||||
std::string ApplicationSettings::getJavaPath() const
|
||||
{
|
||||
return getValue<int>("application/window_base_width", 500);
|
||||
return getValue<std::string>("indexing/java/java_path", "");
|
||||
}
|
||||
|
||||
int ApplicationSettings::getWindowBaseHeight() const
|
||||
void ApplicationSettings::setJavaPath(const std::string path)
|
||||
{
|
||||
return getValue<int>("application/window_base_height", 500);
|
||||
setValue<std::string>("indexing/java/java_path", path);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getJavaMaximumMemory() const
|
||||
{
|
||||
return getValue<int>("indexing/java/java_maximum_memory", 512);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setJavaMaximumMemory(int size)
|
||||
{
|
||||
setValue<int>("indexing/java/java_maximum_memory", size);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
return getPathValues("indexing/cxx/header_search_paths/header_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getHeaderSearchPathsExpanded() const
|
||||
{
|
||||
std::vector<FilePath> paths = getHeaderSearchPaths();
|
||||
expandPaths(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ApplicationSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
|
||||
{
|
||||
return setPathValues("indexing/cxx/header_search_paths/header_search_path", headerSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPaths() const
|
||||
{
|
||||
return getPathValues("indexing/cxx/framework_search_paths/framework_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getFrameworkSearchPathsExpanded() const
|
||||
{
|
||||
std::vector<FilePath> paths = getFrameworkSearchPaths();
|
||||
expandPaths(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ApplicationSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
|
||||
{
|
||||
return setPathValues("indexing/cxx/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCodeTabWidth() const
|
||||
|
||||
@@ -17,17 +17,6 @@ public:
|
||||
|
||||
int getMaxRecentProjectsCount() const;
|
||||
|
||||
// source
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getHeaderSearchPathsExpanded() const;
|
||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<FilePath> getFrameworkSearchPathsExpanded() const;
|
||||
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
|
||||
// application
|
||||
std::string getFontName() const;
|
||||
void setFontName(const std::string& fontName);
|
||||
@@ -47,14 +36,28 @@ public:
|
||||
int getFontSizeStd() const;
|
||||
void setFontSizeStd(const int fontSizeStd);
|
||||
|
||||
int getWindowBaseWidth() const;
|
||||
int getWindowBaseHeight() const;
|
||||
|
||||
int getIndexerThreadCount() const;
|
||||
void setIndexerThreadCount(const int count);
|
||||
|
||||
bool getShowExternalNonFatalErrors() const;
|
||||
void setShowExternalNonFatalErrors(const bool show);
|
||||
|
||||
int getWindowBaseWidth() const;
|
||||
int getWindowBaseHeight() const;
|
||||
std::string getJavaPath() const;
|
||||
void setJavaPath(const std::string path);
|
||||
|
||||
int getJavaMaximumMemory() const;
|
||||
void setJavaMaximumMemory(int size);
|
||||
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getHeaderSearchPathsExpanded() const;
|
||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<FilePath> getFrameworkSearchPathsExpanded() const;
|
||||
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
// code
|
||||
int getCodeTabWidth() const;
|
||||
|
||||
@@ -82,6 +82,19 @@ bool ProjectSettings::setStandard(const std::string& standard)
|
||||
return setValue<std::string>("language_settings/standard", standard);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getJavaClasspaths() const
|
||||
{
|
||||
return getPathValues("source/class_paths/class_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteJavaClasspaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getJavaClasspaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getSourcePaths() const
|
||||
{
|
||||
return getPathValues("source/source_paths/source_path");
|
||||
|
||||
@@ -28,6 +28,10 @@ public:
|
||||
std::string getStandard() const;
|
||||
bool setStandard(const std::string& standard);
|
||||
|
||||
// java... todo: move this
|
||||
std::vector<FilePath> getJavaClasspaths() const;
|
||||
std::vector<FilePath> getAbsoluteJavaClasspaths() const;
|
||||
|
||||
// source
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
std::vector<FilePath> getAbsoluteSourcePaths() const;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "utility/scheduling/TaskDecorator.h"
|
||||
|
||||
TaskDecorator::TaskDecorator()
|
||||
{
|
||||
}
|
||||
|
||||
TaskDecorator::~TaskDecorator()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDecorator::setTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
m_task = task;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef TASK_DECORATOR_H
|
||||
#define TASK_DECORATOR_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class TaskDecorator
|
||||
: public Task
|
||||
{
|
||||
public:
|
||||
TaskDecorator();
|
||||
virtual ~TaskDecorator();
|
||||
|
||||
void setTask(std::shared_ptr<Task> task);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<Task> m_task;
|
||||
};
|
||||
|
||||
#endif // TASK_DECORATOR_H
|
||||
@@ -345,7 +345,7 @@ std::shared_ptr<QtGraphNode> QtGraphView::createNodeRecursive(
|
||||
}
|
||||
else if (node->isAccessNode())
|
||||
{
|
||||
newNode = std::make_shared<QtGraphNodeAccess>(node->accessType);
|
||||
newNode = std::make_shared<QtGraphNodeAccess>(node->accessKind);
|
||||
}
|
||||
else if (node->isExpandToggleNode())
|
||||
{
|
||||
@@ -449,8 +449,8 @@ void QtGraphView::compareNodesRecursive(
|
||||
{
|
||||
if (((*it)->isDataNode() && (*it2)->isDataNode() && (*it)->getTokenId() == (*it2)->getTokenId()) ||
|
||||
((*it)->isAccessNode() && (*it2)->isAccessNode() &&
|
||||
dynamic_cast<QtGraphNodeAccess*>((*it).get())->getAccessType() ==
|
||||
dynamic_cast<QtGraphNodeAccess*>((*it2).get())->getAccessType()) ||
|
||||
dynamic_cast<QtGraphNodeAccess*>((*it).get())->getAccessKind() ==
|
||||
dynamic_cast<QtGraphNodeAccess*>((*it2).get())->getAccessKind()) ||
|
||||
((*it)->isExpandToggleNode() && (*it2)->isExpandToggleNode()) ||
|
||||
((*it)->isBundleNode() && (*it2)->isBundleNode() && (*it)->getTokenId() == (*it2)->getTokenId()))
|
||||
{
|
||||
|
||||
@@ -11,39 +11,42 @@
|
||||
#include "qt/utility/QtDeviceScaledPixmap.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
QtGraphNodeAccess::QtGraphNodeAccess(TokenComponentAccess::AccessType accessType)
|
||||
QtGraphNodeAccess::QtGraphNodeAccess(AccessKind accessKind)
|
||||
: QtGraphNode()
|
||||
, m_access(accessType)
|
||||
, m_accessKind(accessKind)
|
||||
, m_accessIcon(nullptr)
|
||||
, m_accessIconSize(16)
|
||||
{
|
||||
std::string accessString = TokenComponentAccess::getAccessString(accessType);
|
||||
std::string accessString = TokenComponentAccess::getAccessString(m_accessKind);
|
||||
this->setName(accessString);
|
||||
m_text->hide();
|
||||
|
||||
std::string fileName;
|
||||
switch (accessType)
|
||||
std::string iconFileName;
|
||||
switch (m_accessKind)
|
||||
{
|
||||
case TokenComponentAccess::ACCESS_PUBLIC:
|
||||
fileName = "public";
|
||||
case ACCESS_PUBLIC:
|
||||
iconFileName = "public";
|
||||
break;
|
||||
case TokenComponentAccess::ACCESS_PROTECTED:
|
||||
fileName = "protected";
|
||||
case ACCESS_PROTECTED:
|
||||
iconFileName = "protected";
|
||||
break;
|
||||
case TokenComponentAccess::ACCESS_PRIVATE:
|
||||
fileName = "private";
|
||||
case ACCESS_PRIVATE:
|
||||
iconFileName = "private";
|
||||
case ACCESS_DEFAULT:
|
||||
iconFileName = "default";
|
||||
break;
|
||||
case TokenComponentAccess::ACCESS_TEMPLATE:
|
||||
fileName = "template";
|
||||
case ACCESS_TEMPLATE_PARAMETER:
|
||||
case ACCESS_TYPE_PARAMETER:
|
||||
iconFileName = "template";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (fileName.size() > 0)
|
||||
if (iconFileName.size() > 0)
|
||||
{
|
||||
QtDeviceScaledPixmap pixmap(
|
||||
QString::fromStdString(ResourcePaths::getGuiPath() + "graph_view/images/" + fileName + ".png"));
|
||||
QString::fromStdString(ResourcePaths::getGuiPath() + "graph_view/images/" + iconFileName + ".png"));
|
||||
pixmap.scaleToHeight(m_accessIconSize);
|
||||
|
||||
m_accessIcon = new QGraphicsPixmapItem(pixmap.pixmap(), this);
|
||||
@@ -55,9 +58,9 @@ QtGraphNodeAccess::~QtGraphNodeAccess()
|
||||
{
|
||||
}
|
||||
|
||||
TokenComponentAccess::AccessType QtGraphNodeAccess::getAccessType() const
|
||||
AccessKind QtGraphNodeAccess::getAccessKind() const
|
||||
{
|
||||
return m_access;
|
||||
return m_accessKind;
|
||||
}
|
||||
|
||||
bool QtGraphNodeAccess::isAccessNode() const
|
||||
|
||||
@@ -8,10 +8,10 @@ class QtGraphNodeAccess
|
||||
: public QtGraphNode
|
||||
{
|
||||
public:
|
||||
QtGraphNodeAccess(TokenComponentAccess::AccessType accessType);
|
||||
QtGraphNodeAccess(AccessKind accessKind);
|
||||
virtual ~QtGraphNodeAccess();
|
||||
|
||||
TokenComponentAccess::AccessType getAccessType() const;
|
||||
AccessKind getAccessKind() const;
|
||||
|
||||
// QtGraphNode implementation
|
||||
virtual bool isAccessNode() const;
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
void hideLabel();
|
||||
|
||||
private:
|
||||
TokenComponentAccess::AccessType m_access;
|
||||
AccessKind m_accessKind;
|
||||
|
||||
QGraphicsPixmapItem* m_accessIcon;
|
||||
int m_accessIconSize;
|
||||
|
||||
@@ -31,4 +31,7 @@ add_files(
|
||||
data/parser/cxx/PreprocessorCallbacks.h
|
||||
data/parser/cxx/utilityCxx.cpp
|
||||
data/parser/cxx/utilityCxx.h
|
||||
|
||||
data/parser/java/JavaParser.cpp
|
||||
data/parser/java/JavaParser.h
|
||||
)
|
||||
@@ -36,7 +36,7 @@ ASTVisitor::ASTVisitor(clang::ASTContext* context, clang::Preprocessor* preproce
|
||||
, m_thisContext(0)
|
||||
, m_childContext(0)
|
||||
, m_typeContext(RT_Reference)
|
||||
, m_contextAccess(ParserClient::ACCESS_NONE)
|
||||
, m_contextAccess(ACCESS_NONE)
|
||||
{
|
||||
m_declNameCache = std::make_shared<DeclNameCache>([](const clang::NamedDecl* decl) -> NameHierarchy
|
||||
{
|
||||
@@ -519,7 +519,7 @@ bool ASTVisitor::VisitCXXConstructExpr(clang::CXXConstructExpr *e)
|
||||
|
||||
void ASTVisitor::RecordDeclRefExpr(clang::NamedDecl *d, clang::SourceLocation loc, clang::Expr *e, Context context)
|
||||
{
|
||||
SymbolType symbolType = SYMBOL_TYPE_MAX;
|
||||
SymbolKind symbolType = SYMBOL_KIND_MAX;
|
||||
|
||||
if (clang::isa<clang::VarDecl>(d))
|
||||
{
|
||||
@@ -670,7 +670,7 @@ bool ASTVisitor::TraverseCXXRecordDecl(clang::CXXRecordDecl *d)
|
||||
++it) {
|
||||
clang::CXXBaseSpecifier *baseSpecifier = it;
|
||||
ScopedSwitcher<RefType> sw1(m_typeContext, RT_BaseClass);
|
||||
ScopedSwitcher<ParserClient::AccessType> sw2(
|
||||
ScopedSwitcher<AccessKind> sw2(
|
||||
m_contextAccess, convertAccessType(baseSpecifier->getAccessSpecifier())
|
||||
);
|
||||
ScopedSwitcher<std::shared_ptr<ContextNameGenerator>> sw3(
|
||||
@@ -765,7 +765,7 @@ bool ASTVisitor::VisitDecl(clang::Decl *d)
|
||||
RefType refType;
|
||||
refType = fd->isThisDeclarationADefinition() ?
|
||||
RT_Definition : RT_Declaration;
|
||||
SymbolType symbolType;
|
||||
SymbolKind symbolType;
|
||||
if (llvm::isa<clang::CXXMethodDecl>(fd))
|
||||
{
|
||||
symbolType = SYMBOL_METHOD;
|
||||
@@ -803,7 +803,7 @@ bool ASTVisitor::VisitDecl(clang::Decl *d)
|
||||
else
|
||||
refType = RT_Definition;
|
||||
// TODO: Review for correctness. What about local extern?
|
||||
SymbolType symbolType;
|
||||
SymbolKind symbolType;
|
||||
if (isParam)
|
||||
{
|
||||
symbolType = SYMBOL_PARAMETER;
|
||||
@@ -839,7 +839,7 @@ bool ASTVisitor::VisitDecl(clang::Decl *d)
|
||||
refType = RT_Declaration;
|
||||
}
|
||||
|
||||
SymbolType symbolType = SYMBOL_TYPE_MAX;
|
||||
SymbolKind symbolType = SYMBOL_KIND_MAX;
|
||||
// TODO: Handle the C++11 fixed underlying type of enumeration
|
||||
// declarations.
|
||||
switch (td->getTagKind())
|
||||
@@ -1088,7 +1088,7 @@ void ASTVisitor::RecordTypeRef(
|
||||
const clang::Type* type,
|
||||
clang::SourceLocation beginLoc,
|
||||
RefType refType,
|
||||
SymbolType symbolType)
|
||||
SymbolKind symbolType)
|
||||
{
|
||||
if (isLocatedInUnparsedProjectFile(beginLoc))
|
||||
{
|
||||
@@ -1104,7 +1104,7 @@ void ASTVisitor::RecordTypeRef(
|
||||
else if (refType == RT_BaseClass)
|
||||
{
|
||||
m_client->onInheritanceParsed(
|
||||
parseLocation, contextNameHierarchy, typeNameHierarchy, m_contextAccess);
|
||||
parseLocation, contextNameHierarchy, typeNameHierarchy);
|
||||
}
|
||||
else if (refType == RT_TemplateDefaultArgument)
|
||||
{
|
||||
@@ -1120,10 +1120,10 @@ void ASTVisitor::RecordTypeRef(
|
||||
}
|
||||
|
||||
void ASTVisitor::RecordDeclRef(
|
||||
clang::NamedDecl* d,
|
||||
clang::SourceLocation beginLoc,
|
||||
RefType refType,
|
||||
SymbolType symbolType)
|
||||
clang::NamedDecl* d,
|
||||
clang::SourceLocation beginLoc,
|
||||
RefType refType,
|
||||
SymbolKind symbolType)
|
||||
{
|
||||
bool declIsImplicit = isImplicit(d);
|
||||
|
||||
@@ -1181,10 +1181,15 @@ void ASTVisitor::RecordDeclRef(
|
||||
case SYMBOL_CLASS:
|
||||
if (clang::RecordDecl* recordDecl = clang::dyn_cast<clang::RecordDecl>(d))
|
||||
{
|
||||
AccessKind access = convertAccessType(recordDecl->getAccess());
|
||||
/* if (access == ACCESS_NONE) // todo: test what's the default access if none is provided
|
||||
{
|
||||
access =
|
||||
}*/
|
||||
m_client->onClassParsed(
|
||||
parseLocation,
|
||||
declNameHierarchy,
|
||||
convertAccessType(recordDecl->getAccess()),
|
||||
access,
|
||||
(refType == RT_Definition ? getParseLocationOfRecordBody(recordDecl) : ParseLocation()),
|
||||
declIsImplicit);
|
||||
}
|
||||
@@ -1372,7 +1377,7 @@ void ASTVisitor::RecordDeclRef(
|
||||
{
|
||||
const NameHierarchy contextNameHierarchy = getContextName();
|
||||
m_client->onInheritanceParsed(
|
||||
parseLocation, contextNameHierarchy, declNameHierarchy, m_contextAccess);
|
||||
parseLocation, contextNameHierarchy, declNameHierarchy);
|
||||
break;
|
||||
}
|
||||
case RT_Assigned:
|
||||
@@ -1556,18 +1561,18 @@ bool ASTVisitor::isLocatedInProjectFile(clang::SourceLocation loc)
|
||||
return false;
|
||||
}
|
||||
|
||||
ParserClient::AccessType ASTVisitor::convertAccessType(clang::AccessSpecifier access) const
|
||||
AccessKind ASTVisitor::convertAccessType(clang::AccessSpecifier access) const
|
||||
{
|
||||
switch (access)
|
||||
{
|
||||
case clang::AS_public:
|
||||
return ParserClient::ACCESS_PUBLIC;
|
||||
return ACCESS_PUBLIC;
|
||||
case clang::AS_protected:
|
||||
return ParserClient::ACCESS_PROTECTED;
|
||||
return ACCESS_PROTECTED;
|
||||
case clang::AS_private:
|
||||
return ParserClient::ACCESS_PRIVATE;
|
||||
return ACCESS_PRIVATE;
|
||||
case clang::AS_none:
|
||||
return ParserClient::ACCESS_NONE;
|
||||
return ACCESS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <clang/Basic/SourceManager.h>
|
||||
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "data/parser/SymbolType.h"
|
||||
#include "data/parser/SymbolKind.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/Cache.h"
|
||||
|
||||
@@ -202,20 +202,20 @@ private:
|
||||
const clang::Type* type,
|
||||
clang::SourceLocation beginLoc,
|
||||
RefType refType,
|
||||
SymbolType symbolType = SYMBOL_TYPE_MAX);
|
||||
SymbolKind symbolType = SYMBOL_KIND_MAX);
|
||||
|
||||
void RecordDeclRef(
|
||||
clang::NamedDecl *d,
|
||||
clang::SourceLocation beginLoc,
|
||||
RefType refType,
|
||||
SymbolType symbolType = SYMBOL_TYPE_MAX);
|
||||
clang::NamedDecl *d,
|
||||
clang::SourceLocation beginLoc,
|
||||
RefType refType,
|
||||
SymbolKind symbolType = SYMBOL_KIND_MAX);
|
||||
|
||||
bool isImplicit(clang::Decl* d) const;
|
||||
|
||||
bool isLocatedInUnparsedProjectFile(clang::SourceLocation loc);
|
||||
bool isLocatedInProjectFile(clang::SourceLocation loc);
|
||||
|
||||
ParserClient::AccessType convertAccessType(clang::AccessSpecifier access) const;
|
||||
AccessKind convertAccessType(clang::AccessSpecifier access) const;
|
||||
ParserClient::AbstractionType getAbstractionType(const clang::CXXMethodDecl* methodDecl) const;
|
||||
ParseLocation getParseLocationOfRecordBody(clang::RecordDecl* decl) const;
|
||||
ParseLocation getParseLocationOfFunctionBody(const clang::FunctionDecl* decl) const;
|
||||
@@ -238,7 +238,7 @@ private:
|
||||
std::shared_ptr<DeclNameCache> m_declNameCache;
|
||||
std::shared_ptr<TypeNameCache> m_typeNameCache;
|
||||
|
||||
ParserClient::AccessType m_contextAccess;
|
||||
AccessKind m_contextAccess;
|
||||
};
|
||||
|
||||
#endif // AST_VISITOR_H
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
#include "data/parser/java/JavaParser.h"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ReferenceKind.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
JavaParser::JavaParser(ParserClient* client)
|
||||
: Parser(client)
|
||||
, m_id(s_nextParserId++)
|
||||
, m_currentFilePath("")
|
||||
{
|
||||
std::shared_ptr<JavaEnvironmentFactory> factory = JavaEnvironmentFactory::getInstance();
|
||||
if (factory)
|
||||
{
|
||||
m_javaEnvironment = factory->createEnvironment();
|
||||
|
||||
std::vector<JavaEnvironment::NativeMethod> methods;
|
||||
|
||||
methods.push_back({"recordSymbol", "(ILjava/lang/String;IIIIIII)V", (void*)&JavaParser::RecordSymbol});
|
||||
methods.push_back({"recordSymbolWithoutLocation", "(ILjava/lang/String;III)V", (void*)&JavaParser::RecordSymbolWithoutLocation});
|
||||
methods.push_back({"recordSymbolWithScope", "(ILjava/lang/String;IIIIIIIIIII)V", (void*)&JavaParser::RecordSymbolWithScope});
|
||||
methods.push_back({"recordReference", "(IILjava/lang/String;Ljava/lang/String;IIII)V", (void*)&JavaParser::RecordReference});
|
||||
methods.push_back({"recordLocalSymbol", "(ILjava/lang/String;IIII)V", (void*)&JavaParser::RecordLocalSymbol});
|
||||
methods.push_back({"recordComment", "(IIIII)V", (void*)&JavaParser::RecordComment});
|
||||
methods.push_back({"recordError", "(ILjava/lang/String;IIIIII)V", (void*)&JavaParser::RecordError});
|
||||
|
||||
m_javaEnvironment->registerNativeMethods("io/coati/JavaIndexer", methods);
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(s_parsersMutex);
|
||||
s_parsers[m_id] = this;
|
||||
}
|
||||
}
|
||||
|
||||
JavaParser::~JavaParser()
|
||||
{
|
||||
s_parsers.erase(m_id);
|
||||
}
|
||||
|
||||
void JavaParser::parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments)
|
||||
{
|
||||
//m_fileRegister->setFilePaths(filePaths);
|
||||
//setupParsing(arguments);
|
||||
|
||||
//std::vector<std::string> sourcePaths;
|
||||
//for (const FilePath& path : m_fileRegister->getUnparsedSourceFilePaths()) // filter headers
|
||||
//{
|
||||
// sourcePaths.push_back(path.absolute().str());
|
||||
//}
|
||||
|
||||
//runTool(sourcePaths);
|
||||
}
|
||||
|
||||
void JavaParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess, const Arguments& arguments)
|
||||
{
|
||||
m_currentFilePath = filePath.str();
|
||||
m_client->onFileParsed(FileSystem::getFileInfoForPath(filePath));
|
||||
std::string classPath = "";
|
||||
for (const FilePath& path: arguments.javaClassPaths)
|
||||
{
|
||||
classPath += path.str() + ";";
|
||||
}
|
||||
|
||||
// remove tabs because they screw with javaparser's location resolver
|
||||
std::string fileContent = utility::replace(textAccess->getText(), "\t", " ");
|
||||
|
||||
m_javaEnvironment->callStaticVoidMethod("io/coati/JavaIndexer", "processFile", m_id, filePath.str(), fileContent, classPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int JavaParser::s_nextParserId = 0;
|
||||
|
||||
std::map<int, JavaParser*> JavaParser::s_parsers;
|
||||
|
||||
std::mutex JavaParser::s_parsersMutex;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void JavaParser::doRecordSymbol(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
)
|
||||
{
|
||||
AccessKind access = intToAccessKind(jAccess);
|
||||
bool isImplicit = jIsImplicit;
|
||||
|
||||
m_client->recordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
intToSymbolKind(jSymbolType),
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
access,
|
||||
isImplicit
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordSymbolWithoutLocation(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint jAccess, jint jIsImplicit
|
||||
)
|
||||
{
|
||||
AccessKind access = intToAccessKind(jAccess);
|
||||
bool isImplicit = jIsImplicit;
|
||||
|
||||
m_client->recordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
intToSymbolKind(jSymbolType),
|
||||
access,
|
||||
isImplicit
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordSymbolWithScope(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint scopeBeginLine, jint scopeBeginColumn, jint scopeEndLine, jint scopeEndColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
)
|
||||
{
|
||||
AccessKind access = intToAccessKind(jAccess);
|
||||
bool isImplicit = jIsImplicit;
|
||||
|
||||
m_client->recordSymbol(
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jSymbolName)),
|
||||
intToSymbolKind(jSymbolType),
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
ParseLocation(m_currentFilePath, scopeBeginLine, scopeBeginColumn, scopeEndLine, scopeEndColumn),
|
||||
access,
|
||||
isImplicit
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordReference(
|
||||
jint jReferenceKind, jstring jReferencedName, jstring jContextName,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn
|
||||
)
|
||||
{
|
||||
m_client->recordReference(
|
||||
intToReferenceKind(jReferenceKind),
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jReferencedName)),
|
||||
NameHierarchy::deserialize(m_javaEnvironment->toStdString(jContextName)),
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn)
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordLocalSymbol(jstring jSymbolName, jint beginLine, jint beginColumn, jint endLine, jint endColumn)
|
||||
{
|
||||
m_client->onLocalSymbolParsed(
|
||||
m_javaEnvironment->toStdString(jSymbolName),
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn)
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordComment(
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn
|
||||
)
|
||||
{
|
||||
m_client->onCommentParsed(
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn)
|
||||
);
|
||||
}
|
||||
|
||||
void JavaParser::doRecordError(
|
||||
jstring jMessage, jint jFatal, jint jIndexed,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn
|
||||
)
|
||||
{
|
||||
bool fatal = jFatal;
|
||||
bool indexed = jIndexed;
|
||||
|
||||
m_client->onError(
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
m_javaEnvironment->toStdString(jMessage),
|
||||
fatal, indexed
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
#ifndef JAVA_PARSER_H
|
||||
#define JAVA_PARSER_H
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
#include "data/parser/Parser.h"
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
struct JNIEnv_;
|
||||
typedef JNIEnv_ JNIEnv;
|
||||
|
||||
class _jobject;
|
||||
typedef _jobject* jobject;
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef long jint;
|
||||
#else
|
||||
typedef int jint;
|
||||
#endif
|
||||
|
||||
class _jstring;
|
||||
typedef _jstring *jstring;
|
||||
|
||||
class FileRegister;
|
||||
|
||||
class JavaParser: public Parser
|
||||
{
|
||||
public:
|
||||
JavaParser(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);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// This macro makes available a variable T, the passed-in t. blablabla TODO: write somethign real here
|
||||
#define MAKE_PARAMS_0()
|
||||
#define MAKE_PARAMS_1(t1) t1 arg1
|
||||
#define MAKE_PARAMS_2(t1, t2) t1 arg1, t2 arg2
|
||||
#define MAKE_PARAMS_3(t1, t2, t3) t1 arg1, t2 arg2, t3 arg3
|
||||
#define MAKE_PARAMS_4(t1, t2, t3, t4) t1 arg1, t2 arg2, t3 arg3, t4 arg4
|
||||
#define MAKE_PARAMS_5(t1, t2, t3, t4, t5) t1 arg1, t2 arg2, t3 arg3, t4 arg4, t5 arg5
|
||||
#define MAKE_PARAMS_6(t1, t2, t3, t4, t5, t6) t1 arg1, t2 arg2, t3 arg3, t4 arg4, t5 arg5, t6 arg6
|
||||
#define MAKE_PARAMS_7(t1, t2, t3, t4, t5, t6, t7) t1 arg1, t2 arg2, t3 arg3, t4 arg4, t5 arg5, t6 arg6, t7 arg7
|
||||
#define MAKE_PARAMS_8(t1, t2, t3, t4, t5, t6, t7, t8) t1 arg1, t2 arg2, t3 arg3, t4 arg4, t5 arg5, t6 arg6, t7 arg7, t8 arg8
|
||||
#define MAKE_PARAMS_9(t1, t2, t3, t4, t5, t6, t7, t8, t9) t1 arg1, t2 arg2, t3 arg3, t4 arg4, t5 arg5, t6 arg6, t7 arg7, t8 arg8, t9 arg9
|
||||
#define MAKE_PARAMS_10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) t1 arg1, t2 arg2, t3 arg3, t4 arg4, t5 arg5, t6 arg6, t7 arg7, t8 arg8, t9 arg9, t10 arg10
|
||||
#define MAKE_PARAMS_11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) t1 arg1, t2 arg2, t3 arg3, t4 arg4, t5 arg5, t6 arg6, t7 arg7, t8 arg8, t9 arg9, t10 arg10, t11 arg11
|
||||
#define MAKE_PARAMS_12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) t1 arg1, t2 arg2, t3 arg3, t4 arg4, t5 arg5, t6 arg6, t7 arg7, t8 arg8, t9 arg9, t10 arg10, t11 arg11, t12 arg12
|
||||
//.. add as many MAKE_PARAMS_* as required
|
||||
|
||||
#define MAKE_ARGS_0()
|
||||
#define MAKE_ARGS_1(type) arg1
|
||||
#define MAKE_ARGS_2(t1, t2) arg1, arg2
|
||||
#define MAKE_ARGS_3(t1, t2, t3) arg1, arg2, arg3
|
||||
#define MAKE_ARGS_4(t1, t2, t3, t4) arg1, arg2, arg3, arg4
|
||||
#define MAKE_ARGS_5(t1, t2, t3, t4, t5) arg1, arg2, arg3, arg4, arg5
|
||||
#define MAKE_ARGS_6(t1, t2, t3, t4, t5, t6) arg1, arg2, arg3, arg4, arg5, arg6
|
||||
#define MAKE_ARGS_7(t1, t2, t3, t4, t5, t6, t7) arg1, arg2, arg3, arg4, arg5, arg6, arg7
|
||||
#define MAKE_ARGS_8(t1, t2, t3, t4, t5, t6, t7, t8) arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8
|
||||
#define MAKE_ARGS_9(t1, t2, t3, t4, t5, t6, t7, t8, t9) arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
|
||||
#define MAKE_ARGS_10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10
|
||||
#define MAKE_ARGS_11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11
|
||||
#define MAKE_ARGS_12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12
|
||||
//.. add as many MAKE_ARGS_* as there are MAKE_PARAMS_*
|
||||
|
||||
|
||||
|
||||
#define DEF_RELAYING_METHOD_4(NAME, t1, t2, t3, t4) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_4(t1, t2, t3, t4), MAKE_ARGS_4(t1, t2, t3, t4))
|
||||
|
||||
#define DEF_RELAYING_METHOD_5(NAME, t1, t2, t3, t4, t5) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_5(t1, t2, t3, t4, t5), MAKE_ARGS_5(t1, t2, t3, t4, t5))
|
||||
|
||||
#define DEF_RELAYING_METHOD_6(NAME, t1, t2, t3, t4, t5, t6) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_6(t1, t2, t3, t4, t5, t6), MAKE_ARGS_6(t1, t2, t3, t4, t5, t6))
|
||||
|
||||
#define DEF_RELAYING_METHOD_7(NAME, t1, t2, t3, t4, t5, t6, t7) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_7(t1, t2, t3, t4, t5, t6, t7), MAKE_ARGS_7(t1, t2, t3, t4, t5, t6, t7))
|
||||
|
||||
#define DEF_RELAYING_METHOD_8(NAME, t1, t2, t3, t4, t5, t6, t7, t8) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_8(t1, t2, t3, t4, t5, t6, t7, t8), MAKE_ARGS_8(t1, t2, t3, t4, t5, t6, t7, t8))
|
||||
|
||||
#define DEF_RELAYING_METHOD_9(NAME, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_9(t1, t2, t3, t4, t5, t6, t7, t8, t9), MAKE_ARGS_9(t1, t2, t3, t4, t5, t6, t7, t8, t9))
|
||||
|
||||
#define DEF_RELAYING_METHOD_10(NAME, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10), MAKE_ARGS_10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10))
|
||||
|
||||
#define DEF_RELAYING_METHOD_11(NAME, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11), MAKE_ARGS_11(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11))
|
||||
|
||||
#define DEF_RELAYING_METHOD_12(NAME, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) \
|
||||
DEF_RELAYING_METHOD(NAME, MAKE_PARAMS_12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12), MAKE_ARGS_12(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12))
|
||||
|
||||
#define DEF_RELAYING_METHOD(NAME, PARAMETERS, ARGUMENTS) \
|
||||
static void NAME(JNIEnv *env, jobject objectOrClass, jint parserId, PARAMETERS) \
|
||||
{ \
|
||||
std::map<int, JavaParser*>::iterator it = s_parsers.find(int(parserId)); \
|
||||
if (it != s_parsers.end()) \
|
||||
{ \
|
||||
it->second->do##NAME(ARGUMENTS); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
LOG_ERROR("parser with id " + std::to_string(parserId) + " not found"); \
|
||||
} \
|
||||
}
|
||||
|
||||
DEF_RELAYING_METHOD_8(RecordSymbol, jstring, jint, jint, jint, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_4(RecordSymbolWithoutLocation, jstring, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_12(RecordSymbolWithScope, jstring, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_7(RecordReference, jint, jstring, jstring, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_5(RecordLocalSymbol, jstring, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_4(RecordComment, jint, jint, jint, jint)
|
||||
DEF_RELAYING_METHOD_7(RecordError, jstring, jint, jint, jint, jint, jint, jint)
|
||||
|
||||
static int s_nextParserId;
|
||||
static std::map<int, JavaParser*> s_parsers;
|
||||
static std::mutex s_parsersMutex;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void doRecordSymbol(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
);
|
||||
|
||||
void doRecordSymbolWithoutLocation(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint jAccess, jint jIsImplicit
|
||||
);
|
||||
|
||||
void doRecordSymbolWithScope(
|
||||
jstring jSymbolName, jint jSymbolType,
|
||||
jint beginLine, jint beginColumn, jint endLine, jint endColumn,
|
||||
jint scopeBeginLine, jint scopeBeginColumn, jint scopeEndLine, jint scopeEndColumn,
|
||||
jint jAccess, jint jIsImplicit
|
||||
);
|
||||
|
||||
void doRecordReference(jint jRefType, jstring jReferencedName, jstring jContextName, jint beginLine, jint beginColumn, jint endLine, jint endColumn);
|
||||
void doRecordLocalSymbol(jstring jSymbolName, jint beginLine, jint beginColumn, jint endLine, jint endColumn);
|
||||
void doRecordComment(jint beginLine, jint beginColumn, jint endLine, jint endColumn);
|
||||
void doRecordError(jstring jMessage, jint jFatal, jint jIndexed, jint beginLine, jint beginColumn, jint endLine, jint endColumn);
|
||||
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
std::shared_ptr<JavaEnvironment> m_javaEnvironment;
|
||||
|
||||
const int m_id;
|
||||
std::string m_currentFilePath;
|
||||
};
|
||||
|
||||
#endif // JAVA_PARSER_H
|
||||
@@ -15,6 +15,7 @@ add_files(
|
||||
FileSystemTestSuite.h
|
||||
GeneratorTestSuite.h
|
||||
GraphTestSuite.h
|
||||
JavaParserTestSuite.h
|
||||
LogManagerTestSuite.h
|
||||
MatrixBaseTestSuite.h
|
||||
MessageQueueTestSuite.h
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "data/parser/cxx/CxxParser.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "helper/TestFileManager.h"
|
||||
|
||||
@@ -1175,7 +1174,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : private A <2:11 2:11>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A <2:11 2:11>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_class_public_inheritance()
|
||||
@@ -1186,7 +1185,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : public A <2:18 2:18>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A <2:18 2:18>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_class_protected_inheritance()
|
||||
@@ -1197,7 +1196,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : protected A <2:21 2:21>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A <2:21 2:21>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_class_private_inheritance()
|
||||
@@ -1208,7 +1207,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : private A <2:19 2:19>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A <2:19 2:19>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_class_multiple_inheritance()
|
||||
@@ -1223,8 +1222,8 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 2);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "C : public A <4:11 4:11>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[1], "C : private B <5:12 5:12>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "C : A <4:11 4:11>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[1], "C : B <5:12 5:12>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_struct_default_public_inheritance()
|
||||
@@ -1235,7 +1234,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : public A <2:12 2:12>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A <2:12 2:12>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_struct_public_inheritance()
|
||||
@@ -1246,7 +1245,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : public A <2:19 2:19>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A <2:19 2:19>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_struct_protected_inheritance()
|
||||
@@ -1257,7 +1256,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : protected A <2:22 2:22>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A <2:22 2:22>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_struct_private_inheritance()
|
||||
@@ -1268,7 +1267,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : private A <2:20 2:20>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A <2:20 2:20>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_struct_multiple_inheritance()
|
||||
@@ -1283,8 +1282,8 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 2);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "C : public A <4:11 4:11>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[1], "C : private B <5:12 5:12>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "C : A <4:11 4:11>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[1], "C : B <5:12 5:12>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_method_override_when_virtual()
|
||||
@@ -2462,7 +2461,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->inheritances.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : public A<int> <7:17 7:17>");
|
||||
TS_ASSERT_EQUALS(client->inheritances[0], "B : A<int> <7:17 7:17>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_template_class_specialization_with_template_argument()
|
||||
@@ -2948,13 +2947,45 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false)
|
||||
{
|
||||
// todo: implement and replace all the on..DeclParsed
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false)
|
||||
{
|
||||
// todo: implement and replace all the on..DeclParsed
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access = ACCESS_NONE, bool isImplicit = false)
|
||||
{
|
||||
// todo: implement and replace all the on..DeclParsed
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void recordReference(
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
||||
{
|
||||
errors.push_back(addLocationSuffix(message, location));
|
||||
}
|
||||
|
||||
virtual void onTypedefParsed(
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access, bool isImplicit
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessKind access, bool isImplicit
|
||||
)
|
||||
{
|
||||
std::string str = addAccessPrefix(typedefName.getQualifiedName(), access);
|
||||
@@ -2962,14 +2993,14 @@ private:
|
||||
}
|
||||
|
||||
virtual void onClassParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
classes.push_back(addLocationSuffix(addAccessPrefix(nameHierarchy.getQualifiedName(), access), location, scopeLocation));
|
||||
}
|
||||
|
||||
virtual void onStructParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
structs.push_back(addLocationSuffix(addAccessPrefix(nameHierarchy.getQualifiedName(), access), location, scopeLocation));
|
||||
@@ -2980,7 +3011,7 @@ private:
|
||||
globalVariables.push_back(addLocationSuffix(variable.getQualifiedName(), location));
|
||||
}
|
||||
|
||||
virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessType access, bool isImplicit)
|
||||
virtual void onFieldParsed(const ParseLocation& location, const NameHierarchy& field, AccessKind access, bool isImplicit)
|
||||
{
|
||||
fields.push_back(addLocationSuffix(addAccessPrefix(field.getQualifiedName(), access), location));
|
||||
}
|
||||
@@ -2992,7 +3023,7 @@ private:
|
||||
}
|
||||
|
||||
virtual void onMethodParsed(
|
||||
const ParseLocation& location, const NameHierarchy& method, AccessType access, AbstractionType abstraction,
|
||||
const ParseLocation& location, const NameHierarchy& method, AccessKind access, AbstractionType abstraction,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
std::string str = method.getQualifiedNameWithSignature();
|
||||
@@ -3009,7 +3040,7 @@ private:
|
||||
}
|
||||
|
||||
virtual void onEnumParsed(
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessType access,
|
||||
const ParseLocation& location, const NameHierarchy& nameHierarchy, AccessKind access,
|
||||
const ParseLocation& scopeLocation, bool isImplicit)
|
||||
{
|
||||
enums.push_back(addLocationSuffix(addAccessPrefix(nameHierarchy.getQualifiedName(), access), location, scopeLocation));
|
||||
@@ -3051,9 +3082,9 @@ private:
|
||||
|
||||
virtual void onInheritanceParsed(
|
||||
const ParseLocation& location, const NameHierarchy& childNameHierarchy,
|
||||
const NameHierarchy& parentNameHierarchy, AccessType access)
|
||||
const NameHierarchy& parentNameHierarchy)
|
||||
{
|
||||
std::string str = childNameHierarchy.getQualifiedName() + " : " + addAccessPrefix(parentNameHierarchy.getQualifiedName(), access);
|
||||
std::string str = childNameHierarchy.getQualifiedName() + " : " + parentNameHierarchy.getQualifiedName();
|
||||
inheritances.push_back(addLocationSuffix(str, location));
|
||||
}
|
||||
|
||||
@@ -3071,7 +3102,7 @@ private:
|
||||
}
|
||||
|
||||
virtual void onUsageParsed(
|
||||
const ParseLocation& location, const NameHierarchy& userName, SymbolType usedType, const NameHierarchy& usedName)
|
||||
const ParseLocation& location, const NameHierarchy& userName, SymbolKind usedType, const NameHierarchy& usedName)
|
||||
{
|
||||
usages.push_back(addLocationSuffix(userName.getQualifiedNameWithSignature() + " -> " + usedName.getQualifiedName(), location));
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
{
|
||||
Node a(1, Node::NODE_UNDEFINED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_UNDEFINED, NameHierarchy("B"), false);
|
||||
Edge e(3, Edge::EDGE_TYPE_OF, &a, &b);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT(!e.isNode());
|
||||
TS_ASSERT(e.isEdge());
|
||||
@@ -150,16 +150,16 @@ public:
|
||||
{
|
||||
Node a(1, Node::NODE_UNDEFINED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_UNDEFINED, NameHierarchy("B"), false);
|
||||
Edge e(3, Edge::EDGE_TYPE_OF, &a, &b);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT_EQUALS(Edge::EDGE_TYPE_OF, e.getType());
|
||||
TS_ASSERT_EQUALS(Edge::EDGE_USAGE, e.getType());
|
||||
}
|
||||
|
||||
void test_edge_can_be_copied_and_keeps_same_id()
|
||||
{
|
||||
Node a(1, Node::NODE_UNDEFINED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_UNDEFINED, NameHierarchy("B"), false);
|
||||
Edge e(3, Edge::EDGE_TYPE_OF, &a, &b);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
Edge e2(e, &a, &b);
|
||||
|
||||
TS_ASSERT_DIFFERS(&e, &e2);
|
||||
@@ -171,10 +171,10 @@ public:
|
||||
{
|
||||
Node a(1, Node::NODE_UNDEFINED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_UNDEFINED, NameHierarchy("B"), false);
|
||||
Edge e(3, Edge::EDGE_TYPE_OF, &a, &b);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT(e.isType(Edge::EDGE_MEMBER | Edge::EDGE_CALL | Edge::EDGE_TYPE_OF));
|
||||
TS_ASSERT(!e.isType(Edge::EDGE_USAGE | Edge::EDGE_MEMBER | Edge::EDGE_CALL));
|
||||
TS_ASSERT(e.isType(Edge::EDGE_MEMBER | Edge::EDGE_CALL | Edge::EDGE_USAGE));
|
||||
TS_ASSERT(!e.isType(Edge::EDGE_MEMBER | Edge::EDGE_CALL));
|
||||
}
|
||||
|
||||
void test_node_finds_child_node()
|
||||
@@ -235,21 +235,6 @@ public:
|
||||
TS_ASSERT_EQUALS(children[1], &c);
|
||||
}
|
||||
|
||||
void test_node_has_references()
|
||||
{
|
||||
Node a(1, Node::NODE_UNDEFINED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_UNDEFINED, NameHierarchy("B"), false);
|
||||
Node c(3, Node::NODE_UNDEFINED, NameHierarchy("C"), false);
|
||||
Node d(4, Node::NODE_UNDEFINED, NameHierarchy("D"), false);
|
||||
Edge e(5, Edge::EDGE_MEMBER, &a, &b);
|
||||
Edge e2(6, Edge::EDGE_MEMBER, &a, &c);
|
||||
Edge e3(7, Edge::EDGE_USAGE, &c, &d);
|
||||
|
||||
TS_ASSERT(a.hasReferences());
|
||||
TS_ASSERT(!b.hasReferences());
|
||||
TS_ASSERT(c.hasReferences());
|
||||
}
|
||||
|
||||
void test_graph_saves_nodes()
|
||||
{
|
||||
Graph graph;
|
||||
@@ -299,31 +284,6 @@ public:
|
||||
TS_ASSERT_EQUALS(1, graph.getNodeCount());
|
||||
}
|
||||
|
||||
void test_graph_removes_unreferenced_nodes()
|
||||
{
|
||||
Graph graph;
|
||||
|
||||
Node* a = graph.createNode(1, Node::NODE_UNDEFINED, NameHierarchy("A"), false);
|
||||
Node* b = graph.createNode(2, Node::NODE_UNDEFINED, NameHierarchy("B"), false);
|
||||
Node* c = graph.createNode(3, Node::NODE_UNDEFINED, NameHierarchy("C"), false);
|
||||
Node* d = graph.createNode(4, Node::NODE_UNDEFINED, NameHierarchy("D"), false);
|
||||
Node* e = graph.createNode(5, Node::NODE_UNDEFINED, NameHierarchy("E"), false);
|
||||
|
||||
graph.createEdge(6, Edge::EDGE_MEMBER, a, b);
|
||||
graph.createEdge(7, Edge::EDGE_MEMBER, a, c);
|
||||
graph.createEdge(8, Edge::EDGE_USAGE, c, d);
|
||||
graph.createEdge(9, Edge::EDGE_MEMBER, b, e);
|
||||
|
||||
TS_ASSERT_EQUALS(5, graph.getNodeCount());
|
||||
TS_ASSERT_EQUALS(4, graph.getEdgeCount());
|
||||
|
||||
TS_ASSERT(!graph.removeNodeIfUnreferencedRecursive(graph.getNodeById(a->getId())));
|
||||
TS_ASSERT(graph.removeNodeIfUnreferencedRecursive(graph.getNodeById(b->getId())));
|
||||
|
||||
TS_ASSERT_EQUALS(3, graph.getNodeCount());
|
||||
TS_ASSERT_EQUALS(2, graph.getEdgeCount());
|
||||
}
|
||||
|
||||
private:
|
||||
class TestToken: public Token
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
#include "utility/logging/PlainFileLogger.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
TestSuiteFixture::TestSuiteFixture()
|
||||
{
|
||||
@@ -19,6 +20,7 @@ bool TestSuiteFixture::setUpWorld()
|
||||
{
|
||||
LogManager::getInstance()->addLogger(std::make_shared<PlainFileLogger>("data/log/test_log.txt"));
|
||||
LogManager::getInstance()->addLogger(std::make_shared<FileLogger>());
|
||||
ApplicationSettings::getInstance()->load(FilePath("data/TestSettings.xml"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ add_files(
|
||||
|
||||
data/parser/cxx/TaskParseCxx.cpp
|
||||
data/parser/cxx/TaskParseWrapper.cpp
|
||||
|
||||
data/parser/java/TaskParseJava.cpp
|
||||
|
||||
isTrial.cpp
|
||||
main.cpp
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
|
||||
TaskParseWrapper::TaskParseWrapper(
|
||||
std::shared_ptr<Task> child,
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<FileRegister> fileRegister
|
||||
)
|
||||
: m_child(child)
|
||||
, m_storage(storage)
|
||||
: m_storage(storage)
|
||||
{
|
||||
}
|
||||
|
||||
TaskParseWrapper::~TaskParseWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -17,17 +19,17 @@ void TaskParseWrapper::enter()
|
||||
{
|
||||
m_storage->startParsing();
|
||||
|
||||
m_child->enter();
|
||||
m_task->enter();
|
||||
}
|
||||
|
||||
Task::TaskState TaskParseWrapper::update()
|
||||
{
|
||||
return m_child->update();
|
||||
return m_task->update();
|
||||
}
|
||||
|
||||
void TaskParseWrapper::exit()
|
||||
{
|
||||
m_child->exit();
|
||||
m_task->exit();
|
||||
|
||||
m_storage->finishParsing();
|
||||
|
||||
@@ -36,10 +38,10 @@ void TaskParseWrapper::exit()
|
||||
|
||||
void TaskParseWrapper::interrupt()
|
||||
{
|
||||
m_child->interrupt();
|
||||
m_task->interrupt();
|
||||
}
|
||||
|
||||
void TaskParseWrapper::revert()
|
||||
{
|
||||
m_child->revert();
|
||||
m_task->revert();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "data/parser/java/TaskParseJava.h"
|
||||
|
||||
TaskParseJava::TaskParseJava(
|
||||
PersistentStorage* storage,
|
||||
std::shared_ptr<std::mutex> storageMutex,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
const Parser::Arguments& arguments
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseJava::enter()
|
||||
{
|
||||
}
|
||||
|
||||
Task::TaskState TaskParseJava::update()
|
||||
{
|
||||
return Task::STATE_FINISHED;
|
||||
}
|
||||
|
||||
void TaskParseJava::exit()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseJava::interrupt()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseJava::revert()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user