logic: Refactored Code View to process all contents in one update

* Use unified showCodeSnippets method for setting file information on CodeView
* Made async initial file and snippet expansion synced
* Add ScrollParams API to CodeView
* Regard scope size when scrolling to definition
* Only use QtThreadedLambdaFunctor in QtCodeView now
This commit is contained in:
Eberhard Graether
2017-06-05 14:23:43 +02:00
parent 893b223bbc
commit de645be37a
29 changed files with 613 additions and 613 deletions
+19 -21
View File
@@ -153,7 +153,6 @@ QtCodeArea::QtCodeArea(
m_highlighter->highlightDocument();
createAnnotations(locationFile);
annotateText();
}
QtCodeArea::~QtCodeArea()
@@ -294,39 +293,38 @@ uint QtCodeArea::getLineNumberForLocationId(Id locationId) const
return 0;
}
uint QtCodeArea::getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const
std::pair<uint, uint> QtCodeArea::getLineNumbersForLocationId(Id locationId) const
{
int firstActiveLine = 0;
for (const Annotation& annotation : m_annotations)
{
if (annotation.locationType == LocationType::LOCATION_TOKEN && annotation.isActive)
if (annotation.locationId == locationId)
{
if (annotation.tokenIds.find(tokenId) != annotation.tokenIds.end())
{
if (!firstActiveLine || firstActiveLine == annotation.startLine)
{
return getStartLineNumber();
}
else
{
return annotation.startLine;
}
}
else
{
firstActiveLine = annotation.startLine;
}
return std::pair<uint, uint>(annotation.startLine, annotation.endLine);
}
}
return std::pair<uint, uint>(0, 0);
}
Id QtCodeArea::getLocationIdOfFirstActiveLocation(Id tokenId) const
{
for (const Annotation& annotation : m_annotations)
{
if (annotation.locationType == LocationType::LOCATION_TOKEN && annotation.isActive &&
annotation.tokenIds.find(tokenId) != annotation.tokenIds.end())
{
return annotation.locationId;
}
}
return 0;
}
Id QtCodeArea::getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const
Id QtCodeArea::getLocationIdOfFirstActiveScopeLocation(Id tokenId) const
{
for (const Annotation& annotation : m_annotations)
{
if (annotation.locationType == LocationType::LOCATION_TOKEN && annotation.isActive &&
if (annotation.locationType == LocationType::LOCATION_SCOPE && annotation.isActive &&
annotation.tokenIds.find(tokenId) != annotation.tokenIds.end())
{
return annotation.locationId;
+5 -2
View File
@@ -85,8 +85,11 @@ public:
void setIsActiveFile(bool isActiveFile);
uint getLineNumberForLocationId(Id locationId) const;
uint getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const;
Id getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const;
std::pair<uint, uint> getLineNumbersForLocationId(Id locationId) const;
Id getLocationIdOfFirstActiveLocation(Id tokenId) const;
Id getLocationIdOfFirstActiveScopeLocation(Id tokenId) const;
uint getActiveLocationCount() const;
QRectF getLineRectForLineNumber(uint lineNumber) const;
+7 -12
View File
@@ -226,17 +226,17 @@ QtCodeSnippet* QtCodeFile::getFileSnippet() const
return m_fileSnippet.get();
}
std::pair<QtCodeSnippet*, uint> QtCodeFile::getFirstSnippetWithActiveLocation(Id tokenId) const
std::pair<QtCodeSnippet*, Id> QtCodeFile::getFirstSnippetWithActiveLocationId(Id tokenId) const
{
std::pair<QtCodeSnippet*, uint> result(nullptr, 0);
std::pair<QtCodeSnippet*, Id> result(nullptr, 0);
for (std::shared_ptr<QtCodeSnippet> snippet : m_snippets)
{
uint startLineNumber = snippet->getStartLineNumberOfFirstActiveLocationOfTokenId(tokenId);
if (startLineNumber != 0)
Id locationId = snippet->getFirstActiveLocationId(tokenId);
if (locationId != 0)
{
result.first = snippet.get();
result.second = startLineNumber;
result.second = locationId;
break;
}
}
@@ -249,7 +249,7 @@ bool QtCodeFile::isCollapsed() const
return m_isCollapsed;
}
void QtCodeFile::requestContent(bool isFirstInList)
void QtCodeFile::requestContent()
{
if (!isCollapsed() || m_contentRequested)
{
@@ -260,12 +260,7 @@ void QtCodeFile::requestContent(bool isFirstInList)
m_contentRequested = true;
MessageChangeFileView::FileState state =
isFirstInList ? MessageChangeFileView::FILE_DEFAULT_FOR_MODE : MessageChangeFileView::FILE_SNIPPETS;
if (m_isWholeFile)
{
state = MessageChangeFileView::FILE_MAXIMIZED;
}
m_isWholeFile ? MessageChangeFileView::FILE_MAXIMIZED : MessageChangeFileView::FILE_SNIPPETS;
MessageChangeFileView(m_filePath, state, isCollapsed(), m_navigator->hasErrors()).dispatch();
}
+2 -2
View File
@@ -39,11 +39,11 @@ public:
QtCodeSnippet* getSnippetForLine(unsigned int line) const;
QtCodeSnippet* getFileSnippet() const;
std::pair<QtCodeSnippet*, uint> getFirstSnippetWithActiveLocation(Id tokenId) const;
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
bool isCollapsed() const;
void requestContent(bool isFirstInList = false);
void requestContent();
void updateContent();
void setWholeFile(bool isWholeFile, int refCount);
+24 -12
View File
@@ -83,14 +83,12 @@ QScrollArea* QtCodeFileList::getScrollArea()
return this;
}
void QtCodeFileList::addCodeSnippet(
const CodeSnippetParams& params,
bool insert
){
void QtCodeFileList::addCodeSnippet(const CodeSnippetParams& params)
{
QtCodeFile* file = getFile(params.locationFile->getFilePath());
QtCodeSnippet* snippet = nullptr;
if (insert)
if (params.insertSnippet)
{
snippet = file->insertCodeSnippet(params);
}
@@ -103,9 +101,9 @@ void QtCodeFileList::addCodeSnippet(
file->setIsComplete(params.locationFile->isComplete());
}
void QtCodeFileList::requestFileContent(const FilePath& filePath, bool isFirstInList)
void QtCodeFileList::requestFileContent(const FilePath& filePath)
{
getFile(filePath)->requestContent(isFirstInList);
getFile(filePath)->requestContent();
}
bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop)
@@ -147,11 +145,19 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id
file->setSnippets();
}
uint endLineNumber = 0;
if (!lineNumber)
{
if (locationId)
{
lineNumber = snippet->getLineNumberForLocationId(locationId);
std::pair<uint, uint> lineNumbers = snippet->getLineNumbersForLocationId(locationId);
lineNumber = lineNumbers.first;
if (lineNumbers.first != lineNumbers.second)
{
endLineNumber = lineNumbers.second;
}
}
else
{
@@ -159,7 +165,13 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id
}
}
ensureWidgetVisibleAnimated(m_filesArea, snippet, snippet->getLineRectForLineNumber(lineNumber), animated, onTop);
QRectF lineRect = snippet->getLineRectForLineNumber(lineNumber);
if (endLineNumber)
{
lineRect |= snippet->getLineRectForLineNumber(endLineNumber);
}
ensureWidgetVisibleAnimated(m_filesArea, snippet, lineRect, animated, onTop);
return true;
}
@@ -203,9 +215,9 @@ void QtCodeFileList::setFileMaximized(const FilePath path)
getFile(path)->setMaximized();
}
std::pair<QtCodeSnippet*, uint> QtCodeFileList::getFirstSnippetWithActiveLocation(Id tokenId) const
std::pair<QtCodeSnippet*, Id> QtCodeFileList::getFirstSnippetWithActiveLocationId(Id tokenId) const
{
std::pair<QtCodeSnippet*, uint> result(nullptr, 0);
std::pair<QtCodeSnippet*, Id> result(nullptr, 0);
for (std::shared_ptr<QtCodeFile> filePtr : m_files)
{
@@ -214,7 +226,7 @@ std::pair<QtCodeSnippet*, uint> QtCodeFileList::getFirstSnippetWithActiveLocatio
continue;
}
result = filePtr->getFirstSnippetWithActiveLocation(tokenId);
result = filePtr->getFirstSnippetWithActiveLocationId(tokenId);
if (result.first != nullptr)
{
break;
+3 -3
View File
@@ -33,9 +33,9 @@ public:
// QtCodeNaviatebale implementation
virtual QScrollArea* getScrollArea();
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false);
virtual void addCodeSnippet(const CodeSnippetParams& params);
void requestFileContent(const FilePath& filePath, bool isFirstInList = false);
virtual void requestFileContent(const FilePath& filePath);
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop);
virtual void updateFiles();
@@ -47,7 +47,7 @@ public:
void setFileSnippets(const FilePath path);
void setFileMaximized(const FilePath path);
std::pair<QtCodeSnippet*, uint> getFirstSnippetWithActiveLocation(Id tokenId) const;
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
private:
QtCodeNavigator* m_navigator;
+36 -4
View File
@@ -20,6 +20,7 @@ QtCodeFileSingle::QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent)
: m_navigator(navigator)
, m_area(nullptr)
, m_contentRequested(false)
, m_scrollRequested(false)
{
setObjectName("code_container");
@@ -83,7 +84,7 @@ void QtCodeFileSingle::clearCache()
m_filePaths.clear();
}
void QtCodeFileSingle::addCodeSnippet(const CodeSnippetParams& params, bool insert)
void QtCodeFileSingle::addCodeSnippet(const CodeSnippetParams& params)
{
if (!params.locationFile->isWhole())
{
@@ -163,11 +164,24 @@ bool QtCodeFileSingle::requestScroll(const FilePath& filePath, uint lineNumber,
return false;
}
if (!m_scrollRequested)
{
animated = false;
}
uint endLineNumber = 0;
if (!lineNumber)
{
if (locationId)
{
lineNumber = m_area->getLineNumberForLocationId(locationId);
std::pair<uint, uint> lineNumbers = m_area->getLineNumbersForLocationId(locationId);
lineNumber = lineNumbers.first;
if (lineNumbers.first != lineNumbers.second)
{
endLineNumber = lineNumbers.second;
}
}
else
{
@@ -175,7 +189,12 @@ bool QtCodeFileSingle::requestScroll(const FilePath& filePath, uint lineNumber,
}
}
ensurePercentVisibleAnimated(double(lineNumber - 1) / m_area->getEndLineNumber(), animated, onTop);
double percentA = double(lineNumber - 1) / m_area->getEndLineNumber();
double percentB = endLineNumber ? double(endLineNumber - 1) / m_area->getEndLineNumber() : 0.0f;
ensurePercentVisibleAnimated(percentA, percentB, animated, onTop);
m_scrollRequested = true;
return true;
}
@@ -206,6 +225,11 @@ const FilePath& QtCodeFileSingle::getCurrentFilePath() const
return m_currentFilePath;
}
bool QtCodeFileSingle::hasFileCached(const FilePath& filePath) const
{
return getFileData(filePath).area != nullptr;
}
Id QtCodeFileSingle::getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const
{
if (!m_area)
@@ -213,7 +237,13 @@ Id QtCodeFileSingle::getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) con
return 0;
}
return m_area->getLocationIdOfFirstActiveLocationOfTokenId(tokenId);
Id scopeId = m_area->getLocationIdOfFirstActiveScopeLocation(tokenId);
if (scopeId)
{
return scopeId;
}
return m_area->getLocationIdOfFirstActiveLocation(tokenId);
}
QtCodeFileSingle::FileData QtCodeFileSingle::getFileData(const FilePath& filePath) const
@@ -273,6 +303,8 @@ void QtCodeFileSingle::setFileData(const FileData& file)
m_title->show();
m_area->show();
m_scrollRequested = false;
}
else
{
+4 -2
View File
@@ -32,9 +32,9 @@ public:
// QtCodeNaviatebale implementation
virtual QAbstractScrollArea* getScrollArea() override;
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false) override;
virtual void addCodeSnippet(const CodeSnippetParams& params) override;
void requestFileContent(const FilePath& filePath);
virtual void requestFileContent(const FilePath& filePath) override;
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop) override;
virtual void updateFiles() override;
@@ -43,6 +43,7 @@ public:
virtual void onWindowFocus() override;
const FilePath& getCurrentFilePath() const;
bool hasFileCached(const FilePath& filePath) const;
Id getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const;
@@ -75,6 +76,7 @@ private:
std::deque<FilePath> m_filePaths;
bool m_contentRequested;
bool m_scrollRequested;
};
#endif // QT_CODE_FILE_SINGLE_H
+27 -3
View File
@@ -58,7 +58,7 @@ void QtCodeNavigateable::ensureWidgetVisibleAnimated(
}
}
void QtCodeNavigateable::ensurePercentVisibleAnimated(double percent, bool animated, bool onTop)
void QtCodeNavigateable::ensurePercentVisibleAnimated(double percentA, double percentB, bool animated, bool onTop)
{
QAbstractScrollArea* area = getScrollArea();
if (!area)
@@ -74,10 +74,34 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(double percent, bool anima
return;
}
int scrollHeight = totalHeight * percent;
int scrollHeight = totalHeight * percentA;
if (!onTop)
{
scrollHeight -= visibleHeight / 3;
if (percentB)
{
int scrollHeightB = totalHeight * percentB;
int rectHeight = scrollHeightB - scrollHeight;
if (rectHeight < visibleHeight)
{
if (rectHeight < visibleHeight / 2)
{
scrollHeight -= visibleHeight / 4;
}
else
{
scrollHeight += rectHeight / 2 - visibleHeight / 2;
}
}
else
{
scrollHeight -= 20;
}
}
else
{
scrollHeight -= visibleHeight / 4;
}
}
else
{
+3 -2
View File
@@ -19,8 +19,9 @@ public:
virtual QAbstractScrollArea* getScrollArea() = 0;
virtual void addCodeSnippet(const CodeSnippetParams& params, bool insert = false) = 0;
virtual void addCodeSnippet(const CodeSnippetParams& params) = 0;
virtual void requestFileContent(const FilePath& filePath) = 0;
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, bool onTop) = 0;
virtual void updateFiles() = 0;
@@ -30,7 +31,7 @@ public:
protected:
void ensureWidgetVisibleAnimated(QWidget* parentWidget, QWidget *childWidget, QRectF rect, bool animated, bool onTop);
void ensurePercentVisibleAnimated(double percent, bool animated, bool onTop);
void ensurePercentVisibleAnimated(double percentA, double percentB, bool animated, bool onTop);
};
#endif // QT_CODE_NAVIGATEABLE_H
+65 -79
View File
@@ -8,7 +8,6 @@
#include <QVBoxLayout>
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageCodeViewExpandedInitialFiles.h"
#include "utility/messaging/type/MessageScrollCode.h"
#include "utility/messaging/type/MessageShowErrors.h"
#include "utility/ResourcePaths.h"
@@ -137,21 +136,30 @@ QtCodeNavigator::~QtCodeNavigator()
{
}
void QtCodeNavigator::addCodeSnippet(const CodeSnippetParams& params, bool insert)
void QtCodeNavigator::addCodeSnippet(const CodeSnippetParams& params)
{
FilePath currentPath = m_single->getCurrentFilePath();
if (params.reduced)
{
m_list->addCodeSnippet(params, insert);
m_single->addCodeSnippet(params, insert);
m_list->addCodeSnippet(params);
m_single->addCodeSnippet(params);
}
else
{
m_current->addCodeSnippet(params, insert);
m_current->addCodeSnippet(params);
}
if (currentPath != m_single->getCurrentFilePath())
{
m_singleHasNewFile = true;
}
}
void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimePoint modificationTime)
{
bool firstFile = m_references.size() == 0;
m_list->addFile(locationFile->getFilePath(), locationFile->isWhole(), refCount, modificationTime, locationFile->isComplete());
if (locationFile->isWhole())
@@ -195,13 +203,26 @@ void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile,
}
);
}
if (firstFile && m_references.size() && m_references[0].locationType != LOCATION_TOKEN)
{
clearCaches();
}
}
void QtCodeNavigator::addedFiles()
{
if (m_references.size() && m_references[0].locationType != LOCATION_TOKEN)
if (m_mode == MODE_SINGLE && m_references.size())
{
clearCaches();
if (!m_refIndex || !m_activeReference.tokenId)
{
m_single->requestFileContent(m_references.front().filePath);
}
}
if (m_refIndex == 0)
{
updateRefLabel();
}
}
@@ -343,6 +364,11 @@ bool QtCodeNavigator::isInListMode() const
return m_mode == MODE_LIST;
}
bool QtCodeNavigator::hasSingleFileCached(const FilePath& filePath) const
{
return m_single->hasFileCached(filePath);
}
void QtCodeNavigator::showActiveSnippet(
const std::vector<Id>& activeTokenIds, std::shared_ptr<SourceLocationCollection> collection, bool scrollTo)
{
@@ -425,8 +451,11 @@ void QtCodeNavigator::showActiveSnippet(
if (firstReference.tokenId)
{
requestScroll(firstReference.filePath, 0, firstReference.locationId, true, false);
emit scrollRequest();
if (scrollTo)
{
requestScroll(firstReference.filePath, 0, firstReference.locationId, true, false);
emit scrollRequest();
}
m_refIndex = refIndex;
updateRefLabel();
@@ -465,46 +494,6 @@ void QtCodeNavigator::setFileMaximized(const FilePath path)
m_list->setFileMaximized(path);
}
void QtCodeNavigator::setupFiles()
{
if (m_mode == MODE_LIST)
{
std::set<FilePath> filePathsToExpand;
for (const Reference& ref : m_references)
{
if (filePathsToExpand.find(ref.filePath) == filePathsToExpand.end())
{
m_list->requestFileContent(ref.filePath, filePathsToExpand.size() == 0);
filePathsToExpand.insert(ref.filePath);
if (filePathsToExpand.size() >= 3)
{
break;
}
}
}
if (filePathsToExpand.size())
{
MessageCodeViewExpandedInitialFiles(m_refIndex != 0 || m_activeReference.tokenId).dispatch();
}
}
else if (m_references.size())
{
m_singleHasNewFile = (m_single->getCurrentFilePath() != m_references.front().filePath);
if (!m_refIndex || !m_activeReference.tokenId)
{
m_single->requestFileContent(m_references.front().filePath);
}
MessageCodeViewExpandedInitialFiles(true).dispatch();
}
if (m_refIndex == 0)
{
updateRefLabel();
}
}
void QtCodeNavigator::updateFiles()
{
m_current->updateFiles();
@@ -555,7 +544,8 @@ void QtCodeNavigator::scrollToValue(int value, bool inListMode)
if ((m_mode == MODE_LIST) == inListMode)
{
m_value = value;
QTimer::singleShot(1000, this, SLOT(setValue()));
QTimer::singleShot(100, this, SLOT(setValue()));
m_scrollRequest = ScrollRequest();
}
}
@@ -565,7 +555,7 @@ void QtCodeNavigator::scrollToLine(const FilePath& filePath, unsigned int line)
emit scrollRequest();
}
void QtCodeNavigator::scrollToDefinition(bool ignoreActiveReference)
void QtCodeNavigator::scrollToDefinition(bool animated, bool ignoreActiveReference)
{
if (ignoreActiveReference)
{
@@ -594,25 +584,25 @@ void QtCodeNavigator::scrollToDefinition(bool ignoreActiveReference)
return;
}
if (!m_activeTokenId && m_mode == MODE_SINGLE && m_references.size() && m_references.front().locationType != LOCATION_TOKEN)
{
requestScroll(m_references.front().filePath, 0, m_references.front().locationId, false, true);
emit scrollRequest();
return;
}
if (!m_activeTokenId)
{
if (m_mode == MODE_SINGLE && m_references.size() && m_references.front().locationType != LOCATION_TOKEN)
{
requestScroll(m_references.front().filePath, 0, m_references.front().locationId, false, false);
emit scrollRequest();
}
return;
}
if (m_mode == MODE_LIST)
{
std::pair<QtCodeSnippet*, uint> result = m_list->getFirstSnippetWithActiveLocation(m_activeTokenId);
std::cout << animated << std::endl;
std::pair<QtCodeSnippet*, Id> result = m_list->getFirstSnippetWithActiveLocationId(m_activeTokenId);
if (result.first != nullptr)
{
requestScroll(result.first->getFile()->getFilePath(), result.second, 0, false, true);
requestScroll(result.first->getFile()->getFilePath(), 0, result.second, animated, false);
emit scrollRequest();
return;
}
}
else
@@ -620,22 +610,18 @@ void QtCodeNavigator::scrollToDefinition(bool ignoreActiveReference)
Id locationId = m_single->getLocationIdOfFirstActiveLocationOfTokenId(m_activeTokenId);
if (locationId)
{
for (size_t i = 0; i < m_references.size(); i++)
{
if (m_references[i].locationId == locationId)
{
m_refIndex = i + 1;
showCurrentReference(false);
}
}
}
else if (m_references.size())
{
nextReference(false);
requestScroll(m_single->getCurrentFilePath(), 0, locationId, true, false);
emit scrollRequest();
return;
}
}
//m_singleHasNewFile = false;
if (m_references.size())
{
m_current->requestFileContent(m_references.front().filePath);
requestScroll(m_references.front().filePath, 0, m_references.front().locationId, false, false);
emit scrollRequest();
}
}
void QtCodeNavigator::scrollToSnippetIfRequested()
@@ -658,10 +644,6 @@ void QtCodeNavigator::requestScroll(const FilePath& filePath, uint lineNumber, I
{
req.animated = false;
}
else
{
req.animated = (m_single->getCurrentFilePath() == filePath);
}
}
// std::cout << "scroll request: " << req.filePath.str() << " " << req.lineNumber << " " << req.locationId;
@@ -688,6 +670,10 @@ void QtCodeNavigator::handleScrollRequest()
{
m_scrollRequest = ScrollRequest();
}
else if (m_mode == MODE_SINGLE)
{
m_scrollRequest.animated = false;
}
}
void QtCodeNavigator::scrolled(int value)
@@ -789,7 +775,7 @@ void QtCodeNavigator::setMode(Mode mode)
ApplicationSettings::getInstance()->setCodeViewModeSingle(m_mode == MODE_SINGLE);
ApplicationSettings::getInstance()->save();
setupFiles();
scrollToDefinition(false, false);
showContents();
}
@@ -859,7 +845,7 @@ void QtCodeNavigator::handleMessage(MessageShowReference* message)
setCurrentActiveLocationIds(std::vector<Id>(1, ref.locationId));
updateFiles();
requestScroll(ref.filePath, 0, ref.locationId, message->animated, false);
requestScroll(ref.filePath, 0, ref.locationId, true, false);
emit scrollRequest();
if (ref.locationType == LOCATION_ERROR)
+3 -3
View File
@@ -34,7 +34,7 @@ public:
QtCodeNavigator(QWidget* parent = nullptr);
virtual ~QtCodeNavigator();
void addCodeSnippet(const CodeSnippetParams& params, bool insert = false);
void addCodeSnippet(const CodeSnippetParams& params);
void addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimePoint modificationTime);
void addedFiles();
@@ -65,6 +65,7 @@ public:
size_t getFatalErrorCountForFile(const FilePath& filePath) const;
bool isInListMode() const;
bool hasSingleFileCached(const FilePath& filePath) const;
void showActiveSnippet(
const std::vector<Id>& activeTokenIds, std::shared_ptr<SourceLocationCollection> collection, bool scrollTo);
@@ -76,7 +77,6 @@ public:
void setFileSnippets(const FilePath path);
void setFileMaximized(const FilePath path);
void setupFiles();
void updateFiles();
void showContents();
@@ -84,7 +84,7 @@ public:
void scrollToValue(int value, bool inListMode);
void scrollToLine(const FilePath& filePath, unsigned int line);
void scrollToDefinition(bool ignoreActiveReference);
void scrollToDefinition(bool animated, bool ignoreActiveReference);
void scrollToSnippetIfRequested();
+13 -2
View File
@@ -164,9 +164,20 @@ uint QtCodeSnippet::getLineNumberForLocationId(Id locationId) const
return m_codeArea->getLineNumberForLocationId(locationId);
}
uint QtCodeSnippet::getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const
std::pair<uint, uint> QtCodeSnippet::getLineNumbersForLocationId(Id locationId) const
{
return m_codeArea->getStartLineNumberOfFirstActiveLocationOfTokenId(tokenId);
return m_codeArea->getLineNumbersForLocationId(locationId);
}
Id QtCodeSnippet::getFirstActiveLocationId(Id tokenId) const
{
Id scopeId = m_codeArea->getLocationIdOfFirstActiveScopeLocation(tokenId);
if (scopeId)
{
return scopeId;
}
return m_codeArea->getLocationIdOfFirstActiveLocation(tokenId);
}
QRectF QtCodeSnippet::getLineRectForLineNumber(uint lineNumber) const
+3 -1
View File
@@ -44,7 +44,9 @@ public:
void setIsActiveFile(bool isActiveFile);
uint getLineNumberForLocationId(Id locationId) const;
uint getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const;
std::pair<uint, uint> getLineNumbersForLocationId(Id locationId) const;
Id getFirstActiveLocationId(Id tokenId) const;
QRectF getLineRectForLineNumber(uint lineNumber) const;
std::string getCode() const;