data: name hierarchy refactoring
* replaced typenames (which have been stored as single sting where "::" indicated hierarchy levels) by a vector of strings where each element indicates a hierarchy level. * introduced this change to the Storage method signatures, the ParseFunction and ParseVariable * this way the SearchIndex creates a node for each level of the hierarchy.
This commit is contained in:
@@ -144,7 +144,7 @@ std::shared_ptr<SearchIndex::SearchNode> SearchIndex::SearchNode::addNodeRecursi
|
||||
m_nodes.insert(node);
|
||||
}
|
||||
|
||||
if (nameIds->size())
|
||||
if (nameIds->size() > 0)
|
||||
{
|
||||
return node->addNodeRecursive(nameIds, dictionary);
|
||||
}
|
||||
@@ -385,10 +385,13 @@ const std::string& SearchIndex::getWord(Id wordId) const
|
||||
return m_dictionary.getWord(wordId);
|
||||
}
|
||||
|
||||
SearchIndex::SearchNode* SearchIndex::addNode(const std::string& fullName)
|
||||
SearchIndex::SearchNode* SearchIndex::addNode(std::vector<std::string> nameHierarchy)
|
||||
{
|
||||
std::deque<Id> nameIds = m_dictionary.getWordIds(fullName, DELIMITER);
|
||||
|
||||
std::deque<Id> nameIds;
|
||||
for (const std::string& name: nameHierarchy)
|
||||
{
|
||||
nameIds.push_back(m_dictionary.getWordId(name));
|
||||
}
|
||||
if (nameIds.size())
|
||||
{
|
||||
return m_root.addNodeRecursive(&nameIds, m_dictionary).get();
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
Id getWordId(const std::string& word);
|
||||
const std::string& getWord(Id wordId) const;
|
||||
|
||||
SearchNode* addNode(const std::string& fullName);
|
||||
SearchNode* addNode(std::vector<std::string> nameHierarchy);
|
||||
SearchNode* getNode(const std::string& fullName) const;
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> findFuzzyMatches(const std::string& query) const;
|
||||
|
||||
+54
-44
@@ -1,5 +1,7 @@
|
||||
#include "data/Storage.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/graph/filter/GraphFilterConductor.h"
|
||||
#include "data/graph/token_component/TokenComponentConst.h"
|
||||
#include "data/graph/token_component/TokenComponentDataType.h"
|
||||
@@ -47,11 +49,12 @@ void Storage::logLocations() const
|
||||
|
||||
|
||||
Id Storage::onTypedefParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const ParseTypeUsage& underlyingType, AccessType access
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, const ParseTypeUsage& underlyingType,
|
||||
AccessType access
|
||||
){
|
||||
log("typedef", fullName + " -> " + underlyingType.dataType.getFullTypeName(), location);
|
||||
log("typedef", utility::join(nameHierarchy, "::") + " -> " + underlyingType.dataType.getFullTypeName(), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_TYPEDEF, fullName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_TYPEDEF, nameHierarchy);
|
||||
addAccess(node, access);
|
||||
addTokenLocation(node, location);
|
||||
addTypeEdge(node, Edge::EDGE_TYPEDEF_OF, underlyingType);
|
||||
@@ -60,11 +63,12 @@ Id Storage::onTypedefParsed(
|
||||
}
|
||||
|
||||
Id Storage::onClassParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access, const ParseLocation& scopeLocation
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation
|
||||
){
|
||||
log("class", fullName, location);
|
||||
log("class", utility::join(nameHierarchy, "::"), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_CLASS, fullName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_CLASS, nameHierarchy);
|
||||
addAccess(node, access);
|
||||
addTokenLocation(node, location);
|
||||
addTokenLocation(node, scopeLocation, true);
|
||||
@@ -73,11 +77,12 @@ Id Storage::onClassParsed(
|
||||
}
|
||||
|
||||
Id Storage::onStructParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access, const ParseLocation& scopeLocation
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation
|
||||
){
|
||||
log("struct", fullName, location);
|
||||
log("struct", utility::join(nameHierarchy, "::"), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_STRUCT, fullName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_STRUCT, nameHierarchy);
|
||||
addAccess(node, access);
|
||||
addTokenLocation(node, location);
|
||||
addTokenLocation(node, scopeLocation, true);
|
||||
@@ -87,9 +92,9 @@ Id Storage::onStructParsed(
|
||||
|
||||
Id Storage::onGlobalVariableParsed(const ParseLocation& location, const ParseVariable& variable)
|
||||
{
|
||||
log("global", variable.fullName, location);
|
||||
log("global", variable.getFullName(), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_GLOBAL_VARIABLE, variable.fullName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_GLOBAL_VARIABLE, variable.nameHierarchy);
|
||||
|
||||
if (variable.isStatic)
|
||||
{
|
||||
@@ -104,9 +109,9 @@ Id Storage::onGlobalVariableParsed(const ParseLocation& location, const ParseVar
|
||||
|
||||
Id Storage::onFieldParsed(const ParseLocation& location, const ParseVariable& variable, AccessType access)
|
||||
{
|
||||
log("field", variable.fullName, location);
|
||||
log("field", variable.getFullName(), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_FIELD, variable.fullName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_FIELD, variable.nameHierarchy);
|
||||
|
||||
if (!node->getMemberEdge())
|
||||
{
|
||||
@@ -133,7 +138,7 @@ Id Storage::onFieldParsed(const ParseLocation& location, const ParseVariable& va
|
||||
Id Storage::onFunctionParsed(
|
||||
const ParseLocation& location, const ParseFunction& function, const ParseLocation& scopeLocation
|
||||
){
|
||||
log("function", function.fullName, location);
|
||||
log("function", function.getFullName(), location);
|
||||
|
||||
Node* node = addNodeHierarchyWithDistinctSignature(Node::NODE_FUNCTION, function);
|
||||
|
||||
@@ -153,7 +158,7 @@ Id Storage::onMethodParsed(
|
||||
const ParseLocation& location, const ParseFunction& method, AccessType access, AbstractionType abstraction,
|
||||
const ParseLocation& scopeLocation
|
||||
){
|
||||
log("method", method.fullName, location);
|
||||
log("method", method.getFullName(), location);
|
||||
|
||||
Node* node = addNodeHierarchyWithDistinctSignature(Node::NODE_METHOD, method);
|
||||
|
||||
@@ -192,11 +197,11 @@ Id Storage::onMethodParsed(
|
||||
}
|
||||
|
||||
Id Storage::onNamespaceParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const ParseLocation& scopeLocation
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, const ParseLocation& scopeLocation
|
||||
){
|
||||
log("namespace", fullName, location);
|
||||
log("namespace", utility::join(nameHierarchy, "::"), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_NAMESPACE, fullName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_NAMESPACE, nameHierarchy);
|
||||
addTokenLocation(node, location);
|
||||
addTokenLocation(node, scopeLocation, true);
|
||||
|
||||
@@ -204,11 +209,12 @@ Id Storage::onNamespaceParsed(
|
||||
}
|
||||
|
||||
Id Storage::onEnumParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access, const ParseLocation& scopeLocation
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation
|
||||
){
|
||||
log("enum", fullName, location);
|
||||
log("enum", utility::join(nameHierarchy, "::"), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_ENUM, fullName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_ENUM, nameHierarchy);
|
||||
addAccess(node, access);
|
||||
addTokenLocation(node, location);
|
||||
addTokenLocation(node, scopeLocation, true);
|
||||
@@ -216,23 +222,24 @@ Id Storage::onEnumParsed(
|
||||
return node->getId();
|
||||
}
|
||||
|
||||
Id Storage::onEnumFieldParsed(const ParseLocation& location, const std::string& fullName)
|
||||
Id Storage::onEnumFieldParsed(const ParseLocation& location, const std::vector<std::string>& nameHierarchy)
|
||||
{
|
||||
log("enum field", fullName, location);
|
||||
log("enum field", utility::join(nameHierarchy, "::"), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_FIELD, fullName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_FIELD, nameHierarchy);
|
||||
addTokenLocation(node, location);
|
||||
|
||||
return node->getId();
|
||||
}
|
||||
|
||||
Id Storage::onInheritanceParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const std::string& baseName, AccessType access
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy,
|
||||
const std::vector<std::string>& baseNameHierarchy, AccessType access
|
||||
){
|
||||
log("inheritance", fullName + " : " + baseName, location);
|
||||
log("inheritance", utility::join(nameHierarchy, "::") + " : " + utility::join(baseNameHierarchy, "::"), location);
|
||||
|
||||
Node* node = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, fullName);
|
||||
Node* baseNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, baseName);
|
||||
Node* node = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, nameHierarchy);
|
||||
Node* baseNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, baseNameHierarchy);
|
||||
|
||||
Edge* edge = m_graph.createEdge(Edge::EDGE_INHERITANCE, node, baseNode);
|
||||
edge->addComponentAccess(std::make_shared<TokenComponentAccess>(convertAccessType(access)));
|
||||
@@ -244,7 +251,7 @@ Id Storage::onInheritanceParsed(
|
||||
|
||||
Id Storage::onCallParsed(const ParseLocation& location, const ParseFunction& caller, const ParseFunction& callee)
|
||||
{
|
||||
log("call", caller.fullName + " -> " + callee.fullName, location);
|
||||
log("call", caller.getFullName() + " -> " + callee.getFullName(), location);
|
||||
|
||||
Node* callerNode = addNodeHierarchyWithDistinctSignature(Node::NODE_UNDEFINED_FUNCTION, caller);
|
||||
Node* calleeNode = addNodeHierarchyWithDistinctSignature(Node::NODE_UNDEFINED_FUNCTION, callee);
|
||||
@@ -258,9 +265,9 @@ Id Storage::onCallParsed(const ParseLocation& location, const ParseFunction& cal
|
||||
|
||||
Id Storage::onCallParsed(const ParseLocation& location, const ParseVariable& caller, const ParseFunction& callee)
|
||||
{
|
||||
log("call", caller.fullName + " -> " + callee.fullName, location);
|
||||
log("call", caller.getFullName() + " -> " + callee.getFullName(), location);
|
||||
|
||||
Node* callerNode = addNodeHierarchy(Node::NODE_UNDEFINED, caller.fullName);
|
||||
Node* callerNode = addNodeHierarchy(Node::NODE_UNDEFINED, caller.nameHierarchy);
|
||||
Node* calleeNode = addNodeHierarchyWithDistinctSignature(Node::NODE_UNDEFINED_FUNCTION, callee);
|
||||
|
||||
Edge* edge = m_graph.createEdge(Edge::EDGE_CALL, callerNode, calleeNode);
|
||||
@@ -270,12 +277,13 @@ Id Storage::onCallParsed(const ParseLocation& location, const ParseVariable& cal
|
||||
return edge->getId();
|
||||
}
|
||||
|
||||
Id Storage::onFieldUsageParsed(const ParseLocation& location, const ParseFunction& user, const std::string& usedName)
|
||||
Id Storage::onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const std::vector<std::string>& usedNameHierarchy)
|
||||
{
|
||||
log("field usage", user.fullName + " -> " + usedName, location);
|
||||
log("field usage", user.getFullName() + " -> " + utility::join(usedNameHierarchy, "::"), location);
|
||||
|
||||
Node* userNode = addNodeHierarchyWithDistinctSignature(Node::NODE_UNDEFINED_FUNCTION, user);
|
||||
Node* usedNode = addNodeHierarchy(Node::NODE_UNDEFINED_VARIABLE, usedName);
|
||||
Node* usedNode = addNodeHierarchy(Node::NODE_UNDEFINED_VARIABLE, usedNameHierarchy);
|
||||
|
||||
Edge* edge = m_graph.createEdge(Edge::EDGE_USAGE, userNode, usedNode);
|
||||
addTokenLocation(edge, location);
|
||||
@@ -283,13 +291,13 @@ Id Storage::onFieldUsageParsed(const ParseLocation& location, const ParseFunctio
|
||||
return edge->getId();
|
||||
}
|
||||
|
||||
Id Storage::onGlobalVariableUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const std::string& usedName
|
||||
Id Storage::onGlobalVariableUsageParsed( // or static variable used
|
||||
const ParseLocation& location, const ParseFunction& user, const std::vector<std::string>& usedNameHierarchy
|
||||
){
|
||||
log("global usage", user.fullName + " -> " + usedName, location);
|
||||
log("global usage", user.getFullName() + " -> " + utility::join(usedNameHierarchy, "::"), location);
|
||||
|
||||
Node* userNode = addNodeHierarchyWithDistinctSignature(Node::NODE_UNDEFINED_FUNCTION, user);
|
||||
Node* usedNode = addNodeHierarchy(Node::NODE_UNDEFINED_VARIABLE, usedName);
|
||||
Node* usedNode = addNodeHierarchy(Node::NODE_UNDEFINED_VARIABLE, usedNameHierarchy);
|
||||
|
||||
Edge* edge = m_graph.createEdge(Edge::EDGE_USAGE, userNode, usedNode);
|
||||
addTokenLocation(edge, location);
|
||||
@@ -299,7 +307,7 @@ Id Storage::onGlobalVariableUsageParsed(
|
||||
|
||||
Id Storage::onTypeUsageParsed(const ParseTypeUsage& type, const ParseFunction& function)
|
||||
{
|
||||
log("type usage", function.fullName + " -> " + type.dataType.getRawTypeName(), type.location);
|
||||
log("type usage", function.getFullName() + " -> " + type.dataType.getRawTypeName(), type.location);
|
||||
|
||||
Node* functionNode = addNodeHierarchyWithDistinctSignature(Node::NODE_UNDEFINED_FUNCTION, function);
|
||||
Edge* edge = addTypeEdge(functionNode, Edge::EDGE_TYPE_USAGE, type);
|
||||
@@ -555,13 +563,15 @@ void Storage::initSearchIndex()
|
||||
{
|
||||
for (const std::pair<std::string, QueryCommand::CommandType>& p : QueryCommand::getCommandTypeMap())
|
||||
{
|
||||
m_index.addNode(p.first);
|
||||
std::vector<std::string> nodeHierarchy;
|
||||
nodeHierarchy.push_back(p.first);
|
||||
m_index.addNode(nodeHierarchy);
|
||||
}
|
||||
}
|
||||
|
||||
Node* Storage::addNodeHierarchy(Node::NodeType type, const std::string& fullName)
|
||||
Node* Storage::addNodeHierarchy(Node::NodeType type, std::vector<std::string> nameHierarchy)
|
||||
{
|
||||
SearchIndex::SearchNode* searchNode = m_index.addNode(fullName);
|
||||
SearchIndex::SearchNode* searchNode = m_index.addNode(nameHierarchy);
|
||||
if (!searchNode)
|
||||
{
|
||||
LOG_ERROR("No SearchNode");
|
||||
@@ -573,7 +583,7 @@ Node* Storage::addNodeHierarchy(Node::NodeType type, const std::string& fullName
|
||||
|
||||
Node* Storage::addNodeHierarchyWithDistinctSignature(Node::NodeType type, const ParseFunction& function)
|
||||
{
|
||||
SearchIndex::SearchNode* searchNode = m_index.addNode(function.fullName);
|
||||
SearchIndex::SearchNode* searchNode = m_index.addNode(function.nameHierarchy);
|
||||
if (!searchNode)
|
||||
{
|
||||
LOG_ERROR("No SearchNode");
|
||||
@@ -648,7 +658,7 @@ TokenComponentAbstraction* Storage::addAbstraction(Node* node, ParserClient::Abs
|
||||
|
||||
Edge* Storage::addTypeEdge(Node* node, Edge::EdgeType edgeType, const DataType& type)
|
||||
{
|
||||
Node* typeNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, type.getRawTypeName());
|
||||
Node* typeNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, utility::splitToVector(type.getRawTypeName(), "::")); // TODO: do we really need to split here?
|
||||
Edge* edge = m_graph.createEdge(edgeType, node, typeNode);
|
||||
|
||||
// FIXME: When a function uses the same type multiple times then we still only use one edge to save this,
|
||||
|
||||
+16
-10
@@ -29,12 +29,14 @@ public:
|
||||
|
||||
// ParserClient implementation
|
||||
virtual Id onTypedefParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const ParseTypeUsage& underlyingType,
|
||||
AccessType access);
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy,
|
||||
const ParseTypeUsage& underlyingType, AccessType access);
|
||||
virtual Id onClassParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access, const ParseLocation& scopeLocation);
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation);
|
||||
virtual Id onStructParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access, const ParseLocation& scopeLocation);
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation);
|
||||
|
||||
virtual Id onGlobalVariableParsed(const ParseLocation& location, const ParseVariable& variable);
|
||||
virtual Id onFieldParsed(const ParseLocation& location, const ParseVariable& variable, AccessType access);
|
||||
@@ -46,22 +48,24 @@ public:
|
||||
const ParseLocation& scopeLocation);
|
||||
|
||||
virtual Id onNamespaceParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const ParseLocation& scopeLocation);
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, const ParseLocation& scopeLocation);
|
||||
|
||||
virtual Id onEnumParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access, const ParseLocation& scopeLocation);
|
||||
virtual Id onEnumFieldParsed(const ParseLocation& location, const std::string& fullName);
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation);
|
||||
virtual Id onEnumFieldParsed(const ParseLocation& location, const std::vector<std::string>& nameHierarchy);
|
||||
|
||||
virtual Id onInheritanceParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const std::string& baseName, AccessType access);
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy,
|
||||
const std::vector<std::string>& baseNameHierarchy, AccessType access);
|
||||
virtual Id onCallParsed(
|
||||
const ParseLocation& location, const ParseFunction& caller, const ParseFunction& callee);
|
||||
virtual Id onCallParsed(
|
||||
const ParseLocation& location, const ParseVariable& caller, const ParseFunction& callee);
|
||||
virtual Id onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const std::string& usedName);
|
||||
const ParseLocation& location, const ParseFunction& user, const std::vector<std::string>& usedNameHierarchy);
|
||||
virtual Id onGlobalVariableUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const std::string& usedName);
|
||||
const ParseLocation& location, const ParseFunction& user, const std::vector<std::string>& usedNameHierarchy);
|
||||
virtual Id onTypeUsageParsed(const ParseTypeUsage& type, const ParseFunction& function);
|
||||
|
||||
// GraphAccess implementation
|
||||
@@ -91,6 +95,8 @@ protected:
|
||||
private:
|
||||
void initSearchIndex();
|
||||
|
||||
Node* addNodeHierarchy(Node::NodeType type, std::vector<std::string> nameHierarchy);
|
||||
|
||||
Node* addNodeHierarchy(Node::NodeType type, const std::string& fullName);
|
||||
Node* addNodeHierarchyWithDistinctSignature(Node::NodeType type, const ParseFunction& function);
|
||||
|
||||
|
||||
@@ -107,12 +107,12 @@ Node* StorageGraph::insertNodeHierarchy(Node::NodeType type, SearchIndex::Search
|
||||
parentNode = getNodeById(parentSearchNode->getFirstTokenId());
|
||||
}
|
||||
|
||||
while (searchNodes.size())
|
||||
while (searchNodes.size() > 0)
|
||||
{
|
||||
searchNode = searchNodes.front();
|
||||
searchNodes.pop_front();
|
||||
|
||||
parentNode = insertNode(searchNodes.size() ? Node::NODE_UNDEFINED : type, parentNode, searchNode);
|
||||
parentNode = insertNode(searchNodes.size() > 0 ? Node::NODE_UNDEFINED : type, parentNode, searchNode);
|
||||
}
|
||||
|
||||
return parentNode;
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
#include "data/parser/ParseFunction.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
ParseFunction::ParseFunction(
|
||||
const ParseTypeUsage& returnType,
|
||||
const std::string& fullName,
|
||||
const std::vector<std::string>& nameHierarchy,
|
||||
const std::vector<ParseTypeUsage>& parameters,
|
||||
bool isStatic,
|
||||
bool isConst
|
||||
)
|
||||
: returnType(returnType)
|
||||
, fullName(fullName)
|
||||
, nameHierarchy(nameHierarchy)
|
||||
, parameters(parameters)
|
||||
, isStatic(isStatic)
|
||||
, isConst(isConst)
|
||||
{
|
||||
}
|
||||
|
||||
std::string ParseFunction::getFullName() const
|
||||
{
|
||||
return utility::join(nameHierarchy, "::");
|
||||
}
|
||||
|
||||
@@ -9,14 +9,16 @@ struct ParseFunction
|
||||
{
|
||||
ParseFunction(
|
||||
const ParseTypeUsage& returnType,
|
||||
const std::string& fullName,
|
||||
const std::vector<std::string>& nameHierarchy,
|
||||
const std::vector<ParseTypeUsage>& parameters,
|
||||
bool isStatic = false,
|
||||
bool isConst = false
|
||||
);
|
||||
|
||||
std::string getFullName() const;
|
||||
|
||||
const ParseTypeUsage returnType;
|
||||
const std::string fullName;
|
||||
const std::vector<std::string> nameHierarchy;
|
||||
const std::vector<ParseTypeUsage> parameters;
|
||||
const bool isStatic;
|
||||
const bool isConst;
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
#include "data/parser/ParseVariable.h"
|
||||
|
||||
ParseVariable::ParseVariable(const ParseTypeUsage& type, const std::string& fullName, bool isStatic)
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
ParseVariable::ParseVariable(const ParseTypeUsage& type, const std::vector<std::string>& nameHierarchy, bool isStatic)
|
||||
: type(type)
|
||||
, fullName(fullName)
|
||||
, nameHierarchy(nameHierarchy)
|
||||
, isStatic(isStatic)
|
||||
{
|
||||
}
|
||||
|
||||
std::string ParseVariable::getFullName() const
|
||||
{
|
||||
return utility::join(nameHierarchy, "::");
|
||||
}
|
||||
@@ -7,10 +7,12 @@
|
||||
|
||||
struct ParseVariable
|
||||
{
|
||||
ParseVariable(const ParseTypeUsage& type, const std::string& fullName, bool isStatic);
|
||||
ParseVariable(const ParseTypeUsage& type, const std::vector<std::string>& nameHierarchy, bool isStatic);
|
||||
|
||||
std::string getFullName() const;
|
||||
|
||||
const ParseTypeUsage type;
|
||||
const std::string fullName;
|
||||
const std::vector<std::string> nameHierarchy;
|
||||
const bool isStatic;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
#include "data/parser/ParseVariable.h"
|
||||
#include "data/type/DataType.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
std::string ParserClient::addAccessPrefix(const std::string& str, AccessType access)
|
||||
{
|
||||
@@ -86,7 +87,7 @@ std::string ParserClient::addLocationSuffix(
|
||||
|
||||
std::string ParserClient::variableStr(const ParseVariable& variable)
|
||||
{
|
||||
std::string str = variable.type.dataType.getFullTypeName() + " " + variable.fullName;
|
||||
std::string str = variable.type.dataType.getFullTypeName() + " " + variable.getFullName();
|
||||
return addStaticPrefix(str, variable.isStatic);
|
||||
}
|
||||
|
||||
@@ -107,13 +108,13 @@ std::string ParserClient::parameterStr(const std::vector<ParseTypeUsage> paramet
|
||||
std::string ParserClient::functionStr(const ParseFunction& function)
|
||||
{
|
||||
std::string str =
|
||||
function.returnType.dataType.getFullTypeName() + " " + function.fullName + parameterStr(function.parameters);
|
||||
function.returnType.dataType.getFullTypeName() + " " + function.getFullName() + parameterStr(function.parameters);
|
||||
return addConstPrefix(addStaticPrefix(str, function.isStatic), function.isConst, false);
|
||||
}
|
||||
|
||||
std::string ParserClient::functionSignatureStr(const ParseFunction& function)
|
||||
{
|
||||
return addConstPrefix(function.fullName + parameterStr(function.parameters), function.isConst, false);
|
||||
return addConstPrefix(function.getFullName() + parameterStr(function.parameters), function.isConst, false);
|
||||
}
|
||||
|
||||
ParserClient::ParserClient()
|
||||
|
||||
@@ -45,13 +45,13 @@ public:
|
||||
virtual ~ParserClient();
|
||||
|
||||
virtual Id onTypedefParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const ParseTypeUsage& underlyingType,
|
||||
AccessType access) = 0;
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy,
|
||||
const ParseTypeUsage& underlyingType, AccessType access) = 0;
|
||||
virtual Id onClassParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access,
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation) = 0;
|
||||
virtual Id onStructParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access,
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation) = 0;
|
||||
|
||||
virtual Id onGlobalVariableParsed(const ParseLocation& location, const ParseVariable& variable) = 0;
|
||||
@@ -64,23 +64,25 @@ public:
|
||||
const ParseLocation& scopeLocation) = 0;
|
||||
|
||||
virtual Id onNamespaceParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const ParseLocation& scopeLocation) = 0;
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy,
|
||||
const ParseLocation& scopeLocation) = 0;
|
||||
|
||||
virtual Id onEnumParsed(
|
||||
const ParseLocation& location, const std::string& fullName, AccessType access,
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, AccessType access,
|
||||
const ParseLocation& scopeLocation) = 0;
|
||||
virtual Id onEnumFieldParsed(const ParseLocation& location, const std::string& fullName) = 0;
|
||||
virtual Id onEnumFieldParsed(const ParseLocation& location, const std::vector<std::string>& nameHierarchy) = 0;
|
||||
|
||||
virtual Id onInheritanceParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const std::string& baseName, AccessType access) = 0;
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy,
|
||||
const std::vector<std::string>& baseNameHierarchy, AccessType access) = 0;
|
||||
virtual Id onCallParsed(
|
||||
const ParseLocation& location, const ParseFunction& caller, const ParseFunction& callee) = 0;
|
||||
virtual Id onCallParsed(
|
||||
const ParseLocation& location, const ParseVariable& caller, const ParseFunction& callee) = 0;
|
||||
virtual Id onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const std::string& usedName) = 0;
|
||||
const ParseLocation& location, const ParseFunction& user, const std::vector<std::string>& usedNameHierarchy) = 0;
|
||||
virtual Id onGlobalVariableUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const std::string& usedName) = 0;
|
||||
const ParseLocation& location, const ParseFunction& user, const std::vector<std::string>& usedNameHierarchy) = 0;
|
||||
virtual Id onTypeUsageParsed(const ParseTypeUsage& type, const ParseFunction& function) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
#include "data/parser/ParseVariable.h"
|
||||
#include "data/type/DataType.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
ASTVisitor::ASTVisitor(clang::ASTContext* context, ParserClient* client)
|
||||
: m_context(context)
|
||||
@@ -31,7 +32,7 @@ bool ASTVisitor::VisitTypedefDecl(clang::TypedefDecl* declaration)
|
||||
{
|
||||
m_client->onTypedefParsed(
|
||||
getParseLocationForNamedDecl(declaration),
|
||||
declaration->getQualifiedNameAsString(),
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::"),
|
||||
getParseTypeUsage(declaration->getTypeSourceInfo()->getTypeLoc(), declaration->getUnderlyingType()),
|
||||
convertAccessType(declaration->getAccess())
|
||||
);
|
||||
@@ -48,7 +49,7 @@ bool ASTVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl* declaration)
|
||||
{
|
||||
m_client->onClassParsed(
|
||||
getParseLocationForNamedDecl(declaration),
|
||||
declaration->getQualifiedNameAsString(),
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::"),
|
||||
convertAccessType(declaration->getAccess()),
|
||||
getParseLocationOfRecordBody(declaration)
|
||||
);
|
||||
@@ -59,8 +60,8 @@ bool ASTVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl* declaration)
|
||||
{
|
||||
m_client->onInheritanceParsed(
|
||||
getParseLocation(it.getSourceRange()),
|
||||
declaration->getQualifiedNameAsString(),
|
||||
getTypeName(it.getType()),
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::"),
|
||||
utility::splitToVector(getTypeName(it.getType()), "::"),
|
||||
convertAccessType(it.getAccessSpecifier())
|
||||
);
|
||||
}
|
||||
@@ -70,7 +71,7 @@ bool ASTVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl* declaration)
|
||||
{
|
||||
m_client->onStructParsed(
|
||||
getParseLocationForNamedDecl(declaration),
|
||||
declaration->getQualifiedNameAsString(),
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::"),
|
||||
convertAccessType(declaration->getAccess()),
|
||||
getParseLocationOfRecordBody(declaration)
|
||||
);
|
||||
@@ -205,7 +206,7 @@ bool ASTVisitor::VisitCXXConstructorDecl(clang::CXXConstructorDecl* declaration)
|
||||
m_client->onFieldUsageParsed(
|
||||
getParseLocationForNamedDecl(init->getMember(), init->getMemberLocation()),
|
||||
getParseFunction(declaration),
|
||||
init->getMember()->getQualifiedNameAsString()
|
||||
utility::splitToVector(init->getMember()->getQualifiedNameAsString(), "::")
|
||||
);
|
||||
}
|
||||
else if (init->isBaseInitializer())
|
||||
@@ -231,7 +232,7 @@ bool ASTVisitor::VisitNamespaceDecl(clang::NamespaceDecl* declaration)
|
||||
{
|
||||
m_client->onNamespaceParsed(
|
||||
declaration->isAnonymousNamespace() ? ParseLocation() : getParseLocationForNamedDecl(declaration),
|
||||
declaration->getQualifiedNameAsString(),
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::"),
|
||||
getParseLocation(declaration->getSourceRange())
|
||||
);
|
||||
}
|
||||
@@ -245,7 +246,7 @@ bool ASTVisitor::VisitEnumDecl(clang::EnumDecl* declaration)
|
||||
{
|
||||
m_client->onEnumParsed(
|
||||
getParseLocationForNamedDecl(declaration),
|
||||
declaration->getQualifiedNameAsString(),
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::"),
|
||||
convertAccessType(declaration->getAccess()),
|
||||
getParseLocation(declaration->getSourceRange())
|
||||
);
|
||||
@@ -260,7 +261,7 @@ bool ASTVisitor::VisitEnumConstantDecl(clang::EnumConstantDecl* declaration)
|
||||
{
|
||||
m_client->onEnumFieldParsed(
|
||||
getParseLocation(declaration->getSourceRange()),
|
||||
declaration->getQualifiedNameAsString()
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -339,7 +340,7 @@ void ASTVisitor::VisitMemberExprInDeclBody(clang::FunctionDecl* decl, clang::Mem
|
||||
m_client->onFieldUsageParsed(
|
||||
parseLocation,
|
||||
getParseFunction(decl),
|
||||
expr->getMemberDecl()->getQualifiedNameAsString()
|
||||
utility::splitToVector(expr->getMemberDecl()->getQualifiedNameAsString(), "::")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -353,7 +354,7 @@ void ASTVisitor::VisitDeclRefExprInDeclBody(clang::FunctionDecl* decl, clang::De
|
||||
m_client->onGlobalVariableUsageParsed(
|
||||
parseLocation,
|
||||
getParseFunction(decl),
|
||||
expr->getDecl()->getQualifiedNameAsString()
|
||||
utility::splitToVector(expr->getDecl()->getQualifiedNameAsString(), "::")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -512,7 +513,7 @@ ParseVariable ASTVisitor::getParseVariable(clang::DeclaratorDecl* declaration) c
|
||||
|
||||
return ParseVariable(
|
||||
getParseTypeUsage(declaration->getTypeSourceInfo()->getTypeLoc(), declaration->getType()),
|
||||
declaration->getQualifiedNameAsString(),
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::"),
|
||||
isStatic
|
||||
);
|
||||
}
|
||||
@@ -534,7 +535,7 @@ ParseFunction ASTVisitor::getParseFunction(clang::FunctionDecl* declaration) con
|
||||
|
||||
return ParseFunction(
|
||||
getParseTypeUsageOfReturnType(declaration),
|
||||
declaration->getQualifiedNameAsString(),
|
||||
utility::splitToVector(declaration->getQualifiedNameAsString(), "::"),
|
||||
getParameters(declaration),
|
||||
isStatic,
|
||||
isConst
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "data/query/QueryCommand.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
std::map<std::string, QueryCommand::CommandType> QueryCommand::getCommandTypeMap()
|
||||
{
|
||||
static std::map<std::string, CommandType> commandMap;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "data/query/QueryToken.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
Reference in New Issue
Block a user