data: parse variable usage

* Implemented functions for parsing usages of fields and global variables in ASTBodyVisitor and ASTVisitor.
* Storage adds TokenLocatons and Edges for usages.
* Added tests for parsing usage of fields and global variables.

fortune cookie message = Fame, riches and love are yours for the taking.
This commit is contained in:
malte_langkabel
2014-07-17 15:09:53 +02:00
parent 4578c109ec
commit ad5056354d
12 changed files with 180 additions and 12 deletions
+23
View File
@@ -223,6 +223,29 @@ void Storage::onCallParsed(const ParseLocation& location, const std::string& cal
addTokenLocation(edge, location);
}
void Storage::onFieldUsageParsed(const ParseLocation& location, const std::string& userName, const std::string& usedName)
{
log("usage", userName + " -> " + usedName, location);
Node* userNode = m_graph.createNodeHierarchy(userName);
Node* usedNode = m_graph.createNodeHierarchy(usedName);
Edge* edge = m_graph.createEdge(Edge::EDGE_USAGE, userNode, usedNode);
addTokenLocation(edge, location);
}
void Storage::onGlobalVariableUsageParsed(
const ParseLocation& location, const std::string& userName, const std::string& usedName
)
{
log("usage", userName + " -> " + usedName, location);
Node* userNode = m_graph.createNodeHierarchy(userName);
Node* usedNode = m_graph.createNodeHierarchy(usedName);
Edge* edge = m_graph.createEdge(Edge::EDGE_USAGE, userNode, usedNode);
addTokenLocation(edge, location);
}
Id Storage::getIdForNodeWithName(const std::string& name) const
{