logic: Fixed single file mode fulltext references and caching
This commit is contained in:
@@ -311,6 +311,7 @@ void CodeController::handleMessage(MessageShowErrors* message)
|
|||||||
params.clearSnippets = true;
|
params.clearSnippets = true;
|
||||||
params.errorInfos = errors;
|
params.errorInfos = errors;
|
||||||
params.showContents = !message->isReplayed();
|
params.showContents = !message->isReplayed();
|
||||||
|
params.useSingleFileCache = false;
|
||||||
|
|
||||||
showCodeSnippets(snippets, params, false);
|
showCodeSnippets(snippets, params, false);
|
||||||
}
|
}
|
||||||
@@ -335,6 +336,7 @@ void CodeController::handleMessage(MessageSearchFullText* message)
|
|||||||
CodeView::CodeParams params;
|
CodeView::CodeParams params;
|
||||||
params.clearSnippets = true;
|
params.clearSnippets = true;
|
||||||
params.showContents = !message->isReplayed();
|
params.showContents = !message->isReplayed();
|
||||||
|
params.useSingleFileCache = false;
|
||||||
|
|
||||||
showCodeSnippets(getSnippetsForCollection(m_collection), params);
|
showCodeSnippets(getSnippetsForCollection(m_collection), params);
|
||||||
}
|
}
|
||||||
@@ -413,7 +415,10 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFileWithState(
|
|||||||
|
|
||||||
params.modificationTime = m_storageAccess->getFileInfoForFilePath(filePath).lastWriteTime;
|
params.modificationTime = m_storageAccess->getFileInfoForFilePath(filePath).lastWriteTime;
|
||||||
|
|
||||||
params.locationFile = m_collection->getSourceLocationFileByPath(filePath);
|
// make a copy of SourceLocationFile so that isWhole flag is different for first snippet adding the file
|
||||||
|
// and second snippet adding the content
|
||||||
|
params.locationFile =
|
||||||
|
std::make_shared<SourceLocationFile>(*m_collection->getSourceLocationFileByPath(filePath).get());
|
||||||
if (params.locationFile)
|
if (params.locationFile)
|
||||||
{
|
{
|
||||||
params.locationFile->setIsWhole(true);
|
params.locationFile->setIsWhole(true);
|
||||||
@@ -714,7 +719,7 @@ std::vector<std::string> CodeController::getProjectDescription(SourceLocationFil
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeController::expandVisibleSnippets(std::vector<CodeSnippetParams>* snippets) const
|
void CodeController::expandVisibleSnippets(std::vector<CodeSnippetParams>* snippets, bool useSingleFileCache) const
|
||||||
{
|
{
|
||||||
TRACE();
|
TRACE();
|
||||||
|
|
||||||
@@ -736,7 +741,7 @@ void CodeController::expandVisibleSnippets(std::vector<CodeSnippetParams>* snipp
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inListMode && getView()->hasSingleFileCached(oldSnippet.locationFile->getFilePath()))
|
if (useSingleFileCache && !inListMode && getView()->hasSingleFileCached(oldSnippet.locationFile->getFilePath()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -835,7 +840,7 @@ void CodeController::saveOrRestoreViewMode(MessageBase* message)
|
|||||||
void CodeController::showCodeSnippets(
|
void CodeController::showCodeSnippets(
|
||||||
std::vector<CodeSnippetParams> snippets, const CodeView::CodeParams params, bool addSourceLocations)
|
std::vector<CodeSnippetParams> snippets, const CodeView::CodeParams params, bool addSourceLocations)
|
||||||
{
|
{
|
||||||
expandVisibleSnippets(&snippets);
|
expandVisibleSnippets(&snippets, params.useSingleFileCache);
|
||||||
|
|
||||||
CodeView* view = getView();
|
CodeView* view = getView();
|
||||||
view->showCodeSnippets(snippets, params);
|
view->showCodeSnippets(snippets, params);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ private:
|
|||||||
|
|
||||||
std::vector<std::string> getProjectDescription(SourceLocationFile* locationFile) const;
|
std::vector<std::string> getProjectDescription(SourceLocationFile* locationFile) const;
|
||||||
|
|
||||||
void expandVisibleSnippets(std::vector<CodeSnippetParams>* snippets) const;
|
void expandVisibleSnippets(std::vector<CodeSnippetParams>* snippets, bool useSingleFileCache) const;
|
||||||
void addAllSourceLocations(std::vector<CodeSnippetParams>* snippets) const;
|
void addAllSourceLocations(std::vector<CodeSnippetParams>* snippets) const;
|
||||||
void addModificationTimes(std::vector<CodeSnippetParams>* snippets) const;
|
void addModificationTimes(std::vector<CodeSnippetParams>* snippets) const;
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,10 @@ public:
|
|||||||
|
|
||||||
struct CodeParams
|
struct CodeParams
|
||||||
{
|
{
|
||||||
CodeParams()
|
bool clearSnippets = false;
|
||||||
: clearSnippets(false)
|
bool showContents = false;
|
||||||
, showContents(false)
|
bool useSingleFileCache = true;
|
||||||
{}
|
|
||||||
|
|
||||||
bool clearSnippets;
|
|
||||||
bool showContents;
|
|
||||||
std::vector<Id> activeTokenIds;
|
std::vector<Id> activeTokenIds;
|
||||||
std::vector<ErrorInfo> errorInfos;
|
std::vector<ErrorInfo> errorInfos;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
|||||||
, m_value(0)
|
, m_value(0)
|
||||||
, m_refIndex(0)
|
, m_refIndex(0)
|
||||||
, m_singleHasNewFile(false)
|
, m_singleHasNewFile(false)
|
||||||
|
, m_useSingleFileCache(false)
|
||||||
{
|
{
|
||||||
QVBoxLayout* layout = new QVBoxLayout();
|
QVBoxLayout* layout = new QVBoxLayout();
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
@@ -147,8 +148,6 @@ void QtCodeNavigator::updateCodeSnippet(const CodeSnippetParams& params)
|
|||||||
|
|
||||||
void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimeStamp modificationTime)
|
void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimeStamp modificationTime)
|
||||||
{
|
{
|
||||||
bool firstFile = m_references.size() == 0;
|
|
||||||
|
|
||||||
m_list->addFile(locationFile->getFilePath(), locationFile->isWhole(), refCount, modificationTime, locationFile->isComplete());
|
m_list->addFile(locationFile->getFilePath(), locationFile->isWhole(), refCount, modificationTime, locationFile->isComplete());
|
||||||
|
|
||||||
if (locationFile->isWhole())
|
if (locationFile->isWhole())
|
||||||
@@ -192,11 +191,6 @@ void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile,
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstFile && m_references.size() && m_references[0].locationType != LOCATION_TOKEN)
|
|
||||||
{
|
|
||||||
clearCaches();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeNavigator::addedFiles()
|
void QtCodeNavigator::addedFiles()
|
||||||
@@ -217,13 +211,11 @@ void QtCodeNavigator::addedFiles()
|
|||||||
|
|
||||||
void QtCodeNavigator::clear()
|
void QtCodeNavigator::clear()
|
||||||
{
|
{
|
||||||
clearCodeSnippets();
|
clearCodeSnippets(false);
|
||||||
clearCaches();
|
|
||||||
|
|
||||||
updateRefLabel();
|
updateRefLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeNavigator::clearCodeSnippets()
|
void QtCodeNavigator::clearCodeSnippets(bool useSingleFileCache)
|
||||||
{
|
{
|
||||||
m_list->clear();
|
m_list->clear();
|
||||||
|
|
||||||
@@ -235,10 +227,11 @@ void QtCodeNavigator::clearCodeSnippets()
|
|||||||
|
|
||||||
m_activeTokenId = 0;
|
m_activeTokenId = 0;
|
||||||
|
|
||||||
if (m_references.size() && m_references[0].locationType != LOCATION_TOKEN)
|
if (!m_useSingleFileCache || !useSingleFileCache)
|
||||||
{
|
{
|
||||||
clearCaches();
|
clearCaches();
|
||||||
}
|
}
|
||||||
|
m_useSingleFileCache = useSingleFileCache;
|
||||||
|
|
||||||
m_references.clear();
|
m_references.clear();
|
||||||
m_activeReference = Reference();
|
m_activeReference = Reference();
|
||||||
@@ -385,7 +378,7 @@ bool QtCodeNavigator::isInListMode() const
|
|||||||
|
|
||||||
bool QtCodeNavigator::hasSingleFileCached(const FilePath& filePath) const
|
bool QtCodeNavigator::hasSingleFileCached(const FilePath& filePath) const
|
||||||
{
|
{
|
||||||
return m_single->hasFileCached(filePath);
|
return m_useSingleFileCache && m_single->hasFileCached(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeNavigator::showActiveSnippet(
|
void QtCodeNavigator::showActiveSnippet(
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
void addedFiles();
|
void addedFiles();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void clearCodeSnippets();
|
void clearCodeSnippets(bool useSingleFileCache);
|
||||||
void clearFile();
|
void clearFile();
|
||||||
void clearCaches();
|
void clearCaches();
|
||||||
void clearSnippetReferences();
|
void clearSnippetReferences();
|
||||||
@@ -203,6 +203,7 @@ private:
|
|||||||
|
|
||||||
ScrollRequest m_scrollRequest;
|
ScrollRequest m_scrollRequest;
|
||||||
bool m_singleHasNewFile;
|
bool m_singleHasNewFile;
|
||||||
|
bool m_useSingleFileCache;
|
||||||
|
|
||||||
std::vector<std::pair<QtCodeArea*, Id>> m_screenMatches;
|
std::vector<std::pair<QtCodeArea*, Id>> m_screenMatches;
|
||||||
Id m_activeScreenMatchId = 0;
|
Id m_activeScreenMatchId = 0;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ void QtCodeView::showCodeSnippets(const std::vector<CodeSnippetParams>& snippets
|
|||||||
|
|
||||||
if (params.clearSnippets)
|
if (params.clearSnippets)
|
||||||
{
|
{
|
||||||
m_widget->clearCodeSnippets();
|
m_widget->clearCodeSnippets(params.useSingleFileCache);
|
||||||
|
|
||||||
m_widget->setActiveTokenIds(params.activeTokenIds);
|
m_widget->setActiveTokenIds(params.activeTokenIds);
|
||||||
m_widget->setErrorInfos(params.errorInfos);
|
m_widget->setErrorInfos(params.errorInfos);
|
||||||
|
|||||||
Reference in New Issue
Block a user