ui: Added custom trail dialog (issue #249)
* open custom trail dialg via button in top of trail controls * search from symbol to symbol or all referenced/referencing of symbol * define search depth with slider * define horizontal/vertical layout * define node and edge types * renamed depth graph to trail in graph ui * added custom trail UI tests fortune cookie message = A happy surprise is waiting for you.
This commit is contained in:
@@ -38,6 +38,8 @@ add_files(
|
||||
component/controller/CodeController.h
|
||||
component/controller/Controller.cpp
|
||||
component/controller/Controller.h
|
||||
component/controller/CustomTrailController.cpp
|
||||
component/controller/CustomTrailController.h
|
||||
component/controller/ErrorController.cpp
|
||||
component/controller/ErrorController.h
|
||||
component/controller/GraphController.cpp
|
||||
@@ -71,6 +73,7 @@ add_files(
|
||||
component/view/CodeView.h
|
||||
component/view/CompositeView.cpp
|
||||
component/view/CompositeView.h
|
||||
component/view/CustomTrailView.h
|
||||
component/view/DialogView.cpp
|
||||
component/view/DialogView.h
|
||||
component/view/ErrorView.cpp
|
||||
@@ -469,6 +472,7 @@ add_files(
|
||||
utility/messaging/filter_types/MessageFilterSearchAutocomplete.h
|
||||
|
||||
utility/messaging/type/activation/MessageActivateLegend.h
|
||||
utility/messaging/type/activation/MessageActivateFullTextSearch.h
|
||||
|
||||
utility/messaging/type/bookmark/MessageBookmarkActivate.h
|
||||
utility/messaging/type/bookmark/MessageBookmarkBrowse.h
|
||||
@@ -479,6 +483,8 @@ add_files(
|
||||
|
||||
utility/messaging/type/code/MessageCodeShowDefinition.h
|
||||
|
||||
utility/messaging/type/custom_trail/MessageCustomTrailShow.h
|
||||
|
||||
utility/messaging/type/error/MessageActivateErrors.h
|
||||
utility/messaging/type/error/MessageErrorCountClear.h
|
||||
utility/messaging/type/error/MessageErrorCountUpdate.h
|
||||
@@ -497,6 +503,9 @@ add_files(
|
||||
utility/messaging/type/indexing/MessageIndexingStarted.h
|
||||
utility/messaging/type/indexing/MessageIndexingStatus.h
|
||||
|
||||
utility/messaging/type/search/MessageSearch.h
|
||||
utility/messaging/type/search/MessageSearchAutocomplete.h
|
||||
|
||||
utility/messaging/type/tab/MessageTabClose.h
|
||||
utility/messaging/type/tab/MessageTabOpen.h
|
||||
utility/messaging/type/tab/MessageTabOpenWith.h
|
||||
@@ -507,7 +516,6 @@ add_files(
|
||||
utility/messaging/type/MessageActivateBase.h
|
||||
utility/messaging/type/MessageActivateEdge.h
|
||||
utility/messaging/type/MessageActivateFile.h
|
||||
utility/messaging/type/MessageActivateFullTextSearch.h
|
||||
utility/messaging/type/MessageActivateLocalSymbols.h
|
||||
utility/messaging/type/MessageActivateNodes.h
|
||||
utility/messaging/type/MessageActivateSourceLocations.h
|
||||
@@ -544,8 +552,6 @@ add_files(
|
||||
utility/messaging/type/MessageScrollCode.h
|
||||
utility/messaging/type/MessageScrollGraph.h
|
||||
utility/messaging/type/MessageScrollToLine.h
|
||||
utility/messaging/type/MessageSearch.h
|
||||
utility/messaging/type/MessageSearchAutocomplete.h
|
||||
utility/messaging/type/MessageShowReference.h
|
||||
utility/messaging/type/MessageShowScope.h
|
||||
utility/messaging/type/MessageShowStatus.h
|
||||
|
||||
@@ -3,27 +3,30 @@
|
||||
#include "Component.h"
|
||||
#include "ActivationController.h"
|
||||
#include "BookmarkController.h"
|
||||
#include "CodeController.h"
|
||||
#include "ErrorController.h"
|
||||
#include "GraphController.h"
|
||||
#include "RefreshController.h"
|
||||
#include "ScreenSearchController.h"
|
||||
#include "SearchController.h"
|
||||
#include "StatusBarController.h"
|
||||
#include "StatusController.h"
|
||||
#include "TabsController.h"
|
||||
#include "TooltipController.h"
|
||||
#include "UndoRedoController.h"
|
||||
#include "BookmarkView.h"
|
||||
#include "CodeController.h"
|
||||
#include "CodeView.h"
|
||||
#include "CustomTrailController.h"
|
||||
#include "CustomTrailView.h"
|
||||
#include "ErrorController.h"
|
||||
#include "ErrorView.h"
|
||||
#include "GraphController.h"
|
||||
#include "GraphView.h"
|
||||
#include "RefreshController.h"
|
||||
#include "RefreshView.h"
|
||||
#include "ScreenSearchController.h"
|
||||
#include "ScreenSearchView.h"
|
||||
#include "SearchController.h"
|
||||
#include "SearchView.h"
|
||||
#include "StatusBarController.h"
|
||||
#include "StatusBarView.h"
|
||||
#include "StatusController.h"
|
||||
#include "StatusView.h"
|
||||
#include "TabsController.h"
|
||||
#include "TabsView.h"
|
||||
#include "TooltipController.h"
|
||||
#include "TooltipView.h"
|
||||
#include "UndoRedoController.h"
|
||||
#include "UndoRedoView.h"
|
||||
#include "ViewFactory.h"
|
||||
|
||||
@@ -66,6 +69,14 @@ std::shared_ptr<Component> ComponentFactory::createCodeComponent(ViewLayout* vie
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createCustomTrailComponent()
|
||||
{
|
||||
std::shared_ptr<CustomTrailView> view = m_viewFactory->createCustomTrailView();
|
||||
std::shared_ptr<CustomTrailController> controller = std::make_shared<CustomTrailController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createErrorComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<ErrorView> view = m_viewFactory->createErrorView(viewLayout);
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
std::shared_ptr<Component> createActivationComponent();
|
||||
std::shared_ptr<Component> createBookmarkComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createCodeComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createCustomTrailComponent();
|
||||
std::shared_ptr<Component> createErrorComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createGraphComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createRefreshComponent(ViewLayout* viewLayout);
|
||||
|
||||
@@ -98,6 +98,9 @@ void ComponentManager::setupMain(ViewLayout* viewLayout, Id appId)
|
||||
|
||||
std::shared_ptr<Component> statusBarComponent = m_componentFactory.createStatusBarComponent(viewLayout);
|
||||
m_components.push_back(statusBarComponent);
|
||||
|
||||
std::shared_ptr<Component> customTrailComponent = m_componentFactory.createCustomTrailComponent();
|
||||
m_components.push_back(customTrailComponent);
|
||||
}
|
||||
|
||||
void ComponentManager::setupTab(ViewLayout* viewLayout, Id tabId, ScreenSearchSender* screenSearchSender)
|
||||
|
||||
@@ -240,6 +240,17 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
MessageStatus(status).dispatch();
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageActivateTrail* message)
|
||||
{
|
||||
if (message->custom)
|
||||
{
|
||||
getView()->clear();
|
||||
Id nodeId = { message->originId ? message->originId : message->targetId };
|
||||
MessageCodeShowDefinition msg(nodeId);
|
||||
handleMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageActivateTrailEdge* message)
|
||||
{
|
||||
TRACE("trail edge activate");
|
||||
@@ -375,6 +386,11 @@ void CodeController::handleMessage(MessageCodeShowDefinition* message)
|
||||
}
|
||||
|
||||
snippets[0].insertSnippet = true;
|
||||
|
||||
if (!m_collection)
|
||||
{
|
||||
m_collection = std::make_shared<SourceLocationCollection>();
|
||||
}
|
||||
m_collection->addSourceLocationCopies(collection.get());
|
||||
|
||||
saveOrRestoreViewMode(message);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "MessageActivateFullTextSearch.h"
|
||||
#include "MessageActivateLocalSymbols.h"
|
||||
#include "MessageActivateTokens.h"
|
||||
#include "MessageActivateTrail.h"
|
||||
#include "MessageActivateTrailEdge.h"
|
||||
#include "MessageChangeFileView.h"
|
||||
#include "MessageDeactivateEdge.h"
|
||||
@@ -43,6 +44,7 @@ class CodeController
|
||||
, public MessageListener<MessageActivateLegend>
|
||||
, public MessageListener<MessageActivateLocalSymbols>
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageActivateTrail>
|
||||
, public MessageListener<MessageActivateTrailEdge>
|
||||
, public MessageListener<MessageChangeFileView>
|
||||
, public MessageListener<MessageCodeShowDefinition>
|
||||
@@ -69,6 +71,7 @@ private:
|
||||
void handleMessage(MessageActivateLegend* message) override;
|
||||
void handleMessage(MessageActivateLocalSymbols* message) override;
|
||||
void handleMessage(MessageActivateTokens* message) override;
|
||||
void handleMessage(MessageActivateTrail* message) override;
|
||||
void handleMessage(MessageActivateTrailEdge* message) override;
|
||||
void handleMessage(MessageChangeFileView* message) override;
|
||||
void handleMessage(MessageCodeShowDefinition* message) override;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "CustomTrailController.h"
|
||||
|
||||
#include "CustomTrailView.h"
|
||||
#include "NodeTypeSet.h"
|
||||
#include "StorageAccess.h"
|
||||
|
||||
CustomTrailController::CustomTrailController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
{
|
||||
}
|
||||
|
||||
void CustomTrailController::clear()
|
||||
{
|
||||
getView()->clearView();
|
||||
getView()->setAvailableNodeAndEdgeTypes(
|
||||
m_storageAccess->getAvailableNodeTypes(), m_storageAccess->getAvailableEdgeTypes()
|
||||
);
|
||||
}
|
||||
|
||||
void CustomTrailController::autocomplete(const std::wstring query, bool from)
|
||||
{
|
||||
NodeTypeSet nodeTypes = NodeTypeSet::all();
|
||||
nodeTypes.remove(NodeType(NodeType::NODE_MODULE));
|
||||
nodeTypes.remove(NodeType(NodeType::NODE_NAMESPACE));
|
||||
nodeTypes.remove(NodeType(NodeType::NODE_PACKAGE));
|
||||
|
||||
getView()->showAutocompletions(m_storageAccess->getAutocompletionMatches(query, nodeTypes, false), from);
|
||||
}
|
||||
|
||||
void CustomTrailController::activateTrail(MessageActivateTrail message)
|
||||
{
|
||||
Id nodeId = message.originId ? message.originId : message.targetId;
|
||||
message.searchMatches = m_storageAccess->getSearchMatchesForTokenIds({ nodeId });
|
||||
message.dispatch();
|
||||
}
|
||||
|
||||
void CustomTrailController::handleMessage(MessageCustomTrailShow* message)
|
||||
{
|
||||
getView()->showView();
|
||||
}
|
||||
|
||||
void CustomTrailController::handleMessage(MessageIndexingFinished* message)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void CustomTrailController::handleMessage(MessageWindowClosed* message)
|
||||
{
|
||||
getView()->hideView();
|
||||
}
|
||||
|
||||
CustomTrailView* CustomTrailController::getView()
|
||||
{
|
||||
return Controller::getView<CustomTrailView>();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef CUSTOM_TRAIL_CONTROLLER_H
|
||||
#define CUSTOM_TRAIL_CONTROLLER_H
|
||||
|
||||
#include "Controller.h"
|
||||
#include "MessageCustomTrailShow.h"
|
||||
#include "MessageListener.h"
|
||||
#include "MessageWindowClosed.h"
|
||||
#include "MessageIndexingFinished.h"
|
||||
#include "MessageActivateTrail.h"
|
||||
|
||||
class CustomTrailView;
|
||||
class StorageAccess;
|
||||
|
||||
class CustomTrailController
|
||||
: public Controller
|
||||
, public MessageListener<MessageCustomTrailShow>
|
||||
, public MessageListener<MessageIndexingFinished>
|
||||
, public MessageListener<MessageWindowClosed>
|
||||
{
|
||||
public:
|
||||
CustomTrailController(StorageAccess* storageAccess);
|
||||
~CustomTrailController() = default;
|
||||
|
||||
// Controller implementation
|
||||
void clear() override;
|
||||
|
||||
void autocomplete(const std::wstring query, bool from);
|
||||
void activateTrail(MessageActivateTrail message);
|
||||
|
||||
private:
|
||||
void handleMessage(MessageCustomTrailShow* message) override;
|
||||
void handleMessage(MessageIndexingFinished* message) override;
|
||||
void handleMessage(MessageWindowClosed* message) override;
|
||||
|
||||
CustomTrailView* getView();
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
};
|
||||
|
||||
#endif // CUSTOM_TRAIL_CONTROLLER_H
|
||||
@@ -215,10 +215,11 @@ void GraphController::handleMessage(MessageActivateTrail* message)
|
||||
m_activeEdgeIds.clear();
|
||||
|
||||
std::shared_ptr<Graph> graph = m_storageAccess->getGraphForTrail(
|
||||
message->originId, message->targetId, message->trailType, message->depth);
|
||||
message->originId, message->targetId, message->nodeTypes, message->edgeTypes, message->nodeNonIndexed, message->depth,
|
||||
true /* !message->custom || (message->originId && message->targetId) */);
|
||||
|
||||
// remove non-indexed files from include graph if indexed file is origin
|
||||
if (message->trailType & Edge::EDGE_INCLUDE)
|
||||
if (!message->custom && message->edgeTypes & Edge::EDGE_INCLUDE)
|
||||
{
|
||||
Node* fileNode = graph->getNodeById(message->originId ? message->originId : message->targetId);
|
||||
if (fileNode && fileNode->isDefined())
|
||||
@@ -262,11 +263,13 @@ void GraphController::handleMessage(MessageActivateTrail* message)
|
||||
m_graph->setTrailMode(message->horizontalLayout ? Graph::TRAIL_HORIZONTAL : Graph::TRAIL_VERTICAL);
|
||||
m_graph->setHasTrailOrigin(message->originId);
|
||||
|
||||
setVisibility(setActive(m_activeNodeIds, true));
|
||||
m_activeNodeIds = { message->originId ? message->originId : message->targetId };
|
||||
setActive(m_activeNodeIds, true);
|
||||
setVisibility(true);
|
||||
|
||||
MessageStatus(L"Layouting depth graph", false, true).dispatch();
|
||||
|
||||
if (message->trailType & Edge::EDGE_INHERITANCE)
|
||||
if (!message->custom && message->edgeTypes & Edge::EDGE_INHERITANCE)
|
||||
{
|
||||
groupTrailNodes(GroupType::INHERITANCE);
|
||||
}
|
||||
@@ -274,6 +277,15 @@ void GraphController::handleMessage(MessageActivateTrail* message)
|
||||
layoutNesting();
|
||||
layoutTrail(message->horizontalLayout, message->originId);
|
||||
|
||||
if (message->originId && message->targetId)
|
||||
{
|
||||
DummyNode* targetNode = getDummyGraphNodeById(message->targetId).get();
|
||||
if (targetNode)
|
||||
{
|
||||
targetNode->active = true;
|
||||
}
|
||||
}
|
||||
|
||||
MessageStatus(L"Displaying depth graph", false, true).dispatch();
|
||||
|
||||
GraphView::GraphParams params;
|
||||
|
||||
@@ -44,6 +44,14 @@ void SearchController::handleMessage(MessageActivateTokens* message)
|
||||
}
|
||||
}
|
||||
|
||||
void SearchController::handleMessage(MessageActivateTrail* message)
|
||||
{
|
||||
if (message->custom)
|
||||
{
|
||||
updateMatches(message);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchController::handleMessage(MessageFind* message)
|
||||
{
|
||||
if (message->findFulltext)
|
||||
@@ -69,7 +77,7 @@ void SearchController::handleMessage(MessageSearchAutocomplete* message)
|
||||
}
|
||||
|
||||
LOG_INFO(L"autocomplete string: \"" + message->query + L"\"");
|
||||
view->setAutocompletionList(m_storageAccess->getAutocompletionMatches(message->query, message->acceptedNodeTypes));
|
||||
view->setAutocompletionList(m_storageAccess->getAutocompletionMatches(message->query, message->acceptedNodeTypes, true));
|
||||
}
|
||||
|
||||
SearchView* SearchController::getView()
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "MessageActivateAll.h"
|
||||
#include "MessageActivateFullTextSearch.h"
|
||||
#include "MessageActivateTokens.h"
|
||||
#include "MessageActivateTrail.h"
|
||||
#include "MessageFind.h"
|
||||
#include "MessageSearchAutocomplete.h"
|
||||
|
||||
@@ -21,6 +22,7 @@ class SearchController
|
||||
, public MessageListener<MessageActivateFullTextSearch>
|
||||
, public MessageListener<MessageActivateLegend>
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageActivateTrail>
|
||||
, public MessageListener<MessageFind>
|
||||
, public MessageListener<MessageSearchAutocomplete>
|
||||
{
|
||||
@@ -36,6 +38,7 @@ private:
|
||||
void handleMessage(MessageActivateFullTextSearch* message) override;
|
||||
void handleMessage(MessageActivateLegend* message) override;
|
||||
void handleMessage(MessageActivateTokens* message) override;
|
||||
void handleMessage(MessageActivateTrail* message) override;
|
||||
void handleMessage(MessageFind* message) override;
|
||||
void handleMessage(MessageSearchAutocomplete* message) override;
|
||||
|
||||
|
||||
@@ -132,7 +132,10 @@ void UndoRedoController::handleMessage(MessageActivateTrail* message)
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(std::make_shared<MessageActivateTrail>(*message), Command::ORDER_ADAPT, true);
|
||||
Command command(
|
||||
std::make_shared<MessageActivateTrail>(*message),
|
||||
message->custom ? Command::ORDER_ACTIVATE : Command::ORDER_ADAPT
|
||||
);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef CUSTOM_TRAIL_VIEW_H
|
||||
#define CUSTOM_TRAIL_VIEW_H
|
||||
|
||||
#include "SearchMatch.h"
|
||||
#include "View.h"
|
||||
|
||||
class CustomTrailView
|
||||
: public View
|
||||
{
|
||||
public:
|
||||
CustomTrailView(ViewLayout*)
|
||||
: View(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
virtual std::string getName() const
|
||||
{
|
||||
return "custom trail";
|
||||
}
|
||||
|
||||
virtual void clearView() = 0;
|
||||
virtual void setAvailableNodeAndEdgeTypes(NodeType::TypeMask nodeTypes, Edge::TypeMask edgeTypes) = 0;
|
||||
|
||||
virtual void showView() = 0;
|
||||
virtual void hideView() = 0;
|
||||
virtual void showAutocompletions(const std::vector<SearchMatch>& autocompletions, bool from) = 0;
|
||||
};
|
||||
|
||||
#endif // CUSTOM_TRAIL_VIEW_H
|
||||
@@ -9,6 +9,7 @@
|
||||
class BookmarkButtonsView;
|
||||
class BookmarkView;
|
||||
class CodeView;
|
||||
class CustomTrailView;
|
||||
class ErrorView;
|
||||
class GraphView;
|
||||
class GraphViewStyleImpl;
|
||||
@@ -38,6 +39,7 @@ public:
|
||||
virtual std::shared_ptr<BookmarkButtonsView> createBookmarkButtonsView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<BookmarkView> createBookmarkView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<CustomTrailView> createCustomTrailView() const = 0;
|
||||
virtual std::shared_ptr<ErrorView> createErrorView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<RefreshView> createRefreshView(ViewLayout* viewLayout) const = 0;
|
||||
|
||||
@@ -139,7 +139,7 @@ std::wstring NodeType::getReadableTypeWString(NodeType::Type type)
|
||||
return std::wstring(str.begin(), str.end());
|
||||
}
|
||||
|
||||
NodeType::Type NodeType::getTypeForReadableTypeString(const std::wstring str)
|
||||
NodeType::Type NodeType::getTypeForReadableTypeString(const std::wstring& str)
|
||||
{
|
||||
for (NodeType::TypeMask mask = 1; mask <= NodeType::NODE_MAX_VALUE; mask *= 2)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
static std::string getReadableTypeString(NodeType::Type type);
|
||||
static std::wstring getReadableTypeWString(NodeType::Type type);
|
||||
static NodeType::Type getTypeForReadableTypeString(const std::wstring str);
|
||||
static NodeType::Type getTypeForReadableTypeString(const std::wstring& str);
|
||||
|
||||
NodeType(Type type);
|
||||
|
||||
|
||||
@@ -168,6 +168,20 @@ std::wstring Edge::getReadableTypeString(EdgeType type)
|
||||
return L"";
|
||||
}
|
||||
|
||||
Edge::EdgeType Edge::getTypeForReadableTypeString(const std::wstring& str)
|
||||
{
|
||||
for (TypeMask mask = 1; mask <= EDGE_MAX_VALUE; mask *= 2)
|
||||
{
|
||||
EdgeType type = intToType(mask);
|
||||
if (getReadableTypeString(type) == str)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return EDGE_UNDEFINED;
|
||||
}
|
||||
|
||||
std::wstring Edge::getReadableTypeString() const
|
||||
{
|
||||
return getReadableTypeString(m_type);
|
||||
|
||||
@@ -31,7 +31,9 @@ public:
|
||||
EDGE_IMPORT = 1 << 12,
|
||||
EDGE_AGGREGATION = 1 << 13,
|
||||
EDGE_MACRO_USAGE = 1 << 14,
|
||||
EDGE_ANNOTATION_USAGE = 1 << 15
|
||||
EDGE_ANNOTATION_USAGE = 1 << 15,
|
||||
|
||||
EDGE_MAX_VALUE = EDGE_ANNOTATION_USAGE
|
||||
};
|
||||
|
||||
static int typeToInt(EdgeType type);
|
||||
@@ -58,6 +60,8 @@ public:
|
||||
|
||||
static std::wstring getUnderscoredTypeString(EdgeType type);
|
||||
static std::wstring getReadableTypeString(EdgeType type);
|
||||
static EdgeType getTypeForReadableTypeString(const std::wstring& str);
|
||||
|
||||
// Logging.
|
||||
virtual std::wstring getReadableTypeString() const override;
|
||||
std::wstring getAsString() const;
|
||||
|
||||
@@ -670,7 +670,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
|
||||
return collection;
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(const std::wstring& query, NodeTypeSet acceptedNodeTypes) const
|
||||
std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(const std::wstring& query, NodeTypeSet acceptedNodeTypes, bool acceptCommands) const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
@@ -692,7 +692,10 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(const std::
|
||||
utility::append(matches, getAutocompletionFileMatches(query, maxResultsCount));
|
||||
}
|
||||
|
||||
utility::append(matches, getAutocompletionCommandMatches(query, acceptedNodeTypes));
|
||||
if (acceptCommands)
|
||||
{
|
||||
utility::append(matches, getAutocompletionCommandMatches(query, acceptedNodeTypes));
|
||||
}
|
||||
|
||||
// Rescore search matches to check if better score is achieved with higher indices
|
||||
std::vector<SearchMatch> rescoredMatches;
|
||||
@@ -1233,19 +1236,37 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForChildrenOfNodeId(Id nodeId)
|
||||
}
|
||||
|
||||
std::shared_ptr<Graph> PersistentStorage::getGraphForTrail(
|
||||
Id originId, Id targetId, Edge::TypeMask trailType, size_t depth) const
|
||||
Id originId, Id targetId, NodeType::TypeMask nodeTypes, Edge::TypeMask edgeTypes, bool nodeNonIndexed,
|
||||
size_t depth, bool directed) const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::set<Id> nodeIds;
|
||||
std::set<Id> edgeIds;
|
||||
|
||||
std::vector<Id> nodeIdsToProcess;
|
||||
nodeIdsToProcess.push_back(originId ? originId : targetId);
|
||||
nodeIds.insert(originId ? originId : targetId);
|
||||
bool forward = originId;
|
||||
size_t currentDepth = 0;
|
||||
|
||||
nodeIds.insert(nodeIdsToProcess.back());
|
||||
std::vector<Id> nodeIdsToProcess = { *nodeIds.begin() };
|
||||
|
||||
struct TrailNode
|
||||
{
|
||||
Id id = 0;
|
||||
std::set<TrailNode*> parents;
|
||||
std::set<Id> edgeIds;
|
||||
};
|
||||
|
||||
bool isTerminatedTrail = originId && targetId;
|
||||
std::map<Id, TrailNode> trailNodes;
|
||||
|
||||
if (isTerminatedTrail)
|
||||
{
|
||||
TrailNode root;
|
||||
root.id = originId;
|
||||
trailNodes.emplace(originId, root);
|
||||
}
|
||||
|
||||
while (nodeIdsToProcess.size() && (!depth || currentDepth < depth))
|
||||
{
|
||||
std::vector<StorageEdge> edges =
|
||||
@@ -1253,7 +1274,7 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForTrail(
|
||||
m_sqliteIndexStorage.getEdgesBySourceIds(nodeIdsToProcess) :
|
||||
m_sqliteIndexStorage.getEdgesByTargetIds(nodeIdsToProcess);
|
||||
|
||||
if (trailType & Edge::LAYOUT_VERTICAL)
|
||||
if (!directed || edgeTypes & Edge::LAYOUT_VERTICAL)
|
||||
{
|
||||
utility::append(edges,
|
||||
forward ?
|
||||
@@ -1262,33 +1283,165 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForTrail(
|
||||
);
|
||||
}
|
||||
|
||||
nodeIdsToProcess.clear();
|
||||
std::vector<Id> nodeIdsToCheck;
|
||||
std::map<Id, std::vector<StorageEdge>> edgesToInsert;
|
||||
|
||||
for (const StorageEdge& edge : edges)
|
||||
{
|
||||
if (Edge::intToType(edge.type) & trailType)
|
||||
if (Edge::intToType(edge.type) & edgeTypes &&
|
||||
edgeIds.find(edge.id) == edgeIds.end())
|
||||
{
|
||||
bool isForward = forward == !(Edge::intToType(edge.type) & Edge::LAYOUT_VERTICAL);
|
||||
|
||||
const Id nodeId = isForward ? edge.targetNodeId : edge.sourceNodeId;
|
||||
const Id otherNodeId = isForward ? edge.sourceNodeId : edge.targetNodeId;
|
||||
const Id targetNodeId = isForward ? edge.targetNodeId : edge.sourceNodeId;
|
||||
const Id sourceNodeId = isForward ? edge.sourceNodeId : edge.targetNodeId;
|
||||
|
||||
if (nodeIds.find(nodeId) == nodeIds.end())
|
||||
if (nodeIds.find(targetNodeId) == nodeIds.end())
|
||||
{
|
||||
nodeIdsToProcess.push_back(nodeId);
|
||||
nodeIds.insert(nodeId);
|
||||
edgeIds.insert(edge.id);
|
||||
nodeIdsToCheck.push_back(targetNodeId);
|
||||
edgesToInsert[targetNodeId].push_back(edge);
|
||||
}
|
||||
else if (nodeIds.find(otherNodeId) != nodeIds.end())
|
||||
else if (nodeIds.find(sourceNodeId) == nodeIds.end())
|
||||
{
|
||||
if (!directed)
|
||||
{
|
||||
nodeIdsToCheck.push_back(sourceNodeId);
|
||||
edgesToInsert[sourceNodeId].push_back(edge);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeIds.insert(edge.id);
|
||||
|
||||
if (isTerminatedTrail)
|
||||
{
|
||||
TrailNode& target = trailNodes[targetNodeId];
|
||||
TrailNode& origin = trailNodes[sourceNodeId];
|
||||
target.id = targetNodeId;
|
||||
origin.id = sourceNodeId;
|
||||
target.parents.insert(&origin);
|
||||
target.edgeIds.insert(edge.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nodeIdsToProcess.clear();
|
||||
|
||||
if (nodeTypes != 0)
|
||||
{
|
||||
for (const StorageNode& node : m_sqliteIndexStorage.getAllByIds<StorageNode>(nodeIdsToCheck))
|
||||
{
|
||||
NodeType::Type type = NodeType::intToType(node.type);
|
||||
if (type & nodeTypes || (type == NodeType::NODE_SYMBOL && nodeNonIndexed))
|
||||
{
|
||||
if (!nodeNonIndexed)
|
||||
{
|
||||
if (type == NodeType::NODE_FILE)
|
||||
{
|
||||
auto it = m_fileNodeIndexed.find(node.id);
|
||||
if (it == m_fileNodeIndexed.end() || !it->second)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = m_symbolDefinitionKinds.find(node.id);
|
||||
if (it == m_symbolDefinitionKinds.end() || it->second == DEFINITION_NONE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: don't add namespace nodes to the graph, because it destroys trail layouting
|
||||
// Remove when namespaces are proper nodes with children
|
||||
if ((type & (NodeType::NODE_MODULE | NodeType::NODE_NAMESPACE | NodeType::NODE_PACKAGE)) == 0)
|
||||
{
|
||||
nodeIds.insert(node.id);
|
||||
for (const StorageEdge& edge : edgesToInsert[node.id])
|
||||
{
|
||||
if ((Edge::intToType(edge.type) & Edge::EDGE_MEMBER) == 0)
|
||||
{
|
||||
edgeIds.insert(edge.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
nodeIdsToProcess.push_back(node.id);
|
||||
|
||||
if (isTerminatedTrail)
|
||||
{
|
||||
TrailNode& targetNode = trailNodes[node.id];
|
||||
targetNode.id = node.id;
|
||||
|
||||
for (const StorageEdge& edge : edgesToInsert[node.id])
|
||||
{
|
||||
targetNode.edgeIds.insert(edge.id);
|
||||
|
||||
Id sourceNodeId = (edge.targetNodeId == node.id ? edge.sourceNodeId : edge.targetNodeId);
|
||||
TrailNode& oldNode = trailNodes[sourceNodeId];
|
||||
targetNode.parents.insert(&oldNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const Id nodeId : nodeIdsToCheck)
|
||||
{
|
||||
nodeIds.insert(nodeId);
|
||||
nodeIdsToProcess.push_back(nodeId);
|
||||
|
||||
for (const StorageEdge& edge : edgesToInsert[nodeId])
|
||||
{
|
||||
edgeIds.insert(edge.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
edgesToInsert.clear();
|
||||
|
||||
currentDepth++;
|
||||
}
|
||||
|
||||
if (isTerminatedTrail)
|
||||
{
|
||||
nodeIds.clear();
|
||||
edgeIds.clear();
|
||||
|
||||
if (trailNodes.find(targetId) != trailNodes.end())
|
||||
{
|
||||
std::queue<TrailNode*> nodesToProcess;
|
||||
nodesToProcess.push(&trailNodes[targetId]);
|
||||
|
||||
while (nodesToProcess.size())
|
||||
{
|
||||
TrailNode* currentNode = nodesToProcess.front();
|
||||
nodesToProcess.pop();
|
||||
|
||||
if (nodeIds.find(currentNode->id) != nodeIds.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
nodeIds.insert(currentNode->id);
|
||||
edgeIds.insert(currentNode->edgeIds.begin(), currentNode->edgeIds.end());
|
||||
|
||||
for (TrailNode* parent : currentNode->parents)
|
||||
{
|
||||
nodesToProcess.push(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeIds.insert(originId);
|
||||
nodeIds.insert(targetId);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Graph> graph = std::make_shared<Graph>();
|
||||
|
||||
addNodesWithParentsAndEdgesToGraph(utility::toVector(nodeIds), utility::toVector(edgeIds), graph.get(), false);
|
||||
@@ -1298,6 +1451,30 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForTrail(
|
||||
return graph;
|
||||
}
|
||||
|
||||
NodeType::TypeMask PersistentStorage::getAvailableNodeTypes() const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
NodeType::TypeMask mask = 0;
|
||||
for (int type : m_sqliteIndexStorage.getAvailableNodeTypes())
|
||||
{
|
||||
mask |= NodeType::intToType(type);
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
Edge::TypeMask PersistentStorage::getAvailableEdgeTypes() const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
Edge::TypeMask mask = 0;
|
||||
for (int type : m_sqliteIndexStorage.getAvailableEdgeTypes())
|
||||
{
|
||||
mask |= Edge::intToType(type);
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
// TODO: rename: getActiveElementIdsForId; TODO: make separate function for declarationId
|
||||
std::vector<Id> PersistentStorage::getActiveTokenIdsForId(Id tokenId, Id* declarationId) const
|
||||
{
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
std::shared_ptr<SourceLocationCollection> getFullTextSearchLocations(
|
||||
const std::wstring& searchTerm, bool caseSensitive) const override;
|
||||
|
||||
std::vector<SearchMatch> getAutocompletionMatches(const std::wstring& query, NodeTypeSet acceptedNodeTypes) const override;
|
||||
std::vector<SearchMatch> getAutocompletionMatches(const std::wstring& query, NodeTypeSet acceptedNodeTypes, bool acceptCommands) const override;
|
||||
std::vector<SearchMatch> getAutocompletionSymbolMatches(
|
||||
const std::wstring& query, const NodeTypeSet& acceptedNodeTypes, size_t maxResultsCount, size_t maxBestScoredResultsLength) const;
|
||||
std::vector<SearchMatch> getAutocompletionFileMatches(const std::wstring& query, size_t maxResultsCount) const;
|
||||
@@ -116,7 +116,11 @@ public:
|
||||
std::shared_ptr<Graph> getGraphForActiveTokenIds(
|
||||
const std::vector<Id>& tokenIds, const std::vector<Id>& expandedNodeIds, bool* isActiveNamespace = nullptr) const override;
|
||||
std::shared_ptr<Graph> getGraphForChildrenOfNodeId(Id nodeId) const override;
|
||||
std::shared_ptr<Graph> getGraphForTrail(Id originId, Id targetId, Edge::TypeMask trailType, size_t depth) const override;
|
||||
std::shared_ptr<Graph> getGraphForTrail(
|
||||
Id originId, Id targetId, NodeType::TypeMask nodeTypes, Edge::TypeMask trailType, bool nodeNonIndexed, size_t depth, bool directed) const override;
|
||||
|
||||
NodeType::TypeMask getAvailableNodeTypes() const override;
|
||||
Edge::TypeMask getAvailableEdgeTypes() const override;
|
||||
|
||||
std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const override;
|
||||
std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const override;
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
virtual std::shared_ptr<SourceLocationCollection> getFullTextSearchLocations(
|
||||
const std::wstring& searchTerm, bool caseSensitive) const = 0;
|
||||
virtual std::vector<SearchMatch> getAutocompletionMatches(const std::wstring& query, NodeTypeSet acceptedNodeTypes) const = 0;
|
||||
virtual std::vector<SearchMatch> getAutocompletionMatches(const std::wstring& query, NodeTypeSet acceptedNodeTypes, bool acceptCommands) const = 0;
|
||||
virtual std::vector<SearchMatch> getSearchMatchesForTokenIds(const std::vector<Id>& tokenIds) const = 0;
|
||||
|
||||
virtual std::shared_ptr<Graph> getGraphForAll() const = 0;
|
||||
@@ -57,7 +57,10 @@ public:
|
||||
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(
|
||||
const std::vector<Id>& tokenIds, const std::vector<Id>& expandedNodeIds, bool* isActiveNamespace = nullptr) const = 0;
|
||||
virtual std::shared_ptr<Graph> getGraphForChildrenOfNodeId(Id nodeId) const = 0;
|
||||
virtual std::shared_ptr<Graph> getGraphForTrail(Id originId, Id targetId, Edge::TypeMask trailType, size_t depth) const = 0;
|
||||
virtual std::shared_ptr<Graph> getGraphForTrail(Id originId, Id targetId, NodeType::TypeMask nodeTypes, Edge::TypeMask edgeTypes, bool nodeNonIndexed, size_t depth, bool directed) const = 0;
|
||||
|
||||
virtual NodeType::TypeMask getAvailableNodeTypes() const = 0;
|
||||
virtual Edge::TypeMask getAvailableEdgeTypes() const = 0;
|
||||
|
||||
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const = 0;
|
||||
virtual std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const = 0;
|
||||
|
||||
@@ -66,6 +66,35 @@ void StorageAccessProxy::setSubject(std::weak_ptr<StorageAccess> subject)
|
||||
return _DEFAULT_VALUE_; \
|
||||
}
|
||||
|
||||
#define DEF_GETTER_5(_METHOD_NAME_, _PARAM_1_TYPE_, _PARAM_2_TYPE_, _PARAM_3_TYPE_, _PARAM_4_TYPE_, _PARAM_5_TYPE_, _RETURN_TYPE_, _DEFAULT_VALUE_) \
|
||||
UNWRAP(_RETURN_TYPE_) StorageAccessProxy::_METHOD_NAME_(_PARAM_1_TYPE_ p1, _PARAM_2_TYPE_ p2, _PARAM_3_TYPE_ p3, _PARAM_4_TYPE_ p4, _PARAM_5_TYPE_ p5) const \
|
||||
{ \
|
||||
if (std::shared_ptr<StorageAccess> subject = m_subject.lock()) \
|
||||
{ \
|
||||
return subject->_METHOD_NAME_(p1, p2, p3, p4, p5); \
|
||||
} \
|
||||
return _DEFAULT_VALUE_; \
|
||||
}
|
||||
|
||||
#define DEF_GETTER_6(_METHOD_NAME_, _PARAM_1_TYPE_, _PARAM_2_TYPE_, _PARAM_3_TYPE_, _PARAM_4_TYPE_, _PARAM_5_TYPE_, _PARAM_6_TYPE_, _RETURN_TYPE_, _DEFAULT_VALUE_) \
|
||||
UNWRAP(_RETURN_TYPE_) StorageAccessProxy::_METHOD_NAME_(_PARAM_1_TYPE_ p1, _PARAM_2_TYPE_ p2, _PARAM_3_TYPE_ p3, _PARAM_4_TYPE_ p4, _PARAM_5_TYPE_ p5, _PARAM_6_TYPE_ p6) const \
|
||||
{ \
|
||||
if (std::shared_ptr<StorageAccess> subject = m_subject.lock()) \
|
||||
{ \
|
||||
return subject->_METHOD_NAME_(p1, p2, p3, p4, p5, p6); \
|
||||
} \
|
||||
return _DEFAULT_VALUE_; \
|
||||
}
|
||||
|
||||
#define DEF_GETTER_7(_METHOD_NAME_, _PARAM_1_TYPE_, _PARAM_2_TYPE_, _PARAM_3_TYPE_, _PARAM_4_TYPE_, _PARAM_5_TYPE_, _PARAM_6_TYPE_, _PARAM_7_TYPE_, _RETURN_TYPE_, _DEFAULT_VALUE_) \
|
||||
UNWRAP(_RETURN_TYPE_) StorageAccessProxy::_METHOD_NAME_(_PARAM_1_TYPE_ p1, _PARAM_2_TYPE_ p2, _PARAM_3_TYPE_ p3, _PARAM_4_TYPE_ p4, _PARAM_5_TYPE_ p5, _PARAM_6_TYPE_ p6, _PARAM_7_TYPE_ p7) const \
|
||||
{ \
|
||||
if (std::shared_ptr<StorageAccess> subject = m_subject.lock()) \
|
||||
{ \
|
||||
return subject->_METHOD_NAME_(p1, p2, p3, p4, p5, p6, p7); \
|
||||
} \
|
||||
return _DEFAULT_VALUE_; \
|
||||
}
|
||||
|
||||
DEF_GETTER_1(getNodeIdForFileNode, const FilePath&, Id, 0)
|
||||
DEF_GETTER_1(getNodeIdForNameHierarchy, const NameHierarchy&, Id, 0)
|
||||
@@ -79,13 +108,15 @@ DEF_GETTER_1(getNodeIdToParentFileMap, const std::vector<Id>&, NodeIdToParentFil
|
||||
DEF_GETTER_1(getNodeTypeForNodeWithId, Id, NodeType, NodeType(NodeType::NODE_SYMBOL))
|
||||
DEF_GETTER_1(getEdgeById, Id, StorageEdge, StorageEdge())
|
||||
DEF_GETTER_2(getFullTextSearchLocations, const std::wstring &, bool, std::shared_ptr<SourceLocationCollection>, std::make_shared<SourceLocationCollection>())
|
||||
DEF_GETTER_2(getAutocompletionMatches, const std::wstring &, NodeTypeSet, std::vector<SearchMatch>, std::vector<SearchMatch>())
|
||||
DEF_GETTER_3(getAutocompletionMatches, const std::wstring &, NodeTypeSet, bool, std::vector<SearchMatch>, std::vector<SearchMatch>())
|
||||
DEF_GETTER_1(getSearchMatchesForTokenIds, const std::vector<Id>&, std::vector<SearchMatch>, std::vector<SearchMatch>())
|
||||
DEF_GETTER_0(getGraphForAll, std::shared_ptr<Graph>, std::make_shared<Graph>())
|
||||
DEF_GETTER_1(getGraphForNodeTypes, NodeTypeSet, std::shared_ptr<Graph>, std::make_shared<Graph>())
|
||||
DEF_GETTER_3(getGraphForActiveTokenIds, const std::vector<Id>&, const std::vector<Id>&, bool*, std::shared_ptr<Graph>, std::make_shared<Graph>())
|
||||
DEF_GETTER_1(getGraphForChildrenOfNodeId, Id, std::shared_ptr<Graph>, std::make_shared<Graph>())
|
||||
DEF_GETTER_4(getGraphForTrail, Id, Id, Edge::TypeMask, size_t, std::shared_ptr<Graph>, std::make_shared<Graph>())
|
||||
DEF_GETTER_7(getGraphForTrail, Id, Id, NodeType::TypeMask, Edge::TypeMask, bool, size_t, bool, std::shared_ptr<Graph>, std::make_shared<Graph>())
|
||||
DEF_GETTER_0(getAvailableNodeTypes, NodeType::TypeMask, 0);
|
||||
DEF_GETTER_0(getAvailableEdgeTypes, Edge::TypeMask, 0);
|
||||
DEF_GETTER_2(getActiveTokenIdsForId, Id, Id*, std::vector<Id>, {})
|
||||
DEF_GETTER_1(getNodeIdsForLocationIds, const std::vector<Id>&, std::vector<Id>, {})
|
||||
DEF_GETTER_1(getSourceLocationsForTokenIds, const std::vector<Id>&, std::shared_ptr<SourceLocationCollection>, std::make_shared<SourceLocationCollection>())
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
std::shared_ptr<SourceLocationCollection> getFullTextSearchLocations(
|
||||
const std::wstring& searchTerm, bool caseSensitive) const override;
|
||||
std::vector<SearchMatch> getAutocompletionMatches(const std::wstring& query, NodeTypeSet acceptedNodeTypes) const override;
|
||||
std::vector<SearchMatch> getAutocompletionMatches(const std::wstring& query, NodeTypeSet acceptedNodeTypes, bool acceptCommands) const override;
|
||||
std::vector<SearchMatch> getSearchMatchesForTokenIds(const std::vector<Id>& tokenIds) const override;
|
||||
|
||||
std::shared_ptr<Graph> getGraphForAll() const override;
|
||||
@@ -36,7 +36,10 @@ public:
|
||||
std::shared_ptr<Graph> getGraphForActiveTokenIds(
|
||||
const std::vector<Id>& tokenIds, const std::vector<Id>& expandedNodeIds, bool* isActiveNamespace = nullptr) const override;
|
||||
std::shared_ptr<Graph> getGraphForChildrenOfNodeId(Id nodeId) const override;
|
||||
std::shared_ptr<Graph> getGraphForTrail(Id originId, Id targetId, Edge::TypeMask trailType, size_t depth) const override;
|
||||
std::shared_ptr<Graph> getGraphForTrail(Id originId, Id targetId, NodeType::TypeMask nodeTypes, Edge::TypeMask edgeTypes, bool nodeNonIndexed, size_t depth, bool directed) const override;
|
||||
|
||||
NodeType::TypeMask getAvailableNodeTypes() const override;
|
||||
Edge::TypeMask getAvailableEdgeTypes() const override;
|
||||
|
||||
std::vector<Id> getActiveTokenIdsForId(Id tokenId, Id* declarationId) const override;
|
||||
std::vector<Id> getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const override;
|
||||
|
||||
@@ -758,6 +758,46 @@ StorageNode SqliteIndexStorage::getNodeBySerializedName(const std::wstring& seri
|
||||
return StorageNode();
|
||||
}
|
||||
|
||||
std::vector<int> SqliteIndexStorage::getAvailableNodeTypes() const
|
||||
{
|
||||
CppSQLite3Query q = executeQuery("SELECT DISTINCT type FROM node;");
|
||||
|
||||
std::vector<int> types;
|
||||
|
||||
while (!q.eof())
|
||||
{
|
||||
const int type = q.getIntField(0, -1);
|
||||
if (type != -1)
|
||||
{
|
||||
types.push_back(type);
|
||||
}
|
||||
|
||||
q.nextRow();
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
std::vector<int> SqliteIndexStorage::getAvailableEdgeTypes() const
|
||||
{
|
||||
CppSQLite3Query q = executeQuery("SELECT DISTINCT type FROM edge;");
|
||||
|
||||
std::vector<int> types;
|
||||
|
||||
while (!q.eof())
|
||||
{
|
||||
const int type = q.getIntField(0, -1);
|
||||
if (type != -1)
|
||||
{
|
||||
types.push_back(type);
|
||||
}
|
||||
|
||||
q.nextRow();
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
StorageFile SqliteIndexStorage::getFileByPath(const std::wstring& filePath) const
|
||||
{
|
||||
return doGetFirst<StorageFile>("WHERE file.path == '" + utility::encodeToUtf8(filePath) + "'");
|
||||
|
||||
@@ -98,6 +98,9 @@ public:
|
||||
StorageNode getNodeById(Id id) const;
|
||||
StorageNode getNodeBySerializedName(const std::wstring& serializedName) const;
|
||||
|
||||
std::vector<int> getAvailableNodeTypes() const;
|
||||
std::vector<int> getAvailableEdgeTypes() const;
|
||||
|
||||
StorageFile getFileByPath(const std::wstring& filePath) const;
|
||||
|
||||
std::vector<StorageFile> getFilesByPaths(const std::vector<FilePath>& filePaths) const;
|
||||
|
||||
@@ -2,19 +2,48 @@
|
||||
#define MESSAGE_ACTIVATE_TRAIL_H
|
||||
|
||||
#include "Message.h"
|
||||
#include "types.h"
|
||||
#include "MessageActivateBase.h"
|
||||
#include "NodeType.h"
|
||||
#include "TabId.h"
|
||||
#include "types.h"
|
||||
|
||||
class MessageActivateTrail
|
||||
: public Message<MessageActivateTrail>
|
||||
, public MessageActivateBase
|
||||
{
|
||||
public:
|
||||
MessageActivateTrail(Id originId, Id targetId, Edge::TypeMask trailType, size_t depth, bool horizontalLayout)
|
||||
MessageActivateTrail(
|
||||
Id originId, Id targetId, Edge::TypeMask edgeTypes, size_t depth, bool horizontalLayout
|
||||
)
|
||||
: originId(originId)
|
||||
, targetId(targetId)
|
||||
, trailType(trailType)
|
||||
, nodeTypes(0)
|
||||
, edgeTypes(edgeTypes)
|
||||
, nodeNonIndexed(false)
|
||||
, depth(depth)
|
||||
, horizontalLayout(horizontalLayout)
|
||||
, custom(false)
|
||||
{
|
||||
setSchedulerId(TabId::currentTab());
|
||||
}
|
||||
|
||||
MessageActivateTrail(
|
||||
Id originId,
|
||||
Id targetId,
|
||||
NodeType::TypeMask nodeTypes,
|
||||
Edge::TypeMask edgeTypes,
|
||||
bool nodeNonIndexed,
|
||||
size_t depth,
|
||||
bool horizontalLayout
|
||||
)
|
||||
: originId(originId)
|
||||
, targetId(targetId)
|
||||
, nodeTypes(nodeTypes)
|
||||
, edgeTypes(edgeTypes)
|
||||
, nodeNonIndexed(nodeNonIndexed)
|
||||
, depth(depth)
|
||||
, horizontalLayout(horizontalLayout)
|
||||
, custom(true)
|
||||
{
|
||||
setSchedulerId(TabId::currentTab());
|
||||
}
|
||||
@@ -24,11 +53,21 @@ public:
|
||||
return "MessageActivateTrail";
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> getSearchMatches() const override
|
||||
{
|
||||
return searchMatches;
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> searchMatches;
|
||||
|
||||
const Id originId;
|
||||
const Id targetId;
|
||||
const Edge::TypeMask trailType;
|
||||
const NodeType::TypeMask nodeTypes;
|
||||
const Edge::TypeMask edgeTypes;
|
||||
const bool nodeNonIndexed;
|
||||
const size_t depth;
|
||||
const bool horizontalLayout;
|
||||
const bool custom;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ACTIVATE_TRAIL_H
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef MESSAGE_CUSTOM_TRAIL_SHOW_H
|
||||
#define MESSAGE_CUSTOM_TRAIL_SHOW_H
|
||||
|
||||
#include "Message.h"
|
||||
|
||||
class MessageCustomTrailShow
|
||||
: public Message<MessageCustomTrailShow>
|
||||
{
|
||||
public:
|
||||
MessageCustomTrailShow()
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageCustomTrailShow";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_CUSTOM_TRAIL_SHOW_H
|
||||
Reference in New Issue
Block a user