#include "data/access/StorageAccessProxy.h" #include "utility/logging/logging.h" #include "data/graph/Graph.h" #include "data/location/TokenLocationCollection.h" #include "data/location/TokenLocationFile.h" StorageAccessProxy::StorageAccessProxy() : m_subject(nullptr) { } StorageAccessProxy::~StorageAccessProxy() { } bool StorageAccessProxy::hasSubject() const { if (m_subject) { return true; } LOG_ERROR("StorageAccessProxy has no subject."); return false; } void StorageAccessProxy::setSubject(StorageAccess* subject) { m_subject = subject; } Id StorageAccessProxy::getIdForNodeWithName(const std::string& name) const { if (hasSubject()) { return m_subject->getIdForNodeWithName(name); } return 0; } Node::NodeType StorageAccessProxy::getNodeTypeForNodeWithId(Id id) const { if(hasSubject()) { return m_subject->getNodeTypeForNodeWithId(id); } return Node::NODE_UNDEFINED; } std::string StorageAccessProxy::getNameForNodeWithId(Id id) const { if (hasSubject()) { return m_subject->getNameForNodeWithId(id); } return ""; } std::vector StorageAccessProxy::getAutocompletionMatches( const std::string& query, const std::string& word ) const { if (hasSubject()) { return m_subject->getAutocompletionMatches(query, word); } return std::vector(); } std::shared_ptr StorageAccessProxy::getGraphForActiveTokenIds(const std::vector& tokenIds) const { if (hasSubject()) { return m_subject->getGraphForActiveTokenIds(tokenIds); } return std::make_shared(); } std::vector StorageAccessProxy::getActiveTokenIdsForId(Id tokenId, Id* delcarationId) const { if (hasSubject()) { return m_subject->getActiveTokenIdsForId(tokenId, delcarationId); } return std::vector(); } std::vector StorageAccessProxy::getActiveTokenIdsForLocationId(Id locationId) const { if (hasSubject()) { return m_subject->getActiveTokenIdsForLocationId(locationId); } return std::vector(); } std::vector StorageAccessProxy::getTokenIdsForQuery(std::string query) const { if (hasSubject()) { return m_subject->getTokenIdsForQuery(query); } return std::vector(); } Id StorageAccessProxy::getTokenIdForFileNode(const FilePath& filePath) const { if (hasSubject()) { return m_subject->getTokenIdForFileNode(filePath); } return 0; } TokenLocationCollection StorageAccessProxy::getTokenLocationsForTokenIds(const std::vector& tokenIds) const { if (hasSubject()) { return m_subject->getTokenLocationsForTokenIds(tokenIds); } return TokenLocationCollection(); } std::shared_ptr StorageAccessProxy::getTokenLocationsForFile(const std::string& filePath) const { if (hasSubject()) { return m_subject->getTokenLocationsForFile(filePath); } return std::make_shared(""); } std::shared_ptr StorageAccessProxy::getTokenLocationsForLinesInFile( const std::string& filePath, uint firstLineNumber, uint lastLineNumber ) const { if (hasSubject()) { return m_subject->getTokenLocationsForLinesInFile(filePath, firstLineNumber, lastLineNumber); } return std::make_shared(""); } TokenLocationCollection StorageAccessProxy::getErrorTokenLocations(std::vector* errorMessages) const { if (hasSubject()) { return m_subject->getErrorTokenLocations(errorMessages); } return TokenLocationCollection(); } std::shared_ptr StorageAccessProxy::getTokenLocationOfParentScope(const TokenLocation* child) const { if (hasSubject()) { return m_subject->getTokenLocationOfParentScope(child); } return std::make_shared(""); }