logic: Added namespaces to overview and fixed namespace activation

This commit is contained in:
Eberhard Graether
2016-02-08 03:39:08 +01:00
parent d6c03ffb02
commit 29149f313a
24 changed files with 147 additions and 52 deletions
+15 -4
View File
@@ -903,7 +903,8 @@ std::shared_ptr<Graph> Storage::getGraphForAll() const
std::vector<Id> tokenIds;
for (StorageNode node: m_sqliteStorage.getAllNodes())
{
if (node.defined && !m_hierarchyCache.isChildOfVisibleNodeOrInvisible(node.id))
if (node.defined && (!m_hierarchyCache.isChildOfVisibleNodeOrInvisible(node.id) ||
Node::intToType(node.type) == Node::NODE_NAMESPACE))
{
tokenIds.push_back(node.id);
}
@@ -914,12 +915,12 @@ std::shared_ptr<Graph> Storage::getGraphForAll() const
return graph;
}
std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>& tokenIds) const
std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>& tokenIds, bool activeOnly) const
{
std::shared_ptr<Graph> g = std::make_shared<Graph>();
Graph* graph = g.get();
if (tokenIds.size() == 1)
if (tokenIds.size() == 1 && !activeOnly)
{
const Id elementId = tokenIds[0];
@@ -946,7 +947,7 @@ std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>&
addEdgeAndAllChildrenToGraph(elementId, graph);
}
}
else if (tokenIds.size() > 1)
else if (tokenIds.size() >= 1)
{
for (size_t i = 0; i < tokenIds.size(); i++)
{
@@ -970,6 +971,7 @@ std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>&
std::vector<Id> Storage::getActiveTokenIdsForTokenIds(const std::vector<Id>& tokenIds) const
{
bool different = false;
std::vector<Id> activeIds;
for (Id id : tokenIds)
@@ -977,6 +979,10 @@ std::vector<Id> Storage::getActiveTokenIdsForTokenIds(const std::vector<Id>& tok
if (m_sqliteStorage.isNode(id))
{
m_hierarchyCache.addFirstVisibleChildIdsForNodeId(id, &activeIds);
if (id != activeIds.back())
{
different = true;
}
}
else
{
@@ -984,6 +990,11 @@ std::vector<Id> Storage::getActiveTokenIdsForTokenIds(const std::vector<Id>& tok
}
}
if (!different)
{
return tokenIds;
}
std::set<Id> idSet(activeIds.begin(), activeIds.end());
activeIds.clear();
activeIds.insert(activeIds.end(), idSet.begin(), idSet.end());
+1 -1
View File
@@ -147,7 +147,7 @@ public:
virtual std::vector<SearchMatch> getSearchMatchesForTokenIds(const std::vector<Id>& tokenIds) const;
virtual std::shared_ptr<Graph> getGraphForAll() const;
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(const std::vector<Id>& tokenIds) const;
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(const std::vector<Id>& tokenIds, bool activeOnly) const;
virtual std::vector<Id> getActiveTokenIdsForTokenIds(const std::vector<Id>& tokenIds) const;
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const;
+1 -1
View File
@@ -39,7 +39,7 @@ public:
virtual std::vector<SearchMatch> getSearchMatchesForTokenIds(const std::vector<Id>& tokenIds) const = 0;
virtual std::shared_ptr<Graph> getGraphForAll() const = 0;
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(const std::vector<Id>& tokenIds) const = 0;
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(const std::vector<Id>& tokenIds, bool activeOnly) const = 0;
virtual std::vector<Id> getActiveTokenIdsForTokenIds(const std::vector<Id>& tokenIds) const = 0;
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const = 0;
+2 -2
View File
@@ -123,11 +123,11 @@ std::shared_ptr<Graph> StorageAccessProxy::getGraphForAll() const
return std::make_shared<Graph>();
}
std::shared_ptr<Graph> StorageAccessProxy::getGraphForActiveTokenIds(const std::vector<Id>& tokenIds) const
std::shared_ptr<Graph> StorageAccessProxy::getGraphForActiveTokenIds(const std::vector<Id>& tokenIds, bool activeOnly) const
{
if (hasSubject())
{
return m_subject->getGraphForActiveTokenIds(tokenIds);
return m_subject->getGraphForActiveTokenIds(tokenIds, activeOnly);
}
return std::make_shared<Graph>();
+1 -1
View File
@@ -27,7 +27,7 @@ public:
virtual std::vector<SearchMatch> getSearchMatchesForTokenIds(const std::vector<Id>& tokenIds) const;
virtual std::shared_ptr<Graph> getGraphForAll() const;
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(const std::vector<Id>& tokenIds) const;
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(const std::vector<Id>& tokenIds, bool activeOnly) const;
virtual std::vector<Id> getActiveTokenIdsForTokenIds(const std::vector<Id>& tokenIds) const;
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const;