logic: replace template arguments with .. in non-indexed nodes to reduce clutter in search results
This commit is contained in:
@@ -684,10 +684,13 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(
|
||||
match.name = result.text;
|
||||
match.text = result.text;
|
||||
|
||||
const size_t idx = m_hierarchyCache.getIndexOfLastVisibleParentNode(firstNode->id);
|
||||
const NameHierarchy& name = NameHierarchy::deserialize(firstNode->serializedName);
|
||||
match.text = name.getRange(idx, name.size()).getQualifiedName();
|
||||
match.subtext = name.getRange(0, idx).getQualifiedName();
|
||||
NameHierarchy name = NameHierarchy::deserialize(firstNode->serializedName);
|
||||
if (name.getQualifiedName() == match.name)
|
||||
{
|
||||
const size_t idx = m_hierarchyCache.getIndexOfLastVisibleParentNode(firstNode->id);
|
||||
match.text = name.getRange(idx, name.size()).getQualifiedName();
|
||||
match.subtext = name.getRange(0, idx).getQualifiedName();
|
||||
}
|
||||
|
||||
match.delimiter = name.getDelimiter();
|
||||
|
||||
@@ -2484,8 +2487,19 @@ void PersistentStorage::buildSearchIndex()
|
||||
auto it = m_symbolDefinitionKinds.find(node.id);
|
||||
if (it == m_symbolDefinitionKinds.end() || it->second != DEFINITION_IMPLICIT)
|
||||
{
|
||||
NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
|
||||
// we don't use the signature here, so elements with the same signature share the same node.
|
||||
m_symbolIndex.addNode(node.id, NameHierarchy::deserialize(node.serializedName).getQualifiedName());
|
||||
std::string name = nameHierarchy.getQualifiedName();
|
||||
|
||||
// replace template arguments with .. to avoid clutter in search results and have different
|
||||
// template specializations share the same node.
|
||||
if (it->second == DEFINITION_NONE && nameHierarchy.getDelimiter() == NAME_DELIMITER_CXX)
|
||||
{
|
||||
name = utility::replaceBetween(name, '<', '>', "..");
|
||||
}
|
||||
|
||||
m_symbolIndex.addNode(node.id, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef TRACING_H
|
||||
#define TRACING_H
|
||||
|
||||
|
||||
// #define TRACING_ENABLED
|
||||
|
||||
|
||||
#include <mutex>
|
||||
#include <stack>
|
||||
#include <thread>
|
||||
@@ -67,8 +71,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// #define TRACING_ENABLED
|
||||
|
||||
#ifdef TRACING_ENABLED
|
||||
#define TRACE(__name__) \
|
||||
ScopedTrace __trace__(std::string(__name__), __FILE__, __LINE__, __FUNCTION__)
|
||||
|
||||
@@ -215,6 +215,38 @@ namespace utility
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string replaceBetween(const std::string& str, char startDelimiter, char endDelimiter, const std::string& to)
|
||||
{
|
||||
size_t startPos = str.find(startDelimiter);
|
||||
if (startPos == std::string::npos)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
size_t depth = 1;
|
||||
|
||||
for (size_t pos = startPos + 1; pos < str.size(); pos++)
|
||||
{
|
||||
if (str[pos] == endDelimiter && depth)
|
||||
{
|
||||
depth--;
|
||||
|
||||
if (depth == 0)
|
||||
{
|
||||
std::string end = replaceBetween(str.substr(pos + 1), startDelimiter, endDelimiter, to);
|
||||
return str.substr(0, startPos) + startDelimiter + to + endDelimiter + end;
|
||||
}
|
||||
}
|
||||
|
||||
if (str[pos] == startDelimiter)
|
||||
{
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string insertLineBreaksAtBlankSpaces(const std::string& s, size_t maxLineLength)
|
||||
{
|
||||
const std::vector<std::string> atoms = splitToVector(s, " ");
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace utility
|
||||
bool equalsCaseInsensitive(const std::string& a, const std::string& b);
|
||||
|
||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||
std::string replaceBetween(const std::string& str, char startDelimiter, char endDelimiter, const std::string& to);
|
||||
|
||||
std::string insertLineBreaksAtBlankSpaces(const std::string& s, size_t maxLineLength);
|
||||
std::string breakSignature(
|
||||
|
||||
Reference in New Issue
Block a user