data: Fixed aggregation edge creation and display
This commit is contained in:
@@ -126,7 +126,7 @@ void QtStraightLineItem::updateLine(
|
||||
|
||||
QColor color(style.color.c_str());
|
||||
|
||||
this->setPen(QPen(QBrush(color), number + style.width, Qt::SolidLine, Qt::RoundCap));
|
||||
this->setPen(QPen(QBrush(color), style.width, Qt::SolidLine, Qt::RoundCap));
|
||||
|
||||
color = color.darker(110);
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ void GraphController::setActiveAndVisibility(const std::vector<Id>& activeTokenI
|
||||
|
||||
for (DummyEdge& edge : m_dummyEdges)
|
||||
{
|
||||
if (!edge.data || edge.data->isType(Edge::EDGE_AGGREGATION))
|
||||
if (!edge.data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -361,43 +361,9 @@ void GraphController::setActiveAndVisibility(const std::vector<Id>& activeTokenI
|
||||
}
|
||||
}
|
||||
|
||||
for (DummyEdge& edge : m_dummyEdges)
|
||||
{
|
||||
if (!edge.data || !edge.data->isType(Edge::EDGE_AGGREGATION))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
DummyNode* from = findTopLevelDummyNodeRecursive(m_dummyNodes, edge.ownerId);
|
||||
DummyNode* to = findTopLevelDummyNodeRecursive(m_dummyNodes, edge.targetId);
|
||||
|
||||
if (from && to && (from->active || to->active))
|
||||
{
|
||||
TokenComponentAggregation* component = edge.data->getComponent<TokenComponentAggregation>();
|
||||
std::set<Id> ids = component->getAggregationIds();
|
||||
for (Id id : ids)
|
||||
{
|
||||
for (DummyEdge& e : m_dummyEdges)
|
||||
{
|
||||
if (e.visible && e.data && e.data->getId() == id)
|
||||
{
|
||||
component->removeAggregationId(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (component->getAggregationCount() > 0)
|
||||
{
|
||||
edge.visible = true;
|
||||
from->aggregated = true;
|
||||
to->aggregated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (DummyNode& node : m_dummyNodes)
|
||||
{
|
||||
setNodeVisibilityRecursiveBottomUp(node, false);
|
||||
setNodeVisibilityRecursiveBottomUp(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +382,7 @@ void GraphController::setNodeActiveRecursive(DummyNode& node, const std::vector<
|
||||
}
|
||||
}
|
||||
|
||||
bool GraphController::setNodeVisibilityRecursiveBottomUp(DummyNode& node, bool aggregated) const
|
||||
bool GraphController::setNodeVisibilityRecursiveBottomUp(DummyNode& node) const
|
||||
{
|
||||
node.visible = false;
|
||||
node.childVisible = false;
|
||||
@@ -434,13 +400,13 @@ bool GraphController::setNodeVisibilityRecursiveBottomUp(DummyNode& node, bool a
|
||||
|
||||
for (DummyNode& subNode : node.subNodes)
|
||||
{
|
||||
if (setNodeVisibilityRecursiveBottomUp(subNode, aggregated | node.aggregated))
|
||||
if (setNodeVisibilityRecursiveBottomUp(subNode))
|
||||
{
|
||||
node.childVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.active || node.connected || node.childVisible || (!aggregated && node.aggregated))
|
||||
if (node.active || node.connected || node.childVisible)
|
||||
{
|
||||
setNodeVisibilityRecursiveTopDown(node, false);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
|
||||
void setActiveAndVisibility(const std::vector<Id>& activeTokenIds);
|
||||
void setNodeActiveRecursive(DummyNode& node, const std::vector<Id>& activeTokenIds) const;
|
||||
bool setNodeVisibilityRecursiveBottomUp(DummyNode& node, bool aggregated) const;
|
||||
bool setNodeVisibilityRecursiveBottomUp(DummyNode& node) const;
|
||||
void setNodeVisibilityRecursiveTopDown(DummyNode& node, bool parentExpanded) const;
|
||||
|
||||
void splitNamespaceNodes();
|
||||
|
||||
@@ -20,7 +20,6 @@ public:
|
||||
, data(nullptr)
|
||||
, active(false)
|
||||
, connected(false)
|
||||
, aggregated(false)
|
||||
, expanded(false)
|
||||
, hasNamespace(false)
|
||||
, accessType(TokenComponentAccess::ACCESS_NONE)
|
||||
@@ -117,7 +116,6 @@ public:
|
||||
const Node* data;
|
||||
bool active;
|
||||
bool connected;
|
||||
bool aggregated;
|
||||
bool expanded;
|
||||
bool hasNamespace;
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(Edge::EdgeType typ
|
||||
{
|
||||
case Edge::EDGE_AGGREGATION:
|
||||
style.isStraight = true;
|
||||
style.width = 1;
|
||||
style.width = 4;
|
||||
style.zValue = isActive ? -2 : -5;
|
||||
break;
|
||||
case Edge::EDGE_CALL:
|
||||
|
||||
+39
-35
@@ -398,7 +398,8 @@ Id Storage::onTemplateArgumentTypeParsed(
|
||||
}
|
||||
|
||||
Id Storage::onTemplateDefaultArgumentTypeParsed(
|
||||
const ParseTypeUsage& defaultArgumentTypeUsage, const NameHierarchy& templateArgumentTypeNameHierarchy // actually this is the template parameter???
|
||||
const ParseTypeUsage& defaultArgumentTypeUsage,
|
||||
const NameHierarchy& templateArgumentTypeNameHierarchy // actually this is the template parameter???
|
||||
){
|
||||
Id defaultArgumentNodeId = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, defaultArgumentTypeUsage.dataType->getTypeNameHierarchy());
|
||||
// TODO add location for defarg
|
||||
@@ -601,15 +602,8 @@ std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>&
|
||||
std::vector<StorageEdge> edges = m_sqliteStorage.getEdgesBySourceId(node.id);
|
||||
utility::append(edges, m_sqliteStorage.getEdgesByTargetId(node.id));
|
||||
|
||||
const Node::NodeTypeMask nodeTypeMask = Node::NODE_STRUCT | Node::NODE_CLASS;
|
||||
const Edge::EdgeTypeMask edgeTypeMask = Edge::EDGE_TYPE_USAGE | Edge::EDGE_TYPE_OF;
|
||||
|
||||
for (size_t i = 0; i < edges.size(); i++)
|
||||
{
|
||||
if ((node.type & nodeTypeMask) > 0 && (edges[i].type & edgeTypeMask) > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
addEdgeAndAllChildrenToGraph(edges[i].id, graph);
|
||||
}
|
||||
|
||||
@@ -640,7 +634,8 @@ std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>&
|
||||
return g;
|
||||
}
|
||||
|
||||
std::vector<Id> Storage::getActiveTokenIdsForId(Id tokenId, Id* declarationId) const // TODO: rename: getActiveElementIdsForId; TODO: make separate function for declarationId
|
||||
// TODO: rename: getActiveElementIdsForId; TODO: make separate function for declarationId
|
||||
std::vector<Id> Storage::getActiveTokenIdsForId(Id tokenId, Id* declarationId) const
|
||||
{
|
||||
std::vector<Id> activeTokenIds;
|
||||
|
||||
@@ -905,7 +900,7 @@ const SearchIndex& Storage::getSearchIndex() const
|
||||
return m_tokenIndex;
|
||||
}
|
||||
|
||||
Id Storage::addNodeHierarchy(Node::NodeType type, NameHierarchy nameHierarchy)
|
||||
Id Storage::addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy)
|
||||
{
|
||||
addNameHierarchyElements(nameHierarchy);
|
||||
|
||||
@@ -913,6 +908,8 @@ Id Storage::addNodeHierarchy(Node::NodeType type, NameHierarchy nameHierarchy)
|
||||
Id parentNodeId = 0;
|
||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
||||
{
|
||||
Node::NodeType type = (i == nameHierarchy.size() - 1 ? nodeType : Node::NODE_UNDEFINED);
|
||||
|
||||
Id nameHierarchyElementId = 0;
|
||||
if (parentNameHierarchyElementId == 0)
|
||||
{
|
||||
@@ -920,7 +917,8 @@ Id Storage::addNodeHierarchy(Node::NodeType type, NameHierarchy nameHierarchy)
|
||||
}
|
||||
else
|
||||
{
|
||||
nameHierarchyElementId = m_sqliteStorage.getNameHierarchyElementIdByName(nameHierarchy[i]->getFullName(), parentNameHierarchyElementId);
|
||||
nameHierarchyElementId =
|
||||
m_sqliteStorage.getNameHierarchyElementIdByName(nameHierarchy[i]->getFullName(), parentNameHierarchyElementId);
|
||||
}
|
||||
|
||||
const StorageNode node = m_sqliteStorage.getNodeByNameId(nameHierarchyElementId);
|
||||
@@ -1069,13 +1067,20 @@ std::vector<Id> Storage::getDirectChildNodeIds(const Id nodeId) const
|
||||
std::vector<Id> Storage::getAllChildNodeIds(const Id nodeId) const
|
||||
{
|
||||
std::vector<Id> childNodeIds;
|
||||
std::queue<Id> parents;
|
||||
|
||||
std::vector<Id> directChildNodeIds = getDirectChildNodeIds(nodeId);
|
||||
for (size_t i = 0; i < directChildNodeIds.size(); i++)
|
||||
parents.push(nodeId);
|
||||
while (parents.size())
|
||||
{
|
||||
Id id = directChildNodeIds[i];
|
||||
childNodeIds.push_back(id);
|
||||
utility::append(directChildNodeIds, getAllChildNodeIds(id));
|
||||
Id parentId = parents.front();
|
||||
parents.pop();
|
||||
|
||||
std::vector<Id> childs = getDirectChildNodeIds(parentId);
|
||||
for (Id childId : childs)
|
||||
{
|
||||
childNodeIds.push_back(childId);
|
||||
parents.push(childId);
|
||||
}
|
||||
}
|
||||
|
||||
return childNodeIds;
|
||||
@@ -1094,11 +1099,12 @@ void Storage::addEdgeAndAllChildrenToGraph(const Id edgeId, Graph* graph) const
|
||||
graph->createEdge(edgeId, Edge::intToType(storageEdge.type), sourceNode, targetNode);
|
||||
}
|
||||
|
||||
void Storage::addNodeAndAllChildrenToGraph(const Id nodeId, Graph* graph) const
|
||||
Node* Storage::addNodeAndAllChildrenToGraph(const Id nodeId, Graph* graph) const
|
||||
{
|
||||
Node* node = nullptr;
|
||||
if (!graph->getNodeById(nodeId))
|
||||
{
|
||||
addNodeToGraph(nodeId, graph);
|
||||
node = addNodeToGraph(nodeId, graph);
|
||||
}
|
||||
|
||||
std::queue<StorageEdge> unprocessedEdges;
|
||||
@@ -1137,6 +1143,8 @@ void Storage::addNodeAndAllChildrenToGraph(const Id nodeId, Graph* graph) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void Storage::addAggregationEdgesToGraph(const Id nodeId, Graph* graph) const
|
||||
@@ -1195,32 +1203,24 @@ void Storage::addAggregationEdgesToGraph(const Id nodeId, Graph* graph) const
|
||||
if (currentNodeId == nodeId)
|
||||
{
|
||||
needsAdd = false;
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
std::vector<StorageEdge> memberEdges = m_sqliteStorage.getEdgesByTargetType(currentNodeId, Edge::EDGE_MEMBER);
|
||||
|
||||
if (memberEdges.size() > 0)
|
||||
if (memberEdges.size() == 1)
|
||||
{
|
||||
if (m_sqliteStorage.getNodeById(memberEdges[0].sourceNodeId).type != Node::NodeType::NODE_NAMESPACE)
|
||||
Node::NodeType type = Node::intToType(m_sqliteStorage.getNodeById(memberEdges[0].sourceNodeId).type);
|
||||
|
||||
if (type != Node::NODE_UNDEFINED && type != Node::NODE_NAMESPACE)
|
||||
{
|
||||
parentNodeId = memberEdges[0].sourceNodeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int type = m_sqliteStorage.getNodeById(currentNodeId).type;
|
||||
Node::NodeTypeMask mask =
|
||||
Node::NODE_UNDEFINED |
|
||||
Node::NODE_UNDEFINED_FUNCTION |
|
||||
Node::NODE_UNDEFINED_TYPE |
|
||||
Node::NODE_UNDEFINED_VARIABLE;
|
||||
|
||||
Node::NodeTypeMask mask2 = ~mask;
|
||||
|
||||
if (needsAdd && ((type & mask2) > 0))
|
||||
if (needsAdd && currentNodeId)
|
||||
{
|
||||
connectedParentNodeIds[currentNodeId] = it->second;
|
||||
utility::append(connectedParentNodeIds[currentNodeId], it->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1236,7 +1236,11 @@ void Storage::addAggregationEdgesToGraph(const Id nodeId, Graph* graph) const
|
||||
Node* targetNode = graph->getNodeById(aggregationTargetNodeId);
|
||||
if (!targetNode)
|
||||
{
|
||||
targetNode = addNodeToGraph(aggregationTargetNodeId, graph);
|
||||
targetNode = addNodeAndAllChildrenToGraph(getLastParentNodeId(aggregationTargetNodeId), graph);
|
||||
if (targetNode->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE))
|
||||
{
|
||||
targetNode = addNodeToGraph(aggregationTargetNodeId, graph);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenComponentAggregation> componentAggregation = std::make_shared<TokenComponentAggregation>();
|
||||
@@ -1245,7 +1249,7 @@ void Storage::addAggregationEdgesToGraph(const Id nodeId, Graph* graph) const
|
||||
componentAggregation->addAggregationId(edgeInfo.edgeId, edgeInfo.forward);
|
||||
}
|
||||
|
||||
Edge* edge = graph->createEdge(0, Edge::EDGE_AGGREGATION, sourceNode, targetNode);
|
||||
Edge* edge = graph->createEdge(*componentAggregation->getAggregationIds().begin(), Edge::EDGE_AGGREGATION, sourceNode, targetNode);
|
||||
edge->addComponentAggregation(componentAggregation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
const SearchIndex& getSearchIndex() const;
|
||||
|
||||
private:
|
||||
Id addNodeHierarchy(Node::NodeType type, NameHierarchy nameHierarchy);
|
||||
Id addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy);
|
||||
Id addNodeHierarchyWithDistinctSignature(Node::NodeType type, const ParseFunction& function);
|
||||
Id addNameHierarchyElements(NameHierarchy nameHierarchy);
|
||||
int addSourceLocation(int elementNodeId, const ParseLocation& location, bool isScope = false);
|
||||
@@ -150,7 +150,7 @@ private:
|
||||
std::vector<Id> getAllChildNodeIds(const Id nodeId) const;
|
||||
|
||||
void addEdgeAndAllChildrenToGraph(const Id edgeId, Graph* graph) const;
|
||||
void addNodeAndAllChildrenToGraph(const Id nodeId, Graph* graph) const;
|
||||
Node* addNodeAndAllChildrenToGraph(const Id nodeId, Graph* graph) const;
|
||||
void addAggregationEdgesToGraph(const Id nodeId, Graph* graph) const;
|
||||
Node* addNodeToGraph(const Id nodeId, Graph* graph) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user