logic: random fixes and improvements
* added new logos to setup ui * changed wording in status messages and bundle nodes * removed ununsed Vector.h * save NameHierarchy to SearchMatch * fixed NameHierarchyElement retrieval for name elements without parent * fixed match weight to score last letters higher
This commit is contained in:
@@ -497,7 +497,7 @@ Id SqliteStorage::getNameHierarchyElementIdByName(const std::string& name, Id pa
|
||||
else
|
||||
{
|
||||
return getFirstResult<Id>(
|
||||
"SELECT id FROM name_hierarchy_element WHERE name == '" + name + "';"
|
||||
"SELECT id FROM name_hierarchy_element WHERE name == '" + name + "' AND parent_id IS NULL;"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -540,14 +540,22 @@ NameHierarchy SqliteStorage::getNameHierarchyById(const Id id) const
|
||||
"SELECT name, parent_id FROM name_hierarchy_element WHERE id == " + std::to_string(id) + ";"
|
||||
).c_str());
|
||||
|
||||
const std::string elementName = q.getStringField(0, "");
|
||||
const Id parentId = q.getIntField(1, 0);
|
||||
NameHierarchy nameHierarchy;
|
||||
|
||||
NameHierarchy nameHierarchy = (parentId > 0) ? getNameHierarchyById(parentId) : NameHierarchy();
|
||||
|
||||
if (elementName.size() > 0)
|
||||
if (!q.eof())
|
||||
{
|
||||
nameHierarchy.push(std::make_shared<NameElement>(elementName));
|
||||
const std::string elementName = q.getStringField(0, "");
|
||||
const Id parentId = q.getIntField(1, 0);
|
||||
|
||||
if (parentId > 0)
|
||||
{
|
||||
nameHierarchy = getNameHierarchyById(parentId);
|
||||
}
|
||||
|
||||
if (elementName.size() > 0)
|
||||
{
|
||||
nameHierarchy.push(std::make_shared<NameElement>(elementName));
|
||||
}
|
||||
}
|
||||
|
||||
return nameHierarchy;
|
||||
|
||||
+13
-35
@@ -719,14 +719,7 @@ Id Storage::getIdForNodeWithNameHierarchy(const NameHierarchy& nameHierarchy) co
|
||||
|
||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
||||
{
|
||||
Id parentId = currentId;
|
||||
currentId = m_sqliteStorage.getNameHierarchyElementIdByName(nameHierarchy[i]->getFullName(), parentId);
|
||||
|
||||
if (currentId == 0)
|
||||
{
|
||||
currentId = parentId;
|
||||
break;
|
||||
}
|
||||
currentId = m_sqliteStorage.getNameHierarchyElementIdByName(nameHierarchy[i]->getFullName(), currentId);
|
||||
}
|
||||
|
||||
return m_sqliteStorage.getNodeByNameId(currentId).id;
|
||||
@@ -799,16 +792,11 @@ std::vector<SearchMatch> Storage::getSearchMatchesForTokenIds(const std::vector<
|
||||
|
||||
if (m_sqliteStorage.isFile(tokenId))
|
||||
{
|
||||
StorageFile file = m_sqliteStorage.getFileById(tokenId);
|
||||
|
||||
match.fullName = m_tokenIndex.getNameHierarchyForTokenId(tokenId).getFullName();
|
||||
match.nodeType = Node::NODE_FILE;
|
||||
}
|
||||
else if (m_sqliteStorage.isNode(tokenId))
|
||||
{
|
||||
StorageNode node = m_sqliteStorage.getNodeById(tokenId);
|
||||
|
||||
match.fullName = m_tokenIndex.getNameHierarchyForTokenId(tokenId).getFullName();
|
||||
match.nodeType = Node::intToType(node.type);
|
||||
}
|
||||
else
|
||||
@@ -817,6 +805,7 @@ std::vector<SearchMatch> Storage::getSearchMatchesForTokenIds(const std::vector<
|
||||
}
|
||||
|
||||
match.tokenIds.insert(tokenId);
|
||||
match.nameHierarchy = m_tokenIndex.getNameHierarchyForTokenId(tokenId);
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
matches.push_back(match);
|
||||
@@ -954,13 +943,8 @@ std::vector<Id> Storage::getTokenIdsForMatches(const std::vector<SearchMatch>& m
|
||||
std::set<Id> idSet;
|
||||
for (const SearchMatch& match : matches)
|
||||
{
|
||||
std::vector<SearchMatch> ms = getAutocompletionMatches("", match.fullName);
|
||||
|
||||
for (size_t i = 0; i < ms.size(); i++)
|
||||
{
|
||||
utility::append(idSet, ms[i].tokenIds);
|
||||
break;
|
||||
}
|
||||
SearchNode* searchNode = m_tokenIndex.getNode(match.nameHierarchy);
|
||||
utility::append(idSet, searchNode->getTokenIds());
|
||||
}
|
||||
|
||||
std::vector<Id> ids;
|
||||
@@ -1187,25 +1171,22 @@ std::shared_ptr<TextAccess> Storage::getFileContent(const FilePath& filePath) co
|
||||
|
||||
Id Storage::addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, bool distinct)
|
||||
{
|
||||
addNameHierarchyElements(nameHierarchy);
|
||||
std::vector<Id> nameIds = addNameHierarchyElements(nameHierarchy);
|
||||
|
||||
Id parentNameHierarchyElementId = 0;
|
||||
Id parentNodeId = 0;
|
||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
||||
for (size_t i = 0; i < nameIds.size(); i++)
|
||||
{
|
||||
Id nameId = nameIds[i];
|
||||
bool lastName = (i == nameHierarchy.size() - 1);
|
||||
|
||||
Node::NodeType type = (lastName ? nodeType : Node::NODE_UNDEFINED);
|
||||
|
||||
Id nameHierarchyElementId =
|
||||
m_sqliteStorage.getNameHierarchyElementIdByName(nameHierarchy[i]->getFullName(), parentNameHierarchyElementId);
|
||||
|
||||
const StorageNode node = m_sqliteStorage.getNodeByNameId(nameHierarchyElementId);
|
||||
const StorageNode node = m_sqliteStorage.getNodeByNameId(nameId);
|
||||
Id nodeId = node.id;
|
||||
|
||||
if (nodeId == 0 || (lastName && distinct))
|
||||
{
|
||||
nodeId = m_sqliteStorage.addNode(Node::typeToInt(type), nameHierarchyElementId);
|
||||
nodeId = m_sqliteStorage.addNode(Node::typeToInt(type), nameId);
|
||||
|
||||
if (parentNodeId != 0)
|
||||
{
|
||||
@@ -1221,7 +1202,6 @@ Id Storage::addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarch
|
||||
}
|
||||
}
|
||||
|
||||
parentNameHierarchyElementId = nameHierarchyElementId;
|
||||
parentNodeId = nodeId;
|
||||
}
|
||||
|
||||
@@ -1242,8 +1222,9 @@ Id Storage::addNodeHierarchyWithDistinctSignature(Node::NodeType type, const Par
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
Id Storage::addNameHierarchyElements(NameHierarchy nameHierarchy)
|
||||
std::vector<Id> Storage::addNameHierarchyElements(NameHierarchy nameHierarchy)
|
||||
{
|
||||
std::vector<Id> nameIds;
|
||||
Id parentId = 0;
|
||||
bool nodeMayExist = true;
|
||||
|
||||
@@ -1256,10 +1237,6 @@ Id Storage::addNameHierarchyElements(NameHierarchy nameHierarchy)
|
||||
{
|
||||
nodeId = m_sqliteStorage.getNameHierarchyElementIdByName(elementName, parentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeId = 0;
|
||||
}
|
||||
|
||||
if (nodeId == 0)
|
||||
{
|
||||
@@ -1267,10 +1244,11 @@ Id Storage::addNameHierarchyElements(NameHierarchy nameHierarchy)
|
||||
nodeMayExist = false;
|
||||
}
|
||||
|
||||
nameIds.push_back(nodeId);
|
||||
parentId = nodeId;
|
||||
}
|
||||
|
||||
return parentId;
|
||||
return nameIds;
|
||||
}
|
||||
|
||||
int Storage::addSourceLocation(int elementNodeId, const ParseLocation& location, bool isScope)
|
||||
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
private:
|
||||
Id addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, bool distinct = false);
|
||||
Id addNodeHierarchyWithDistinctSignature(Node::NodeType type, const ParseFunction& function);
|
||||
Id addNameHierarchyElements(NameHierarchy nameHierarchy);
|
||||
std::vector<Id> addNameHierarchyElements(NameHierarchy nameHierarchy);
|
||||
int addSourceLocation(int elementNodeId, const ParseLocation& location, bool isScope = false);
|
||||
|
||||
Id addEdge(Id sourceNodeId, Id targetNodeId, Edge::EdgeType type);
|
||||
|
||||
@@ -45,12 +45,11 @@ void TaskCleanStorage::exit()
|
||||
ss << "clearing files done, ";
|
||||
ss << std::setprecision(2) << std::fixed << utility::duration(m_start) << " seconds";
|
||||
MessageStatus(ss.str()).dispatch();
|
||||
|
||||
}
|
||||
|
||||
void TaskCleanStorage::interrupt()
|
||||
{
|
||||
MessageStatus("Clearing file interrupted", false, true).dispatch();
|
||||
MessageStatus("clearing files interrupted", false, true).dispatch();
|
||||
}
|
||||
|
||||
void TaskCleanStorage::revert()
|
||||
|
||||
@@ -63,7 +63,7 @@ Task::TaskState TaskParseCxx::update()
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "parsing (ESC to quit): [";
|
||||
ss << "analyzing files (ESC to quit): [";
|
||||
ss << fileRegister->getParsedFilesCount() << "/" << fileRegister->getFilesCount() << "] ";
|
||||
ss << sourcePath;
|
||||
|
||||
@@ -85,7 +85,7 @@ Task::TaskState TaskParseCxx::update()
|
||||
|
||||
void TaskParseCxx::exit()
|
||||
{
|
||||
MessageStatus("Building search index").dispatch();
|
||||
MessageStatus("building search index").dispatch();
|
||||
|
||||
m_client->finishParsing();
|
||||
|
||||
@@ -101,6 +101,7 @@ void TaskParseCxx::exit()
|
||||
|
||||
void TaskParseCxx::interrupt()
|
||||
{
|
||||
MessageStatus("analyzing files interrupted", false, true).dispatch();
|
||||
}
|
||||
|
||||
void TaskParseCxx::revert()
|
||||
|
||||
@@ -79,6 +79,18 @@ SearchNode* SearchIndex::addNode(NameHierarchy nameHierarchy)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SearchNode* SearchIndex::getNode(const NameHierarchy& nameHierarchy) const
|
||||
{
|
||||
std::deque<Id> nameIds = m_dictionary.getWordIdsConst(nameHierarchy);
|
||||
|
||||
if (nameIds.size())
|
||||
{
|
||||
return m_root.getNodeRecursive(&nameIds).get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SearchNode* SearchIndex::getNode(const std::string& fullName) const
|
||||
{
|
||||
std::deque<Id> nameIds = m_dictionary.getWordIdsConst(fullName, DELIMITER);
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
const std::string& getWord(Id wordId) const;
|
||||
|
||||
SearchNode* addNode(NameHierarchy nameHierarchy);
|
||||
SearchNode* getNode(const NameHierarchy& nameHierarchy) const;
|
||||
SearchNode* getNode(const std::string& fullName) const;
|
||||
SearchNode* getNode(const SearchNode* searchNode) const;
|
||||
|
||||
|
||||
@@ -38,21 +38,20 @@ std::string SearchMatch::searchMatchesToString(const std::vector<SearchMatch>& m
|
||||
|
||||
for (size_t i = 0; i < matches.size(); i++)
|
||||
{
|
||||
ss << '@' << matches[i].fullName;
|
||||
ss << '@' << matches[i].getFullName();
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
SearchMatch::SearchMatch()
|
||||
: fullName("")
|
||||
, typeName("")
|
||||
: typeName("")
|
||||
, searchType(SEARCH_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
SearchMatch::SearchMatch(const std::string& query)
|
||||
: fullName(query)
|
||||
: nameHierarchy(query)
|
||||
, typeName("")
|
||||
, searchType(SEARCH_NONE)
|
||||
{
|
||||
@@ -65,7 +64,7 @@ bool SearchMatch::isValid() const
|
||||
|
||||
void SearchMatch::print(std::ostream& ostream) const
|
||||
{
|
||||
ostream << weight << '\t' << fullName << std::endl << '\t';
|
||||
ostream << weight << '\t' << nameHierarchy.getFullName() << std::endl << '\t';
|
||||
size_t i = 0;
|
||||
for (size_t index : indices)
|
||||
{
|
||||
@@ -80,6 +79,11 @@ void SearchMatch::print(std::ostream& ostream) const
|
||||
ostream << std::endl;
|
||||
}
|
||||
|
||||
std::string SearchMatch::getFullName() const
|
||||
{
|
||||
return nameHierarchy.getFullName();
|
||||
}
|
||||
|
||||
std::string SearchMatch::getNodeTypeAsString() const
|
||||
{
|
||||
return Node::getTypeString(nodeType);
|
||||
|
||||
@@ -31,10 +31,11 @@ struct SearchMatch
|
||||
|
||||
void print(std::ostream& ostream) const;
|
||||
|
||||
std::string getFullName() const;
|
||||
std::string getNodeTypeAsString() const;
|
||||
std::string getSearchTypeName() const;
|
||||
|
||||
std::string fullName;
|
||||
NameHierarchy nameHierarchy;
|
||||
std::string typeName;
|
||||
|
||||
Node::NodeType nodeType;
|
||||
|
||||
@@ -255,7 +255,7 @@ void SearchNode::removeSearchNode(SearchNode* node)
|
||||
SearchMatch SearchNode::fuzzyMatchData(const std::string& query, const SearchNode* parent) const
|
||||
{
|
||||
SearchMatch data;
|
||||
data.fullName = getFullName();
|
||||
data.nameHierarchy = getNameHierarchy();
|
||||
data.tokenIds = m_tokenIds;
|
||||
data.weight = 0;
|
||||
|
||||
@@ -364,7 +364,7 @@ std::pair<size_t, size_t> SearchNode::fuzzyMatch(
|
||||
weight += 20;
|
||||
}
|
||||
|
||||
if (last == '_' || next == '_')
|
||||
if (last == '_' || next == '_' || next == '\0')
|
||||
{
|
||||
weight += 20;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user