logic: Fixed multiple active symbols broken on undo
* fixed undoing to multiple actives didn't show all nodes in graph * fixed wrong name in search bar, status message and history dropdown * fixed flicker when activating multiple nodes in code view
This commit is contained in:
@@ -98,7 +98,6 @@ add_files(
|
||||
component/NetworkFactory.cpp
|
||||
component/NetworkFactory.h
|
||||
|
||||
data/access/StorageAccess.cpp
|
||||
data/access/StorageAccess.h
|
||||
data/access/StorageAccessProxy.cpp
|
||||
data/access/StorageAccessProxy.h
|
||||
|
||||
@@ -185,7 +185,12 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
Id declarationId = 0; // 0 means that no token is found.
|
||||
if (!message->isAggregation)
|
||||
{
|
||||
params.activeTokenIds = m_storageAccess->getActiveTokenIdsForId(params.activeTokenIds[0], &declarationId);
|
||||
std::vector<Id> activeTokenIds;
|
||||
for (Id tokenId : params.activeTokenIds)
|
||||
{
|
||||
utility::append(activeTokenIds, m_storageAccess->getActiveTokenIdsForId(tokenId, &declarationId));
|
||||
}
|
||||
params.activeTokenIds = activeTokenIds;
|
||||
}
|
||||
|
||||
if (message->isEdge)
|
||||
@@ -213,12 +218,11 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
size_t fileCount = m_collection->getSourceLocationFileCount();
|
||||
size_t referenceCount = m_collection->getSourceLocationCount();
|
||||
|
||||
std::wstring status = L"";
|
||||
|
||||
std::vector<NameHierarchy> tokenNames = message->getTokenNamesOfMatches();
|
||||
if (tokenNames.size())
|
||||
std::wstring status;
|
||||
for (const SearchMatch& match : message->getSearchMatches())
|
||||
{
|
||||
status += L"Activate \"" + tokenNames[0].getQualifiedName() + L"\": ";
|
||||
status += L"Activate \"" + match.name + L"\": ";
|
||||
break;
|
||||
}
|
||||
|
||||
status += std::to_wstring(message->tokenIds.size()) + L" ";
|
||||
|
||||
@@ -481,11 +481,10 @@ void UndoRedoController::replayCommand(std::list<Command>::iterator it)
|
||||
|
||||
if (!msg->isEdge && !msg->isAggregation)
|
||||
{
|
||||
std::pair<std::vector<Id>, std::vector<SearchMatch>> ret =
|
||||
m_storageAccess->getNodeIdsAndSearchMatchesForNameHierarchies(msg->getTokenNamesOfMatches());
|
||||
|
||||
msg->tokenIds = ret.first;
|
||||
msg->searchMatches = ret.second;
|
||||
for (SearchMatch& match : msg->getSearchMatches())
|
||||
{
|
||||
match.tokenIds = m_storageAccess->getNodeIdsForNameHierarchies(match.tokenNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m->getType() == MessageActivateErrors::getStaticType())
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#include "StorageAccess.h"
|
||||
|
||||
std::pair<std::vector<Id>, std::vector<SearchMatch>> StorageAccess::getNodeIdsAndSearchMatchesForNameHierarchies(
|
||||
const std::vector<NameHierarchy> nameHierarchies) const
|
||||
{
|
||||
std::vector<Id> tokenIds = getNodeIdsForNameHierarchies(nameHierarchies);
|
||||
std::vector<SearchMatch> matches;
|
||||
|
||||
if (tokenIds.size())
|
||||
{
|
||||
matches = getSearchMatchesForTokenIds(tokenIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const NameHierarchy& name : nameHierarchies)
|
||||
{
|
||||
matches.push_back(SearchMatch(name.getQualifiedName()));
|
||||
}
|
||||
|
||||
if (!matches.size())
|
||||
{
|
||||
matches.push_back(SearchMatch(L"<invalid>"));
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(tokenIds, matches);
|
||||
}
|
||||
@@ -106,9 +106,6 @@ public:
|
||||
virtual TooltipInfo getTooltipInfoForTokenIds(const std::vector<Id>& tokenIds, TooltipOrigin origin) const = 0;
|
||||
virtual TooltipInfo getTooltipInfoForSourceLocationIdsAndLocalSymbolIds(
|
||||
const std::vector<Id>& locationIds, const std::vector<Id>& localSymbolIds) const = 0;
|
||||
|
||||
std::pair<std::vector<Id>, std::vector<SearchMatch>> getNodeIdsAndSearchMatchesForNameHierarchies(
|
||||
const std::vector<NameHierarchy> nameHierarchies) const;
|
||||
};
|
||||
|
||||
#endif // STORAGE_ACCESS_H
|
||||
|
||||
@@ -103,12 +103,12 @@ SearchMatch::SearchMatch()
|
||||
SearchMatch::SearchMatch(const std::wstring& query)
|
||||
: name(query)
|
||||
, text(query)
|
||||
, tokenName(query, NAME_DELIMITER_UNKNOWN)
|
||||
, typeName(L"")
|
||||
, nodeType(NodeType::NODE_SYMBOL)
|
||||
, searchType(SEARCH_NONE)
|
||||
, hasChildren(false)
|
||||
{
|
||||
tokenNames.emplace_back(query, NAME_DELIMITER_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ struct SearchMatch
|
||||
std::wstring subtext;
|
||||
|
||||
std::vector<Id> tokenIds;
|
||||
NameHierarchy tokenName;
|
||||
std::vector<NameHierarchy> tokenNames;
|
||||
|
||||
NameDelimiterType delimiter;
|
||||
|
||||
|
||||
@@ -652,10 +652,10 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(const std::
|
||||
{
|
||||
lastMatch = &match;
|
||||
}
|
||||
else if (lastMatch->score == match.score)
|
||||
else if (lastMatch->score == match.score && match.tokenNames.size())
|
||||
{
|
||||
size_t lastSize = lastMatch->name.size();
|
||||
if (match.name.find(nameDelimiterTypeToString(match.tokenName.getDelimiter()), lastSize) == lastSize)
|
||||
if (match.name.find(nameDelimiterTypeToString(match.tokenNames[0].getDelimiter()), lastSize) == lastSize)
|
||||
{
|
||||
match.score -= 10;
|
||||
}
|
||||
@@ -721,7 +721,10 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(
|
||||
{
|
||||
if (elementId != 0)
|
||||
{
|
||||
StorageNode* node = &storageNodeMap[elementId];
|
||||
|
||||
match.tokenIds.push_back(elementId);
|
||||
match.tokenNames.push_back(NameHierarchy::deserialize(node->serializedName));
|
||||
|
||||
if (!match.hasChildren && acceptedNodeTypes == NodeTypeSet::all()) // TODO: check if node types of children match
|
||||
{
|
||||
@@ -730,11 +733,16 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(
|
||||
|
||||
if (!firstNode)
|
||||
{
|
||||
firstNode = &storageNodeMap[elementId];
|
||||
firstNode = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!firstNode)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
match.name = result.text;
|
||||
match.text = result.text;
|
||||
|
||||
@@ -749,7 +757,6 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(
|
||||
}
|
||||
}
|
||||
|
||||
match.tokenName = name;
|
||||
match.indices = result.indices;
|
||||
match.score = result.score;
|
||||
match.nodeType = NodeType::intToType(firstNode->type);
|
||||
@@ -788,13 +795,14 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionFileMatches(const s
|
||||
match.subtext = match.name;
|
||||
|
||||
match.tokenIds = result.elementIds;
|
||||
if (match.tokenIds.size())
|
||||
for (Id tokenId : match.tokenIds)
|
||||
{
|
||||
match.tokenName = NameHierarchy(getFileNodePath(match.tokenIds[0]).wstr(), NAME_DELIMITER_FILE);
|
||||
match.tokenNames.push_back(NameHierarchy(getFileNodePath(tokenId).wstr(), NAME_DELIMITER_FILE));
|
||||
}
|
||||
else
|
||||
|
||||
if (!match.tokenNames.size())
|
||||
{
|
||||
match.tokenName = NameHierarchy(match.name, NAME_DELIMITER_FILE);
|
||||
match.tokenNames.push_back(NameHierarchy(match.name, NAME_DELIMITER_FILE));
|
||||
}
|
||||
|
||||
match.indices = result.indices;
|
||||
@@ -878,7 +886,7 @@ std::vector<SearchMatch> PersistentStorage::getSearchMatchesForTokenIds(const st
|
||||
match.text = nameHierarchy.getRawName();
|
||||
|
||||
match.tokenIds.push_back(elementId);
|
||||
match.tokenName = nameHierarchy;
|
||||
match.tokenNames.push_back(nameHierarchy);
|
||||
match.nodeType = NodeType::intToType(node.type);
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
|
||||
@@ -35,7 +35,10 @@ public:
|
||||
|
||||
for (const SearchMatch& match : searchMatches)
|
||||
{
|
||||
os << match.tokenName.getQualifiedName() << L" ";
|
||||
for (const NameHierarchy& name : match.tokenNames)
|
||||
{
|
||||
os << name.getQualifiedName() << L" ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,16 +56,6 @@ public:
|
||||
return searchMatches;
|
||||
}
|
||||
|
||||
std::vector<NameHierarchy> getTokenNamesOfMatches() const
|
||||
{
|
||||
std::vector<NameHierarchy> tokenNames;
|
||||
for (const SearchMatch& match : searchMatches)
|
||||
{
|
||||
tokenNames.push_back(match.tokenName);
|
||||
}
|
||||
return tokenNames;
|
||||
}
|
||||
|
||||
std::vector<Id> tokenIds;
|
||||
std::vector<SearchMatch> searchMatches;
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@ public:
|
||||
for (const SearchMatch& match : m_matches)
|
||||
{
|
||||
os << " @" << match.name;
|
||||
for (Id id : match.tokenIds)
|
||||
{
|
||||
os << ' ' << id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ void QtCodeFileList::clear()
|
||||
{
|
||||
for (QtCodeFile* file : m_files)
|
||||
{
|
||||
file->hide();
|
||||
file->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@@ -190,10 +190,10 @@ bool QtSmartSearchBox::event(QEvent *event)
|
||||
{
|
||||
addMatchAndUpdate(m_highlightedMatch);
|
||||
}
|
||||
else if (m_highlightedMatch.hasChildren)
|
||||
else if (m_highlightedMatch.hasChildren && m_highlightedMatch.tokenNames.size())
|
||||
{
|
||||
setEditText(QString::fromStdWString(
|
||||
m_highlightedMatch.getFullName() + nameDelimiterTypeToString(m_highlightedMatch.tokenName.getDelimiter())));
|
||||
m_highlightedMatch.getFullName() + nameDelimiterTypeToString(m_highlightedMatch.tokenNames[0].getDelimiter())));
|
||||
requestAutoCompletions();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -131,7 +131,6 @@ void QtCodeView::showCodeSnippets(const std::vector<CodeSnippetParams>& snippets
|
||||
if (snippet.isCollapsed)
|
||||
{
|
||||
m_widget->addFile(snippet.locationFile, snippet.refCount, snippet.modificationTime);
|
||||
|
||||
addedFiles = true;
|
||||
}
|
||||
else
|
||||
@@ -162,6 +161,11 @@ void QtCodeView::updateCodeSnippets(const std::vector<CodeSnippetParams>& snippe
|
||||
|
||||
for (const CodeSnippetParams& snippet : snippets)
|
||||
{
|
||||
if (!snippet.locationFile || snippet.isCollapsed || snippet.reduced)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_widget->updateCodeSnippet(snippet);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user