logic: show whole file in CodeView when file node is active

This commit is contained in:
Eberhard Graether
2015-03-24 23:01:40 +01:00
parent 0d2a76c2eb
commit eb9092a07f
6 changed files with 32 additions and 14 deletions
@@ -144,9 +144,18 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForFile(cons
{
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(file->getFilePath().str());
std::vector<std::pair<uint, uint>> ranges = getSnippetRangesForFile(file);
std::vector<CodeView::CodeSnippetParams> snippets;
std::vector<std::pair<uint, uint>> ranges;
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)
{
CodeView::CodeSnippetParams params;
+2 -11
View File
@@ -957,17 +957,8 @@ TokenLocationCollection Storage::getTokenLocationsForTokenIds(const std::vector<
if (token->isNode() && dynamic_cast<Node*>(token)->isType(Node::NODE_FILE))
{
TokenLocationFile* locationFile =
m_locationCollection.findTokenLocationFileByPath(dynamic_cast<Node*>(token)->getFullName());
if (locationFile)
{
locationFile->forEachTokenLocation(
[&ret](TokenLocation* tokenLocation) -> void
{
ret.addTokenLocationAsPlainCopy(tokenLocation);
}
);
}
ret.addTokenLocationFileAsPlainCopy(m_locationCollection.findTokenLocationFileByPath(
dynamic_cast<Node*>(token)->getComponent<TokenComponentFilePath>()->getFilePath()));
}
else
{
@@ -141,6 +141,20 @@ void TokenLocationCollection::removeTokenLocationFile(TokenLocationFile* file)
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)
{
const FilePath& filePath = location->getTokenLocationLine()->getTokenLocationFile()->getFilePath();
@@ -44,6 +44,7 @@ public:
void removeTokenLocationFile(TokenLocationFile* file);
TokenLocationFile* addTokenLocationFileAsPlainCopy(const TokenLocationFile* locationFile);
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
void clear();
+2 -1
View File
@@ -6,7 +6,8 @@
#include "data/location/TokenLocationLine.h"
TokenLocationFile::TokenLocationFile(const FilePath& filePath)
: m_filePath(filePath)
: isWholeCopy(false)
, m_filePath(filePath)
{
}
@@ -40,6 +40,8 @@ public:
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
bool isWholeCopy;
private:
TokenLocationLine* findTokenLocationLine(unsigned int lineNumber) const;
TokenLocationLine* createTokenLocationLine(unsigned int lineNumber);