data/logic/ui: added aggregation edges

This change adds the creation of aggregation edges to the StorageGraph, which save the connection counts between
children in their parents. Aggregation edges are displayed using a straight line, that is thicker than more connections
it represents with the connection count in the middle.
This commit is contained in:
Eberhard Graether
2015-01-07 14:42:35 +01:00
parent 8dafd0435f
commit ee85abfc7b
18 changed files with 410 additions and 117 deletions
+4 -3
View File
@@ -99,9 +99,10 @@ public:
"7 nodes: "
"class:A field:A::count undefined_type:int undefined_type:void class:B function:main "
"undefined_function:B::B\n"
"7 edges: "
"child:A->A::count type_use:A::count->int inheritance:B->A return_type:main->int type_usage:main->B "
"child:B->B::B call:main->B::B\n"
"13 edges: "
"child:A->A::count aggregation:A->int aggregation:A->void type_use:A::count->int inheritance:B->A "
"aggregation:B->void aggregation:B->int return_type:main->int type_usage:main->B child:B->B::B "
"call:main->B::B aggregation:main->B aggregation:main->A\n"
);
}
+30 -3
View File
@@ -1,5 +1,6 @@
#include "cxxtest/TestSuite.h"
#include "data/graph/token_component/TokenComponentAggregation.h"
#include "data/graph/StorageGraph.h"
#include "data/search/SearchIndex.h"
@@ -74,6 +75,32 @@ public:
TS_ASSERT_EQUALS(ab->getParentNode(), a);
}
void test_graph_creates_aggregation_edges()
{
TestStorageGraph graph;
Node* a = graph.createNodeHierarchy(Node::NODE_CLASS, "A");
Node* ab = graph.createNodeHierarchy(Node::NODE_CLASS, "A::B");
Node* c = graph.createNodeHierarchy(Node::NODE_CLASS, "C");
Node* cd = graph.createNodeHierarchy(Node::NODE_CLASS, "C::D");
Node* cdd = graph.createNodeHierarchy(Node::NODE_METHOD, "C::D::D");
Edge* i = graph.createEdge(Edge::EDGE_INHERITANCE, ab, cd);
Edge* t = graph.createEdge(Edge::EDGE_TYPE_USAGE, cdd, a);
TS_ASSERT_EQUALS(5, graph.getNodeCount());
TS_ASSERT_EQUALS(8, graph.getEdgeCount());
Edge* e1 = graph.getEdge(Edge::EDGE_AGGREGATION, a, c);
TS_ASSERT(e1);
TS_ASSERT_EQUALS(2, e1->getComponent<TokenComponentAggregation>()->getAggregationCount());
TS_ASSERT_EQUALS(i->getId(), *e1->getComponent<TokenComponentAggregation>()->getAggregationIds().begin());
TS_ASSERT_EQUALS(t->getId(), *(++e1->getComponent<TokenComponentAggregation>()->getAggregationIds().begin()));
Edge* e2 = graph.getEdge(Edge::EDGE_AGGREGATION, ab, c);
TS_ASSERT(e2);
TS_ASSERT_EQUALS(1, e2->getComponent<TokenComponentAggregation>()->getAggregationCount());
TS_ASSERT_EQUALS(i->getId(), *e2->getComponent<TokenComponentAggregation>()->getAggregationIds().begin());
}
void test_graph_removes_nodes()
{
TestStorageGraph graph;
@@ -278,14 +305,14 @@ public:
}
);
TS_ASSERT_EQUALS(4, plainGraph.getNodeCount());
TS_ASSERT_EQUALS(3, plainGraph.getEdgeCount());
TS_ASSERT_EQUALS(5, plainGraph.getNodeCount());
TS_ASSERT_EQUALS(4, plainGraph.getEdgeCount());
TS_ASSERT(plainGraph.getNode("A"));
TS_ASSERT(plainGraph.getNode("A::B"));
TS_ASSERT(plainGraph.getNode("A::B::C"));
TS_ASSERT(plainGraph.getNode("D"));
TS_ASSERT(!plainGraph.getNode("E"));
TS_ASSERT(plainGraph.getNode("E"));
}
private: