ui: Show list in tooltip when clicking source location with multiple tokens or local symbols
* Also shows list of all implicit symbols at a source location e.g. default constructors or template specializations
This commit is contained in:
@@ -14,8 +14,6 @@
|
||||
|
||||
#include "data/location/SourceLocationFile.h"
|
||||
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||
#include "utility/messaging/type/MessageActivateSourceLocations.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenIds.h"
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageMoveIDECursor.h"
|
||||
@@ -364,8 +362,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
else
|
||||
{
|
||||
activateSourceLocations(annotations);
|
||||
activateLocalSymbols(annotations);
|
||||
activateAnnotations(annotations);
|
||||
}
|
||||
}
|
||||
else if (m_navigator->getActiveLocalSymbolIds().size())
|
||||
@@ -518,73 +515,6 @@ void QtCodeArea::setIDECursorPosition()
|
||||
MessageMoveIDECursor(getSourceLocationFile()->getFilePath().str(), lineColumn.first, lineColumn.second).dispatch();
|
||||
}
|
||||
|
||||
void QtCodeArea::activateSourceLocations(const std::vector<const Annotation*>& annotations)
|
||||
{
|
||||
std::vector<Id> locationIds;
|
||||
std::set<Id> tokenIds;
|
||||
|
||||
bool allActive = true;
|
||||
for (const Annotation* annotation : annotations)
|
||||
{
|
||||
if (annotation->locationType == LOCATION_TOKEN)
|
||||
{
|
||||
if (!annotation->isActive)
|
||||
{
|
||||
allActive = false;
|
||||
}
|
||||
|
||||
if (annotation->locationId > 0)
|
||||
{
|
||||
locationIds.push_back(annotation->locationId);
|
||||
}
|
||||
|
||||
if (annotation->tokenIds.size())
|
||||
{
|
||||
tokenIds.insert(annotation->tokenIds.begin(), annotation->tokenIds.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!allActive)
|
||||
{
|
||||
if (locationIds.size())
|
||||
{
|
||||
MessageActivateSourceLocations(locationIds).dispatch();
|
||||
}
|
||||
else if (tokenIds.size()) // fallback for links in project description
|
||||
{
|
||||
MessageActivateTokenIds(utility::toVector(tokenIds)).dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeArea::activateLocalSymbols(const std::vector<const Annotation*>& annotations)
|
||||
{
|
||||
std::vector<Id> localSymbolIds;
|
||||
|
||||
bool allActive = true;
|
||||
for (const Annotation* annotation : annotations)
|
||||
{
|
||||
if (annotation->locationType == LOCATION_LOCAL_SYMBOL)
|
||||
{
|
||||
if (!annotation->isActive)
|
||||
{
|
||||
allActive = false;
|
||||
}
|
||||
|
||||
if (annotation->tokenIds.size())
|
||||
{
|
||||
localSymbolIds.insert(localSymbolIds.end(), annotation->tokenIds.begin(), annotation->tokenIds.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!allActive || localSymbolIds.size())
|
||||
{
|
||||
MessageActivateLocalSymbols(localSymbolIds).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeArea::activateErrors(const std::vector<const Annotation*>& annotations)
|
||||
{
|
||||
std::vector<Id> errorIds;
|
||||
|
||||
@@ -100,8 +100,6 @@ private slots:
|
||||
void setIDECursorPosition();
|
||||
|
||||
private:
|
||||
void activateSourceLocations(const std::vector<const Annotation*>& annotations);
|
||||
void activateLocalSymbols(const std::vector<const Annotation*>& annotations);
|
||||
void activateErrors(const std::vector<const Annotation*>& annotations);
|
||||
|
||||
void annotateText();
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
#include "qt/utility/QtHighlighter.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||
#include "utility/messaging/type/MessageActivateSourceLocations.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenIds.h"
|
||||
#include "utility/messaging/type/MessageTooltipShow.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
std::vector<QtCodeField::AnnotationColor> QtCodeField::s_annotationColors;
|
||||
@@ -253,16 +256,7 @@ void QtCodeField::mouseReleaseEvent(QMouseEvent* event)
|
||||
return;
|
||||
}
|
||||
|
||||
std::set<Id> tokenIds;
|
||||
for (const Annotation* annotation : annotations)
|
||||
{
|
||||
tokenIds.insert(annotation->tokenIds.begin(), annotation->tokenIds.end());
|
||||
}
|
||||
|
||||
if (tokenIds.size())
|
||||
{
|
||||
MessageActivateTokenIds(utility::toVector(tokenIds)).dispatch();
|
||||
}
|
||||
activateAnnotations(annotations);
|
||||
}
|
||||
|
||||
void QtCodeField::focusTokenIds(const std::vector<Id>& tokenIds)
|
||||
@@ -353,7 +347,7 @@ void QtCodeField::createAnnotations(std::shared_ptr<SourceLocationFile> location
|
||||
locationFile->forEachSourceLocation(
|
||||
[&](const SourceLocation* location)
|
||||
{
|
||||
if (locationIds.find(location->getLocationId()) != locationIds.end())
|
||||
if (location->getLocationId() && locationIds.find(location->getLocationId()) != locationIds.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -409,6 +403,67 @@ void QtCodeField::createAnnotations(std::shared_ptr<SourceLocationFile> location
|
||||
);
|
||||
}
|
||||
|
||||
void QtCodeField::activateAnnotations(const std::vector<const Annotation*>& annotations)
|
||||
{
|
||||
std::vector<Id> locationIds;
|
||||
std::set<Id> tokenIds;
|
||||
std::set<Id> localSymbolIds;
|
||||
|
||||
bool allActive = true;
|
||||
for (const Annotation* annotation : annotations)
|
||||
{
|
||||
if (annotation->locationType == LOCATION_TOKEN)
|
||||
{
|
||||
if (!annotation->isActive)
|
||||
{
|
||||
allActive = false;
|
||||
}
|
||||
|
||||
if (annotation->locationId > 0)
|
||||
{
|
||||
locationIds.push_back(annotation->locationId);
|
||||
}
|
||||
|
||||
if (annotation->tokenIds.size())
|
||||
{
|
||||
tokenIds.insert(annotation->tokenIds.begin(), annotation->tokenIds.end());
|
||||
}
|
||||
}
|
||||
else if (annotation->locationType == LOCATION_LOCAL_SYMBOL)
|
||||
{
|
||||
if (!annotation->isActive)
|
||||
{
|
||||
allActive = false;
|
||||
}
|
||||
|
||||
if (annotation->tokenIds.size())
|
||||
{
|
||||
localSymbolIds.insert(annotation->tokenIds.begin(), annotation->tokenIds.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!allActive)
|
||||
{
|
||||
if (tokenIds.size() > 1 || localSymbolIds.size() > 1 || (tokenIds.size() && localSymbolIds.size()))
|
||||
{
|
||||
MessageTooltipShow(locationIds, utility::toVector(localSymbolIds), TOOLTIP_ORIGIN_CODE).dispatch();
|
||||
}
|
||||
else if (locationIds.size())
|
||||
{
|
||||
MessageActivateSourceLocations(locationIds).dispatch();
|
||||
}
|
||||
else if (tokenIds.size()) // fallback for links in project description
|
||||
{
|
||||
MessageActivateTokenIds(utility::toVector(tokenIds)).dispatch();
|
||||
}
|
||||
else if (localSymbolIds.size())
|
||||
{
|
||||
MessageActivateLocalSymbols(utility::toVector(localSymbolIds)).dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int QtCodeField::toTextEditPosition(int lineNumber, int columnNumber) const
|
||||
{
|
||||
lineNumber -= m_startLineNumber - 1;
|
||||
|
||||
@@ -83,6 +83,7 @@ protected:
|
||||
const std::set<Id>& activeSymbolIds, const std::set<Id>& activeLocationIds, const std::set<Id>& focusedSymbolIds);
|
||||
|
||||
void createAnnotations(std::shared_ptr<SourceLocationFile> locationFile);
|
||||
void activateAnnotations(const std::vector<const Annotation*>& annotations);
|
||||
|
||||
int toTextEditPosition(int lineNumber, int columnNumber) const;
|
||||
std::pair<int, int> toLineColumn(int textEditPosition) const;
|
||||
|
||||
Reference in New Issue
Block a user