data: refactored file clearing on reparse to use TaskClearStorage
This commit is contained in:
@@ -151,7 +151,12 @@ void QtGraphEdge::onClick()
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageActivateEdge(getData()->getId(), getData()->getType(), getData()->getName()).dispatch();
|
||||
MessageActivateEdge(
|
||||
getData()->getId(),
|
||||
getData()->getType(),
|
||||
getData()->getFrom()->getNameHierarchy(),
|
||||
getData()->getTo()->getNameHierarchy()
|
||||
).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ void Application::handleMessage(MessageFinishedParsing* message)
|
||||
|
||||
m_isInitialParse = false;
|
||||
|
||||
Id mainId = m_storageCache->getIdForNodeWithName("main");
|
||||
Id mainId = m_storageCache->getIdForNodeWithNameHierarchy(NameHierarchy("main"));
|
||||
|
||||
if (!mainId)
|
||||
{
|
||||
@@ -122,7 +122,7 @@ void Application::handleMessage(MessageFinishedParsing* message)
|
||||
message.addNode(
|
||||
mainId,
|
||||
m_storageCache->getNodeTypeForNodeWithId(mainId),
|
||||
m_storageCache->getNameForNodeWithId(mainId)
|
||||
m_storageCache->getNameHierarchyForNodeWithId(mainId)
|
||||
);
|
||||
message.isFromSystem = true;
|
||||
message.dispatch();
|
||||
|
||||
@@ -188,6 +188,8 @@ add_files(
|
||||
data/StorageCache.cpp
|
||||
data/StorageCache.h
|
||||
data/StorageTypes.h
|
||||
data/TaskCleanStorage.cpp
|
||||
data/TaskCleanStorage.h
|
||||
|
||||
settings/ApplicationSettings.cpp
|
||||
settings/ApplicationSettings.h
|
||||
|
||||
+11
-8
@@ -7,9 +7,11 @@
|
||||
#include "data/access/StorageAccessProxy.h"
|
||||
#include "data/graph/Token.h"
|
||||
#include "data/parser/cxx/TaskParseCxx.h"
|
||||
#include "data/TaskCleanStorage.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/scheduling/TaskGroupSequential.h"
|
||||
|
||||
std::shared_ptr<Project> Project::create(StorageAccessProxy* storageAccessProxy)
|
||||
{
|
||||
@@ -103,27 +105,28 @@ void Project::parseCode()
|
||||
std::set<FilePath> removedFilePaths = m_fileManager.getRemovedFilePaths();
|
||||
|
||||
utility::append(updatedFilePaths, m_storage->getDependingFilePaths(updatedFilePaths));
|
||||
utility::append(removedFilePaths, m_storage->getDependingFilePaths(removedFilePaths));
|
||||
utility::append(updatedFilePaths, m_storage->getDependingFilePaths(removedFilePaths));
|
||||
|
||||
MessageStatus("Clearing updated files").dispatch();
|
||||
m_storage->clearFileElements(updatedFilePaths);
|
||||
std::shared_ptr<TaskGroupSequential> taskGroup = std::make_shared<TaskGroupSequential>();
|
||||
|
||||
MessageStatus("Clearing removed files").dispatch();
|
||||
m_storage->clearFileElements(removedFilePaths);
|
||||
std::set<FilePath> filesToClean;
|
||||
utility::append(filesToClean, removedFilePaths);
|
||||
utility::append(filesToClean, updatedFilePaths);
|
||||
|
||||
MessageStatus("Cleaning up names").dispatch();
|
||||
m_storage->removeUnusedNames();
|
||||
taskGroup->addTask(std::make_shared<TaskCleanStorage>(m_storage.get(), filesToClean));
|
||||
|
||||
std::vector<FilePath> filesToParse;
|
||||
filesToParse.insert(filesToParse.end(), addedFilePaths.begin(), addedFilePaths.end());
|
||||
filesToParse.insert(filesToParse.end(), updatedFilePaths.begin(), updatedFilePaths.end());
|
||||
|
||||
Task::dispatch(std::make_shared<TaskParseCxx>(
|
||||
taskGroup->addTask(std::make_shared<TaskParseCxx>(
|
||||
m_storage.get(),
|
||||
&m_fileManager,
|
||||
getParserArguments(),
|
||||
filesToParse
|
||||
));
|
||||
|
||||
Task::dispatch(taskGroup);
|
||||
}
|
||||
|
||||
void Project::logStats() const
|
||||
|
||||
@@ -270,7 +270,7 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForFile(std:
|
||||
m_storageAccess->getTokenLocationOfParentScope(firstUsedLine->getTokenLocations().begin()->second.get())->forEachStartTokenLocation(
|
||||
[&](TokenLocation* location)
|
||||
{
|
||||
params.title = m_storageAccess->getNameForNodeWithId(location->getTokenId());
|
||||
params.title = m_storageAccess->getNameHierarchyForNodeWithId(location->getTokenId()).getFullName();
|
||||
params.titleId = location->getId();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -19,19 +19,8 @@ void FeatureController::handleMessage(MessageActivateEdge* message)
|
||||
{
|
||||
if (message->type == Edge::EDGE_AGGREGATION)
|
||||
{
|
||||
const std::string sourceStartDelimiter = ":";
|
||||
const std::string sourceEndDelimiter = "->";
|
||||
|
||||
const int sourceStartPosition = message->name.find(sourceStartDelimiter) + sourceStartDelimiter.size();
|
||||
const int sourceEndPosition = message->name.find(sourceEndDelimiter);
|
||||
const int targetStartPosition = sourceEndPosition + sourceEndDelimiter.size();
|
||||
const int targetEndPosition = message->name.size();
|
||||
|
||||
const std::string sourceName = message->name.substr(sourceStartPosition, sourceEndPosition - sourceStartPosition);
|
||||
const std::string targetName = message->name.substr(targetStartPosition, targetEndPosition - targetStartPosition);
|
||||
|
||||
const int sourceId = m_storageAccess->getIdForNodeWithName(sourceName);
|
||||
const int targetId = m_storageAccess->getIdForNodeWithName(targetName);
|
||||
const Id sourceId = m_storageAccess->getIdForNodeWithNameHierarchy(message->fromNameHierarchy);
|
||||
const Id targetId = m_storageAccess->getIdForNodeWithNameHierarchy(message->toNameHierarchy);
|
||||
|
||||
MessageActivateTokens m(m_storageAccess->getTokenIdsForAggregationEdge(sourceId, targetId));
|
||||
m.isAggregation = true;
|
||||
@@ -44,7 +33,7 @@ void FeatureController::handleMessage(MessageActivateEdge* message)
|
||||
|
||||
if (!message->isFresh())
|
||||
{
|
||||
edgeId = m_storageAccess->getIdForEdgeWithName(message->name);
|
||||
edgeId = m_storageAccess->getIdForEdge(message->type, message->fromNameHierarchy, message->toNameHierarchy);
|
||||
}
|
||||
|
||||
if (!edgeId)
|
||||
@@ -80,17 +69,18 @@ void FeatureController::handleMessage(MessageActivateNodes* message)
|
||||
{
|
||||
for (const MessageActivateNodes::ActiveNode& node : message->nodes)
|
||||
{
|
||||
nodeIds.push_back(m_storageAccess->getIdForNodeWithName(node.name));
|
||||
Id nodeId = m_storageAccess->getIdForNodeWithNameHierarchy(node.nameHierarchy);
|
||||
if (nodeId > 0)
|
||||
{
|
||||
nodeIds.push_back(nodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeIds.size())
|
||||
{
|
||||
MessageActivateTokens m(nodeIds);
|
||||
m.isFromSystem = message->isFromSystem;
|
||||
m.undoRedoType = message->undoRedoType;
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
MessageActivateTokens m(nodeIds);
|
||||
m.isFromSystem = message->isFromSystem;
|
||||
m.undoRedoType = message->undoRedoType;
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageActivateTokenLocations* message)
|
||||
@@ -104,7 +94,7 @@ void FeatureController::handleMessage(MessageActivateTokenLocations* message)
|
||||
msg.addNode(
|
||||
nodeId,
|
||||
m_storageAccess->getNodeTypeForNodeWithId(nodeId),
|
||||
m_storageAccess->getNameForNodeWithId(nodeId)
|
||||
m_storageAccess->getNameHierarchyForNodeWithId(nodeId)
|
||||
);
|
||||
}
|
||||
msg.dispatchImmediately();
|
||||
|
||||
@@ -43,6 +43,12 @@ void GraphController::handleMessage(MessageActivateTokens* message)
|
||||
m_activeEdgeIds.clear();
|
||||
}
|
||||
|
||||
if (!m_activeNodeIds.size() && !m_activeEdgeIds.size())
|
||||
{
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
createDummyGraphForTokenIds(utility::concat(m_activeNodeIds, m_activeEdgeIds));
|
||||
|
||||
buildGraph(message);
|
||||
@@ -133,6 +139,18 @@ GraphView* GraphController::getView() const
|
||||
return Controller::getView<GraphView>();
|
||||
}
|
||||
|
||||
void GraphController::clear()
|
||||
{
|
||||
m_dummyNodes.clear();
|
||||
m_dummyEdges.clear();
|
||||
|
||||
m_activeNodeIds.clear();
|
||||
m_activeEdgeIds.clear();
|
||||
|
||||
m_graph.reset();
|
||||
getView()->clear();
|
||||
}
|
||||
|
||||
void GraphController::createDummyGraphForTokenIds(const std::vector<Id>& tokenIds)
|
||||
{
|
||||
GraphView* view = getView();
|
||||
|
||||
@@ -48,6 +48,8 @@ private:
|
||||
|
||||
GraphView* getView() const;
|
||||
|
||||
void clear();
|
||||
|
||||
void createDummyGraphForTokenIds(const std::vector<Id>& tokenIds);
|
||||
DummyNode createDummyNodeTopDown(Node* node);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void SearchController::handleMessage(MessageActivateNodes* message)
|
||||
for (const MessageActivateNodes::ActiveNode& node : message->nodes)
|
||||
{
|
||||
SearchMatch match;
|
||||
match.fullName = node.name;
|
||||
match.fullName = node.nameHierarchy.getFullName();
|
||||
match.nodeType = node.type;
|
||||
match.tokenIds.insert(node.nodeId);
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
@@ -28,7 +28,7 @@ UndoRedoController::Command::Command(std::shared_ptr<MessageBase> message, size_
|
||||
void UndoRedoController::handleMessage(MessageActivateEdge* message)
|
||||
{
|
||||
if (m_lastCommand.message && m_lastCommand.message->getType() == message->getType() &&
|
||||
static_cast<MessageActivateEdge*>(m_lastCommand.message.get())->name == message->name)
|
||||
static_cast<MessageActivateEdge*>(m_lastCommand.message.get())->getFullName() == message->getFullName())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -53,7 +53,8 @@ void UndoRedoController::handleMessage(MessageActivateNodes* message)
|
||||
{
|
||||
if (m_lastCommand.message && m_lastCommand.message->getType() == message->getType() && message->nodes.size() &&
|
||||
static_cast<MessageActivateNodes*>(m_lastCommand.message.get())->nodes.size() == message->nodes.size() &&
|
||||
static_cast<MessageActivateNodes*>(m_lastCommand.message.get())->nodes[0].name == message->nodes[0].name)
|
||||
static_cast<MessageActivateNodes*>(m_lastCommand.message.get())->nodes[0].nameHierarchy.getFullName() ==
|
||||
message->nodes[0].nameHierarchy.getFullName())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
+40
-52
@@ -46,24 +46,6 @@ void Storage::clearCaches()
|
||||
m_hierarchyCache.clear();
|
||||
}
|
||||
|
||||
void Storage::clearFileElements(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
for (const FilePath& filePath: filePaths)
|
||||
{
|
||||
clearFileElements(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
void Storage::clearFileElements(const FilePath& filePath)
|
||||
{
|
||||
Id fileId = m_sqliteStorage.getFileByName(filePath.fileName()).id;
|
||||
if (fileId != 0)
|
||||
{
|
||||
m_sqliteStorage.removeElementsWithLocationInFile(fileId);
|
||||
m_sqliteStorage.removeFile(fileId);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> Storage::getDependingFilePaths(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
@@ -79,15 +61,12 @@ std::set<FilePath> Storage::getDependingFilePaths(const FilePath& filePath)
|
||||
{
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
|
||||
Id fileNodeId = getFileNodeId(filePath);
|
||||
std::vector<StorageEdge> incomingEdges = m_sqliteStorage.getEdgesByTargetType(
|
||||
fileNodeId, Edge::typeToInt(Edge::EDGE_INCLUDE)
|
||||
getFileNodeId(filePath), Edge::typeToInt(Edge::EDGE_INCLUDE)
|
||||
);
|
||||
for (StorageEdge incomingEdge: incomingEdges)
|
||||
for (const StorageEdge& incomingEdge: incomingEdges)
|
||||
{
|
||||
Id dependingFileId = incomingEdge.sourceNodeId;
|
||||
FilePath dependingFilePath = FilePath(m_sqliteStorage.getFileById(dependingFileId).filePath);
|
||||
|
||||
FilePath dependingFilePath = getFileNodePath(incomingEdge.sourceNodeId);
|
||||
dependingFilePaths.insert(dependingFilePath);
|
||||
|
||||
std::set<FilePath> dependingFilePathsSubset = getDependingFilePaths(dependingFilePath);
|
||||
@@ -97,6 +76,16 @@ std::set<FilePath> Storage::getDependingFilePaths(const FilePath& filePath)
|
||||
return dependingFilePaths;
|
||||
}
|
||||
|
||||
void Storage::clearFileElement(const FilePath& filePath)
|
||||
{
|
||||
Id fileId = getFileNodeId(filePath);
|
||||
if (fileId != 0)
|
||||
{
|
||||
m_sqliteStorage.removeElementsWithLocationInFile(fileId);
|
||||
m_sqliteStorage.removeFile(fileId);
|
||||
}
|
||||
}
|
||||
|
||||
void Storage::removeUnusedNames()
|
||||
{
|
||||
m_sqliteStorage.removeUnusedNameHierarchyElements();
|
||||
@@ -688,44 +677,30 @@ Id Storage::onMacroExpandParsed(const ParseLocation &location, const NameHierarc
|
||||
return edgeId;
|
||||
}
|
||||
|
||||
Id Storage::getIdForNodeWithName(const std::string& fullName) const // use name hierarchy here
|
||||
Id Storage::getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const
|
||||
{
|
||||
std::vector<std::string> nameParts = utility::splitToVector(fullName, "::");
|
||||
Id currentId = 0;
|
||||
|
||||
Id parentId = 0;
|
||||
for (size_t i = 0; i < nameParts.size(); i++)
|
||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
||||
{
|
||||
Id currentId = 0;
|
||||
if (parentId == 0)
|
||||
{
|
||||
currentId = m_sqliteStorage.getNameHierarchyElementIdByName(nameParts[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentId = m_sqliteStorage.getNameHierarchyElementIdByName(nameParts[i], parentId);
|
||||
}
|
||||
|
||||
parentId = currentId;
|
||||
Id parentId = currentId;
|
||||
currentId = m_sqliteStorage.getNameHierarchyElementIdByName(nameHierarchy[i]->getFullName(), parentId);
|
||||
|
||||
if (currentId == 0)
|
||||
{
|
||||
currentId = parentId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return m_sqliteStorage.getNodeByNameId(parentId).id;
|
||||
return m_sqliteStorage.getNodeByNameId(currentId).id;
|
||||
}
|
||||
|
||||
Id Storage::getIdForEdgeWithName(const std::string& name) const
|
||||
{
|
||||
Edge::EdgeType type;
|
||||
std::string sourceName;
|
||||
std::string targetName;
|
||||
|
||||
Edge::splitName(name, &type, &sourceName, &targetName);
|
||||
|
||||
int sourceId = getIdForNodeWithName(sourceName);
|
||||
int targetId = getIdForNodeWithName(targetName);
|
||||
Id Storage::getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy
|
||||
) const {
|
||||
int sourceId = getIdForNodeWithNameHierarchy(fromNameHierarchy);
|
||||
int targetId = getIdForNodeWithNameHierarchy(toNameHierarchy);
|
||||
return m_sqliteStorage.getEdgeBySourceTargetType(sourceId, targetId, type).id;
|
||||
}
|
||||
|
||||
@@ -750,10 +725,10 @@ std::vector<FileInfo> Storage::getInfoOnAllFiles() const
|
||||
return fileInfos;
|
||||
}
|
||||
|
||||
std::string Storage::getNameForNodeWithId(Id nodeId) const
|
||||
NameHierarchy Storage::getNameHierarchyForNodeWithId(Id nodeId) const
|
||||
{
|
||||
Id nameHierarchyElementId = m_sqliteStorage.getNameHierarchyElementIdByNodeId(nodeId);
|
||||
return m_sqliteStorage.getNameHierarchyById(nameHierarchyElementId).getFullName();
|
||||
return m_sqliteStorage.getNameHierarchyById(nameHierarchyElementId);
|
||||
// return m_tokenIndex.getNameHierarchyForTokenId(nodeId).getFullName();
|
||||
}
|
||||
|
||||
@@ -1325,6 +1300,19 @@ Id Storage::getFileNodeId(const FilePath& filePath) const
|
||||
return storageFile.id;
|
||||
}
|
||||
|
||||
FilePath Storage::getFileNodePath(Id fileId) const
|
||||
{
|
||||
for (const std::pair<FilePath, Id>& p : m_fileNodeIds)
|
||||
{
|
||||
if (p.second == fileId)
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
}
|
||||
|
||||
return m_sqliteStorage.getFileById(fileId).filePath;
|
||||
}
|
||||
|
||||
Id Storage::getLastVisibleParentNodeId(const Id nodeId) const
|
||||
{
|
||||
return m_hierarchyCache.getLastVisibleParentNodeId(nodeId);
|
||||
|
||||
@@ -26,11 +26,10 @@ public:
|
||||
void clear();
|
||||
void clearCaches();
|
||||
|
||||
void clearFileElements(const std::set<FilePath>& filePaths);
|
||||
void clearFileElements(const FilePath& filePath);
|
||||
std::set<FilePath> getDependingFilePaths(const std::set<FilePath>& filePaths);
|
||||
std::set<FilePath> getDependingFilePaths(const FilePath& filePath);
|
||||
|
||||
void clearFileElement(const FilePath& filePath);
|
||||
void removeUnusedNames();
|
||||
|
||||
void logGraph() const;
|
||||
@@ -123,12 +122,13 @@ public:
|
||||
virtual Id onMacroExpandParsed(const ParseLocation& location, const NameHierarchy& macroNameHierarchy);
|
||||
|
||||
// StorageAccess implementation
|
||||
virtual Id getIdForNodeWithName(const std::string& fullName) const;
|
||||
virtual Id getIdForEdgeWithName(const std::string& name) const;
|
||||
virtual Id getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const;
|
||||
virtual Id getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const;
|
||||
|
||||
virtual std::vector<FileInfo> getInfoOnAllFiles() const;
|
||||
|
||||
virtual std::string getNameForNodeWithId(Id nodeId) const;
|
||||
virtual NameHierarchy getNameHierarchyForNodeWithId(Id nodeId) const;
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id nodeId) const;
|
||||
virtual std::vector<SearchMatch> getAutocompletionMatches(
|
||||
const std::string& query, const std::string& word) const;
|
||||
@@ -168,6 +168,7 @@ private:
|
||||
Id addEdge(Id sourceNodeId, Id targetNodeId, Edge::EdgeType type, ParseLocation location);
|
||||
|
||||
Id getFileNodeId(const FilePath& filePath) const;
|
||||
FilePath getFileNodePath(Id fileId) const;
|
||||
|
||||
Id getLastVisibleParentNodeId(const Id nodeId) const;
|
||||
std::vector<Id> getAllChildNodeIds(const Id nodeId) const;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#include "data/TaskCleanStorage.h"
|
||||
|
||||
#include "data/Storage.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
TaskCleanStorage::TaskCleanStorage(Storage* storage, const std::set<FilePath>& filePaths)
|
||||
: m_storage(storage)
|
||||
, m_fileCount(filePaths.size())
|
||||
{
|
||||
for (const FilePath& p : filePaths)
|
||||
{
|
||||
m_filePaths.push(p);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskCleanStorage::enter()
|
||||
{
|
||||
m_start = utility::durationStart();
|
||||
}
|
||||
|
||||
Task::TaskState TaskCleanStorage::update()
|
||||
{
|
||||
if (!m_filePaths.size())
|
||||
{
|
||||
if (m_fileCount)
|
||||
{
|
||||
MessageStatus("Cleaning up names", false, true).dispatch();
|
||||
m_storage->removeUnusedNames();
|
||||
}
|
||||
|
||||
return Task::STATE_FINISHED;
|
||||
}
|
||||
|
||||
FilePath filePath = m_filePaths.front();
|
||||
m_filePaths.pop();
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "clearing (ESC to quit): [";
|
||||
ss << m_fileCount - m_filePaths.size() - 1 << "/" << m_fileCount << "] ";
|
||||
ss << filePath.str();
|
||||
|
||||
MessageStatus(ss.str(), false, true).dispatch();
|
||||
|
||||
m_storage->clearFileElement(filePath);
|
||||
|
||||
return Task::STATE_RUNNING;
|
||||
}
|
||||
|
||||
void TaskCleanStorage::exit()
|
||||
{
|
||||
// std::cout << "clean duration: " << utility::duration(m_start) << std::endl;
|
||||
}
|
||||
|
||||
void TaskCleanStorage::interrupt()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskCleanStorage::revert()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef TASK_CLEAN_STORAGE_H
|
||||
#define TASK_CLEAN_STORAGE_H
|
||||
|
||||
#include <queue>
|
||||
#include <set>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/scheduling/Task.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
class Storage;
|
||||
|
||||
class TaskCleanStorage
|
||||
: public Task
|
||||
{
|
||||
public:
|
||||
TaskCleanStorage(
|
||||
Storage* storage,
|
||||
const std::set<FilePath>& filePaths
|
||||
);
|
||||
|
||||
virtual void enter();
|
||||
virtual TaskState update();
|
||||
virtual void exit();
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
|
||||
private:
|
||||
Storage* m_storage;
|
||||
std::queue<FilePath> m_filePaths;
|
||||
const size_t m_fileCount;
|
||||
|
||||
utility::TimePoint m_start;
|
||||
};
|
||||
|
||||
#endif // TASK_PARSE_CXX_H
|
||||
@@ -23,12 +23,13 @@ class StorageAccess
|
||||
public:
|
||||
virtual ~StorageAccess();
|
||||
|
||||
virtual Id getIdForNodeWithName(const std::string& name) const = 0;
|
||||
virtual Id getIdForEdgeWithName(const std::string& name) const = 0;
|
||||
virtual Id getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const = 0;
|
||||
virtual Id getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const = 0;
|
||||
|
||||
virtual std::vector<FileInfo> getInfoOnAllFiles() const = 0;
|
||||
|
||||
virtual std::string getNameForNodeWithId(Id id) const = 0;
|
||||
virtual NameHierarchy getNameHierarchyForNodeWithId(Id id) const = 0;
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const = 0;
|
||||
virtual std::vector<SearchMatch> getAutocompletionMatches(
|
||||
const std::string& query, const std::string& word) const = 0;
|
||||
|
||||
@@ -32,21 +32,22 @@ void StorageAccessProxy::setSubject(StorageAccess* subject)
|
||||
m_subject = subject;
|
||||
}
|
||||
|
||||
Id StorageAccessProxy::getIdForNodeWithName(const std::string& name) const
|
||||
Id StorageAccessProxy::getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getIdForNodeWithName(name);
|
||||
return m_subject->getIdForNodeWithNameHierarchy(nameHierarchy);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Id StorageAccessProxy::getIdForEdgeWithName(const std::string& name) const
|
||||
{
|
||||
Id StorageAccessProxy::getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy
|
||||
) const {
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getIdForEdgeWithName(name);
|
||||
return m_subject->getIdForEdge(type, fromNameHierarchy, toNameHierarchy);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -71,14 +72,14 @@ Node::NodeType StorageAccessProxy::getNodeTypeForNodeWithId(Id id) const
|
||||
return Node::NODE_UNDEFINED;
|
||||
}
|
||||
|
||||
std::string StorageAccessProxy::getNameForNodeWithId(Id id) const
|
||||
NameHierarchy StorageAccessProxy::getNameHierarchyForNodeWithId(Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getNameForNodeWithId(id);
|
||||
return m_subject->getNameHierarchyForNodeWithId(id);
|
||||
}
|
||||
|
||||
return "";
|
||||
return NameHierarchy();
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> StorageAccessProxy::getAutocompletionMatches(
|
||||
|
||||
@@ -13,12 +13,13 @@ public:
|
||||
void setSubject(StorageAccess* subject);
|
||||
|
||||
// StorageAccess implementation
|
||||
virtual Id getIdForNodeWithName(const std::string& name) const;
|
||||
virtual Id getIdForEdgeWithName(const std::string& name) const;
|
||||
virtual Id getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) const;
|
||||
virtual Id getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const;
|
||||
|
||||
virtual std::vector<FileInfo> getInfoOnAllFiles() const;
|
||||
|
||||
virtual std::string getNameForNodeWithId(Id id) const;
|
||||
virtual NameHierarchy getNameHierarchyForNodeWithId(Id id) const;
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const;
|
||||
virtual std::vector<SearchMatch> getAutocompletionMatches(
|
||||
const std::string& query, const std::string& word) const;
|
||||
|
||||
@@ -117,24 +117,6 @@ std::string Edge::getName() const
|
||||
return getTypeString() + ":" + getFrom()->getFullName() + "->" + getTo()->getFullName();
|
||||
}
|
||||
|
||||
void Edge::splitName(const std::string& name, EdgeType* type, std::string* fromName, std::string* toName)
|
||||
{
|
||||
EdgeTypeMask mask = 1;
|
||||
std::string typeStr = utility::substrBefore(name, ':');
|
||||
|
||||
while (typeStr != getTypeString(static_cast<EdgeType>(mask)))
|
||||
{
|
||||
mask = mask << 1;
|
||||
}
|
||||
|
||||
*type = static_cast<EdgeType>(mask);
|
||||
|
||||
std::string names = utility::substrAfter(name, ':');
|
||||
|
||||
*fromName = utility::substrBefore(names, '-');
|
||||
*toName = utility::substrAfter(utility::substrAfter(names, '-'), '>');
|
||||
}
|
||||
|
||||
bool Edge::isNode() const
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -54,7 +54,6 @@ public:
|
||||
Node* getTo() const;
|
||||
|
||||
std::string getName() const;
|
||||
static void splitName(const std::string& name, EdgeType* type, std::string* fromName, std::string* toName);
|
||||
|
||||
// Token implementation
|
||||
virtual bool isNode() const;
|
||||
|
||||
@@ -156,6 +156,11 @@ std::string Node::getFullName() const
|
||||
return m_nameHierarchy.getFullName();
|
||||
}
|
||||
|
||||
NameHierarchy Node::getNameHierarchy() const
|
||||
{
|
||||
return m_nameHierarchy;
|
||||
}
|
||||
|
||||
const std::vector<Edge*>& Node::getEdges() const
|
||||
{
|
||||
return m_edges;
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
|
||||
std::string getName() const;
|
||||
std::string getFullName() const;
|
||||
NameHierarchy getNameHierarchy() const;
|
||||
|
||||
const std::vector<Edge*>& getEdges() const;
|
||||
|
||||
|
||||
@@ -5,15 +5,17 @@
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "data/graph/Edge.h"
|
||||
#include "data/name/NameHierarchy.h"
|
||||
|
||||
class MessageActivateEdge
|
||||
: public Message<MessageActivateEdge>
|
||||
{
|
||||
public:
|
||||
MessageActivateEdge(Id tokenId, Edge::EdgeType type, const std::string& name)
|
||||
MessageActivateEdge(Id tokenId, Edge::EdgeType type, const NameHierarchy& fromName, const NameHierarchy& toName)
|
||||
: tokenId(tokenId)
|
||||
, type(type)
|
||||
, name(name)
|
||||
, fromNameHierarchy(fromName)
|
||||
, toNameHierarchy(toName)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -27,9 +29,15 @@ public:
|
||||
return type == Edge::EDGE_AGGREGATION;
|
||||
}
|
||||
|
||||
std::string getFullName() const
|
||||
{
|
||||
return Edge::getTypeString(type) + ":" + fromNameHierarchy.getFullName() + "->" + toNameHierarchy.getFullName();
|
||||
}
|
||||
|
||||
const Id tokenId;
|
||||
const Edge::EdgeType type;
|
||||
const std::string name;
|
||||
const NameHierarchy fromNameHierarchy;
|
||||
const NameHierarchy toNameHierarchy;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ACTIVATE_EDGE_H
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
{
|
||||
Id nodeId;
|
||||
Node::NodeType type;
|
||||
std::string name;
|
||||
NameHierarchy nameHierarchy;
|
||||
};
|
||||
|
||||
MessageActivateNodes()
|
||||
@@ -22,12 +22,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void addNode(Id tokenId, Node::NodeType type, const std::string& name)
|
||||
void addNode(Id tokenId, Node::NodeType type, const NameHierarchy& nameHierarchy)
|
||||
{
|
||||
ActiveNode node;
|
||||
node.nodeId = tokenId;
|
||||
node.type = type;
|
||||
node.name = name;
|
||||
node.nameHierarchy = nameHierarchy;
|
||||
|
||||
nodes.push_back(node);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user