diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 12dfd435..3a1b4689 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -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 diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index 8db7a7e0..9a926f70 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -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 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 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" "; diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index 18493f8a..798a04e1 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -481,11 +481,10 @@ void UndoRedoController::replayCommand(std::list::iterator it) if (!msg->isEdge && !msg->isAggregation) { - std::pair, std::vector> 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()) diff --git a/src/lib/data/access/StorageAccess.cpp b/src/lib/data/access/StorageAccess.cpp deleted file mode 100644 index 2337fd7e..00000000 --- a/src/lib/data/access/StorageAccess.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "StorageAccess.h" - -std::pair, std::vector> StorageAccess::getNodeIdsAndSearchMatchesForNameHierarchies( - const std::vector nameHierarchies) const -{ - std::vector tokenIds = getNodeIdsForNameHierarchies(nameHierarchies); - std::vector 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"")); - } - } - - return std::make_pair(tokenIds, matches); -} diff --git a/src/lib/data/access/StorageAccess.h b/src/lib/data/access/StorageAccess.h index 1990fa65..5ecb6ccb 100644 --- a/src/lib/data/access/StorageAccess.h +++ b/src/lib/data/access/StorageAccess.h @@ -106,9 +106,6 @@ public: virtual TooltipInfo getTooltipInfoForTokenIds(const std::vector& tokenIds, TooltipOrigin origin) const = 0; virtual TooltipInfo getTooltipInfoForSourceLocationIdsAndLocalSymbolIds( const std::vector& locationIds, const std::vector& localSymbolIds) const = 0; - - std::pair, std::vector> getNodeIdsAndSearchMatchesForNameHierarchies( - const std::vector nameHierarchies) const; }; #endif // STORAGE_ACCESS_H diff --git a/src/lib/data/search/SearchMatch.cpp b/src/lib/data/search/SearchMatch.cpp index 8a043336..1624ef64 100644 --- a/src/lib/data/search/SearchMatch.cpp +++ b/src/lib/data/search/SearchMatch.cpp @@ -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); } diff --git a/src/lib/data/search/SearchMatch.h b/src/lib/data/search/SearchMatch.h index d39ba079..bbbb25ef 100644 --- a/src/lib/data/search/SearchMatch.h +++ b/src/lib/data/search/SearchMatch.h @@ -65,7 +65,7 @@ struct SearchMatch std::wstring subtext; std::vector tokenIds; - NameHierarchy tokenName; + std::vector tokenNames; NameDelimiterType delimiter; diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 140f2c41..aa9e692d 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -652,10 +652,10 @@ std::vector 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 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 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 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 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 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; diff --git a/src/lib/utility/messaging/type/MessageActivateTokens.h b/src/lib/utility/messaging/type/MessageActivateTokens.h index ff5e2168..5c6bebae 100644 --- a/src/lib/utility/messaging/type/MessageActivateTokens.h +++ b/src/lib/utility/messaging/type/MessageActivateTokens.h @@ -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 getTokenNamesOfMatches() const - { - std::vector tokenNames; - for (const SearchMatch& match : searchMatches) - { - tokenNames.push_back(match.tokenName); - } - return tokenNames; - } - std::vector tokenIds; std::vector searchMatches; diff --git a/src/lib/utility/messaging/type/MessageSearch.h b/src/lib/utility/messaging/type/MessageSearch.h index cffff4ac..11f908d7 100644 --- a/src/lib/utility/messaging/type/MessageSearch.h +++ b/src/lib/utility/messaging/type/MessageSearch.h @@ -31,6 +31,10 @@ public: for (const SearchMatch& match : m_matches) { os << " @" << match.name; + for (Id id : match.tokenIds) + { + os << ' ' << id; + } } } diff --git a/src/lib_gui/qt/element/QtCodeFileList.cpp b/src/lib_gui/qt/element/QtCodeFileList.cpp index 2d0e2de1..83c7967e 100644 --- a/src/lib_gui/qt/element/QtCodeFileList.cpp +++ b/src/lib_gui/qt/element/QtCodeFileList.cpp @@ -74,6 +74,7 @@ void QtCodeFileList::clear() { for (QtCodeFile* file : m_files) { + file->hide(); file->deleteLater(); } diff --git a/src/lib_gui/qt/element/QtSmartSearchBox.cpp b/src/lib_gui/qt/element/QtSmartSearchBox.cpp index 2ec9c5db..cb0c5071 100644 --- a/src/lib_gui/qt/element/QtSmartSearchBox.cpp +++ b/src/lib_gui/qt/element/QtSmartSearchBox.cpp @@ -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 diff --git a/src/lib_gui/qt/view/QtCodeView.cpp b/src/lib_gui/qt/view/QtCodeView.cpp index 788b7253..7d8564bc 100644 --- a/src/lib_gui/qt/view/QtCodeView.cpp +++ b/src/lib_gui/qt/view/QtCodeView.cpp @@ -131,7 +131,6 @@ void QtCodeView::showCodeSnippets(const std::vector& 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& snippe for (const CodeSnippetParams& snippet : snippets) { + if (!snippet.locationFile || snippet.isCollapsed || snippet.reduced) + { + continue; + } + m_widget->updateCodeSnippet(snippet); } });