utility: added FilePath abstraction and rewrote data management to use it
The utility class FilePath wraps an instance of boost::filesystem::path. Using FilePath allows for easy comparision of file paths on different platforms using absolute or relative paths. Whereever file paths are compared, this wrapper should be used.
This commit is contained in:
@@ -108,7 +108,7 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForActiveTok
|
||||
for (CodeView::CodeSnippetParams& params : fileSnippets)
|
||||
{
|
||||
params.locationFile = m_locationAccess->getTokenLocationsForLinesInFile(
|
||||
file->getFilePath(), params.startLineNumber, params.endLineNumber);
|
||||
file->getFilePath().str(), params.startLineNumber, params.endLineNumber);
|
||||
}
|
||||
|
||||
if (declarationId != 0)
|
||||
@@ -144,7 +144,7 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForActiveTok
|
||||
|
||||
std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForFile(const TokenLocationFile* file) const
|
||||
{
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(file->getFilePath());
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(file->getFilePath().str());
|
||||
|
||||
std::vector<std::pair<uint, uint>> ranges = getSnippetRangesForFile(file);
|
||||
std::vector<CodeView::CodeSnippetParams> snippets;
|
||||
|
||||
@@ -40,21 +40,21 @@ bool CodeView::CodeSnippetParams::sort(const CodeSnippetParams& a, const CodeSni
|
||||
return false;
|
||||
}
|
||||
|
||||
const FilePath& aFilePath = a.locationFile.getFilePath();
|
||||
const FilePath& bFilePath = b.locationFile.getFilePath();
|
||||
|
||||
// different files
|
||||
if (a.locationFile.getFilePath() != b.locationFile.getFilePath())
|
||||
if (aFilePath != bFilePath)
|
||||
{
|
||||
// first header
|
||||
if (FileSystem::filePathWithoutExtension(a.locationFile.getFilePath()) ==
|
||||
FileSystem::filePathWithoutExtension(b.locationFile.getFilePath()))
|
||||
if (aFilePath.withoutExtension() == bFilePath.withoutExtension())
|
||||
{
|
||||
return FileSystem::extension(a.locationFile.getFilePath()) >
|
||||
FileSystem::extension(b.locationFile.getFilePath());
|
||||
return aFilePath.extension() > bFilePath.extension();
|
||||
}
|
||||
// alphabetical filepath without extension
|
||||
else
|
||||
{
|
||||
return FileSystem::filePathWithoutExtension(a.locationFile.getFilePath())
|
||||
< FileSystem::filePathWithoutExtension(b.locationFile.getFilePath());
|
||||
return aFilePath.withoutExtension() < bFilePath.withoutExtension();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user