ui: don't hide implicit children of implicit nodes
This commit is contained in:
@@ -1473,7 +1473,7 @@ void GraphController::addExpandToggleNode(DummyNode* node) const
|
|||||||
|
|
||||||
for (const std::shared_ptr<DummyNode>& subSubNode : subNode->subNodes)
|
for (const std::shared_ptr<DummyNode>& subSubNode : subNode->subNodes)
|
||||||
{
|
{
|
||||||
if (subSubNode->visible && (!subSubNode->isGraphNode() || !subSubNode->data->isImplicit()))
|
if (subSubNode->visible && (!subSubNode->isGraphNode() || !subSubNode->data->isImplicit() || node->data->isImplicit()))
|
||||||
{
|
{
|
||||||
visibleSubNodeCount++;
|
visibleSubNodeCount++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,15 @@ size_t HierarchyCache::HierarchyNode::getNonImplicitChildrenCount() const
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HierarchyCache::HierarchyNode::addChildIds(std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const
|
||||||
|
{
|
||||||
|
for (const HierarchyNode* child : m_children)
|
||||||
|
{
|
||||||
|
nodeIds->push_back(child->getNodeId());
|
||||||
|
edgeIds->push_back(child->getEdgeId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void HierarchyCache::HierarchyNode::addNonImplicitChildIds(std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const
|
void HierarchyCache::HierarchyNode::addNonImplicitChildIds(std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const
|
||||||
{
|
{
|
||||||
for (const HierarchyNode* child : m_children)
|
for (const HierarchyNode* child : m_children)
|
||||||
@@ -136,7 +145,8 @@ void HierarchyCache::clear()
|
|||||||
m_nodes.clear();
|
m_nodes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchyCache::createConnection(Id edgeId, Id fromId, Id toId, bool sourceVisible, bool targetImplicit)
|
void HierarchyCache::createConnection(
|
||||||
|
Id edgeId, Id fromId, Id toId, bool sourceVisible, bool sourceImplicit, bool targetImplicit)
|
||||||
{
|
{
|
||||||
HierarchyNode* from = createNode(fromId);
|
HierarchyNode* from = createNode(fromId);
|
||||||
HierarchyNode* to = createNode(toId);
|
HierarchyNode* to = createNode(toId);
|
||||||
@@ -145,6 +155,7 @@ void HierarchyCache::createConnection(Id edgeId, Id fromId, Id toId, bool source
|
|||||||
to->setParent(from);
|
to->setParent(from);
|
||||||
|
|
||||||
from->setIsVisible(sourceVisible);
|
from->setIsVisible(sourceVisible);
|
||||||
|
from->setIsImplicit(sourceImplicit);
|
||||||
|
|
||||||
to->setEdgeId(edgeId);
|
to->setEdgeId(edgeId);
|
||||||
to->setIsImplicit(targetImplicit);
|
to->setIsImplicit(targetImplicit);
|
||||||
@@ -227,21 +238,35 @@ void HierarchyCache::addAllChildIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HierarchyCache::addFirstNonImplicitChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const
|
void HierarchyCache::addFirstChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const
|
||||||
{
|
{
|
||||||
HierarchyNode* node = getNode(nodeId);
|
HierarchyNode* node = getNode(nodeId);
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
node->addNonImplicitChildIds(nodeIds, edgeIds);
|
if (node->isImplicit())
|
||||||
|
{
|
||||||
|
node->addChildIds(nodeIds, edgeIds);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
node->addNonImplicitChildIds(nodeIds, edgeIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t HierarchyCache::getFirstNonImplicitChildIdsCountForNodeId(Id nodeId) const
|
size_t HierarchyCache::getFirstChildIdsCountForNodeId(Id nodeId) const
|
||||||
{
|
{
|
||||||
HierarchyNode* node = getNode(nodeId);
|
HierarchyNode* node = getNode(nodeId);
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
return node->getNonImplicitChildrenCount();
|
if (node->isImplicit())
|
||||||
|
{
|
||||||
|
return node->getChildrenCount();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return node->getNonImplicitChildrenCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class HierarchyCache
|
|||||||
public:
|
public:
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void createConnection(Id edgeId, Id fromId, Id toId, bool sourceVisible, bool targetImplicit);
|
void createConnection(Id edgeId, Id fromId, Id toId, bool sourceVisible, bool sourceImplicit, bool targetImplicit);
|
||||||
void createInheritance(Id edgeId, Id fromId, Id toId);
|
void createInheritance(Id edgeId, Id fromId, Id toId);
|
||||||
|
|
||||||
Id getLastVisibleParentNodeId(Id nodeId) const;
|
Id getLastVisibleParentNodeId(Id nodeId) const;
|
||||||
@@ -22,9 +22,9 @@ public:
|
|||||||
void addAllVisibleParentIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
void addAllVisibleParentIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
||||||
|
|
||||||
void addAllChildIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
void addAllChildIdsForNodeId(Id nodeId, std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
||||||
void addFirstNonImplicitChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const;
|
void addFirstChildIdsForNodeId(Id nodeId, std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const;
|
||||||
|
|
||||||
size_t getFirstNonImplicitChildIdsCountForNodeId(Id nodeId) const;
|
size_t getFirstChildIdsCountForNodeId(Id nodeId) const;
|
||||||
|
|
||||||
bool isChildOfVisibleNodeOrInvisible(Id nodeId) const;
|
bool isChildOfVisibleNodeOrInvisible(Id nodeId) const;
|
||||||
|
|
||||||
@@ -55,6 +55,7 @@ private:
|
|||||||
size_t getChildrenCount() const;
|
size_t getChildrenCount() const;
|
||||||
size_t getNonImplicitChildrenCount() const;
|
size_t getNonImplicitChildrenCount() const;
|
||||||
|
|
||||||
|
void addChildIds(std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const;
|
||||||
void addNonImplicitChildIds(std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const;
|
void addNonImplicitChildIds(std::vector<Id>* nodeIds, std::vector<Id>* edgeIds) const;
|
||||||
void addChildIdsRecursive(std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
void addChildIdsRecursive(std::set<Id>* nodeIds, std::set<Id>* edgeIds) const;
|
||||||
|
|
||||||
|
|||||||
@@ -918,7 +918,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(
|
|||||||
if (nodeType & (Node::NODE_NAMESPACE | Node::NODE_PACKAGE))
|
if (nodeType & (Node::NODE_NAMESPACE | Node::NODE_PACKAGE))
|
||||||
{
|
{
|
||||||
ids.clear();
|
ids.clear();
|
||||||
m_hierarchyCache.addFirstNonImplicitChildIdsForNodeId(elementId, &ids, &edgeIds);
|
m_hierarchyCache.addFirstChildIdsForNodeId(elementId, &ids, &edgeIds);
|
||||||
edgeIds.clear();
|
edgeIds.clear();
|
||||||
|
|
||||||
isNamespace = true;
|
isNamespace = true;
|
||||||
@@ -926,7 +926,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
nodeIds.push_back(elementId);
|
nodeIds.push_back(elementId);
|
||||||
m_hierarchyCache.addFirstNonImplicitChildIdsForNodeId(elementId, &nodeIds, &edgeIds);
|
m_hierarchyCache.addFirstChildIdsForNodeId(elementId, &nodeIds, &edgeIds);
|
||||||
edgeIds.clear();
|
edgeIds.clear();
|
||||||
|
|
||||||
std::vector<StorageEdge> edges = m_sqliteIndexStorage.getEdgesBySourceOrTargetId(elementId);
|
std::vector<StorageEdge> edges = m_sqliteIndexStorage.getEdgesBySourceOrTargetId(elementId);
|
||||||
@@ -1019,7 +1019,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForActiveTokenIds(
|
|||||||
{
|
{
|
||||||
if (graph->getNodeById(nodeId))
|
if (graph->getNodeById(nodeId))
|
||||||
{
|
{
|
||||||
m_hierarchyCache.addFirstNonImplicitChildIdsForNodeId(nodeId, &expandedChildIds, &expandedChildEdgeIds);
|
m_hierarchyCache.addFirstChildIdsForNodeId(nodeId, &expandedChildIds, &expandedChildEdgeIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1050,7 +1050,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForChildrenOfNodeId(Id nodeId)
|
|||||||
std::vector<Id> edgeIds;
|
std::vector<Id> edgeIds;
|
||||||
|
|
||||||
nodeIds.push_back(nodeId);
|
nodeIds.push_back(nodeId);
|
||||||
m_hierarchyCache.addFirstNonImplicitChildIdsForNodeId(nodeId, &nodeIds, &edgeIds);
|
m_hierarchyCache.addFirstChildIdsForNodeId(nodeId, &nodeIds, &edgeIds);
|
||||||
|
|
||||||
std::shared_ptr<Graph> graph = std::make_shared<Graph>();
|
std::shared_ptr<Graph> graph = std::make_shared<Graph>();
|
||||||
addNodesToGraph(nodeIds, graph.get(), true);
|
addNodesToGraph(nodeIds, graph.get(), true);
|
||||||
@@ -2171,7 +2171,7 @@ void PersistentStorage::addNodesToGraph(const std::vector<Id>& newNodeIds, Graph
|
|||||||
|
|
||||||
if (addChildCount)
|
if (addChildCount)
|
||||||
{
|
{
|
||||||
node->setChildCount(m_hierarchyCache.getFirstNonImplicitChildIdsCountForNodeId(storageNode.id));
|
node->setChildCount(m_hierarchyCache.getFirstChildIdsCountForNodeId(storageNode.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2637,15 +2637,22 @@ void PersistentStorage::buildHierarchyCache()
|
|||||||
{
|
{
|
||||||
bool sourceIsVisible = !(sourceNodeTypeMap[edge.sourceNodeId] & Node::NODE_NOT_VISIBLE);
|
bool sourceIsVisible = !(sourceNodeTypeMap[edge.sourceNodeId] & Node::NODE_NOT_VISIBLE);
|
||||||
|
|
||||||
|
bool sourceIsImplicit = false;
|
||||||
|
auto it = m_symbolDefinitionKinds.find(edge.sourceNodeId);
|
||||||
|
if (it != m_symbolDefinitionKinds.end())
|
||||||
|
{
|
||||||
|
sourceIsImplicit = (it->second == DEFINITION_IMPLICIT);
|
||||||
|
}
|
||||||
|
|
||||||
bool targetIsImplicit = false;
|
bool targetIsImplicit = false;
|
||||||
auto it = m_symbolDefinitionKinds.find(edge.targetNodeId);
|
it = m_symbolDefinitionKinds.find(edge.targetNodeId);
|
||||||
if (it != m_symbolDefinitionKinds.end())
|
if (it != m_symbolDefinitionKinds.end())
|
||||||
{
|
{
|
||||||
targetIsImplicit = (it->second == DEFINITION_IMPLICIT);
|
targetIsImplicit = (it->second == DEFINITION_IMPLICIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hierarchyCache.createConnection(
|
m_hierarchyCache.createConnection(
|
||||||
edge.id, edge.sourceNodeId, edge.targetNodeId, sourceIsVisible, targetIsImplicit);
|
edge.id, edge.sourceNodeId, edge.targetNodeId, sourceIsVisible, sourceIsImplicit, targetIsImplicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<StorageEdge> inheritanceEdges = m_sqliteIndexStorage.getEdgesByType(Edge::typeToInt(Edge::EDGE_INHERITANCE));
|
std::vector<StorageEdge> inheritanceEdges = m_sqliteIndexStorage.getEdgesByType(Edge::typeToInt(Edge::EDGE_INHERITANCE));
|
||||||
|
|||||||
Reference in New Issue
Block a user