ui/logic/data: refreshing only source files that have been updated
This change adds the refresh component that allows for refreshing the source code via UI or shortcut. If automatic refreshing is activated via the UI, the code is refreshed anytime the window gets focus. The contents of all the updated source files get removed from Storage, before reparsing them. File dependencies are not respected yet.
This commit is contained in:
@@ -114,13 +114,16 @@ void Graph::removeNode(Node* node)
|
||||
return;
|
||||
}
|
||||
|
||||
node->forEachEdgeOfType(Edge::EDGE_MEMBER, [this, node](Edge* e)
|
||||
{
|
||||
if (node == e->getFrom())
|
||||
node->forEachEdgeOfType(
|
||||
Edge::EDGE_MEMBER,
|
||||
[this, node](Edge* e)
|
||||
{
|
||||
this->removeNode(e->getTo());
|
||||
if (node == e->getFrom())
|
||||
{
|
||||
this->removeNode(e->getTo());
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
node->forEachEdge(
|
||||
[this](Edge* e)
|
||||
@@ -131,7 +134,7 @@ void Graph::removeNode(Node* node)
|
||||
|
||||
if (node->getEdges().size())
|
||||
{
|
||||
LOG_ERROR("Node has still edges.");
|
||||
LOG_ERROR("Node still has edges.");
|
||||
}
|
||||
|
||||
m_nodes.erase(it);
|
||||
@@ -154,6 +157,25 @@ void Graph::removeEdge(Edge* edge)
|
||||
m_edges.erase(it);
|
||||
}
|
||||
|
||||
bool Graph::removeNodeIfUnreferencedRecursive(Node* node)
|
||||
{
|
||||
if (!node->hasReferences())
|
||||
{
|
||||
Node* parent = node->getParentNode();
|
||||
|
||||
removeNode(node);
|
||||
|
||||
if (parent)
|
||||
{
|
||||
removeNodeIfUnreferencedRecursive(parent);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Node* Graph::findNode(std::function<bool(Node*)> func) const
|
||||
{
|
||||
std::map<Id, std::shared_ptr<Node>>::const_iterator it = find_if(m_nodes.begin(), m_nodes.end(),
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
|
||||
void removeNode(Node* node);
|
||||
void removeEdge(Edge* edge);
|
||||
bool removeNodeIfUnreferencedRecursive(Node* node);
|
||||
|
||||
Node* findNode(std::function<bool(Node*)> func) const;
|
||||
Edge* findEdge(std::function<bool(Edge*)> func) const;
|
||||
|
||||
@@ -203,6 +203,37 @@ void Node::forEachChildNode(std::function<void(Node*)> func) const
|
||||
);
|
||||
}
|
||||
|
||||
bool Node::hasReferences() const
|
||||
{
|
||||
if (getLocationIds().size() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hasChildrenWithReferences = false;
|
||||
size_t childNodeCount = 0;
|
||||
|
||||
forEachEdgeOfType(
|
||||
Edge::EDGE_MEMBER,
|
||||
[&](Edge* edge)
|
||||
{
|
||||
childNodeCount++;
|
||||
|
||||
if (!hasChildrenWithReferences && edge->getTo() != this && edge->getTo()->hasReferences())
|
||||
{
|
||||
hasChildrenWithReferences = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (hasChildrenWithReferences || getEdges().size() > childNodeCount)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Node::isNode() const
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -68,6 +68,8 @@ public:
|
||||
void forEachEdgeOfType(Edge::EdgeType type, std::function<void(Edge*)> func) const;
|
||||
void forEachChildNode(std::function<void(Node*)> func) const;
|
||||
|
||||
bool hasReferences() const;
|
||||
|
||||
// Token implementation.
|
||||
virtual bool isNode() const;
|
||||
virtual bool isEdge() const;
|
||||
|
||||
Reference in New Issue
Block a user