ui: Added custom tooltipping to code and graph (issue #195)
* Tooltips show node type with access specifier, reference count and fully qualified name * Fields and global variables include the type name * Methods and functinos show whole signature. Gets broken into multiple lines if too long. Included changes: * Upgraded to C++14 * fixed clang warnings * Pass location of .srctrlprj file to build.sh script to load on launch * Split off QtCodeField for showing highlighted and annotated code fom QtCodeArea * removed TokenComponentSignature * added TaskDecoratorDelay bug id = 195
This commit is contained in:
+14
-5
@@ -41,6 +41,8 @@ add_files(
|
||||
component/controller/StatusBarController.h
|
||||
component/controller/StatusController.cpp
|
||||
component/controller/StatusController.h
|
||||
component/controller/TooltipController.cpp
|
||||
component/controller/TooltipController.h
|
||||
component/controller/UndoRedoController.cpp
|
||||
component/controller/UndoRedoController.h
|
||||
|
||||
@@ -75,6 +77,8 @@ add_files(
|
||||
component/view/StatusView.h
|
||||
component/view/TabbedView.cpp
|
||||
component/view/TabbedView.h
|
||||
component/view/TooltipView.cpp
|
||||
component/view/TooltipView.h
|
||||
component/view/UndoRedoView.cpp
|
||||
component/view/UndoRedoView.h
|
||||
component/view/View.cpp
|
||||
@@ -125,8 +129,6 @@ add_files(
|
||||
data/graph/token_component/TokenComponentFilePath.cpp
|
||||
data/graph/token_component/TokenComponentFilePath.h
|
||||
data/graph/token_component/TokenComponentInheritanceChain.h
|
||||
data/graph/token_component/TokenComponentSignature.cpp
|
||||
data/graph/token_component/TokenComponentSignature.h
|
||||
data/graph/token_component/TokenComponentStatic.cpp
|
||||
data/graph/token_component/TokenComponentStatic.h
|
||||
|
||||
@@ -211,13 +213,13 @@ add_files(
|
||||
data/search/SearchIndex.h
|
||||
data/search/SearchMatch.cpp
|
||||
data/search/SearchMatch.h
|
||||
|
||||
|
||||
data/storage/migration/SqliteStorageMigration.cpp
|
||||
data/storage/migration/SqliteStorageMigration.h
|
||||
data/storage/migration/SqliteStorageMigrationLambda.cpp
|
||||
data/storage/migration/SqliteStorageMigrationLambda.h
|
||||
data/storage/migration/SqliteStorageMigrator.h
|
||||
|
||||
|
||||
data/storage/sqlite/SqliteBookmarkStorage.cpp
|
||||
data/storage/sqlite/SqliteBookmarkStorage.h
|
||||
data/storage/sqlite/SqliteDatabaseIndex.cpp
|
||||
@@ -226,7 +228,7 @@ add_files(
|
||||
data/storage/sqlite/SqliteIndexStorage.h
|
||||
data/storage/sqlite/SqliteStorage.cpp
|
||||
data/storage/sqlite/SqliteStorage.h
|
||||
|
||||
|
||||
data/storage/IntermediateStorage.cpp
|
||||
data/storage/IntermediateStorage.h
|
||||
data/storage/PersistentStorage.cpp
|
||||
@@ -240,6 +242,9 @@ add_files(
|
||||
data/storage/StorageTypes.h
|
||||
data/storage/StorageStats.h
|
||||
|
||||
data/tooltip/TooltipInfo.h
|
||||
data/tooltip/TooltipOrigin.h
|
||||
|
||||
data/DefinitionKind.cpp
|
||||
data/DefinitionKind.h
|
||||
data/ErrorCountInfo.h
|
||||
@@ -410,6 +415,8 @@ add_files(
|
||||
utility/messaging/type/MessageStatus.h
|
||||
utility/messaging/type/MessageStatusFilterChanged.h
|
||||
utility/messaging/type/MessageSwitchColorScheme.h
|
||||
utility/messaging/type/MessageTooltipHide.h
|
||||
utility/messaging/type/MessageTooltipShow.h
|
||||
utility/messaging/type/MessageToUndoRedoPosition.h
|
||||
utility/messaging/type/MessageUndo.h
|
||||
utility/messaging/type/MessageWindowClosed.h
|
||||
@@ -438,6 +445,8 @@ add_files(
|
||||
utility/scheduling/TaskDecorator.h
|
||||
utility/scheduling/TaskDecoratorRepeat.cpp
|
||||
utility/scheduling/TaskDecoratorRepeat.h
|
||||
utility/scheduling/TaskDecoratorDelay.cpp
|
||||
utility/scheduling/TaskDecoratorDelay.h
|
||||
utility/scheduling/TaskGroup.cpp
|
||||
utility/scheduling/TaskGroup.h
|
||||
utility/scheduling/TaskGroupParallel.cpp
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "component/controller/SearchController.h"
|
||||
#include "component/controller/StatusBarController.h"
|
||||
#include "component/controller/StatusController.h"
|
||||
#include "component/controller/TooltipController.h"
|
||||
#include "component/controller/UndoRedoController.h"
|
||||
#include "component/view/BookmarkView.h"
|
||||
#include "component/view/CodeView.h"
|
||||
@@ -20,6 +21,7 @@
|
||||
#include "component/view/SearchView.h"
|
||||
#include "component/view/StatusBarView.h"
|
||||
#include "component/view/StatusView.h"
|
||||
#include "component/view/TooltipView.h"
|
||||
#include "component/view/UndoRedoView.h"
|
||||
#include "component/view/ViewFactory.h"
|
||||
|
||||
@@ -56,6 +58,14 @@ std::shared_ptr<Component> ComponentFactory::createActivationComponent()
|
||||
return std::make_shared<Component>(nullptr, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createTooltipComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<TooltipView> view = m_viewFactory->createTooltipView(viewLayout);
|
||||
std::shared_ptr<Controller> controller = std::make_shared<TooltipController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createBookmarkComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<BookmarkView> view = m_viewFactory->createBookmarkView(viewLayout);
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
std::shared_ptr<Component> createSearchComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createStatusBarComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createStatusComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createTooltipComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createUndoRedoComponent(ViewLayout* viewLayout);
|
||||
|
||||
private:
|
||||
|
||||
@@ -51,6 +51,9 @@ void ComponentManager::setup(ViewLayout* viewLayout)
|
||||
std::shared_ptr<Component> activationComponent = m_componentFactory->createActivationComponent();
|
||||
m_components.push_back(activationComponent);
|
||||
|
||||
std::shared_ptr<Component> tooltipComponent = m_componentFactory->createTooltipComponent(viewLayout);
|
||||
m_components.push_back(tooltipComponent);
|
||||
|
||||
m_dialogView = m_componentFactory->getViewFactory()->createDialogView(viewLayout, m_componentFactory->getStorageAccess());
|
||||
|
||||
std::shared_ptr<TabbedView> tabbedView =
|
||||
|
||||
@@ -196,7 +196,10 @@ void IDECommunicationController::handlePing(const NetworkProtocolHelper::PingMes
|
||||
|
||||
void IDECommunicationController::handleMessage(MessageWindowFocus* message)
|
||||
{
|
||||
sendUpdatePing();
|
||||
if (message->focusIn)
|
||||
{
|
||||
sendUpdatePing();
|
||||
}
|
||||
}
|
||||
|
||||
void IDECommunicationController::handleMessage(MessageIDECreateCDB* message)
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
#include "TooltipController.h"
|
||||
|
||||
#include "component/view/CodeView.h"
|
||||
#include "component/view/GraphView.h"
|
||||
#include "component/view/TooltipView.h"
|
||||
#include "data/access/StorageAccess.h"
|
||||
|
||||
#include "utility/scheduling/TaskDecoratorDelay.h"
|
||||
#include "utility/scheduling/TaskLambda.h"
|
||||
|
||||
Id TooltipController::TooltipRequest::s_requestId = 1;
|
||||
|
||||
TooltipController::TooltipController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
, m_hideRequest(false)
|
||||
{
|
||||
}
|
||||
|
||||
TooltipController::~TooltipController()
|
||||
{
|
||||
}
|
||||
|
||||
void TooltipController::clear()
|
||||
{
|
||||
m_showRequest.reset();
|
||||
m_hideRequest = false;
|
||||
getView()->hideTooltip(true);
|
||||
}
|
||||
|
||||
void TooltipController::handleMessage(MessageActivateTokens* message)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void TooltipController::handleMessage(MessageFocusIn* message)
|
||||
{
|
||||
if (!message->tokenIds.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
requestTooltipShow(message->tokenIds, TooltipInfo(), message->origin);
|
||||
}
|
||||
|
||||
void TooltipController::handleMessage(MessageFocusOut* message)
|
||||
{
|
||||
requestTooltipHide();
|
||||
}
|
||||
|
||||
void TooltipController::handleMessage(MessageGraphNodeExpand* message)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void TooltipController::handleMessage(MessageTooltipHide* message)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void TooltipController::handleMessage(MessageTooltipShow* message)
|
||||
{
|
||||
requestTooltipShow(std::vector<Id>(), message->tooltipInfo, message->origin);
|
||||
}
|
||||
|
||||
void TooltipController::handleMessage(MessageWindowFocus* message)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
TooltipView* TooltipController::getView() const
|
||||
{
|
||||
return Controller::getView<TooltipView>();
|
||||
}
|
||||
|
||||
View* TooltipController::getViewForOrigin(TooltipOrigin origin) const
|
||||
{
|
||||
std::string viewName = (origin == TOOLTIP_ORIGIN_CODE ? CodeView::VIEW_NAME : GraphView::VIEW_NAME);
|
||||
return getView()->getViewLayout()->findFloatingView(viewName);
|
||||
}
|
||||
|
||||
void TooltipController::requestTooltipShow(const std::vector<Id> tokenIds, TooltipInfo info, TooltipOrigin origin)
|
||||
{
|
||||
Id requestId = TooltipRequest::s_requestId++;
|
||||
|
||||
m_showRequest = std::make_unique<TooltipRequest>();
|
||||
m_showRequest->requestId = requestId;
|
||||
m_showRequest->tokenIds = tokenIds;
|
||||
m_showRequest->info = info;
|
||||
m_showRequest->origin = origin;
|
||||
|
||||
size_t delayMS = 700;
|
||||
if (getView()->tooltipVisible())
|
||||
{
|
||||
delayMS = 300;
|
||||
}
|
||||
|
||||
Task::dispatch(std::make_shared<TaskDecoratorDelay>(delayMS)->addChildTask(
|
||||
std::make_shared<TaskLambda>(
|
||||
[requestId, this]()
|
||||
{
|
||||
if (m_showRequest && m_showRequest->requestId == requestId)
|
||||
{
|
||||
if (!m_showRequest->info.isValid() && m_showRequest->tokenIds.size())
|
||||
{
|
||||
m_showRequest->info = m_storageAccess->getTooltipInfoForTokenIds(
|
||||
m_showRequest->tokenIds, m_showRequest->origin);
|
||||
}
|
||||
|
||||
TooltipView* view = getView();
|
||||
if (m_showRequest->info.isValid())
|
||||
{
|
||||
view->showTooltip(m_showRequest->info, getViewForOrigin(m_showRequest->origin));
|
||||
|
||||
m_showRequest.reset();
|
||||
m_hideRequest = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
void TooltipController::requestTooltipHide()
|
||||
{
|
||||
m_showRequest.reset();
|
||||
m_hideRequest = true;
|
||||
|
||||
Task::dispatch(std::make_shared<TaskDecoratorDelay>(500)->addChildTask(
|
||||
std::make_shared<TaskLambda>(
|
||||
[this]()
|
||||
{
|
||||
if (m_hideRequest)
|
||||
{
|
||||
m_hideRequest = false;
|
||||
|
||||
getView()->hideTooltip(false);
|
||||
}
|
||||
}
|
||||
)
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#ifndef TOOLTIP_CONTROLLER_H
|
||||
#define TOOLTIP_CONTROLLER_H
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeExpand.h"
|
||||
#include "utility/messaging/type/MessageTooltipHide.h"
|
||||
#include "utility/messaging/type/MessageTooltipShow.h"
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
|
||||
class StorageAccess;
|
||||
class TooltipView;
|
||||
|
||||
class TooltipController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageFocusIn>
|
||||
, public MessageListener<MessageFocusOut>
|
||||
, public MessageListener<MessageGraphNodeExpand>
|
||||
, public MessageListener<MessageTooltipHide>
|
||||
, public MessageListener<MessageTooltipShow>
|
||||
, public MessageListener<MessageWindowFocus>
|
||||
{
|
||||
public:
|
||||
TooltipController(StorageAccess* storageAccess);
|
||||
virtual ~TooltipController();
|
||||
|
||||
// Controller
|
||||
virtual void clear();
|
||||
|
||||
// MessageListener
|
||||
virtual void handleMessage(MessageActivateTokens* message);
|
||||
virtual void handleMessage(MessageFocusIn* message);
|
||||
virtual void handleMessage(MessageFocusOut* message);
|
||||
virtual void handleMessage(MessageGraphNodeExpand* message);
|
||||
virtual void handleMessage(MessageTooltipHide* message);
|
||||
virtual void handleMessage(MessageTooltipShow* message);
|
||||
virtual void handleMessage(MessageWindowFocus* message);
|
||||
|
||||
private:
|
||||
struct TooltipRequest
|
||||
{
|
||||
static Id s_requestId;
|
||||
|
||||
Id requestId;
|
||||
std::vector<Id> tokenIds;
|
||||
|
||||
TooltipInfo info;
|
||||
TooltipOrigin origin;
|
||||
};
|
||||
|
||||
TooltipView* getView() const;
|
||||
View* getViewForOrigin(TooltipOrigin origin) const;
|
||||
|
||||
void requestTooltipShow(const std::vector<Id> tokenIds, TooltipInfo info, TooltipOrigin origin);
|
||||
void requestTooltipHide();
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
|
||||
std::unique_ptr<TooltipRequest> m_showRequest;
|
||||
bool m_hideRequest;
|
||||
};
|
||||
|
||||
#endif // TOOLTIP_CONTROLLER_H
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "component/controller/CodeController.h"
|
||||
|
||||
const char* CodeView::VIEW_NAME = "Code";
|
||||
|
||||
CodeView::CodeView(ViewLayout* viewLayout)
|
||||
: View(viewLayout)
|
||||
{
|
||||
@@ -13,7 +15,7 @@ CodeView::~CodeView()
|
||||
|
||||
std::string CodeView::getName() const
|
||||
{
|
||||
return "Code";
|
||||
return VIEW_NAME;
|
||||
}
|
||||
|
||||
CodeController* CodeView::getController()
|
||||
|
||||
@@ -16,6 +16,8 @@ class CodeView
|
||||
: public View
|
||||
{
|
||||
public:
|
||||
static const char* VIEW_NAME;
|
||||
|
||||
enum FileState
|
||||
{
|
||||
FILE_MINIMIZED,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "component/view/GraphView.h"
|
||||
|
||||
const char* GraphView::VIEW_NAME = "Graph";
|
||||
|
||||
GraphView::GraphView(ViewLayout* viewLayout)
|
||||
: View(viewLayout)
|
||||
{
|
||||
@@ -11,5 +13,5 @@ GraphView::~GraphView()
|
||||
|
||||
std::string GraphView::getName() const
|
||||
{
|
||||
return "Graph";
|
||||
return VIEW_NAME;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ class GraphView
|
||||
: public View
|
||||
{
|
||||
public:
|
||||
static const char* VIEW_NAME;
|
||||
|
||||
struct GraphParams
|
||||
{
|
||||
bool animatedTransition;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "component/view/TooltipView.h"
|
||||
|
||||
TooltipView::TooltipView(ViewLayout* viewLayout)
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
TooltipView::~TooltipView()
|
||||
{
|
||||
}
|
||||
|
||||
std::string TooltipView::getName() const
|
||||
{
|
||||
return "TooltipView";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef TOOLTIP_VIEW_H
|
||||
#define TOOLTIP_VIEW_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "component/view/View.h"
|
||||
#include "data/name/NameHierarchy.h"
|
||||
#include "data/tooltip/TooltipInfo.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class TooltipView
|
||||
: public View
|
||||
{
|
||||
public:
|
||||
TooltipView(ViewLayout* viewLayout);
|
||||
virtual ~TooltipView();
|
||||
|
||||
// View implementation
|
||||
virtual std::string getName() const;
|
||||
|
||||
virtual void showTooltip(TooltipInfo info, const View* parent) = 0;
|
||||
virtual void hideTooltip(bool force) = 0;
|
||||
|
||||
virtual bool tooltipVisible() const = 0;
|
||||
};
|
||||
|
||||
#endif // TOOLTIP_VIEW_H
|
||||
@@ -18,6 +18,7 @@ class StatusBarView;
|
||||
class StatusView;
|
||||
class StorageAccess;
|
||||
class TabbedView;
|
||||
class TooltipView;
|
||||
class UndoRedoView;
|
||||
class ViewLayout;
|
||||
|
||||
@@ -41,6 +42,7 @@ public:
|
||||
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<StatusView> createStatusView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<TooltipView> createTooltipView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<UndoRedoView> createUndoRedoView(ViewLayout* viewLayout) const = 0;
|
||||
|
||||
virtual std::shared_ptr<DialogView> createDialogView(ViewLayout* viewLayout, StorageAccess* storageAccess) const = 0;
|
||||
|
||||
@@ -7,3 +7,8 @@ ViewLayout::ViewLayout()
|
||||
ViewLayout::~ViewLayout()
|
||||
{
|
||||
}
|
||||
|
||||
View* ViewLayout::findFloatingView(const std::string& name) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef VIEW_LAYOUT_H
|
||||
#define VIEW_LAYOUT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class View;
|
||||
|
||||
class ViewLayout
|
||||
@@ -14,6 +16,8 @@ public:
|
||||
|
||||
virtual void showView(View* view) = 0;
|
||||
virtual void hideView(View* view) = 0;
|
||||
|
||||
virtual View* findFloatingView(const std::string& name) const;
|
||||
};
|
||||
|
||||
#endif // VIEW_LAYOUT_H
|
||||
|
||||
@@ -16,14 +16,17 @@
|
||||
#include "data/ErrorFilter.h"
|
||||
#include "data/ErrorInfo.h"
|
||||
#include "data/storage/StorageStats.h"
|
||||
#include "data/tooltip/TooltipInfo.h"
|
||||
#include "data/tooltip/TooltipOrigin.h"
|
||||
|
||||
class FilePath;
|
||||
struct FileInfo;
|
||||
class Graph;
|
||||
class SourceLocationCollection;
|
||||
class SourceLocationFile;
|
||||
class TextAccess;
|
||||
|
||||
struct FileInfo;
|
||||
|
||||
class StorageAccess
|
||||
{
|
||||
public:
|
||||
@@ -34,7 +37,7 @@ public:
|
||||
virtual std::vector<Id> getNodeIdsForNameHierarchies(const std::vector<NameHierarchy> nameHierarchies) const = 0;
|
||||
|
||||
virtual NameHierarchy getNameHierarchyForNodeId(Id id) const = 0;
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const = 0;
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id>& nodeIds) const = 0;
|
||||
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const = 0;
|
||||
|
||||
@@ -79,20 +82,22 @@ public:
|
||||
|
||||
virtual void setErrorFilter(const ErrorFilter& filter);
|
||||
|
||||
virtual Id addNodeBookmark(const NodeBookmark& bookmark) = 0; // todo: remove these from storage access
|
||||
virtual Id addEdgeBookmark(const EdgeBookmark& bookmark) = 0; // todo: remove these from storage access
|
||||
virtual Id addBookmarkCategory(const std::string& categoryName) = 0; // todo: remove these from storage access
|
||||
// todo: remove bookmark related methods from storage access
|
||||
virtual Id addNodeBookmark(const NodeBookmark& bookmark) = 0;
|
||||
virtual Id addEdgeBookmark(const EdgeBookmark& bookmark) = 0;
|
||||
virtual Id addBookmarkCategory(const std::string& categoryName) = 0;
|
||||
|
||||
virtual void updateBookmark(const Id bookmarkId, const std::string& name, const std::string& comment, const std::string& categoryName) = 0; // todo: remove these from storage access
|
||||
|
||||
virtual void removeBookmark(const Id id) = 0; // todo: remove these from storage access
|
||||
virtual void removeBookmarkCategory(const Id id) = 0; // todo: remove these from storage access
|
||||
virtual void updateBookmark(
|
||||
const Id bookmarkId, const std::string& name, const std::string& comment, const std::string& categoryName) = 0;
|
||||
virtual void removeBookmark(const Id id) = 0;
|
||||
virtual void removeBookmarkCategory(const Id id) = 0;
|
||||
|
||||
virtual std::vector<NodeBookmark> getAllNodeBookmarks() const = 0;
|
||||
virtual std::vector<EdgeBookmark> getAllEdgeBookmarks() const = 0;
|
||||
|
||||
virtual std::vector<BookmarkCategory> getAllBookmarkCategories() const = 0;
|
||||
|
||||
virtual TooltipInfo getTooltipInfoForTokenIds(const std::vector<Id>& tokenIds, TooltipOrigin origin) const = 0;
|
||||
|
||||
protected:
|
||||
ErrorFilter m_errorFilter;
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ NameHierarchy StorageAccessProxy::getNameHierarchyForNodeId(Id id) const
|
||||
return NameHierarchy(NAME_DELIMITER_UNKNOWN);
|
||||
}
|
||||
|
||||
std::vector<NameHierarchy> StorageAccessProxy::getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const
|
||||
std::vector<NameHierarchy> StorageAccessProxy::getNameHierarchiesForNodeIds(const std::vector<Id>& nodeIds) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
@@ -415,6 +415,16 @@ std::vector<BookmarkCategory> StorageAccessProxy::getAllBookmarkCategories() con
|
||||
return std::vector<BookmarkCategory>();
|
||||
}
|
||||
|
||||
TooltipInfo StorageAccessProxy::getTooltipInfoForTokenIds(const std::vector<Id>& tokenIds, TooltipOrigin origin) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getTooltipInfoForTokenIds(tokenIds, origin);
|
||||
}
|
||||
|
||||
return TooltipInfo();
|
||||
}
|
||||
|
||||
void StorageAccessProxy::setErrorFilter(const ErrorFilter& filter)
|
||||
{
|
||||
StorageAccess::setErrorFilter(filter);
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
virtual std::vector<Id> getNodeIdsForNameHierarchies(const std::vector<NameHierarchy> nameHierarchies) const;
|
||||
|
||||
virtual NameHierarchy getNameHierarchyForNodeId(Id id) const;
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const;
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id>& nodeIds) const;
|
||||
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const;
|
||||
|
||||
@@ -73,16 +73,17 @@ public:
|
||||
virtual Id addEdgeBookmark(const EdgeBookmark& bookmark);
|
||||
virtual Id addBookmarkCategory(const std::string& categoryName);
|
||||
|
||||
virtual void updateBookmark(const Id bookmarkId, const std::string& name, const std::string& comment, const std::string& categoryName);
|
||||
|
||||
virtual void updateBookmark(
|
||||
const Id bookmarkId, const std::string& name, const std::string& comment, const std::string& categoryName);
|
||||
virtual void removeBookmark(const Id id);
|
||||
virtual void removeBookmarkCategory(const Id id);
|
||||
|
||||
virtual std::vector<NodeBookmark> getAllNodeBookmarks() const;
|
||||
virtual std::vector<EdgeBookmark> getAllEdgeBookmarks() const;
|
||||
|
||||
virtual std::vector<BookmarkCategory> getAllBookmarkCategories() const;
|
||||
|
||||
virtual TooltipInfo getTooltipInfoForTokenIds(const std::vector<Id>& tokenIds, TooltipOrigin origin) const;
|
||||
|
||||
protected:
|
||||
virtual void setErrorFilter(const ErrorFilter& filter);
|
||||
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
#include "data/graph/token_component/TokenComponentConst.h"
|
||||
#include "data/graph/token_component/TokenComponentStatic.h"
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
|
||||
const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_NAMESPACE | Node::NODE_PACKAGE;
|
||||
const Node::NodeTypeMask Node::NODE_USEABLE_TYPE = Node::NODE_NON_INDEXED | Node::NODE_BUILTIN_TYPE |
|
||||
Node::NODE_STRUCT | Node::NODE_CLASS | Node::NODE_INTERFACE | Node::NODE_TYPEDEF;
|
||||
const Node::NodeTypeMask Node::NODE_INHERITABLE_TYPE = Node::NODE_NON_INDEXED | Node::NODE_BUILTIN_TYPE |
|
||||
NODE_TYPE | Node::NODE_STRUCT | Node::NODE_CLASS | Node::NODE_INTERFACE;
|
||||
const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = NODE_NAMESPACE | NODE_PACKAGE;
|
||||
const Node::NodeTypeMask Node::NODE_USEABLE_TYPE = NODE_NON_INDEXED | NODE_BUILTIN_TYPE | NODE_STRUCT | NODE_CLASS |
|
||||
NODE_UNION | NODE_INTERFACE | NODE_TYPEDEF;
|
||||
const Node::NodeTypeMask Node::NODE_INHERITABLE_TYPE = NODE_NON_INDEXED | NODE_BUILTIN_TYPE | NODE_TYPE | NODE_STRUCT |
|
||||
NODE_CLASS | NODE_INTERFACE;
|
||||
const Node::NodeTypeMask Node::NODE_MEMBER_TYPE = NODE_METHOD | NODE_FIELD | NODE_CLASS | NODE_INTERFACE | NODE_STRUCT |
|
||||
NODE_UNION | NODE_TYPEDEF | NODE_ENUM;
|
||||
|
||||
std::string Node::getUnderscoredTypeString(NodeType type)
|
||||
{
|
||||
@@ -469,23 +470,6 @@ void Node::addComponentFilePath(std::shared_ptr<TokenComponentFilePath> componen
|
||||
}
|
||||
}
|
||||
|
||||
void Node::addComponentSignature(std::shared_ptr<TokenComponentSignature> component)
|
||||
{
|
||||
if (getComponent<TokenComponentSignature>())
|
||||
{
|
||||
LOG_ERROR("TokenComponentSignature has been set before!");
|
||||
return;
|
||||
}
|
||||
else if (!isType(NODE_FUNCTION | NODE_METHOD))
|
||||
{
|
||||
LOG_ERROR("TokenComponentFilePath can't be set on node of type: " + getReadableTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
addComponent(component);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::addComponentAccess(std::shared_ptr<TokenComponentAccess> component)
|
||||
{
|
||||
if (getComponent<TokenComponentAccess>())
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
static const NodeTypeMask NODE_NOT_VISIBLE;
|
||||
static const NodeTypeMask NODE_USEABLE_TYPE;
|
||||
static const NodeTypeMask NODE_INHERITABLE_TYPE;
|
||||
static const NodeTypeMask NODE_MEMBER_TYPE;
|
||||
|
||||
Node(Id id, NodeType type, NameHierarchy nameHierarchy, bool defined);
|
||||
Node(const Node& other);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
|
||||
TokenComponentSignature::TokenComponentSignature(const std::string& signature)
|
||||
: m_signature(signature)
|
||||
{
|
||||
}
|
||||
|
||||
TokenComponentSignature::~TokenComponentSignature()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenComponent> TokenComponentSignature::copy() const
|
||||
{
|
||||
return std::make_shared<TokenComponentSignature>(*this);
|
||||
}
|
||||
|
||||
const std::string& TokenComponentSignature::getSignature() const
|
||||
{
|
||||
return m_signature;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef TOKEN_COMPONENT_SIGNATURE_H
|
||||
#define TOKEN_COMPONENT_SIGNATURE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "data/graph/token_component/TokenComponent.h"
|
||||
|
||||
class TokenComponentSignature
|
||||
: public TokenComponent
|
||||
{
|
||||
public:
|
||||
TokenComponentSignature(const std::string& signature);
|
||||
virtual ~TokenComponentSignature();
|
||||
|
||||
virtual std::shared_ptr<TokenComponent> copy() const;
|
||||
|
||||
const std::string& getSignature() const;
|
||||
|
||||
private:
|
||||
const std::string m_signature;
|
||||
};
|
||||
|
||||
#endif // TOKEN_COMPONENT_SIGNATURE_H
|
||||
@@ -61,6 +61,16 @@ bool NameElement::Signature::isValid() const
|
||||
return ((m_prefix + m_postfix).size() > 0);
|
||||
}
|
||||
|
||||
const std::string& NameElement::Signature::getPrefix() const
|
||||
{
|
||||
return m_prefix;
|
||||
}
|
||||
|
||||
const std::string& NameElement::Signature::getPostfix() const
|
||||
{
|
||||
return m_postfix;
|
||||
}
|
||||
|
||||
NameElement::NameElement(const std::string& name)
|
||||
: m_name(name)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,9 @@ public:
|
||||
std::string qualifyName(const std::string& name) const;
|
||||
bool isValid() const;
|
||||
|
||||
const std::string& getPrefix() const;
|
||||
const std::string& getPostfix() const;
|
||||
|
||||
private:
|
||||
std::string m_prefix;
|
||||
std::string m_postfix;
|
||||
|
||||
@@ -161,3 +161,13 @@ std::string NameHierarchy::getRawNameWithSignature() const
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
NameElement::Signature NameHierarchy::getSignature() const
|
||||
{
|
||||
if (m_elements.size())
|
||||
{
|
||||
return m_elements.back()->getSignature(); // todo: use separator for signature!
|
||||
}
|
||||
|
||||
return NameElement::Signature();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ public:
|
||||
std::string getRawName() const;
|
||||
std::string getRawNameWithSignature() const;
|
||||
|
||||
NameElement::Signature getSignature() const;
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<NameElement>> m_elements;
|
||||
NameDelimiterType m_delimiter;
|
||||
|
||||
@@ -25,3 +25,25 @@ int accessKindToInt(AccessKind t)
|
||||
return t;
|
||||
}
|
||||
|
||||
std::string accessKindToString(AccessKind t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case ACCESS_NONE:
|
||||
return "";
|
||||
case ACCESS_PUBLIC:
|
||||
return "public";
|
||||
case ACCESS_PROTECTED:
|
||||
return "protected";
|
||||
case ACCESS_PRIVATE:
|
||||
return "private";
|
||||
case ACCESS_DEFAULT:
|
||||
return "default";
|
||||
case ACCESS_TEMPLATE_PARAMETER:
|
||||
return "template parameter";
|
||||
case ACCESS_TYPE_PARAMETER:
|
||||
return "type parameter";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef ACCESS_KIND_H
|
||||
#define ACCESS_KIND_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum AccessKind
|
||||
{ // these values need to be the same as AccessKind in Java code
|
||||
ACCESS_NONE = 0,
|
||||
@@ -14,5 +16,6 @@ enum AccessKind
|
||||
|
||||
AccessKind intToAccessKind(int v);
|
||||
int accessKindToInt(AccessKind t);
|
||||
std::string accessKindToString(AccessKind t);
|
||||
|
||||
#endif // ACCESS_KIND_H
|
||||
|
||||
@@ -15,14 +15,6 @@ TaskParseWrapper::~TaskParseWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskParseWrapper::setTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
if (task)
|
||||
{
|
||||
m_taskRunner = std::make_shared<TaskRunner>(task);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskParseWrapper::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
int sourceFileCount = 0;
|
||||
@@ -54,8 +46,3 @@ void TaskParseWrapper::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_taskRunner->reset();
|
||||
}
|
||||
|
||||
void TaskParseWrapper::doTerminate()
|
||||
{
|
||||
m_taskRunner->terminate();
|
||||
}
|
||||
|
||||
@@ -19,19 +19,15 @@ public:
|
||||
TaskParseWrapper(PersistentStorage* storage);
|
||||
virtual ~TaskParseWrapper();
|
||||
|
||||
virtual void setTask(std::shared_ptr<Task> task);
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doTerminate();
|
||||
|
||||
PersistentStorage* m_storage;
|
||||
|
||||
TimePoint m_start;
|
||||
std::shared_ptr<TaskRunner> m_taskRunner;
|
||||
};
|
||||
|
||||
#endif // TASK_PARSE_WRAPPER_H
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
#include "data/graph/token_component/TokenComponentAggregation.h"
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
#include "data/graph/token_component/TokenComponentInheritanceChain.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
#include "data/graph/Graph.h"
|
||||
#include "data/location/SourceLocationCollection.h"
|
||||
#include "data/location/SourceLocationFile.h"
|
||||
#include "data/parser/AccessKind.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
PersistentStorage::PersistentStorage(const FilePath& dbPath, const FilePath& bookmarkPath)
|
||||
: m_sqliteIndexStorage(dbPath)
|
||||
@@ -147,182 +147,6 @@ void PersistentStorage::addError(
|
||||
);
|
||||
}
|
||||
|
||||
Id PersistentStorage::addNodeBookmark(const NodeBookmark& bookmark)
|
||||
{
|
||||
const Id categoryId = addBookmarkCategory(bookmark.getCategory().getName());
|
||||
const Id id = m_sqliteBookmarkStorage.addBookmark(
|
||||
bookmark.getName(), bookmark.getComment(), bookmark.getTimeStamp().toString(), categoryId);
|
||||
|
||||
for (const Id& nodeId: bookmark.getNodeIds())
|
||||
{
|
||||
m_sqliteBookmarkStorage.addBookmarkedNode(id, m_sqliteIndexStorage.getNodeById(nodeId).serializedName);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
Id PersistentStorage::addEdgeBookmark(const EdgeBookmark& bookmark)
|
||||
{
|
||||
const Id categoryId = addBookmarkCategory(bookmark.getCategory().getName());
|
||||
const Id id = m_sqliteBookmarkStorage.addBookmark(
|
||||
bookmark.getName(), bookmark.getComment(), bookmark.getTimeStamp().toString(), categoryId);
|
||||
for (const Id& edgeId: bookmark.getEdgeIds())
|
||||
{
|
||||
const StorageEdge storageEdge = m_sqliteIndexStorage.getEdgeById(edgeId);
|
||||
|
||||
bool sourceNodeActive = storageEdge.sourceNodeId == bookmark.getActiveNodeId();
|
||||
m_sqliteBookmarkStorage.addBookmarkedEdge(
|
||||
id,
|
||||
// todo: optimization for multiple edges in same bookmark: use a local cache here
|
||||
m_sqliteIndexStorage.getNodeById(storageEdge.sourceNodeId).serializedName,
|
||||
m_sqliteIndexStorage.getNodeById(storageEdge.targetNodeId).serializedName,
|
||||
storageEdge.type,
|
||||
sourceNodeActive
|
||||
);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
Id PersistentStorage::addBookmarkCategory(const std::string& name)
|
||||
{
|
||||
if (name.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Id id = m_sqliteBookmarkStorage.getBookmarkCategoryByName(name).id;
|
||||
if (id == 0)
|
||||
{
|
||||
id = m_sqliteBookmarkStorage.addBookmarkCategory(name);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
void PersistentStorage::updateBookmark(
|
||||
const Id bookmarkId, const std::string& name, const std::string& comment, const std::string& categoryName)
|
||||
{
|
||||
const Id categoryId = addBookmarkCategory(categoryName); // only creates category if id didn't exist before;
|
||||
m_sqliteBookmarkStorage.updateBookmark(bookmarkId, name, comment, categoryId);
|
||||
}
|
||||
|
||||
void PersistentStorage::removeBookmark(const Id id)
|
||||
{
|
||||
m_sqliteBookmarkStorage.removeBookmark(id);
|
||||
}
|
||||
|
||||
void PersistentStorage::removeBookmarkCategory(Id id)
|
||||
{
|
||||
m_sqliteBookmarkStorage.removeBookmarkCategory(id);
|
||||
}
|
||||
|
||||
std::vector<NodeBookmark> PersistentStorage::getAllNodeBookmarks() const
|
||||
{
|
||||
std::unordered_map<Id, StorageBookmarkCategory> bookmarkCategories;
|
||||
for (const StorageBookmarkCategory& bookmarkCategory: m_sqliteBookmarkStorage.getAllBookmarkCategories())
|
||||
{
|
||||
bookmarkCategories[bookmarkCategory.id] = bookmarkCategory;
|
||||
}
|
||||
|
||||
std::unordered_map<Id, std::vector<Id>> bookmarkIdToBookmarkedNodeIds;
|
||||
for (const StorageBookmarkedNode& bookmarkedNode: m_sqliteBookmarkStorage.getAllBookmarkedNodes())
|
||||
{
|
||||
bookmarkIdToBookmarkedNodeIds[bookmarkedNode.bookmarkId].push_back(
|
||||
m_sqliteIndexStorage.getNodeBySerializedName(bookmarkedNode.serializedNodeName).id);
|
||||
}
|
||||
|
||||
std::vector<NodeBookmark> nodeBookmarks;
|
||||
|
||||
for (const StorageBookmark& storageBookmark: m_sqliteBookmarkStorage.getAllBookmarks())
|
||||
{
|
||||
auto itCategories = bookmarkCategories.find(storageBookmark.categoryId);
|
||||
auto itNodeIds = bookmarkIdToBookmarkedNodeIds.find(storageBookmark.id);
|
||||
if (itCategories != bookmarkCategories.end() && itNodeIds != bookmarkIdToBookmarkedNodeIds.end())
|
||||
{
|
||||
NodeBookmark bookmark(
|
||||
storageBookmark.id,
|
||||
storageBookmark.name,
|
||||
storageBookmark.comment,
|
||||
storageBookmark.timestamp,
|
||||
BookmarkCategory(itCategories->second.id, itCategories->second.name)
|
||||
);
|
||||
bookmark.setNodeIds(itNodeIds->second);
|
||||
bookmark.setIsValid();
|
||||
nodeBookmarks.push_back(bookmark);
|
||||
}
|
||||
}
|
||||
|
||||
return nodeBookmarks;
|
||||
}
|
||||
|
||||
std::vector<EdgeBookmark> PersistentStorage::getAllEdgeBookmarks() const
|
||||
{
|
||||
std::unordered_map<Id, StorageBookmarkCategory> bookmarkCategories;
|
||||
for (const StorageBookmarkCategory& bookmarkCategory: m_sqliteBookmarkStorage.getAllBookmarkCategories())
|
||||
{
|
||||
bookmarkCategories[bookmarkCategory.id] = bookmarkCategory;
|
||||
}
|
||||
|
||||
std::unordered_map<Id, std::vector<StorageBookmarkedEdge>> bookmarkIdToBookmarkedEdges;
|
||||
for (const StorageBookmarkedEdge& bookmarkedEdge: m_sqliteBookmarkStorage.getAllBookmarkedEdges())
|
||||
{
|
||||
bookmarkIdToBookmarkedEdges[bookmarkedEdge.bookmarkId].push_back(bookmarkedEdge);
|
||||
}
|
||||
|
||||
std::vector<EdgeBookmark> edgeBookmarks;
|
||||
|
||||
Cache<std::string, Id> nodeIdCache([&](std::string serializedNodeName)
|
||||
{
|
||||
return m_sqliteIndexStorage.getNodeBySerializedName(serializedNodeName).id;
|
||||
}
|
||||
);
|
||||
|
||||
for (const StorageBookmark& storageBookmark: m_sqliteBookmarkStorage.getAllBookmarks())
|
||||
{
|
||||
auto itCategories = bookmarkCategories.find(storageBookmark.categoryId);
|
||||
auto itBookmarkedEdges = bookmarkIdToBookmarkedEdges.find(storageBookmark.id);
|
||||
if (itCategories != bookmarkCategories.end() && itBookmarkedEdges != bookmarkIdToBookmarkedEdges.end())
|
||||
{
|
||||
EdgeBookmark bookmark(
|
||||
storageBookmark.id,
|
||||
storageBookmark.name,
|
||||
storageBookmark.comment,
|
||||
storageBookmark.timestamp,
|
||||
BookmarkCategory(itCategories->second.id, itCategories->second.name)
|
||||
);
|
||||
|
||||
Id activeNodeId = 0;
|
||||
for (const StorageBookmarkedEdge& bookmarkedEdge: itBookmarkedEdges->second)
|
||||
{
|
||||
const Id sourceNodeId = nodeIdCache.getValue(bookmarkedEdge.serializedSourceNodeName);
|
||||
const Id targetNodeId = nodeIdCache.getValue(bookmarkedEdge.serializedTargetNodeName);
|
||||
const Id edgeId =
|
||||
m_sqliteIndexStorage.getEdgeBySourceTargetType(sourceNodeId, targetNodeId, bookmarkedEdge.edgeType).id;
|
||||
bookmark.addEdgeId(edgeId);
|
||||
|
||||
if (activeNodeId == 0)
|
||||
{
|
||||
activeNodeId = bookmarkedEdge.sourceNodeActive ? sourceNodeId : targetNodeId;
|
||||
}
|
||||
}
|
||||
bookmark.setActiveNodeId(activeNodeId);
|
||||
bookmark.setIsValid();
|
||||
edgeBookmarks.push_back(bookmark);
|
||||
}
|
||||
}
|
||||
|
||||
return edgeBookmarks;
|
||||
}
|
||||
|
||||
std::vector<BookmarkCategory> PersistentStorage::getAllBookmarkCategories() const
|
||||
{
|
||||
std::vector<BookmarkCategory> categories;
|
||||
for (const StorageBookmarkCategory storageBookmarkCategoriy: m_sqliteBookmarkStorage.getAllBookmarkCategories())
|
||||
{
|
||||
categories.push_back(BookmarkCategory(storageBookmarkCategoriy.id, storageBookmarkCategoriy.name));
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
|
||||
void PersistentStorage::forEachNode(std::function<void(const StorageNode& /*data*/)> callback) const
|
||||
{
|
||||
for (StorageNode& node: m_sqliteIndexStorage.getAll<StorageNode>())
|
||||
@@ -602,7 +426,7 @@ NameHierarchy PersistentStorage::getNameHierarchyForNodeId(Id nodeId) const
|
||||
return NameHierarchy::deserialize(m_sqliteIndexStorage.getFirstById<StorageNode>(nodeId).serializedName);
|
||||
}
|
||||
|
||||
std::vector<NameHierarchy> PersistentStorage::getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const
|
||||
std::vector<NameHierarchy> PersistentStorage::getNameHierarchiesForNodeIds(const std::vector<Id>& nodeIds) const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
@@ -1564,6 +1388,370 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getErrorSourceLocat
|
||||
return collection;
|
||||
}
|
||||
|
||||
Id PersistentStorage::addNodeBookmark(const NodeBookmark& bookmark)
|
||||
{
|
||||
const Id categoryId = addBookmarkCategory(bookmark.getCategory().getName());
|
||||
const Id id = m_sqliteBookmarkStorage.addBookmark(
|
||||
bookmark.getName(), bookmark.getComment(), bookmark.getTimeStamp().toString(), categoryId);
|
||||
|
||||
for (const Id& nodeId: bookmark.getNodeIds())
|
||||
{
|
||||
m_sqliteBookmarkStorage.addBookmarkedNode(id, m_sqliteIndexStorage.getNodeById(nodeId).serializedName);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
Id PersistentStorage::addEdgeBookmark(const EdgeBookmark& bookmark)
|
||||
{
|
||||
const Id categoryId = addBookmarkCategory(bookmark.getCategory().getName());
|
||||
const Id id = m_sqliteBookmarkStorage.addBookmark(
|
||||
bookmark.getName(), bookmark.getComment(), bookmark.getTimeStamp().toString(), categoryId);
|
||||
for (const Id& edgeId: bookmark.getEdgeIds())
|
||||
{
|
||||
const StorageEdge storageEdge = m_sqliteIndexStorage.getEdgeById(edgeId);
|
||||
|
||||
bool sourceNodeActive = storageEdge.sourceNodeId == bookmark.getActiveNodeId();
|
||||
m_sqliteBookmarkStorage.addBookmarkedEdge(
|
||||
id,
|
||||
// todo: optimization for multiple edges in same bookmark: use a local cache here
|
||||
m_sqliteIndexStorage.getNodeById(storageEdge.sourceNodeId).serializedName,
|
||||
m_sqliteIndexStorage.getNodeById(storageEdge.targetNodeId).serializedName,
|
||||
storageEdge.type,
|
||||
sourceNodeActive
|
||||
);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
Id PersistentStorage::addBookmarkCategory(const std::string& name)
|
||||
{
|
||||
if (name.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Id id = m_sqliteBookmarkStorage.getBookmarkCategoryByName(name).id;
|
||||
if (id == 0)
|
||||
{
|
||||
id = m_sqliteBookmarkStorage.addBookmarkCategory(name);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
void PersistentStorage::updateBookmark(
|
||||
const Id bookmarkId, const std::string& name, const std::string& comment, const std::string& categoryName)
|
||||
{
|
||||
const Id categoryId = addBookmarkCategory(categoryName); // only creates category if id didn't exist before;
|
||||
m_sqliteBookmarkStorage.updateBookmark(bookmarkId, name, comment, categoryId);
|
||||
}
|
||||
|
||||
void PersistentStorage::removeBookmark(const Id id)
|
||||
{
|
||||
m_sqliteBookmarkStorage.removeBookmark(id);
|
||||
}
|
||||
|
||||
void PersistentStorage::removeBookmarkCategory(Id id)
|
||||
{
|
||||
m_sqliteBookmarkStorage.removeBookmarkCategory(id);
|
||||
}
|
||||
|
||||
std::vector<NodeBookmark> PersistentStorage::getAllNodeBookmarks() const
|
||||
{
|
||||
std::unordered_map<Id, StorageBookmarkCategory> bookmarkCategories;
|
||||
for (const StorageBookmarkCategory& bookmarkCategory: m_sqliteBookmarkStorage.getAllBookmarkCategories())
|
||||
{
|
||||
bookmarkCategories[bookmarkCategory.id] = bookmarkCategory;
|
||||
}
|
||||
|
||||
std::unordered_map<Id, std::vector<Id>> bookmarkIdToBookmarkedNodeIds;
|
||||
for (const StorageBookmarkedNode& bookmarkedNode: m_sqliteBookmarkStorage.getAllBookmarkedNodes())
|
||||
{
|
||||
bookmarkIdToBookmarkedNodeIds[bookmarkedNode.bookmarkId].push_back(
|
||||
m_sqliteIndexStorage.getNodeBySerializedName(bookmarkedNode.serializedNodeName).id);
|
||||
}
|
||||
|
||||
std::vector<NodeBookmark> nodeBookmarks;
|
||||
|
||||
for (const StorageBookmark& storageBookmark: m_sqliteBookmarkStorage.getAllBookmarks())
|
||||
{
|
||||
auto itCategories = bookmarkCategories.find(storageBookmark.categoryId);
|
||||
auto itNodeIds = bookmarkIdToBookmarkedNodeIds.find(storageBookmark.id);
|
||||
if (itCategories != bookmarkCategories.end() && itNodeIds != bookmarkIdToBookmarkedNodeIds.end())
|
||||
{
|
||||
NodeBookmark bookmark(
|
||||
storageBookmark.id,
|
||||
storageBookmark.name,
|
||||
storageBookmark.comment,
|
||||
storageBookmark.timestamp,
|
||||
BookmarkCategory(itCategories->second.id, itCategories->second.name)
|
||||
);
|
||||
bookmark.setNodeIds(itNodeIds->second);
|
||||
bookmark.setIsValid();
|
||||
nodeBookmarks.push_back(bookmark);
|
||||
}
|
||||
}
|
||||
|
||||
return nodeBookmarks;
|
||||
}
|
||||
|
||||
std::vector<EdgeBookmark> PersistentStorage::getAllEdgeBookmarks() const
|
||||
{
|
||||
std::unordered_map<Id, StorageBookmarkCategory> bookmarkCategories;
|
||||
for (const StorageBookmarkCategory& bookmarkCategory: m_sqliteBookmarkStorage.getAllBookmarkCategories())
|
||||
{
|
||||
bookmarkCategories[bookmarkCategory.id] = bookmarkCategory;
|
||||
}
|
||||
|
||||
std::unordered_map<Id, std::vector<StorageBookmarkedEdge>> bookmarkIdToBookmarkedEdges;
|
||||
for (const StorageBookmarkedEdge& bookmarkedEdge: m_sqliteBookmarkStorage.getAllBookmarkedEdges())
|
||||
{
|
||||
bookmarkIdToBookmarkedEdges[bookmarkedEdge.bookmarkId].push_back(bookmarkedEdge);
|
||||
}
|
||||
|
||||
std::vector<EdgeBookmark> edgeBookmarks;
|
||||
|
||||
Cache<std::string, Id> nodeIdCache([&](std::string serializedNodeName)
|
||||
{
|
||||
return m_sqliteIndexStorage.getNodeBySerializedName(serializedNodeName).id;
|
||||
}
|
||||
);
|
||||
|
||||
for (const StorageBookmark& storageBookmark: m_sqliteBookmarkStorage.getAllBookmarks())
|
||||
{
|
||||
auto itCategories = bookmarkCategories.find(storageBookmark.categoryId);
|
||||
auto itBookmarkedEdges = bookmarkIdToBookmarkedEdges.find(storageBookmark.id);
|
||||
if (itCategories != bookmarkCategories.end() && itBookmarkedEdges != bookmarkIdToBookmarkedEdges.end())
|
||||
{
|
||||
EdgeBookmark bookmark(
|
||||
storageBookmark.id,
|
||||
storageBookmark.name,
|
||||
storageBookmark.comment,
|
||||
storageBookmark.timestamp,
|
||||
BookmarkCategory(itCategories->second.id, itCategories->second.name)
|
||||
);
|
||||
|
||||
Id activeNodeId = 0;
|
||||
for (const StorageBookmarkedEdge& bookmarkedEdge: itBookmarkedEdges->second)
|
||||
{
|
||||
const Id sourceNodeId = nodeIdCache.getValue(bookmarkedEdge.serializedSourceNodeName);
|
||||
const Id targetNodeId = nodeIdCache.getValue(bookmarkedEdge.serializedTargetNodeName);
|
||||
const Id edgeId =
|
||||
m_sqliteIndexStorage.getEdgeBySourceTargetType(sourceNodeId, targetNodeId, bookmarkedEdge.edgeType).id;
|
||||
bookmark.addEdgeId(edgeId);
|
||||
|
||||
if (activeNodeId == 0)
|
||||
{
|
||||
activeNodeId = bookmarkedEdge.sourceNodeActive ? sourceNodeId : targetNodeId;
|
||||
}
|
||||
}
|
||||
bookmark.setActiveNodeId(activeNodeId);
|
||||
bookmark.setIsValid();
|
||||
edgeBookmarks.push_back(bookmark);
|
||||
}
|
||||
}
|
||||
|
||||
return edgeBookmarks;
|
||||
}
|
||||
|
||||
std::vector<BookmarkCategory> PersistentStorage::getAllBookmarkCategories() const
|
||||
{
|
||||
std::vector<BookmarkCategory> categories;
|
||||
for (const StorageBookmarkCategory storageBookmarkCategoriy: m_sqliteBookmarkStorage.getAllBookmarkCategories())
|
||||
{
|
||||
categories.push_back(BookmarkCategory(storageBookmarkCategoriy.id, storageBookmarkCategoriy.name));
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
|
||||
TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>& tokenIds, TooltipOrigin origin) const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
TooltipInfo info;
|
||||
|
||||
if (!tokenIds.size())
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
StorageNode node = m_sqliteIndexStorage.getFirstById<StorageNode>(tokenIds[0]);
|
||||
if (node.id == 0 && origin == TOOLTIP_ORIGIN_CODE)
|
||||
{
|
||||
StorageEdge edge = m_sqliteIndexStorage.getFirstById<StorageEdge>(tokenIds[0]);
|
||||
|
||||
if (edge.id > 0)
|
||||
{
|
||||
node = m_sqliteIndexStorage.getFirstById<StorageNode>(edge.targetNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.id == 0)
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
Node::NodeType type = Node::intToType(node.type);
|
||||
info.title = Node::getReadableTypeString(type);
|
||||
|
||||
DefinitionKind defKind = DEFINITION_NONE;
|
||||
StorageSymbol symbol = m_sqliteIndexStorage.getFirstById<StorageSymbol>(node.id);
|
||||
if (symbol.id > 0)
|
||||
{
|
||||
defKind = intToDefinitionKind(symbol.definitionKind);
|
||||
}
|
||||
|
||||
if (type & Node::NODE_MEMBER_TYPE)
|
||||
{
|
||||
StorageComponentAccess access = m_sqliteIndexStorage.getComponentAccessByNodeId(node.id);
|
||||
if (access.nodeId != 0)
|
||||
{
|
||||
info.title = accessKindToString(intToAccessKind(access.type)) + " " + info.title;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == Node::NODE_FILE)
|
||||
{
|
||||
bool complete = false;
|
||||
auto it = m_fileNodeComplete.find(node.id);
|
||||
if (it != m_fileNodeComplete.end())
|
||||
{
|
||||
complete = it->second;
|
||||
}
|
||||
|
||||
if (!complete)
|
||||
{
|
||||
info.title = "incomplete " + info.title;
|
||||
}
|
||||
}
|
||||
else if (defKind == DEFINITION_NONE && type != Node::NODE_NON_INDEXED)
|
||||
{
|
||||
info.title = "non-indexed " + info.title;
|
||||
}
|
||||
else if (defKind == DEFINITION_IMPLICIT)
|
||||
{
|
||||
info.title = "implicit " + info.title;
|
||||
}
|
||||
|
||||
info.count = 0;
|
||||
info.countText = "reference";
|
||||
for (auto edge : m_sqliteIndexStorage.getEdgesByTargetId(node.id))
|
||||
{
|
||||
if (Edge::intToType(edge.type) != Edge::EDGE_MEMBER)
|
||||
{
|
||||
info.count++;
|
||||
}
|
||||
}
|
||||
|
||||
info.snippets.push_back(getTooltipSnippetForNode(node));
|
||||
|
||||
if (origin == TOOLTIP_ORIGIN_CODE)
|
||||
{
|
||||
info.offset = Vec2i(20, 30);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.offset = Vec2i(50, 20);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& node) const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
TooltipSnippet snippet;
|
||||
NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
snippet.code = nameHierarchy.getQualifiedNameWithSignature();
|
||||
snippet.locationFile = std::make_shared<SourceLocationFile>(
|
||||
FilePath(nameHierarchy.getDelimiter() == NAME_DELIMITER_JAVA ? "main.java" : "main.cpp"), true, true);
|
||||
|
||||
if (Node::intToType(node.type) & (Node::NODE_FUNCTION | Node::NODE_METHOD | Node::NODE_FIELD | Node::NODE_GLOBAL_VARIABLE))
|
||||
{
|
||||
snippet.code = utility::breakSignature(
|
||||
nameHierarchy.getSignature().getPrefix(),
|
||||
nameHierarchy.getQualifiedName(),
|
||||
nameHierarchy.getSignature().getPostfix(),
|
||||
50,
|
||||
ApplicationSettings::getInstance()->getCodeTabWidth()
|
||||
);
|
||||
|
||||
std::vector<Id> typeNodeIds;
|
||||
for (auto edge : m_sqliteIndexStorage.getEdgesBySourceId(node.id))
|
||||
{
|
||||
if (Edge::intToType(edge.type) == Edge::EDGE_TYPE_USAGE)
|
||||
{
|
||||
typeNodeIds.push_back(edge.targetNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::pair<std::string, Id>, bool(*)(const std::pair<std::string, Id>&, const std::pair<std::string, Id>&)> typeNames(
|
||||
[](const std::pair<std::string, Id>& a, const std::pair<std::string, Id>& b)
|
||||
{
|
||||
if (a.first.size() == b.first.size())
|
||||
{
|
||||
return a.first < b.first;
|
||||
}
|
||||
|
||||
return a.first.size() > b.first.size();
|
||||
}
|
||||
);
|
||||
|
||||
typeNames.insert(std::make_pair(nameHierarchy.getQualifiedName(), node.id));
|
||||
for (auto typeNode : m_sqliteIndexStorage.getAllByIds<StorageNode>(typeNodeIds))
|
||||
{
|
||||
typeNames.insert(std::make_pair(
|
||||
NameHierarchy::deserialize(typeNode.serializedName).getQualifiedName(),
|
||||
typeNode.id
|
||||
));
|
||||
}
|
||||
|
||||
Id locationId = 1;
|
||||
std::vector<std::pair<size_t, size_t>> locationRanges;
|
||||
for (auto p : typeNames)
|
||||
{
|
||||
size_t pos = 0;
|
||||
while (pos != std::string::npos)
|
||||
{
|
||||
pos = snippet.code.find(p.first, pos);
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool inRange = false;
|
||||
for (auto p : locationRanges)
|
||||
{
|
||||
if (pos + 1 >= p.first && pos + 1 <= p.second)
|
||||
{
|
||||
inRange = true;
|
||||
pos = p.second + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRange)
|
||||
{
|
||||
snippet.locationFile->addSourceLocation(
|
||||
LOCATION_TOKEN, locationId, std::vector<Id>(1, p.second), 1, pos + 1, 1, pos + p.first.size());
|
||||
|
||||
locationRanges.push_back(std::make_pair(pos + 1, pos + p.first.size()));
|
||||
pos += p.first.size();
|
||||
locationId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snippet.locationFile->addSourceLocation(
|
||||
LOCATION_TOKEN, 0, std::vector<Id>(1, node.id), 1, 1, 1, snippet.code.size());
|
||||
}
|
||||
|
||||
return snippet;
|
||||
}
|
||||
|
||||
Id PersistentStorage::getFileNodeId(const FilePath& filePath) const
|
||||
{
|
||||
if (filePath.empty())
|
||||
@@ -1864,17 +2052,6 @@ void PersistentStorage::addNodesToGraph(const std::vector<Id>& newNodeIds, Graph
|
||||
node->setExplicit(true);
|
||||
}
|
||||
|
||||
if (type == Node::NODE_FUNCTION || type == Node::NODE_METHOD)
|
||||
{
|
||||
std::string signatureString = nameHierarchy.getRawNameWithSignature();
|
||||
if (signatureString.size() > 0) // this should always be the case since functions and methods must have sigs.
|
||||
{
|
||||
node->addComponentSignature(
|
||||
std::make_shared<TokenComponentSignature>(signatureString)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (addChildCount)
|
||||
{
|
||||
node->setChildCount(m_hierarchyCache.getFirstNonImplicitChildIdsCountForNodeId(storageNode.id));
|
||||
|
||||
@@ -30,20 +30,6 @@ public:
|
||||
virtual void addComponentAccess(Id nodeId , int type);
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
virtual void addError(const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
virtual Id addNodeBookmark(const NodeBookmark& bookmark);
|
||||
virtual Id addEdgeBookmark(const EdgeBookmark& bookmark);
|
||||
virtual Id addBookmarkCategory(const std::string& categoryName);
|
||||
|
||||
void updateBookmark(const Id bookmarkId, const std::string& name, const std::string& comment, const std::string& categoryName);
|
||||
|
||||
virtual void removeBookmark(const Id id);
|
||||
virtual void removeBookmarkCategory(const Id id);
|
||||
|
||||
std::vector<NodeBookmark> getAllNodeBookmarks() const;
|
||||
std::vector<EdgeBookmark> getAllEdgeBookmarks() const;
|
||||
|
||||
|
||||
virtual std::vector<BookmarkCategory> getAllBookmarkCategories() const;
|
||||
|
||||
virtual void forEachNode(std::function<void(const StorageNode& /*data*/)> callback) const;
|
||||
virtual void forEachFile(std::function<void(const StorageFile& /*data*/)> callback) const;
|
||||
@@ -89,7 +75,7 @@ public:
|
||||
virtual std::vector<Id> getNodeIdsForNameHierarchies(const std::vector<NameHierarchy> nameHierarchies) const;
|
||||
|
||||
virtual NameHierarchy getNameHierarchyForNodeId(Id nodeId) const;
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const;
|
||||
virtual std::vector<NameHierarchy> getNameHierarchiesForNodeIds(const std::vector<Id>& nodeIds) const;
|
||||
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id nodeId) const;
|
||||
|
||||
@@ -138,6 +124,21 @@ public:
|
||||
virtual std::vector<ErrorInfo> getErrorsLimited() const;
|
||||
virtual std::shared_ptr<SourceLocationCollection> getErrorSourceLocationsLimited(std::vector<ErrorInfo>* errors) const;
|
||||
|
||||
virtual Id addNodeBookmark(const NodeBookmark& bookmark);
|
||||
virtual Id addEdgeBookmark(const EdgeBookmark& bookmark);
|
||||
virtual Id addBookmarkCategory(const std::string& categoryName);
|
||||
|
||||
virtual void updateBookmark(const Id bookmarkId, const std::string& name, const std::string& comment, const std::string& categoryName);
|
||||
virtual void removeBookmark(const Id id);
|
||||
virtual void removeBookmarkCategory(const Id id);
|
||||
|
||||
virtual std::vector<NodeBookmark> getAllNodeBookmarks() const;
|
||||
virtual std::vector<EdgeBookmark> getAllEdgeBookmarks() const;
|
||||
virtual std::vector<BookmarkCategory> getAllBookmarkCategories() const;
|
||||
|
||||
virtual TooltipInfo getTooltipInfoForTokenIds(const std::vector<Id>& tokenIds, TooltipOrigin origin) const;
|
||||
TooltipSnippet getTooltipSnippetForNode(const StorageNode& node) const;
|
||||
|
||||
private:
|
||||
Id getFileNodeId(const FilePath& filePath) const;
|
||||
std::vector<Id> getFileNodeIds(const std::vector<FilePath>& filePaths) const;
|
||||
|
||||
@@ -219,9 +219,10 @@ int SqliteStorage::executeStatementScalar(CppSQLite3Statement& statement, const
|
||||
|
||||
if (q.eof() || q.numFields() < 1)
|
||||
{
|
||||
char error[] = "Invalid scalar query";
|
||||
throw CppSQLite3Exception(
|
||||
CPPSQLITE_ERROR,
|
||||
"Invalid scalar query",
|
||||
error,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef TOOLTIP_INFO_H
|
||||
#define TOOLTIP_INFO_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "utility/math/Vector2.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class SourceLocationFile;
|
||||
|
||||
struct TooltipSnippet
|
||||
{
|
||||
std::string code;
|
||||
std::shared_ptr<SourceLocationFile> locationFile;
|
||||
};
|
||||
|
||||
struct TooltipInfo
|
||||
{
|
||||
bool isValid() const
|
||||
{
|
||||
return title.size() || snippets.size();
|
||||
}
|
||||
|
||||
std::string title;
|
||||
|
||||
int count = -1;
|
||||
std::string countText;
|
||||
|
||||
std::vector<TooltipSnippet> snippets;
|
||||
|
||||
Vec2i offset;
|
||||
};
|
||||
|
||||
#endif // TOOLTIP_INFO_H
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef TOOLTIP_ORIGIN_H
|
||||
#define TOOLTIP_ORIGIN_H
|
||||
|
||||
enum TooltipOrigin
|
||||
{
|
||||
TOOLTIP_ORIGIN_GRAPH,
|
||||
TOOLTIP_ORIGIN_CODE
|
||||
};
|
||||
|
||||
#endif // TOOLTIP_ORIGIN_H
|
||||
@@ -6,12 +6,15 @@
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "data/tooltip/TooltipOrigin.h"
|
||||
|
||||
class MessageFocusIn
|
||||
: public Message<MessageFocusIn>
|
||||
{
|
||||
public:
|
||||
MessageFocusIn(const std::vector<Id>& tokenIds)
|
||||
MessageFocusIn(const std::vector<Id>& tokenIds, TooltipOrigin origin)
|
||||
: tokenIds(tokenIds)
|
||||
, origin(origin)
|
||||
{
|
||||
setIsLogged(false);
|
||||
}
|
||||
@@ -30,6 +33,7 @@ public:
|
||||
}
|
||||
|
||||
const std::vector<Id> tokenIds;
|
||||
const TooltipOrigin origin;
|
||||
};
|
||||
|
||||
#endif //MESSAGE_FOCUS_IN_H
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef MESSAGE_TOOLTIP_HIDE_H
|
||||
#define MESSAGE_TOOLTIP_HIDE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageTooltipHide
|
||||
: public Message<MessageTooltipHide>
|
||||
{
|
||||
public:
|
||||
MessageTooltipHide()
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageTooltipHide";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_TOOLTIP_HIDE_H
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef MESSAGE_TOOLTIP_SHOW_H
|
||||
#define MESSAGE_TOOLTIP_SHOW_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/tooltip/TooltipOrigin.h"
|
||||
#include "data/tooltip/TooltipInfo.h"
|
||||
|
||||
class MessageTooltipShow
|
||||
: public Message<MessageTooltipShow>
|
||||
{
|
||||
public:
|
||||
MessageTooltipShow(TooltipInfo info, TooltipOrigin origin)
|
||||
: tooltipInfo(info)
|
||||
, origin(origin)
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageTooltipShow";
|
||||
}
|
||||
|
||||
const TooltipInfo tooltipInfo;
|
||||
const TooltipOrigin origin;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_TOOLTIP_SHOW_H
|
||||
@@ -3,10 +3,12 @@
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageWindowFocus: public Message<MessageWindowFocus>
|
||||
class MessageWindowFocus
|
||||
: public Message<MessageWindowFocus>
|
||||
{
|
||||
public:
|
||||
MessageWindowFocus()
|
||||
MessageWindowFocus(bool focusIn)
|
||||
: focusIn(focusIn)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,6 +16,8 @@ public:
|
||||
{
|
||||
return "MessageWindowFocus";
|
||||
}
|
||||
|
||||
const bool focusIn;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_WINDOW_FOCUS_H
|
||||
|
||||
@@ -11,6 +11,7 @@ public:
|
||||
enum TaskState
|
||||
{
|
||||
STATE_RUNNING,
|
||||
STATE_HOLD,
|
||||
STATE_SUCCESS,
|
||||
STATE_FAILURE
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "utility/scheduling/TaskDecorator.h"
|
||||
|
||||
#include "utility/scheduling/TaskRunner.h"
|
||||
|
||||
TaskDecorator::TaskDecorator()
|
||||
{
|
||||
}
|
||||
@@ -14,7 +16,20 @@ std::shared_ptr<TaskDecorator> TaskDecorator::addChildTask(std::shared_ptr<Task>
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
void TaskDecorator::setTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
if (task)
|
||||
{
|
||||
m_taskRunner = std::make_shared<TaskRunner>(task);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDecorator::terminate()
|
||||
{
|
||||
doTerminate();
|
||||
}
|
||||
|
||||
void TaskDecorator::doTerminate()
|
||||
{
|
||||
m_taskRunner->terminate();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class TaskRunner;
|
||||
|
||||
class TaskDecorator
|
||||
: public Task
|
||||
, public std::enable_shared_from_this<TaskDecorator>
|
||||
@@ -14,11 +16,14 @@ public:
|
||||
virtual ~TaskDecorator();
|
||||
std::shared_ptr<TaskDecorator> addChildTask(std::shared_ptr<Task> child);
|
||||
|
||||
virtual void setTask(std::shared_ptr<Task> task) = 0;
|
||||
virtual void setTask(std::shared_ptr<Task> task);
|
||||
virtual void terminate();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<TaskRunner> m_taskRunner;
|
||||
|
||||
private:
|
||||
virtual void doTerminate() = 0;
|
||||
virtual void doTerminate();
|
||||
};
|
||||
|
||||
#endif // TASK_DECORATOR_H
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "utility/scheduling/TaskDecoratorDelay.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
TaskDecoratorDelay::TaskDecoratorDelay(size_t delayMS)
|
||||
: m_delayMS(delayMS)
|
||||
, m_delayComplete(delayMS == 0)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_start = TimePoint::now();
|
||||
}
|
||||
|
||||
Task::TaskState TaskDecoratorDelay::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (m_delayComplete)
|
||||
{
|
||||
return m_taskRunner->update(blackboard);
|
||||
}
|
||||
|
||||
const int SLEEP_TIME_MS = 25;
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(SLEEP_TIME_MS));
|
||||
|
||||
m_delayComplete = (TimePoint::now().deltaMS(m_start) >= m_delayMS);
|
||||
|
||||
return Task::STATE_HOLD;
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (m_delayComplete)
|
||||
{
|
||||
m_taskRunner->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doTerminate()
|
||||
{
|
||||
if (m_delayComplete)
|
||||
{
|
||||
m_taskRunner->terminate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef TASK_DECORATOR_DELAY_H
|
||||
#define TASK_DECORATOR_DELAY_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "utility/scheduling/TaskDecorator.h"
|
||||
#include "utility/scheduling/TaskRunner.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
class TaskDecoratorDelay
|
||||
: public TaskDecorator
|
||||
{
|
||||
public:
|
||||
TaskDecoratorDelay(size_t delayMS);
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doTerminate();
|
||||
|
||||
const size_t m_delayMS;
|
||||
|
||||
TimePoint m_start;
|
||||
bool m_delayComplete;
|
||||
};
|
||||
|
||||
#endif // TASK_DECORATOR_DELAY_H
|
||||
@@ -6,14 +6,6 @@ TaskDecoratorRepeat::TaskDecoratorRepeat(ConditionType condition, TaskState exit
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDecoratorRepeat::setTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
if (task)
|
||||
{
|
||||
m_taskRunner = std::make_shared<TaskRunner>(task);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDecoratorRepeat::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
@@ -48,8 +40,3 @@ void TaskDecoratorRepeat::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_taskRunner->reset();
|
||||
}
|
||||
|
||||
void TaskDecoratorRepeat::doTerminate()
|
||||
{
|
||||
m_taskRunner->terminate();
|
||||
}
|
||||
|
||||
@@ -17,16 +17,12 @@ public:
|
||||
|
||||
TaskDecoratorRepeat(ConditionType condition, TaskState exitState);
|
||||
|
||||
virtual void setTask(std::shared_ptr<Task> task);
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doTerminate();
|
||||
|
||||
std::shared_ptr<TaskRunner> m_taskRunner;
|
||||
const ConditionType m_condition;
|
||||
const TaskState m_exitState;
|
||||
};
|
||||
|
||||
@@ -105,7 +105,7 @@ void TaskGroupParallel::processTaskThreaded(
|
||||
{
|
||||
TaskState state = taskInfo->taskRunner->update(blackboard);
|
||||
|
||||
if (state != STATE_RUNNING)
|
||||
if (state == STATE_SUCCESS || state == STATE_FAILURE)
|
||||
{
|
||||
if (state == STATE_FAILURE)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,10 @@ Task::TaskState TaskGroupSelector::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
{
|
||||
m_taskIndex = -1;
|
||||
}
|
||||
else if (state == STATE_HOLD)
|
||||
{
|
||||
return STATE_HOLD;
|
||||
}
|
||||
|
||||
return STATE_RUNNING;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ Task::TaskState TaskGroupSequence::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
{
|
||||
m_taskIndex = -1;
|
||||
}
|
||||
else if (state == STATE_HOLD)
|
||||
{
|
||||
return STATE_HOLD;
|
||||
}
|
||||
|
||||
return STATE_RUNNING;
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ void TaskScheduler::processTasks()
|
||||
while (m_taskRunners.size())
|
||||
{
|
||||
std::shared_ptr<TaskRunner> runner = m_taskRunners.front();
|
||||
Task::TaskState state = Task::STATE_RUNNING;
|
||||
|
||||
{
|
||||
m_tasksMutex.unlock();
|
||||
@@ -166,7 +167,8 @@ void TaskScheduler::processTasks()
|
||||
}
|
||||
}
|
||||
|
||||
if (runner->update(blackboard) != Task::STATE_RUNNING)
|
||||
state = runner->update(blackboard);
|
||||
if (state != Task::STATE_RUNNING)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -174,6 +176,11 @@ void TaskScheduler::processTasks()
|
||||
}
|
||||
|
||||
m_taskRunners.pop_front();
|
||||
|
||||
if (state == Task::STATE_HOLD)
|
||||
{
|
||||
m_taskRunners.push_back(runner);
|
||||
}
|
||||
}
|
||||
|
||||
m_terminateRunningTasks = false;
|
||||
|
||||
@@ -256,6 +256,112 @@ namespace utility
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string breakSignature(
|
||||
std::string returnPart, std::string namePart, std::string paramPart,
|
||||
size_t maxLineLength, size_t tabWidth)
|
||||
{
|
||||
namePart = ' ' + namePart;
|
||||
|
||||
size_t totalSize = returnPart.size() + namePart.size() + paramPart.size();
|
||||
if (totalSize <= maxLineLength)
|
||||
{
|
||||
return returnPart + namePart + paramPart;
|
||||
}
|
||||
|
||||
if (paramPart.size())
|
||||
{
|
||||
namePart += paramPart[0];
|
||||
paramPart.erase(0, 1);
|
||||
}
|
||||
|
||||
size_t parenPos = paramPart.rfind(')');
|
||||
std::string endPart;
|
||||
if (parenPos == 0)
|
||||
{
|
||||
namePart += paramPart;
|
||||
paramPart = "";
|
||||
}
|
||||
else if (parenPos != std::string::npos)
|
||||
{
|
||||
endPart = paramPart.substr(parenPos);
|
||||
paramPart = paramPart.substr(0, parenPos);
|
||||
}
|
||||
|
||||
if (paramPart.size() && paramPart.size() + tabWidth - endPart.size() > maxLineLength)
|
||||
{
|
||||
std::vector<std::string> paramLines;
|
||||
while (true)
|
||||
{
|
||||
size_t parenCount = 0;
|
||||
bool split = false;
|
||||
for (size_t i = 0; i < paramPart.size(); i++)
|
||||
{
|
||||
char c = paramPart[i];
|
||||
if (parenCount == 0 && c == ',')
|
||||
{
|
||||
paramLines.push_back(paramPart.substr(0, i + 1));
|
||||
paramPart = paramPart.substr(i + 2);
|
||||
split = true;
|
||||
break;
|
||||
}
|
||||
else if (c == '<' || c == '(')
|
||||
{
|
||||
parenCount++;
|
||||
}
|
||||
else if (c == '>' || c == ')')
|
||||
{
|
||||
parenCount--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!split)
|
||||
{
|
||||
paramLines.push_back(paramPart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
paramPart = "";
|
||||
for (std::string str : paramLines)
|
||||
{
|
||||
paramPart += "\n\t" + str;
|
||||
size_t length = tabWidth + str.size();
|
||||
maxLineLength = std::max(length, maxLineLength);
|
||||
}
|
||||
}
|
||||
else if (paramPart.size())
|
||||
{
|
||||
paramPart = "\n\t" + paramPart;
|
||||
}
|
||||
|
||||
if (returnPart.size() + namePart.size() <= maxLineLength)
|
||||
{
|
||||
namePart = returnPart + namePart;
|
||||
returnPart = "";
|
||||
}
|
||||
|
||||
std::string sig;
|
||||
|
||||
if (returnPart.size())
|
||||
{
|
||||
sig += returnPart + '\n';
|
||||
}
|
||||
|
||||
sig += namePart;
|
||||
|
||||
if (paramPart.size())
|
||||
{
|
||||
sig += paramPart;
|
||||
}
|
||||
|
||||
if (endPart.size())
|
||||
{
|
||||
sig += '\n' + endPart;
|
||||
}
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
std::string trim(const std::string &str)
|
||||
{
|
||||
auto wsfront = std::find_if_not(str.begin(), str.end(), [](int c){ return std::isspace(c); });
|
||||
|
||||
@@ -47,6 +47,9 @@ namespace utility
|
||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||
|
||||
std::string insertLineBreaksAtBlankSpaces(const std::string& s, size_t maxLineLength);
|
||||
std::string breakSignature(
|
||||
std::string returnPart, std::string namePart, std::string paramPart,
|
||||
size_t maxLineLength, size_t tabWidth);
|
||||
|
||||
std::string trim(const std::string &str);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user