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:
@@ -1,22 +1,4 @@
|
||||
ConfigManager.cpp ERROR: value path/to/nowhere is not present in config.
|
||||
Token.cpp ERROR: Location Id was not referenced by this Token.
|
||||
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
|
||||
Edge.cpp ERROR: Nodes are not plain copies.
|
||||
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
|
||||
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
|
||||
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
|
||||
Storage.cpp INFO: method: A::getCount <input.cc 8:13 8:20>
|
||||
Storage.cpp INFO: global usage: A::getCount -> A::count <input.cc 10:10 10:14>
|
||||
Storage.cpp INFO: method: A::process <input.cc 14:15 14:21>
|
||||
Storage.cpp INFO: field: A::count <input.cc 17:13 17:17>
|
||||
Storage.cpp INFO: class: B <input.cc 20:7 20:7>
|
||||
Storage.cpp INFO: inheritance: B : A <input.cc 21:4 21:11>
|
||||
Storage.cpp INFO: method: B::process <input.cc 24:15 24:21>
|
||||
Storage.cpp INFO: type usage: B::process -> int <input.cc 26:3 26:5>
|
||||
Storage.cpp INFO: function: main <input.cc 30:5 30:8>
|
||||
Storage.cpp INFO: type usage: main -> B <input.cc 32:2 32:2>
|
||||
Storage.cpp INFO: call: main -> B::B <input.cc 32:4 32:4>
|
||||
Storage.cpp INFO: call: main -> A::getCount <input.cc 34:9 34:21>
|
||||
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
|
||||
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
|
||||
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
|
||||
@@ -49,6 +31,24 @@ SearchIndex.cpp INFO:
|
||||
237 A::A
|
||||
^^^^
|
||||
|
||||
Storage.cpp INFO: class: A <input.cc 1:7 1:7>
|
||||
Storage.cpp INFO: method: A::A <input.cc 4:2 4:2>
|
||||
Storage.cpp INFO: global usage: A::A -> A::count <input.cc 5:3 5:7>
|
||||
Storage.cpp INFO: method: A::getCount <input.cc 8:13 8:20>
|
||||
Storage.cpp INFO: global usage: A::getCount -> A::count <input.cc 10:10 10:14>
|
||||
Storage.cpp INFO: method: A::process <input.cc 14:15 14:21>
|
||||
Storage.cpp INFO: field: A::count <input.cc 17:13 17:17>
|
||||
Storage.cpp INFO: class: B <input.cc 20:7 20:7>
|
||||
Storage.cpp INFO: inheritance: B : A <input.cc 21:4 21:11>
|
||||
Storage.cpp INFO: method: B::process <input.cc 24:15 24:21>
|
||||
Storage.cpp INFO: type usage: B::process -> int <input.cc 26:3 26:5>
|
||||
Storage.cpp INFO: function: main <input.cc 30:5 30:8>
|
||||
Storage.cpp INFO: type usage: main -> B <input.cc 32:2 32:2>
|
||||
Storage.cpp INFO: call: main -> B::B <input.cc 32:4 32:4>
|
||||
Storage.cpp INFO: call: main -> A::getCount <input.cc 34:9 34:21>
|
||||
Token.cpp ERROR: Location Id was not referenced by this Token.
|
||||
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
|
||||
Edge.cpp ERROR: Nodes are not plain copies.
|
||||
Settings.cpp WARNING: File for Settings not found.
|
||||
ConfigManager.cpp ERROR: value Bool is not present in config.
|
||||
ConfigManager.cpp ERROR: value Int is not present in config.
|
||||
@@ -64,6 +64,7 @@ ConfigManager.cpp ERROR: value Int is not present in config.
|
||||
ConfigManager.cpp ERROR: value Float is not present in config.
|
||||
ConfigManager.cpp ERROR: value String is not present in config.
|
||||
ConfigManager.cpp ERROR: value NewBool is not present in config.
|
||||
Graph.cpp ERROR: Can't remove member edge, without removing the child node.
|
||||
Storage.cpp INFO: typedef: type -> int <file.cpp 1:1 1:1>
|
||||
Storage.cpp INFO: class: Class <file.cpp 1:1 1:1>
|
||||
Storage.cpp INFO: struct: Struct <file.cpp 1:1 1:1>
|
||||
@@ -103,7 +104,6 @@ Storage.cpp INFO: global usage: isTrue -> global <file.cpp 1:7 1:7>
|
||||
Storage.cpp INFO: function: isTrue <file.cpp 1:0 1:0>
|
||||
Storage.cpp INFO: struct: Struct <file.cpp 1:0 1:0>
|
||||
Storage.cpp INFO: type usage: isTrue -> Struct <file.cpp 1:0 1:0>
|
||||
Graph.cpp ERROR: Can't remove member edge, without removing the child node.
|
||||
TextAccess.cpp WARNING: Index 'firstLine' has to be lower or equal index 'lastLine', is 3 > 2
|
||||
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
|
||||
TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,51 +1,48 @@
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include <strings.h>
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::deque<std::string> split(const std::string& str, char delimiter)
|
||||
{
|
||||
return split(str, std::string(1, delimiter));
|
||||
return split<std::deque<std::string>>(str, std::string(1, delimiter));
|
||||
}
|
||||
|
||||
std::deque<std::string> split(const std::string& str, const std::string& delimiter)
|
||||
{
|
||||
size_t pos = 0;
|
||||
size_t oldPos = 0;
|
||||
std::deque<std::string> c;
|
||||
return split<std::deque<std::string>>(str, delimiter);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
pos = str.find(delimiter, oldPos);
|
||||
c.push_back(str.substr(oldPos, pos - oldPos));
|
||||
oldPos = pos + delimiter.size();
|
||||
}
|
||||
while (pos != std::string::npos);
|
||||
std::vector<std::string> splitToVector(const std::string& str, char delimiter)
|
||||
{
|
||||
return split<std::vector<std::string>>(str, std::string(1, delimiter));
|
||||
}
|
||||
|
||||
return c;
|
||||
std::vector<std::string> splitToVector(const std::string& str, const std::string& delimiter)
|
||||
{
|
||||
return split<std::vector<std::string>>(str, delimiter);
|
||||
}
|
||||
|
||||
std::string join(const std::deque<std::string>& list, char delimiter)
|
||||
{
|
||||
return join(list, std::string(1, delimiter));
|
||||
return join<std::deque<std::string> >(list, std::string(1, delimiter));
|
||||
}
|
||||
|
||||
std::string join(const std::deque<std::string>& list, const std::string& delimiter)
|
||||
{
|
||||
std::stringstream ss;
|
||||
bool first = true;
|
||||
for (const std::string& str : list)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
ss << delimiter;
|
||||
}
|
||||
first = false;
|
||||
return join<std::deque<std::string> >(list, delimiter);
|
||||
}
|
||||
|
||||
ss << str;
|
||||
}
|
||||
return ss.str();
|
||||
std::string join(const std::vector<std::string>& list, char delimiter)
|
||||
{
|
||||
return join<std::vector<std::string> >(list, std::string(1, delimiter));
|
||||
}
|
||||
|
||||
std::string join(const std::vector<std::string>& list, const std::string& delimiter)
|
||||
{
|
||||
return join<std::vector<std::string> >(list, delimiter);
|
||||
}
|
||||
|
||||
std::deque<std::string> tokenize(const std::string& str, char delimiter)
|
||||
@@ -121,6 +118,17 @@ namespace utility
|
||||
|
||||
bool equalsCaseInsensitive(const std::string& a, const std::string& b)
|
||||
{
|
||||
return strcasecmp(a.c_str(), b.c_str()) == 0;
|
||||
if (a.size() == b.size())
|
||||
{
|
||||
for (int i = 0; i < a.size(); i++)
|
||||
{
|
||||
if (tolower(a[i]) != tolower(b[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,25 @@
|
||||
#include <deque>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace utility
|
||||
{
|
||||
template <typename ContainerType>
|
||||
ContainerType split(const std::string& str, const std::string& delimiter);
|
||||
|
||||
std::deque<std::string> split(const std::string& str, char delimiter);
|
||||
std::deque<std::string> split(const std::string& str, const std::string& delimiter);
|
||||
std::vector<std::string> splitToVector(const std::string& str, char delimiter);
|
||||
std::vector<std::string> splitToVector(const std::string& str, const std::string& delimiter);
|
||||
|
||||
template <typename ContainerType>
|
||||
std::string join(const ContainerType& list, const std::string& delimiter);
|
||||
|
||||
std::string join(const std::deque<std::string>& list, char delimiter);
|
||||
std::string join(const std::deque<std::string>& list, const std::string& delimiter);
|
||||
std::string join(const std::vector<std::string>& list, char delimiter);
|
||||
std::string join(const std::vector<std::string>& list, const std::string& delimiter);
|
||||
|
||||
std::deque<std::string> tokenize(const std::string& str, char delimiter);
|
||||
std::deque<std::string> tokenize(const std::string& str, const std::string& delimiter);
|
||||
@@ -23,6 +34,43 @@ namespace utility
|
||||
bool isPrefix(const std::string& prefix, const std::string& text);
|
||||
|
||||
bool equalsCaseInsensitive(const std::string& a, const std::string& b);
|
||||
|
||||
|
||||
template <typename ContainerType>
|
||||
ContainerType split(const std::string& str, const std::string& delimiter)
|
||||
{
|
||||
size_t pos = 0;
|
||||
size_t oldPos = 0;
|
||||
ContainerType c;
|
||||
|
||||
do
|
||||
{
|
||||
pos = str.find(delimiter, oldPos);
|
||||
c.push_back(str.substr(oldPos, pos - oldPos));
|
||||
oldPos = pos + delimiter.size();
|
||||
}
|
||||
while (pos != std::string::npos);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
template <typename ContainerType>
|
||||
std::string join(const ContainerType& list, const std::string& delimiter)
|
||||
{
|
||||
std::stringstream ss;
|
||||
bool first = true;
|
||||
for (const std::string& str : list)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
ss << delimiter;
|
||||
}
|
||||
first = false;
|
||||
|
||||
ss << str;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // UTILITY_STRING_H
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
#include "data/parser/ParseVariable.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
class CxxParserTestSuite: public CxxTest::TestSuite
|
||||
{
|
||||
@@ -1005,28 +1006,28 @@ private:
|
||||
{
|
||||
public:
|
||||
virtual Id onTypedefParsed(
|
||||
const ParseLocation& location, const std::string& fullName, const ParseTypeUsage& underlyingType,
|
||||
const ParseLocation& location, const std::vector<std::string>& nameHierarchy, const ParseTypeUsage& underlyingType,
|
||||
AccessType access
|
||||
)
|
||||
{
|
||||
std::string str = addAccessPrefix(underlyingType.dataType.getFullTypeName() + " -> " + fullName, access);
|
||||
std::string str = addAccessPrefix(underlyingType.dataType.getFullTypeName() + " -> " + utility::join(nameHierarchy, "::"), access);
|
||||
typedefs.push_back(addLocationSuffix(str, location));
|
||||
return 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)
|
||||
{
|
||||
classes.push_back(addLocationSuffix(addAccessPrefix(fullName, access), location, scopeLocation));
|
||||
classes.push_back(addLocationSuffix(addAccessPrefix(utility::join(nameHierarchy, "::"), access), location, scopeLocation));
|
||||
return 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)
|
||||
{
|
||||
structs.push_back(addLocationSuffix(addAccessPrefix(fullName, access), location, scopeLocation));
|
||||
structs.push_back(addLocationSuffix(addAccessPrefix(utility::join(nameHierarchy, "::"), access), location, scopeLocation));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1074,30 +1075,30 @@ private:
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
namespaces.push_back(addLocationSuffix(fullName, location, scopeLocation));
|
||||
namespaces.push_back(addLocationSuffix(utility::join(nameHierarchy, "::"), location, scopeLocation));
|
||||
return 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)
|
||||
{
|
||||
enums.push_back(addLocationSuffix(addAccessPrefix(fullName, access), location, scopeLocation));
|
||||
enums.push_back(addLocationSuffix(addAccessPrefix(utility::join(nameHierarchy, "::"), access), location, scopeLocation));
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id onEnumFieldParsed(const ParseLocation& location, const std::string& fullName)
|
||||
virtual Id onEnumFieldParsed(const ParseLocation& location, const std::vector<std::string>& nameHierarchy)
|
||||
{
|
||||
enumFields.push_back(addLocationSuffix(fullName, location));
|
||||
enumFields.push_back(addLocationSuffix(utility::join(nameHierarchy, "::"), location));
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
std::string str = fullName + " : " + addAccessPrefix(baseName, access);
|
||||
std::string str = utility::join(nameHierarchy, "::") + " : " + addAccessPrefix(utility::join(baseNameHierarchy, "::"), access);
|
||||
inheritances.push_back(addLocationSuffix(str, location));
|
||||
return 0;
|
||||
}
|
||||
@@ -1112,21 +1113,21 @@ private:
|
||||
virtual Id onCallParsed(
|
||||
const ParseLocation& location, const ParseVariable& caller, const ParseFunction& callee)
|
||||
{
|
||||
calls.push_back(addLocationSuffix(caller.fullName + " -> " + functionStr(callee), location));
|
||||
calls.push_back(addLocationSuffix(caller.getFullName() + " -> " + functionStr(callee), location));
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
usages.push_back(addLocationSuffix(functionStr(user) + " -> " + usedName, location));
|
||||
usages.push_back(addLocationSuffix(functionStr(user) + " -> " + utility::join(usedNameHierarchy, "::"), location));
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
usages.push_back(addLocationSuffix(functionStr(user) + " -> " + usedName, location));
|
||||
usages.push_back(addLocationSuffix(functionStr(user) + " -> " + utility::join(usedNameHierarchy, "::"), location));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "data/SearchIndex.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
class SearchIndexTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
@@ -16,7 +17,7 @@ public:
|
||||
void test_add_node()
|
||||
{
|
||||
SearchIndex index;
|
||||
SearchIndex::SearchNode* node = index.addNode("util");
|
||||
SearchIndex::SearchNode* node = index.addNode(utility::splitToVector("util", "::"));
|
||||
|
||||
TS_ASSERT(node);
|
||||
TS_ASSERT_EQUALS("util", node->getName());
|
||||
@@ -30,7 +31,7 @@ public:
|
||||
void test_get_node()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("util");
|
||||
index.addNode(utility::splitToVector("util", "::"));
|
||||
SearchIndex::SearchNode* node = index.getNode("util");
|
||||
|
||||
TS_ASSERT(node);
|
||||
@@ -48,7 +49,7 @@ public:
|
||||
void test_add_hierarchy_node()
|
||||
{
|
||||
SearchIndex index;
|
||||
SearchIndex::SearchNode* node = index.addNode("util::math::pow");
|
||||
SearchIndex::SearchNode* node = index.addNode(utility::splitToVector("util::math::pow", "::"));
|
||||
|
||||
TS_ASSERT(node);
|
||||
TS_ASSERT_EQUALS("pow", node->getName());
|
||||
@@ -67,23 +68,23 @@ public:
|
||||
void test_reuse_hierarchy_node()
|
||||
{
|
||||
SearchIndex index;
|
||||
SearchIndex::SearchNode* node = index.addNode("math::pow");
|
||||
SearchIndex::SearchNode* node2 = index.addNode("math::floor");
|
||||
SearchIndex::SearchNode* node1 = index.addNode(utility::splitToVector("math::pow", "::"));
|
||||
SearchIndex::SearchNode* node2 = index.addNode(utility::splitToVector("math::floor", "::"));
|
||||
|
||||
TS_ASSERT(node);
|
||||
TS_ASSERT(node1);
|
||||
TS_ASSERT(node2);
|
||||
|
||||
TS_ASSERT_EQUALS("pow", node->getName());
|
||||
TS_ASSERT_EQUALS("pow", node1->getName());
|
||||
TS_ASSERT_EQUALS("floor", node2->getName());
|
||||
|
||||
TS_ASSERT_EQUALS(node->getParent(), node2->getParent());
|
||||
TS_ASSERT_EQUALS(node1->getParent(), node2->getParent());
|
||||
}
|
||||
|
||||
void test_clear()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("math");
|
||||
index.addNode("string");
|
||||
index.addNode(utility::splitToVector("math", "::"));
|
||||
index.addNode(utility::splitToVector("string", "::"));
|
||||
|
||||
TS_ASSERT(index.getNode("math"));
|
||||
|
||||
@@ -95,9 +96,9 @@ public:
|
||||
void test_fuzzy_matching()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("util");
|
||||
index.addNode("math");
|
||||
index.addNode("string");
|
||||
index.addNode(utility::splitToVector("util", "::"));
|
||||
index.addNode(utility::splitToVector("math", "::"));
|
||||
index.addNode(utility::splitToVector("string", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("u");
|
||||
|
||||
@@ -114,8 +115,8 @@ public:
|
||||
void test_fuzzy_matching_is_case_insensitive()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("util");
|
||||
index.addNode("MATH");
|
||||
index.addNode(utility::splitToVector("util", "::"));
|
||||
index.addNode(utility::splitToVector("MATH", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("t");
|
||||
|
||||
@@ -133,9 +134,9 @@ public:
|
||||
void test_fuzzy_matching_wheighs_by_distance_and_alphabet()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("util");
|
||||
index.addNode("math");
|
||||
index.addNode("string");
|
||||
index.addNode(utility::splitToVector("util", "::"));
|
||||
index.addNode(utility::splitToVector("math", "::"));
|
||||
index.addNode(utility::splitToVector("string", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("t");
|
||||
|
||||
@@ -157,8 +158,8 @@ public:
|
||||
void test_fuzzy_matching_wheighs_higher_by_uppercase()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("uTil");
|
||||
index.addNode("string");
|
||||
index.addNode(utility::splitToVector("uTil", "::"));
|
||||
index.addNode(utility::splitToVector("string", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("t");
|
||||
|
||||
@@ -170,8 +171,8 @@ public:
|
||||
void test_fuzzy_matching_wheighs_higher_on_consecutive_letters()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("oaabbcc");
|
||||
index.addNode("ocbaabc");
|
||||
index.addNode(utility::splitToVector("oaabbcc", "::"));
|
||||
index.addNode(utility::splitToVector("ocbaabc", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("abc");
|
||||
|
||||
@@ -183,9 +184,9 @@ public:
|
||||
void test_fuzzy_matching_in_hierarchy()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("util::math::ceil");
|
||||
index.addNode("util::math::floor");
|
||||
index.addNode("util::string::concat");
|
||||
index.addNode(utility::splitToVector("util::math::ceil", "::"));
|
||||
index.addNode(utility::splitToVector("util::math::floor", "::"));
|
||||
index.addNode(utility::splitToVector("util::string::concat", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("t");
|
||||
|
||||
@@ -202,9 +203,9 @@ public:
|
||||
void test_fuzzy_matching_in_hierarchy_respects_collin()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("util::math::ceil");
|
||||
index.addNode("util::math::floor");
|
||||
index.addNode("util::string::concat");
|
||||
index.addNode(utility::splitToVector("util::math::ceil", "::"));
|
||||
index.addNode(utility::splitToVector("util::math::floor", "::"));
|
||||
index.addNode(utility::splitToVector("util::string::concat", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("u:i");
|
||||
|
||||
@@ -221,8 +222,8 @@ public:
|
||||
void test_fuzzy_matching_in_hierarchy_weighs_front_letters_higher()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("abc::dfe::ghi");
|
||||
index.addNode("abc::hgi");
|
||||
index.addNode(utility::splitToVector("abc::dfe::ghi", "::"));
|
||||
index.addNode(utility::splitToVector("abc::hgi", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("g");
|
||||
|
||||
@@ -234,9 +235,9 @@ public:
|
||||
void test_fuzzy_matching_with_defined_start_node()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode("math::ceil");
|
||||
index.addNode("math::floor");
|
||||
index.addNode("string::concat");
|
||||
index.addNode(utility::splitToVector("math::ceil", "::"));
|
||||
index.addNode(utility::splitToVector("math::floor", "::"));
|
||||
index.addNode(utility::splitToVector("string::concat", "::"));
|
||||
|
||||
std::vector<SearchIndex::SearchMatch> matches = index.findFuzzyMatches("\"math\"c");
|
||||
|
||||
|
||||
@@ -295,14 +295,14 @@ private:
|
||||
public:
|
||||
Node* createNodeHierarchy(Node::NodeType type, const std::string& name)
|
||||
{
|
||||
SearchIndex::SearchNode* searchNode = m_index.addNode(name);
|
||||
SearchIndex::SearchNode* searchNode = m_index.addNode(utility::splitToVector(name, "::"));
|
||||
return StorageGraph::createNodeHierarchy(type, searchNode);
|
||||
}
|
||||
|
||||
Node* createNodeHierarchyWithDistinctSignature(
|
||||
Node::NodeType type, const std::string& name, Id signatureId
|
||||
){
|
||||
SearchIndex::SearchNode* searchNode = m_index.addNode(name);
|
||||
SearchIndex::SearchNode* searchNode = m_index.addNode(utility::splitToVector(name, "::"));
|
||||
std::shared_ptr<TokenComponentSignature> signature = std::make_shared<TokenComponentSignature>(signatureId);
|
||||
return StorageGraph::createNodeHierarchyWithDistinctSignature(type, searchNode, signature);
|
||||
}
|
||||
|
||||
+44
-37
@@ -18,7 +18,7 @@ public:
|
||||
void test_storage_saves_typedef()
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onTypedefParsed(validLocation(1), "type", typeUsage("int"), ParserClient::ACCESS_NONE);
|
||||
Id id = storage.onTypedefParsed(validLocation(1), utility::splitToVector("type", "::"), typeUsage("int"), ParserClient::ACCESS_NONE);
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
void test_storage_saves_class()
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onClassParsed(validLocation(1), "Class", ParserClient::ACCESS_NONE, validLocation(2));
|
||||
Id id = storage.onClassParsed(validLocation(1), utility::splitToVector("Class", "::"), ParserClient::ACCESS_NONE, validLocation(2));
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void test_storage_saves_struct()
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onStructParsed(validLocation(1), "Struct", ParserClient::ACCESS_NONE, validLocation(2));
|
||||
Id id = storage.onStructParsed(validLocation(1), utility::splitToVector("Struct", "::"), ParserClient::ACCESS_NONE, validLocation(2));
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
void test_storage_saves_global_variable()
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onGlobalVariableParsed(validLocation(42), ParseVariable(typeUsage("char"), "Global", false));
|
||||
Id id = storage.onGlobalVariableParsed(validLocation(42), ParseVariable(typeUsage("char"), utility::splitToVector("Global", "::"), false));
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
void test_storage_saves_global_variable_static()
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onGlobalVariableParsed(validLocation(7), ParseVariable(typeUsage("char"), "Global", true));
|
||||
Id id = storage.onGlobalVariableParsed(validLocation(7), ParseVariable(typeUsage("char"), utility::splitToVector("Global", "::"), true));
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onFieldParsed(
|
||||
validLocation(3), ParseVariable(typeUsage("bool"), "m_field", false), ParserClient::ACCESS_NONE
|
||||
validLocation(3), ParseVariable(typeUsage("bool"), utility::splitToVector("m_field", "::"), false), ParserClient::ACCESS_NONE
|
||||
);
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onFieldParsed(
|
||||
validLocation(11), ParseVariable(typeUsage("bool"), "Struct::m_field", false), ParserClient::ACCESS_PUBLIC
|
||||
validLocation(11), ParseVariable(typeUsage("bool"), utility::splitToVector("Struct::m_field", "::"), false), ParserClient::ACCESS_PUBLIC
|
||||
);
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onFunctionParsed(
|
||||
validLocation(14), ParseFunction(typeUsage("bool"), "isTrue", parameters("char")), validLocation(41)
|
||||
validLocation(14), ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char")), validLocation(41)
|
||||
);
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onMethodParsed(
|
||||
validLocation(9),
|
||||
ParseFunction(typeUsage("void"), "isMethod", parameters("bool")),
|
||||
ParseFunction(typeUsage("void"), utility::splitToVector("isMethod", "::"), parameters("bool")),
|
||||
ParserClient::ACCESS_NONE,
|
||||
ParserClient::ABSTRACTION_NONE,
|
||||
validLocation(4)
|
||||
@@ -228,7 +228,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onMethodParsed(
|
||||
validLocation(1),
|
||||
ParseFunction(typeUsage("void"), "isMethod", parameters("bool"), true),
|
||||
ParseFunction(typeUsage("void"), utility::splitToVector("isMethod", "::"), parameters("bool"), true),
|
||||
ParserClient::ACCESS_NONE,
|
||||
ParserClient::ABSTRACTION_NONE,
|
||||
validLocation(4)
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onMethodParsed(
|
||||
validLocation(1),
|
||||
ParseFunction(typeUsage("void"), "Class::isMethod", parameters("bool")),
|
||||
ParseFunction(typeUsage("void"), utility::splitToVector("Class::isMethod", "::"), parameters("bool")),
|
||||
ParserClient::ACCESS_PROTECTED,
|
||||
ParserClient::ABSTRACTION_VIRTUAL,
|
||||
validLocation(4)
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
void test_storage_saves_namespace()
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onNamespaceParsed(validLocation(1), "utility", validLocation(2));
|
||||
Id id = storage.onNamespaceParsed(validLocation(1), utility::splitToVector("utility", "::"), validLocation(2));
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
void test_storage_saves_enum()
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onEnumParsed(validLocation(17), "Category", ParserClient::ACCESS_NONE, validLocation(23));
|
||||
Id id = storage.onEnumParsed(validLocation(17), utility::splitToVector("Category", "::"), ParserClient::ACCESS_NONE, validLocation(23));
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -315,7 +315,9 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id =
|
||||
storage.onEnumParsed(validLocation(1), "Class::Category", ParserClient::ACCESS_PRIVATE, validLocation(2));
|
||||
storage.onEnumParsed(validLocation(1), utility::splitToVector("Class::Category", "::"),
|
||||
ParserClient::ACCESS_PRIVATE, validLocation(2)
|
||||
);
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -338,7 +340,7 @@ public:
|
||||
void test_storage_saves_enum_field()
|
||||
{
|
||||
TestStorage storage;
|
||||
Id id = storage.onEnumFieldParsed(validLocation(1), "VALUE");
|
||||
Id id = storage.onEnumFieldParsed(validLocation(1), utility::splitToVector("VALUE", "::"));
|
||||
|
||||
Node* node = storage.getNodeWithId(id);
|
||||
TS_ASSERT(node);
|
||||
@@ -353,9 +355,12 @@ public:
|
||||
void test_storage_saves_inheritance()
|
||||
{
|
||||
TestStorage storage;
|
||||
storage.onClassParsed(validLocation(), "ClassA", ParserClient::ACCESS_NONE, validLocation());
|
||||
storage.onClassParsed(validLocation(), "ClassB", ParserClient::ACCESS_NONE, validLocation());
|
||||
Id id = storage.onInheritanceParsed(validLocation(5), "ClassB", "ClassA", ParserClient::ACCESS_PUBLIC);
|
||||
storage.onClassParsed(validLocation(), utility::splitToVector("ClassA", "::"), ParserClient::ACCESS_NONE, validLocation());
|
||||
storage.onClassParsed(validLocation(), utility::splitToVector("ClassB", "::"), ParserClient::ACCESS_NONE, validLocation());
|
||||
Id id =
|
||||
storage.onInheritanceParsed(validLocation(5), utility::splitToVector("ClassB", "::"),
|
||||
utility::splitToVector("ClassA", "::"), ParserClient::ACCESS_PUBLIC
|
||||
);
|
||||
|
||||
Edge* edge = storage.getEdgeWithId(id);
|
||||
TS_ASSERT(edge);
|
||||
@@ -376,15 +381,15 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
storage.onFunctionParsed(
|
||||
validLocation(), ParseFunction(typeUsage("bool"), "isTrue", parameters("char")), validLocation()
|
||||
validLocation(), ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char")), validLocation()
|
||||
);
|
||||
storage.onFunctionParsed(
|
||||
validLocation(), ParseFunction(typeUsage("void"), "func", parameters("bool")), validLocation()
|
||||
validLocation(), ParseFunction(typeUsage("void"), utility::splitToVector("func", "::"), parameters("bool")), validLocation()
|
||||
);
|
||||
Id id = storage.onCallParsed(
|
||||
validLocation(9),
|
||||
ParseFunction(typeUsage("bool"), "isTrue", parameters("char")),
|
||||
ParseFunction(typeUsage("void"), "func", parameters("bool"))
|
||||
ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char")),
|
||||
ParseFunction(typeUsage("void"), utility::splitToVector("func", "::"), parameters("bool"))
|
||||
);
|
||||
|
||||
Edge* edge = storage.getEdgeWithId(id);
|
||||
@@ -402,15 +407,15 @@ public:
|
||||
void test_storage_saves_call_in_global_variable_declaration()
|
||||
{
|
||||
TestStorage storage;
|
||||
storage.onGlobalVariableParsed(validLocation(), ParseVariable(typeUsage("bool"), "global", false));
|
||||
storage.onGlobalVariableParsed(validLocation(), ParseVariable(typeUsage("bool"), utility::splitToVector("global", "::"), false));
|
||||
storage.onFunctionParsed(
|
||||
validLocation(), ParseFunction(typeUsage("bool"), "isTrue", parameters("char")), validLocation()
|
||||
validLocation(), ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char")), validLocation()
|
||||
);
|
||||
|
||||
Id id = storage.onCallParsed(
|
||||
validLocation(7),
|
||||
ParseVariable(typeUsage("bool"), "global", false),
|
||||
ParseFunction(typeUsage("bool"), "isTrue", parameters("char"))
|
||||
ParseVariable(typeUsage("bool"), utility::splitToVector("global", "::"), false),
|
||||
ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char"))
|
||||
);
|
||||
|
||||
Edge* edge = storage.getEdgeWithId(id);
|
||||
@@ -429,16 +434,16 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
storage.onFunctionParsed(
|
||||
validLocation(), ParseFunction(typeUsage("bool"), "isTrue", parameters("char")), validLocation()
|
||||
validLocation(), ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char")), validLocation()
|
||||
);
|
||||
storage.onFieldParsed(
|
||||
validLocation(), ParseVariable(typeUsage("bool"), "Foo::m_field", false), ParserClient::ACCESS_PRIVATE
|
||||
validLocation(), ParseVariable(typeUsage("bool"), utility::splitToVector("Foo::m_field", "::"), false), ParserClient::ACCESS_PRIVATE
|
||||
);
|
||||
|
||||
Id id = storage.onFieldUsageParsed(
|
||||
validLocation(7),
|
||||
ParseFunction(typeUsage("bool"), "isTrue", parameters("char")),
|
||||
"Foo::m_field"
|
||||
ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char")),
|
||||
utility::splitToVector("Foo::m_field", "::")
|
||||
);
|
||||
|
||||
Edge* edge = storage.getEdgeWithId(id);
|
||||
@@ -457,14 +462,14 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
storage.onFunctionParsed(
|
||||
validLocation(), ParseFunction(typeUsage("bool"), "isTrue", parameters("char")), validLocation()
|
||||
validLocation(), ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char")), validLocation()
|
||||
);
|
||||
storage.onGlobalVariableParsed(validLocation(), ParseVariable(typeUsage("bool"), "global", false));
|
||||
storage.onGlobalVariableParsed(validLocation(), ParseVariable(typeUsage("bool"), utility::splitToVector("global", "::"), false));
|
||||
|
||||
Id id = storage.onGlobalVariableUsageParsed(
|
||||
validLocation(7),
|
||||
ParseFunction(typeUsage("bool"), "isTrue", parameters("char")),
|
||||
"global"
|
||||
ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char")),
|
||||
utility::splitToVector("global", "::")
|
||||
);
|
||||
|
||||
Edge* edge = storage.getEdgeWithId(id);
|
||||
@@ -483,13 +488,15 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
storage.onFunctionParsed(
|
||||
validLocation(), ParseFunction(typeUsage("bool"), "isTrue", parameters("char")), validLocation()
|
||||
validLocation(), ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"),
|
||||
parameters("char")), validLocation()
|
||||
);
|
||||
storage.onStructParsed(validLocation(), "Struct", ParserClient::ACCESS_NONE, validLocation());
|
||||
storage.onStructParsed(
|
||||
validLocation(), utility::splitToVector("Struct", "::"), ParserClient::ACCESS_NONE, validLocation());
|
||||
|
||||
Id id = storage.onTypeUsageParsed(
|
||||
typeUsage("Struct"),
|
||||
ParseFunction(typeUsage("bool"), "isTrue", parameters("char"))
|
||||
ParseFunction(typeUsage("bool"), utility::splitToVector("isTrue", "::"), parameters("char"))
|
||||
);
|
||||
|
||||
Edge* edge = storage.getEdgeWithId(id);
|
||||
|
||||
Reference in New Issue
Block a user