logic: show whole file in CodeView when file node is active
This commit is contained in:
@@ -144,9 +144,18 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForFile(cons
|
|||||||
{
|
{
|
||||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(file->getFilePath().str());
|
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(file->getFilePath().str());
|
||||||
|
|
||||||
std::vector<std::pair<uint, uint>> ranges = getSnippetRangesForFile(file);
|
std::vector<std::pair<uint, uint>> ranges;
|
||||||
std::vector<CodeView::CodeSnippetParams> snippets;
|
|
||||||
|
|
||||||
|
if (file->isWholeCopy)
|
||||||
|
{
|
||||||
|
ranges.push_back(std::make_pair(1, textAccess->getLineCount()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ranges = getSnippetRangesForFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<CodeView::CodeSnippetParams> snippets;
|
||||||
for (const std::pair<uint, uint>& range: ranges)
|
for (const std::pair<uint, uint>& range: ranges)
|
||||||
{
|
{
|
||||||
CodeView::CodeSnippetParams params;
|
CodeView::CodeSnippetParams params;
|
||||||
|
|||||||
@@ -957,17 +957,8 @@ TokenLocationCollection Storage::getTokenLocationsForTokenIds(const std::vector<
|
|||||||
|
|
||||||
if (token->isNode() && dynamic_cast<Node*>(token)->isType(Node::NODE_FILE))
|
if (token->isNode() && dynamic_cast<Node*>(token)->isType(Node::NODE_FILE))
|
||||||
{
|
{
|
||||||
TokenLocationFile* locationFile =
|
ret.addTokenLocationFileAsPlainCopy(m_locationCollection.findTokenLocationFileByPath(
|
||||||
m_locationCollection.findTokenLocationFileByPath(dynamic_cast<Node*>(token)->getFullName());
|
dynamic_cast<Node*>(token)->getComponent<TokenComponentFilePath>()->getFilePath()));
|
||||||
if (locationFile)
|
|
||||||
{
|
|
||||||
locationFile->forEachTokenLocation(
|
|
||||||
[&ret](TokenLocation* tokenLocation) -> void
|
|
||||||
{
|
|
||||||
ret.addTokenLocationAsPlainCopy(tokenLocation);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -141,6 +141,20 @@ void TokenLocationCollection::removeTokenLocationFile(TokenLocationFile* file)
|
|||||||
m_files.erase(file->getFilePath());
|
m_files.erase(file->getFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TokenLocationFile* TokenLocationCollection::addTokenLocationFileAsPlainCopy(const TokenLocationFile* locationFile)
|
||||||
|
{
|
||||||
|
TokenLocationFile* file = createTokenLocationFile(locationFile->getFilePath());
|
||||||
|
locationFile->forEachTokenLocation(
|
||||||
|
[this, &file](TokenLocation* tokenLocation) -> void
|
||||||
|
{
|
||||||
|
TokenLocation* copy = file->addTokenLocationAsPlainCopy(tokenLocation);
|
||||||
|
m_locations.emplace(copy->getId(), copy);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
file->isWholeCopy = true;
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
TokenLocation* TokenLocationCollection::addTokenLocationAsPlainCopy(const TokenLocation* location)
|
TokenLocation* TokenLocationCollection::addTokenLocationAsPlainCopy(const TokenLocation* location)
|
||||||
{
|
{
|
||||||
const FilePath& filePath = location->getTokenLocationLine()->getTokenLocationFile()->getFilePath();
|
const FilePath& filePath = location->getTokenLocationLine()->getTokenLocationFile()->getFilePath();
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public:
|
|||||||
|
|
||||||
void removeTokenLocationFile(TokenLocationFile* file);
|
void removeTokenLocationFile(TokenLocationFile* file);
|
||||||
|
|
||||||
|
TokenLocationFile* addTokenLocationFileAsPlainCopy(const TokenLocationFile* locationFile);
|
||||||
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
|
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
#include "data/location/TokenLocationLine.h"
|
#include "data/location/TokenLocationLine.h"
|
||||||
|
|
||||||
TokenLocationFile::TokenLocationFile(const FilePath& filePath)
|
TokenLocationFile::TokenLocationFile(const FilePath& filePath)
|
||||||
: m_filePath(filePath)
|
: isWholeCopy(false)
|
||||||
|
, m_filePath(filePath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public:
|
|||||||
|
|
||||||
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
|
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
|
||||||
|
|
||||||
|
bool isWholeCopy;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TokenLocationLine* findTokenLocationLine(unsigned int lineNumber) const;
|
TokenLocationLine* findTokenLocationLine(unsigned int lineNumber) const;
|
||||||
TokenLocationLine* createTokenLocationLine(unsigned int lineNumber);
|
TokenLocationLine* createTokenLocationLine(unsigned int lineNumber);
|
||||||
|
|||||||
Reference in New Issue
Block a user