logic: fulltextsearch with suffixarray

* delete test.sqlite in storagetestsuite in desstructor
* remove new and delete from suffixarray
* case sensitive fts
* fixed fulltext results annotated like errors
* lazy suffix array building
* fulltextsearch folder added
* go back too branch without _publish
* suffixarray working
* logic: Improved code view performance
This commit is contained in:
Andreas Stallinger
2016-06-07 08:49:34 +02:00
parent 53120cf270
commit 6edcd77eb2
25 changed files with 602 additions and 258 deletions
@@ -241,7 +241,9 @@ void CodeController::handleMessage(MessageShowErrors* message)
void CodeController::handleMessage(MessageSearchFullText* message)
{
CodeView* view = getView();
std::vector<CodeSnippetParams> snippets = getSnippetsForFullTextSearch(message->searchTerm);
view->setErrorInfos(std::vector<ErrorInfo>());
std::vector<CodeSnippetParams> snippets = getSnippetsForFullTextSearch(message->searchTerm, message->caseSensitive);
view->showCodeSnippets(snippets, std::vector<Id>());
showContents(message);
@@ -603,23 +605,32 @@ std::shared_ptr<TokenLocationFile> CodeController::getTokenLocationOfParentScope
return file;
}
std::vector<CodeSnippetParams> CodeController::getSnippetsForFullTextSearch(
const std::string& searchTerm) const
const std::string& searchTerm, bool caseSensitive) const
{
std::shared_ptr<TokenLocationCollection> collection =
m_storageAccess->getFullTextSearchLocations(searchTerm);
m_storageAccess->getFullTextSearchLocations(searchTerm, caseSensitive);
std::vector<CodeSnippetParams> snippets;
snippets.reserve(collection->getTokenLocationFileCount());
collection->forEachTokenLocationFile(
[&](std::shared_ptr<TokenLocationFile> file) -> void
{
//CodeSnippetParams params;
//params.locationFile = file;
//params.startLineNumber = 1;
//std::shared_ptr<TextAccess> textAccess = m_storageAccess->getFileContent(file->getFilePath());
//params.code = textAccess->getText();
//snippets.push_back(params);
//if (snippets.size() < 10)
{
//{
std::vector<CodeSnippetParams> fileSnippets = getSnippetsForFile(file);
snippets.insert(snippets.end(), fileSnippets.begin(), fileSnippets.end());
}
//}
//else
//{
//CodeSnippetParams params;
@@ -69,7 +69,7 @@ private:
std::vector<CodeSnippetParams> getSnippetsForFile(
std::shared_ptr<TokenLocationFile> activeTokenLocations, std::shared_ptr<TokenLocationFile> fileLocations) const;
std::vector<CodeSnippetParams> getSnippetsForFile(std::shared_ptr<TokenLocationFile> file) const;
std::vector<CodeSnippetParams> getSnippetsForFullTextSearch(const std::string& searchTerm) const;
std::vector<CodeSnippetParams> getSnippetsForFullTextSearch(const std::string& searchTerm, bool caseSensitive) const;
std::shared_ptr<SnippetMerger> buildMergerHierarchy(
TokenLocation* location, std::shared_ptr<TokenLocationFile> context, SnippetMerger& fileScopedMerger, std::map<int, std::shared_ptr<SnippetMerger>>& mergers) const;
std::shared_ptr<TokenLocationFile> getTokenLocationOfParentScope(const TokenLocation* location, std::shared_ptr<TokenLocationFile> context) const;
@@ -59,7 +59,12 @@ void SearchController::handleMessage(MessageSearchAutocomplete* message)
void SearchController::handleMessage(MessageSearchFullText* message)
{
LOG_INFO("fulltext string: \"" + message->searchTerm + "\"");
SearchMatch match("@" + message->searchTerm);
std::string prefix = "@";
if (message->caseSensitive)
{
prefix += "@";
}
SearchMatch match(prefix + message->searchTerm);
getView()->setMatches(std::vector<SearchMatch>(1, match));
}