From 054b8fab17e09a3beade4c345fc16bf549adb399 Mon Sep 17 00:00:00 2001 From: malte_langkabel Date: Thu, 4 May 2017 10:55:16 +0200 Subject: [PATCH] logic: reduce access to filesystem while indexing * use canonical filepath cache in cxx indexer * made constructors of FilePath explicit * use FilePath at more places instead of string * forward declares FilePath wherever possible --- src/app/main.cpp | 2 +- src/lib/Application.cpp | 4 +- src/lib/ApplicationStateMonitor.h | 3 +- .../component/controller/CodeController.cpp | 3 +- src/lib/component/controller/CodeController.h | 1 + .../controller/IDECommunicationController.cpp | 10 +-- src/lib/component/view/CodeView.h | 2 +- src/lib/component/view/ErrorView.h | 2 + src/lib/component/view/GraphViewStyle.cpp | 12 +-- src/lib/data/IntermediateStorage.cpp | 6 +- src/lib/data/PersistentStorage.cpp | 8 +- src/lib/data/PersistentStorage.h | 4 +- src/lib/data/SqliteBookmarkStorage.h | 1 - src/lib/data/SqliteIndexStorage.cpp | 6 +- src/lib/data/SqliteIndexStorage.h | 5 +- src/lib/data/TaskCleanStorage.cpp | 1 + src/lib/data/TaskCleanStorage.h | 2 +- src/lib/data/TaskFinishParsing.h | 1 - src/lib/data/access/StorageAccess.h | 6 +- src/lib/data/access/StorageAccessProxy.cpp | 11 +-- src/lib/data/access/StorageAccessProxy.h | 2 +- src/lib/data/location/SourceLocationFile.h | 1 + src/lib/data/parser/Parser.h | 2 - src/lib/project/Project.cpp | 4 +- src/lib/project/SourceGroup.cpp | 2 + src/lib/project/SourceGroup.h | 2 +- src/lib/settings/ApplicationSettings.cpp | 12 +-- src/lib/settings/ApplicationSettings.h | 4 +- src/lib/settings/Settings.cpp | 2 +- src/lib/utility/Cache.h | 7 ++ src/lib/utility/ResourcePaths.cpp | 20 ++--- src/lib/utility/ResourcePaths.h | 12 +-- src/lib/utility/UserPaths.cpp | 26 +++---- src/lib/utility/UserPaths.h | 20 ++--- .../utility/commandline/CommandLineParser.cpp | 6 +- src/lib/utility/file/FilePath.cpp | 76 ++++++++++++++----- src/lib/utility/file/FilePath.h | 11 ++- src/lib/utility/file/FileRegister.cpp | 5 +- .../utility/file/FileRegisterStateData.cpp | 2 + src/lib/utility/file/FileSystem.cpp | 22 ++---- src/lib/utility/file/FileSystem.h | 6 +- .../interprocess/SharedUUIDManager.cpp | 6 +- src/lib/utility/logging/FileLogger.cpp | 6 +- src/lib/utility/logging/FileLogger.h | 5 +- src/lib/utility/text/TextAccess.cpp | 10 +-- src/lib/utility/text/TextAccess.h | 10 ++- src/lib/utility/utilityLibrary.h | 1 - src/lib_cxx/CMakeLists.txt | 1 + src/lib_cxx/data/indexer/IndexerCommandCxx.h | 3 +- .../data/indexer/IndexerCommandCxxManual.cpp | 1 - .../data/indexer/IndexerCommandCxxManual.h | 3 +- src/lib_cxx/data/parser/cxx/ASTAction.h | 15 +++- .../data/parser/cxx/ASTActionFactory.cpp | 10 ++- .../data/parser/cxx/ASTActionFactory.h | 9 ++- src/lib_cxx/data/parser/cxx/ASTConsumer.cpp | 12 ++- src/lib_cxx/data/parser/cxx/ASTConsumer.h | 10 ++- .../data/parser/cxx/CommentHandler.cpp | 11 ++- src/lib_cxx/data/parser/cxx/CommentHandler.h | 10 ++- src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp | 48 +++++++----- src/lib_cxx/data/parser/cxx/CxxAstVisitor.h | 14 +++- .../cxx/CxxAstVisitorComponentIndexer.cpp | 7 +- .../data/parser/cxx/CxxDiagnosticConsumer.cpp | 4 +- .../data/parser/cxx/CxxDiagnosticConsumer.h | 4 + src/lib_cxx/data/parser/cxx/CxxParser.cpp | 35 +++++++-- src/lib_cxx/data/parser/cxx/CxxParser.h | 4 +- .../data/parser/cxx/CxxVerboseAstVisitor.cpp | 10 ++- .../data/parser/cxx/CxxVerboseAstVisitor.h | 9 ++- .../data/parser/cxx/PreprocessorCallbacks.cpp | 16 ++-- .../data/parser/cxx/PreprocessorCallbacks.h | 8 +- src/lib_cxx/data/parser/cxx/cxxCacheTypes.h | 11 +++ src/lib_cxx/utility/CompilationDatabase.cpp | 4 +- src/lib_cxx/utility/CompilationDatabase.h | 2 +- .../platform_includes/includesWindows.h | 6 +- src/lib_gui/qt/QtApplication.cpp | 2 +- .../qt/element/QtAutocompletionList.cpp | 2 +- src/lib_gui/qt/element/QtBookmark.cpp | 6 +- src/lib_gui/qt/element/QtBookmarkCategory.cpp | 8 +- src/lib_gui/qt/element/QtCodeFileList.cpp | 1 + src/lib_gui/qt/element/QtCodeFileSingle.cpp | 1 + src/lib_gui/qt/element/QtCodeFileSingle.h | 1 + .../qt/element/QtCodeFileTitleButton.cpp | 9 +-- src/lib_gui/qt/element/QtCodeNavigateable.h | 2 +- src/lib_gui/qt/element/QtCodeNavigator.cpp | 8 +- src/lib_gui/qt/element/QtDirectoryListBox.cpp | 18 ++--- src/lib_gui/qt/element/QtHelpButton.cpp | 4 +- src/lib_gui/qt/element/QtLocationPicker.cpp | 4 +- src/lib_gui/qt/element/QtProgressBar.cpp | 2 +- src/lib_gui/qt/element/QtRefreshBar.cpp | 2 +- src/lib_gui/qt/element/QtSearchBar.cpp | 4 +- src/lib_gui/qt/element/QtStatusBar.cpp | 4 +- src/lib_gui/qt/element/QtUndoRedo.cpp | 4 +- src/lib_gui/qt/graphics/QtGraphicsView.cpp | 4 +- src/lib_gui/qt/graphics/QtGraphicsView.h | 2 - src/lib_gui/qt/utility/utilityQt.cpp | 13 ++-- src/lib_gui/qt/utility/utilityQt.h | 5 +- src/lib_gui/qt/view/QtBookmarkView.cpp | 10 +-- src/lib_gui/qt/view/QtCodeView.cpp | 2 +- src/lib_gui/qt/view/QtErrorView.cpp | 2 +- src/lib_gui/qt/view/QtGraphView.cpp | 10 +-- src/lib_gui/qt/view/QtLogView.cpp | 2 +- src/lib_gui/qt/view/QtRefreshView.cpp | 2 +- src/lib_gui/qt/view/QtSearchView.cpp | 2 +- src/lib_gui/qt/view/QtTabbedView.cpp | 2 +- src/lib_gui/qt/view/QtUndoRedoView.cpp | 2 +- .../qt/view/graphElements/QtGraphNode.cpp | 2 +- .../view/graphElements/QtGraphNodeAccess.cpp | 2 +- .../qt/view/graphElements/QtGraphNodeData.cpp | 1 + .../qt/view/graphElements/QtGraphNodeData.h | 4 +- .../graphElements/QtGraphNodeExpandToggle.cpp | 2 +- src/lib_gui/qt/window/QtAbout.cpp | 10 +-- src/lib_gui/qt/window/QtBookmarkBrowser.cpp | 4 +- src/lib_gui/qt/window/QtBookmarkCreator.cpp | 4 +- src/lib_gui/qt/window/QtIndexingDialog.cpp | 8 +- src/lib_gui/qt/window/QtKeyboardShortcuts.cpp | 2 +- src/lib_gui/qt/window/QtLicense.cpp | 3 +- src/lib_gui/qt/window/QtMainWindow.cpp | 22 +++--- src/lib_gui/qt/window/QtSelectPathsDialog.cpp | 4 +- src/lib_gui/qt/window/QtSelectPathsDialog.h | 2 +- src/lib_gui/qt/window/QtSplashScreen.cpp | 4 +- src/lib_gui/qt/window/QtStartScreen.cpp | 14 ++-- src/lib_gui/qt/window/QtWindow.cpp | 6 +- .../project_wizzard/QtProjectWizzard.cpp | 2 +- .../QtProjectWizzardContentData.cpp | 6 +- .../QtProjectWizzardContentPath.cpp | 4 +- .../QtProjectWizzardContentPreferences.cpp | 4 +- .../QtProjectWizzardContentSelect.cpp | 2 +- .../path_detector/CombinedPathDetector.cpp | 2 + .../utility/path_detector/PathDetector.cpp | 2 + .../utility/path_detector/PathDetector.h | 2 +- .../cxx_header/CxxFrameworkPathDetector.cpp | 1 + .../cxx_header/CxxHeaderPathDetector.cpp | 1 + .../cxx_header/CxxVsHeaderPathDetector.cpp | 8 +- .../java_runtime/JavaPathDetector.h | 1 - .../java_runtime/JavaPathDetectorLinux.cpp | 3 +- .../java_runtime/JavaPathDetectorMac.cpp | 1 + .../java_runtime/JavaPathDetectorWindows.cpp | 1 + .../MavenPathDetectorUnix.cpp | 1 + .../MavenPathDetectorWindows.cpp | 1 + .../data/indexer/IndexerCommandJava.h | 3 +- src/lib_java/data/parser/java/JavaParser.cpp | 7 +- src/lib_java/data/parser/java/JavaParser.h | 4 +- src/lib_java/project/SourceGroupJava.cpp | 24 +++--- src/lib_java/utility/utilityMaven.cpp | 9 ++- src/lib_java/utility/utilityMaven.h | 4 +- src/test/ConfigManagerTestSuite.h | 2 +- src/test/CxxParserTestSuite.h | 2 +- src/test/FileManagerTestSuite.h | 4 +- src/test/FilePathTestSuite.h | 2 +- src/test/FileSystemTestSuite.h | 14 ++-- src/test/JavaParserTestSuite.h | 2 +- src/test/SettingsTestSuite.h | 14 ++-- src/test/SourceLocationCollectionTestSuite.h | 40 +++++----- src/test/SqliteBookmarkStorageTestSuite.h | 24 +++--- src/test/SqliteIndexStorageTestSuite.h | 16 ++-- src/test/StorageTestSuite.h | 6 +- src/test/TextAccessTestSuite.h | 8 +- 156 files changed, 656 insertions(+), 444 deletions(-) create mode 100644 src/lib_cxx/data/parser/cxx/cxxCacheTypes.h diff --git a/src/app/main.cpp b/src/app/main.cpp index 214e0c6c..5e97e77a 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -83,7 +83,7 @@ void prefillMavenExecutablePath() { MessageStatus("Run Maven executable path detection, found: " + paths.front().str()); - settings->setMavenPath(paths.front().str()); + settings->setMavenPath(paths.front()); settings->save(); } else diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 40a7a1d2..1c9426f7 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -71,10 +71,10 @@ void Application::destroyInstance() void Application::loadSettings() { - MessageStatus("Load settings: " + UserPaths::getAppSettingsPath()).dispatch(); + MessageStatus("Load settings: " + UserPaths::getAppSettingsPath().str()).dispatch(); std::shared_ptr settings = ApplicationSettings::getInstance(); - settings->load(FilePath(UserPaths::getAppSettingsPath())); + settings->load(UserPaths::getAppSettingsPath()); LogManager::getInstance()->setLoggingEnabled(settings->getLoggingEnabled()); diff --git a/src/lib/ApplicationStateMonitor.h b/src/lib/ApplicationStateMonitor.h index 95f9e8a0..ddaeb3f6 100644 --- a/src/lib/ApplicationStateMonitor.h +++ b/src/lib/ApplicationStateMonitor.h @@ -3,8 +3,9 @@ #include #include +#include -#include "utility/file/FilePath.h" +class FilePath; class ApplicationStateMonitor { diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index a740111e..6b741d3f 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -2,6 +2,7 @@ #include +#include "utility/file/FileInfo.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/text/TextAccess.h" #include "utility/tracing.h" @@ -241,7 +242,7 @@ void CodeController::handleMessage(MessageChangeFileView* message) else { std::shared_ptr file = - m_storageAccess->getSourceLocationsForFile(message->filePath.str()); + m_storageAccess->getSourceLocationsForFile(message->filePath); SourceLocationFile* activeLocations = m_collection->getSourceLocationFileByPath(message->filePath).get(); if (activeLocations) diff --git a/src/lib/component/controller/CodeController.h b/src/lib/component/controller/CodeController.h index fa5d4178..c2e09bc2 100644 --- a/src/lib/component/controller/CodeController.h +++ b/src/lib/component/controller/CodeController.h @@ -4,6 +4,7 @@ #include #include +#include "utility/file/FilePath.h" #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/MessageActivateAll.h" #include "utility/messaging/type/MessageActivateLocalSymbols.h" diff --git a/src/lib/component/controller/IDECommunicationController.cpp b/src/lib/component/controller/IDECommunicationController.cpp index 4543725c..edd6278f 100644 --- a/src/lib/component/controller/IDECommunicationController.cpp +++ b/src/lib/component/controller/IDECommunicationController.cpp @@ -81,12 +81,12 @@ void IDECommunicationController::handleSetActiveTokenMessage( { const unsigned int cursorColumn = message.column; - if (FileSystem::getFileInfoForPath(message.fileLocation).lastWriteTime - == m_storageAccess->getFileInfoForFilePath(message.fileLocation).lastWriteTime) + if (FileSystem::getFileInfoForPath(FilePath(message.fileLocation)).lastWriteTime + == m_storageAccess->getFileInfoForFilePath(FilePath(message.fileLocation)).lastWriteTime) { // file was not modified std::shared_ptr sourceLocationFile = m_storageAccess->getSourceLocationsForLinesInFile( - message.fileLocation, message.row, message.row + FilePath(message.fileLocation), message.row, message.row ); std::vector selectedLocationIds; @@ -116,10 +116,10 @@ void IDECommunicationController::handleSetActiveTokenMessage( } } - Id fileId = m_storageAccess->getNodeIdForFileNode(message.fileLocation); + Id fileId = m_storageAccess->getNodeIdForFileNode(FilePath(message.fileLocation)); if (fileId > 0) { - MessageActivateFile(message.fileLocation, message.row).dispatchImmediately(); + MessageActivateFile(FilePath(message.fileLocation), message.row).dispatchImmediately(); MessageActivateWindow().dispatch(); } else diff --git a/src/lib/component/view/CodeView.h b/src/lib/component/view/CodeView.h index bba32597..e9b2123c 100644 --- a/src/lib/component/view/CodeView.h +++ b/src/lib/component/view/CodeView.h @@ -4,12 +4,12 @@ #include #include "data/ErrorInfo.h" -#include "utility/file/FilePath.h" #include "component/view/helper/CodeSnippetParams.h" #include "component/view/View.h" class CodeController; +class FilePath; class SourceLocationCollection; class CodeView diff --git a/src/lib/component/view/ErrorView.h b/src/lib/component/view/ErrorView.h index 3bcd4b3f..237170eb 100644 --- a/src/lib/component/view/ErrorView.h +++ b/src/lib/component/view/ErrorView.h @@ -1,6 +1,8 @@ #ifndef ERROR_VIEW_H #define ERROR_VIEW_H +#include + #include "component/view/View.h" #include "data/ErrorInfo.h" diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp index c400b620..dd497da5 100644 --- a/src/lib/component/view/GraphViewStyle.cpp +++ b/src/lib/component/view/GraphViewStyle.cpp @@ -519,7 +519,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused) style.color = getNodeColor("bundle", isFocused); addIcon(Node::NODE_ENUM, false, &style); - style.iconPath = ResourcePaths::getGuiPath() + "graph_view/images/bundle.png"; + style.iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/bundle.png"; return style; } @@ -712,23 +712,23 @@ void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* s { case Node::NODE_NAMESPACE: case Node::NODE_PACKAGE: - style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/namespace.png"; + style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/namespace.png"; style->iconSize = s_fontSize - 4; style->iconOffset.x = -1; style->iconOffset.y = 5; return; case Node::NODE_ENUM: - style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/enum.png"; + style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/enum.png"; break; case Node::NODE_TYPEDEF: - style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/typedef.png"; + style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/typedef.png"; break; case Node::NODE_MACRO: - style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/macro.png"; + style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/macro.png"; break; case Node::NODE_FILE: - style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/file.png"; + style->iconPath = ResourcePaths::getGuiPath().str() + "graph_view/images/file.png"; break; default: return; diff --git a/src/lib/data/IntermediateStorage.cpp b/src/lib/data/IntermediateStorage.cpp index 4d95d568..ba4539ed 100644 --- a/src/lib/data/IntermediateStorage.cpp +++ b/src/lib/data/IntermediateStorage.cpp @@ -48,15 +48,15 @@ void IntermediateStorage::setAllFilesIncomplete() void IntermediateStorage::setFilesWithErrorsIncomplete() { - std::set errorFiles; + std::set errorFileNames; for (StorageError& error : m_errors) { - errorFiles.insert(error.filePath); + errorFileNames.insert(error.filePath.str()); } for (StorageFile& file : m_files) { - if (errorFiles.find(file.filePath) != errorFiles.end()) + if (errorFileNames.find(file.filePath) != errorFileNames.end()) { file.complete = false; } diff --git a/src/lib/data/PersistentStorage.cpp b/src/lib/data/PersistentStorage.cpp index 4b7b6a93..4b7483ca 100644 --- a/src/lib/data/PersistentStorage.cpp +++ b/src/lib/data/PersistentStorage.cpp @@ -4,6 +4,8 @@ #include #include "utility/Cache.h" +#include "utility/file/FileInfo.h" +#include "utility/file/FilePath.h" #include "utility/file/FileSystem.h" #include "utility/logging/logging.h" #include "utility/messaging/type/MessageNewErrors.h" @@ -1273,7 +1275,7 @@ std::shared_ptr PersistentStorage::getSourceLocationsF for (const StorageFile& file : m_sqliteIndexStorage.getAllByIds(fileIds)) { - collection->addSourceLocationFile(m_sqliteIndexStorage.getSourceLocationsForFile(file.filePath)); + collection->addSourceLocationFile(m_sqliteIndexStorage.getSourceLocationsForFile(FilePath(file.filePath))); } if (nonFileIds.size()) @@ -1351,7 +1353,7 @@ std::shared_ptr PersistentStorage::getSourceLocationsForFile } std::shared_ptr PersistentStorage::getSourceLocationsForLinesInFile( - const std::string& filePath, uint firstLineNumber, uint lastLineNumber + const FilePath& filePath, uint firstLineNumber, uint lastLineNumber ) const { TRACE(); @@ -2041,7 +2043,7 @@ void PersistentStorage::buildSearchIndex() auto it = fileMap.find(node.id); if (it != fileMap.end()) { - FilePath filePath = it->second.filePath; + FilePath filePath(it->second.filePath); if (filePath.exists()) { diff --git a/src/lib/data/PersistentStorage.h b/src/lib/data/PersistentStorage.h index 81bba249..a8258413 100644 --- a/src/lib/data/PersistentStorage.h +++ b/src/lib/data/PersistentStorage.h @@ -4,8 +4,6 @@ #include #include -#include "utility/file/FilePath.h" - #include "data/access/StorageAccess.h" #include "data/fulltextsearch/FullTextSearchIndex.h" #include "data/graph/token_component/TokenComponentAccess.h" @@ -125,7 +123,7 @@ public: virtual std::shared_ptr getSourceLocationsForFile(const FilePath& filePath) const; virtual std::shared_ptr getSourceLocationsForLinesInFile( - const std::string& filePath, uint firstLineNumber, uint lastLineNumber + const FilePath& filePath, uint firstLineNumber, uint lastLineNumber ) const; virtual std::shared_ptr getCommentLocationsInFile(const FilePath& filePath) const; diff --git a/src/lib/data/SqliteBookmarkStorage.h b/src/lib/data/SqliteBookmarkStorage.h index 911b87dd..53d8abe5 100644 --- a/src/lib/data/SqliteBookmarkStorage.h +++ b/src/lib/data/SqliteBookmarkStorage.h @@ -8,7 +8,6 @@ #include "data/bookmark/NodeBookmark.h" #include "data/SqliteStorage.h" #include "data/StorageTypes.h" -#include "utility/file/FilePath.h" #include "utility/types.h" class SqliteBookmarkStorage diff --git a/src/lib/data/SqliteIndexStorage.cpp b/src/lib/data/SqliteIndexStorage.cpp index fa706043..8c2728c5 100644 --- a/src/lib/data/SqliteIndexStorage.cpp +++ b/src/lib/data/SqliteIndexStorage.cpp @@ -74,7 +74,7 @@ void SqliteIndexStorage::addFile(const int id, const std::string& filePath, cons return; } - std::shared_ptr content = TextAccess::createFromFile(filePath); + std::shared_ptr content = TextAccess::createFromFile(FilePath(filePath)); const size_t lineCount = content->getLineCount(); const bool success = executeStatement( @@ -589,7 +589,7 @@ std::shared_ptr SqliteIndexStorage::getFileContentByPath(const std:: LOG_ERROR(std::to_string(e.errorCode()) + ": " + e.errorMessage()); } - return TextAccess::createFromFile(filePath); + return TextAccess::createFromFile(FilePath(filePath)); } void SqliteIndexStorage::setFileComplete(bool complete, Id fileId) @@ -1176,7 +1176,7 @@ std::vector SqliteIndexStorage::doGetAll(const std:: if (lineNumber != -1 && columnNumber != -1) { - errors.push_back(StorageError(id, message, filePath, lineNumber, columnNumber, fatal, indexed)); + errors.push_back(StorageError(id, message, FilePath(filePath), lineNumber, columnNumber, fatal, indexed)); id++; } diff --git a/src/lib/data/SqliteIndexStorage.h b/src/lib/data/SqliteIndexStorage.h index 26074cd2..9533dc13 100644 --- a/src/lib/data/SqliteIndexStorage.h +++ b/src/lib/data/SqliteIndexStorage.h @@ -7,14 +7,13 @@ #include "data/location/SourceLocationFile.h" #include "data/name/NameHierarchy.h" -#include "data/StorageTypes.h" #include "data/SqliteDatabaseIndex.h" -#include "utility/file/FilePath.h" +#include "data/SqliteStorage.h" +#include "data/StorageTypes.h" #include "utility/types.h" #include "utility/utility.h" #include "utility/utilityString.h" -#include "data/SqliteStorage.h" class TextAccess; class Version; diff --git a/src/lib/data/TaskCleanStorage.cpp b/src/lib/data/TaskCleanStorage.cpp index da8ae2b4..40546c9a 100644 --- a/src/lib/data/TaskCleanStorage.cpp +++ b/src/lib/data/TaskCleanStorage.cpp @@ -2,6 +2,7 @@ #include "component/view/DialogView.h" #include "data/PersistentStorage.h" +#include "utility/file/FilePath.h" #include "utility/scheduling/Blackboard.h" #include "utility/utility.h" #include "Application.h" diff --git a/src/lib/data/TaskCleanStorage.h b/src/lib/data/TaskCleanStorage.h index afb4d38d..7a0aa302 100644 --- a/src/lib/data/TaskCleanStorage.h +++ b/src/lib/data/TaskCleanStorage.h @@ -3,11 +3,11 @@ #include -#include "utility/file/FilePath.h" #include "utility/scheduling/Task.h" #include "utility/TimePoint.h" class DialogView; +class FilePath; class PersistentStorage; class TaskCleanStorage diff --git a/src/lib/data/TaskFinishParsing.h b/src/lib/data/TaskFinishParsing.h index 97ef33fa..f3996240 100644 --- a/src/lib/data/TaskFinishParsing.h +++ b/src/lib/data/TaskFinishParsing.h @@ -3,7 +3,6 @@ #include -#include "utility/file/FilePath.h" #include "utility/scheduling/Task.h" class DialogView; diff --git a/src/lib/data/access/StorageAccess.h b/src/lib/data/access/StorageAccess.h index b762cda8..57d892cb 100644 --- a/src/lib/data/access/StorageAccess.h +++ b/src/lib/data/access/StorageAccess.h @@ -6,8 +6,6 @@ #include #include "utility/types.h" -#include "utility/file/FileInfo.h" -#include "utility/file/FilePath.h" #include "data/bookmark/Bookmark.h" #include "data/bookmark/BookmarkCategory.h" @@ -20,6 +18,8 @@ #include "data/ErrorInfo.h" #include "data/StorageStats.h" +class FilePath; +struct FileInfo; class Graph; class SourceLocationCollection; class SourceLocationFile; @@ -61,7 +61,7 @@ public: const std::vector& locationIds) const = 0; virtual std::shared_ptr getSourceLocationsForFile(const FilePath& filePath) const = 0; virtual std::shared_ptr getSourceLocationsForLinesInFile( - const std::string& filePath, uint firstLineNumber, uint lastLineNumber) const = 0; + const FilePath& filePath, uint firstLineNumber, uint lastLineNumber) const = 0; virtual std::shared_ptr getCommentLocationsInFile(const FilePath& filePath) const = 0; diff --git a/src/lib/data/access/StorageAccessProxy.cpp b/src/lib/data/access/StorageAccessProxy.cpp index f0e9b71d..65e27b67 100644 --- a/src/lib/data/access/StorageAccessProxy.cpp +++ b/src/lib/data/access/StorageAccessProxy.cpp @@ -4,8 +4,9 @@ #include "data/location/SourceLocationCollection.h" #include "data/location/SourceLocationFile.h" -#include "utility/logging/logging.h" #include "utility/file/FileInfo.h" +#include "utility/file/FilePath.h" +#include "utility/logging/logging.h" #include "utility/messaging/type/MessageShowErrors.h" #include "utility/TimePoint.h" @@ -224,11 +225,11 @@ std::shared_ptr StorageAccessProxy::getSourceLocationsForFil return m_subject->getSourceLocationsForFile(filePath); } - return std::make_shared("", false, false); + return std::make_shared(FilePath(), false, false); } std::shared_ptr StorageAccessProxy::getSourceLocationsForLinesInFile( - const std::string& filePath, uint firstLineNumber, uint lastLineNumber + const FilePath& filePath, uint firstLineNumber, uint lastLineNumber ) const { if (hasSubject()) @@ -236,7 +237,7 @@ std::shared_ptr StorageAccessProxy::getSourceLocationsForLin return m_subject->getSourceLocationsForLinesInFile(filePath, firstLineNumber, lastLineNumber); } - return std::make_shared("", false, false); + return std::make_shared(FilePath(), false, false); } std::shared_ptr StorageAccessProxy::getCommentLocationsInFile(const FilePath& filePath) const @@ -246,7 +247,7 @@ std::shared_ptr StorageAccessProxy::getCommentLocationsInFil return m_subject->getCommentLocationsInFile(filePath); } - return std::make_shared("", false, false); + return std::make_shared(FilePath(), false, false); } std::shared_ptr StorageAccessProxy::getFileContent(const FilePath& filePath) const diff --git a/src/lib/data/access/StorageAccessProxy.h b/src/lib/data/access/StorageAccessProxy.h index 15354673..c4d9f9dd 100644 --- a/src/lib/data/access/StorageAccessProxy.h +++ b/src/lib/data/access/StorageAccessProxy.h @@ -51,7 +51,7 @@ public: ) const; virtual std::shared_ptr getSourceLocationsForFile(const FilePath& filePath) const; virtual std::shared_ptr getSourceLocationsForLinesInFile( - const std::string& filePath, uint firstLineNumber, uint lastLineNumber + const FilePath& filePath, uint firstLineNumber, uint lastLineNumber ) const; virtual std::shared_ptr getCommentLocationsInFile(const FilePath& filePath) const; diff --git a/src/lib/data/location/SourceLocationFile.h b/src/lib/data/location/SourceLocationFile.h index d27af6ae..1bbd6c58 100644 --- a/src/lib/data/location/SourceLocationFile.h +++ b/src/lib/data/location/SourceLocationFile.h @@ -2,6 +2,7 @@ #define SOURCE_LOCATION_FILE_H #include +#include #include #include diff --git a/src/lib/data/parser/Parser.h b/src/lib/data/parser/Parser.h index 88a7112f..a621c861 100644 --- a/src/lib/data/parser/Parser.h +++ b/src/lib/data/parser/Parser.h @@ -5,8 +5,6 @@ #include #include -#include "utility/file/FilePath.h" - class ParserClient; class TextAccess; diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 6e7fd3e1..e983c8e1 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -229,7 +229,7 @@ void Project::load() { m_state = PROJECT_STATE_OUTVERSIONED; } - else if (utility::replace(TextAccess::createFromFile(projectSettingsPath.str())->getText(), "\r", "") != + else if (utility::replace(TextAccess::createFromFile(projectSettingsPath)->getText(), "\r", "") != utility::replace(TextAccess::createFromString(m_storage->getProjectSettingsText())->getText(), "\r", "")) { m_state = PROJECT_STATE_OUTDATED; @@ -424,7 +424,7 @@ void Project::buildIndex(const std::set& filesToClean, bool fullRefres m_storage->clear(); } - m_storage->setProjectSettingsText(TextAccess::createFromFile(getProjectSettingsFilePath().str())->getText()); + m_storage->setProjectSettingsText(TextAccess::createFromFile(getProjectSettingsFilePath())->getText()); std::shared_ptr taskSequential = std::make_shared(); diff --git a/src/lib/project/SourceGroup.cpp b/src/lib/project/SourceGroup.cpp index aa290ec2..12ce9895 100644 --- a/src/lib/project/SourceGroup.cpp +++ b/src/lib/project/SourceGroup.cpp @@ -1,5 +1,7 @@ #include "project/SourceGroup.h" +#include "utility/file/FilePath.h" + SourceGroup::~SourceGroup() { } diff --git a/src/lib/project/SourceGroup.h b/src/lib/project/SourceGroup.h index 9fe4abde..2156f859 100644 --- a/src/lib/project/SourceGroup.h +++ b/src/lib/project/SourceGroup.h @@ -5,10 +5,10 @@ #include #include -#include "utility/file/FilePath.h" #include "settings/LanguageType.h" #include "settings/SourceGroupType.h" +class FilePath; class IndexerCommand; class SourceGroup diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index 683a8473..a7829e52 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -110,7 +110,7 @@ void ApplicationSettings::setUseAnimations(bool useAnimations) FilePath ApplicationSettings::getColorSchemePath() const { - FilePath defaultPath(ResourcePaths::getColorSchemesPath() + "bright.xml"); + FilePath defaultPath(ResourcePaths::getColorSchemesPath().concat(FilePath("bright.xml"))); FilePath path(getValue("application/color_scheme", defaultPath.str())); if (path != defaultPath && !path.exists()) @@ -276,14 +276,14 @@ void ApplicationSettings::setJavaMaximumMemory(int size) setValue("indexing/java/java_maximum_memory", size); } -std::string ApplicationSettings::getMavenPath() const +FilePath ApplicationSettings::getMavenPath() const { - return getValue("indexing/java/maven_path", ""); + return FilePath(getValue("indexing/java/maven_path", "")); } -void ApplicationSettings::setMavenPath(const std::string path) +void ApplicationSettings::setMavenPath(const FilePath& path) { - setValue("indexing/java/maven_path", path); + setValue("indexing/java/maven_path", path.str()); } std::vector ApplicationSettings::getHeaderSearchPaths() const @@ -369,7 +369,7 @@ std::vector ApplicationSettings::getRecentProjects() const } else { - recentProjects.push_back(UserPaths::getSampleProjectsPath() + project.str()); + recentProjects.push_back(UserPaths::getSampleProjectsPath().concat(project)); } } return recentProjects; diff --git a/src/lib/settings/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h index 0a014102..41de1b3c 100644 --- a/src/lib/settings/ApplicationSettings.h +++ b/src/lib/settings/ApplicationSettings.h @@ -82,8 +82,8 @@ public: int getJavaMaximumMemory() const; void setJavaMaximumMemory(int size); - std::string getMavenPath() const; - void setMavenPath(const std::string path); + FilePath getMavenPath() const; + void setMavenPath(const FilePath& path); std::vector getHeaderSearchPaths() const; std::vector getHeaderSearchPathsExpanded() const; diff --git a/src/lib/settings/Settings.cpp b/src/lib/settings/Settings.cpp index 92b6b1ce..0cc5250b 100644 --- a/src/lib/settings/Settings.cpp +++ b/src/lib/settings/Settings.cpp @@ -31,7 +31,7 @@ bool Settings::load(const FilePath& filePath) { if (filePath.exists()) { - m_config = ConfigManager::createAndLoad(TextAccess::createFromFile(filePath.str())); + m_config = ConfigManager::createAndLoad(TextAccess::createFromFile(filePath)); m_filePath = filePath; return true; } diff --git a/src/lib/utility/Cache.h b/src/lib/utility/Cache.h index 3ee702f1..aff5c194 100644 --- a/src/lib/utility/Cache.h +++ b/src/lib/utility/Cache.h @@ -14,11 +14,16 @@ public: private: std::function m_calculator; std::unordered_map m_map; + + size_t m_hitCount; + size_t m_missCount; }; template Cache::Cache(std::function calculator) : m_calculator(calculator) + , m_hitCount(0) + , m_missCount(0) { } @@ -28,8 +33,10 @@ ValType Cache::getValue(KeyType key) typename std::unordered_map::const_iterator it = m_map.find(key); if (it != m_map.end()) { + ++m_hitCount; return it->second; } + ++m_missCount; ValType val = m_calculator(key); m_map[key] = val; return val; diff --git a/src/lib/utility/ResourcePaths.cpp b/src/lib/utility/ResourcePaths.cpp index daf113a5..bce6ca40 100644 --- a/src/lib/utility/ResourcePaths.cpp +++ b/src/lib/utility/ResourcePaths.cpp @@ -2,27 +2,27 @@ #include "AppPath.h" -std::string ResourcePaths::getColorSchemesPath() +FilePath ResourcePaths::getColorSchemesPath() { - return AppPath::getAppPath() + "data/color_schemes/"; + return FilePath(AppPath::getAppPath() + "data/color_schemes/"); } -std::string ResourcePaths::getFallbackPath() +FilePath ResourcePaths::getFallbackPath() { - return AppPath::getAppPath() + "data/fallback/"; + return FilePath(AppPath::getAppPath() + "data/fallback/"); } -std::string ResourcePaths::getFontsPath() +FilePath ResourcePaths::getFontsPath() { - return AppPath::getAppPath() + "data/fonts/"; + return FilePath(AppPath::getAppPath() + "data/fonts/"); } -std::string ResourcePaths::getGuiPath() +FilePath ResourcePaths::getGuiPath() { - return AppPath::getAppPath() + "data/gui/"; + return FilePath(AppPath::getAppPath() + "data/gui/"); } -std::string ResourcePaths::getJavaPath() +FilePath ResourcePaths::getJavaPath() { - return AppPath::getAppPath() + "data/java/"; + return FilePath(AppPath::getAppPath() + "data/java/"); } diff --git a/src/lib/utility/ResourcePaths.h b/src/lib/utility/ResourcePaths.h index d1943f60..d573c97a 100644 --- a/src/lib/utility/ResourcePaths.h +++ b/src/lib/utility/ResourcePaths.h @@ -3,14 +3,16 @@ #include +#include "utility/file/FilePath.h" + class ResourcePaths { public: - static std::string getColorSchemesPath(); - static std::string getFallbackPath(); - static std::string getFontsPath(); - static std::string getGuiPath(); - static std::string getJavaPath(); + static FilePath getColorSchemesPath(); + static FilePath getFallbackPath(); + static FilePath getFontsPath(); + static FilePath getGuiPath(); + static FilePath getJavaPath(); }; #endif // RESOURCE_PATHS_H diff --git a/src/lib/utility/UserPaths.cpp b/src/lib/utility/UserPaths.cpp index 7a853e91..878599a9 100644 --- a/src/lib/utility/UserPaths.cpp +++ b/src/lib/utility/UserPaths.cpp @@ -1,21 +1,21 @@ #include "utility/UserPaths.h" -std::string UserPaths::s_userDataPath = ""; -std::string UserPaths::s_sampleProjectsPath = ""; +FilePath UserPaths::s_userDataPath; +FilePath UserPaths::s_sampleProjectsPath; -std::string UserPaths::getUserDataPath() +FilePath UserPaths::getUserDataPath() { return s_userDataPath; } -void UserPaths::setUserDataPath(const std::string& path) +void UserPaths::setUserDataPath(const FilePath& path) { s_userDataPath = path; } -std::string UserPaths::getSampleProjectsPath() +FilePath UserPaths::getSampleProjectsPath() { - if (s_sampleProjectsPath.size()) + if (s_sampleProjectsPath.str().size()) { return s_sampleProjectsPath; } @@ -23,22 +23,22 @@ std::string UserPaths::getSampleProjectsPath() return s_userDataPath; } -void UserPaths::setSampleProjectsPath(const std::string& path) +void UserPaths::setSampleProjectsPath(const FilePath& path) { s_sampleProjectsPath = path; } -std::string UserPaths::getAppSettingsPath() +FilePath UserPaths::getAppSettingsPath() { - return getUserDataPath() + "ApplicationSettings.xml"; + return getUserDataPath().concat(FilePath("ApplicationSettings.xml")); } -std::string UserPaths::getWindowSettingsPath() +FilePath UserPaths::getWindowSettingsPath() { - return getUserDataPath() + "window_settings.ini"; + return getUserDataPath().concat(FilePath("window_settings.ini")); } -std::string UserPaths::getLogPath() +FilePath UserPaths::getLogPath() { - return getUserDataPath() + "log/"; + return getUserDataPath().concat(FilePath("log/")); } diff --git a/src/lib/utility/UserPaths.h b/src/lib/utility/UserPaths.h index 51c0696b..869db852 100644 --- a/src/lib/utility/UserPaths.h +++ b/src/lib/utility/UserPaths.h @@ -3,22 +3,24 @@ #include +#include "utility/file/FilePath.h" + class UserPaths { public: - static std::string getUserDataPath(); - static void setUserDataPath(const std::string& path); + static FilePath getUserDataPath(); + static void setUserDataPath(const FilePath& path); - static std::string getSampleProjectsPath(); - static void setSampleProjectsPath(const std::string& path); + static FilePath getSampleProjectsPath(); + static void setSampleProjectsPath(const FilePath& path); - static std::string getAppSettingsPath(); - static std::string getWindowSettingsPath(); - static std::string getLogPath(); + static FilePath getAppSettingsPath(); + static FilePath getWindowSettingsPath(); + static FilePath getLogPath(); private: - static std::string s_userDataPath; - static std::string s_sampleProjectsPath; + static FilePath s_userDataPath; + static FilePath s_sampleProjectsPath; }; #endif // USER_PATHS_H diff --git a/src/lib/utility/commandline/CommandLineParser.cpp b/src/lib/utility/commandline/CommandLineParser.cpp index ee2f75f2..b1a3019f 100644 --- a/src/lib/utility/commandline/CommandLineParser.cpp +++ b/src/lib/utility/commandline/CommandLineParser.cpp @@ -74,7 +74,7 @@ CommandLineParser::CommandLineParser(int argc, char** argv, const std::string& v if (vm.count("licenseFile")) { std::cout << "licensefile flag" << std::endl; - if (FileSystem::exists(licensefile)) + if (FilePath(licensefile).exists()) { std::cout << "licensefile exists" << std::endl; processLicense(m_license.loadFromFile(licensefile)); @@ -166,7 +166,7 @@ void CommandLineParser::processProjectfile(const std::string& file) } std::shared_ptr configManager = ConfigManager::createEmpty(); - if (!configManager->load(TextAccess::createFromFile(projectfile.str()))) + if (!configManager->load(TextAccess::createFromFile(projectfile))) { m_errorString = errorstring + " could not be loaded(invalid)"; return; @@ -180,7 +180,7 @@ void CommandLineParser::projectLoad() if (m_projectFile.exists() && (m_projectFile.extension() == ".srctrlprj" || m_projectFile.extension() == ".coatiproject")) { - MessageLoadProject(m_projectFile.str(), m_force).dispatch(); + MessageLoadProject(m_projectFile, m_force).dispatch(); } } diff --git a/src/lib/utility/file/FilePath.cpp b/src/lib/utility/file/FilePath.cpp index 543a9b42..b59e29e9 100644 --- a/src/lib/utility/file/FilePath.cpp +++ b/src/lib/utility/file/FilePath.cpp @@ -8,6 +8,9 @@ FilePath::FilePath() : m_exists(false) , m_checkedExists(false) + , m_isDirectory(false) + , m_checkedIsDirectory(false) + , m_canonicalized(false) { } @@ -15,6 +18,9 @@ FilePath::FilePath(const char* filePath) : m_path(filePath) , m_exists(false) , m_checkedExists(false) + , m_isDirectory(false) + , m_checkedIsDirectory(false) + , m_canonicalized(false) { } @@ -22,6 +28,9 @@ FilePath::FilePath(const std::string& filePath) : m_path(filePath) , m_exists(false) , m_checkedExists(false) + , m_isDirectory(false) + , m_checkedIsDirectory(false) + , m_canonicalized(false) { } @@ -29,6 +38,9 @@ FilePath::FilePath(const boost::filesystem::path& filePath) : m_path(filePath) , m_exists(false) , m_checkedExists(false) + , m_isDirectory(false) + , m_checkedIsDirectory(false) + , m_canonicalized(false) { } @@ -36,6 +48,9 @@ FilePath::FilePath(const std::string& filePath, const std::string& base) : m_path(boost::filesystem::absolute(filePath, base)) , m_exists(false) , m_checkedExists(false) + , m_isDirectory(false) + , m_checkedIsDirectory(false) + , m_canonicalized(false) { } @@ -60,9 +75,21 @@ bool FilePath::exists() const return m_exists; } +bool FilePath::recheckExists() const +{ + m_checkedExists = false; + return exists(); +} + bool FilePath::isDirectory() const { - return boost::filesystem::is_directory(m_path); + if (!m_checkedIsDirectory) + { + m_isDirectory = boost::filesystem::is_directory(m_path); + m_checkedIsDirectory = true; + } + + return m_isDirectory; } bool FilePath::isAbsolute() const @@ -72,37 +99,50 @@ bool FilePath::isAbsolute() const FilePath FilePath::parentDirectory() const { - return m_path.parent_path(); + FilePath parentDirectory(m_path.parent_path()); + parentDirectory.m_checkedIsDirectory = true; + parentDirectory.m_isDirectory = true; + + if (m_checkedExists && m_exists) + { + parentDirectory.m_checkedExists = true; + parentDirectory.m_exists = true; + } + return parentDirectory; } FilePath FilePath::absolute() const { - return boost::filesystem::absolute(m_path); + return FilePath(boost::filesystem::absolute(m_path)); } FilePath FilePath::canonical() const { + if (m_canonicalized) + { + return FilePath(*this); + } if (!exists()) { - return FilePath(m_path); + return FilePath(*this); } boost::filesystem::path abs_p = boost::filesystem::absolute(m_path); - boost::filesystem::path result; + boost::filesystem::path canonicalPath; for (boost::filesystem::path::iterator it = abs_p.begin(); it != abs_p.end(); ++it) { if (*it == "..") { // /a/b/.. is not necessarily /a if b is a symbolic link - if (boost::filesystem::is_symlink(result)) - result /= *it; + if (boost::filesystem::is_symlink(canonicalPath)) + canonicalPath /= *it; // /a/b/../.. is not /a/b/.. under most circumstances // We can end up with ..s in our result because of symbolic links - else if (result.filename() == "..") - result /= *it; + else if (canonicalPath.filename() == "..") + canonicalPath /= *it; // Otherwise it should be safe to resolve the parent else - result = result.parent_path(); + canonicalPath = canonicalPath.parent_path(); } else if (*it == ".") { @@ -111,10 +151,12 @@ FilePath FilePath::canonical() const else { // Just cat other path entries - result /= *it; + canonicalPath /= *it; } } - return result; + FilePath ret(canonicalPath); + ret.m_canonicalized = true; + return ret; } std::vector FilePath::expandEnvironmentVariables() const @@ -132,7 +174,7 @@ std::vector FilePath::expandEnvironmentVariables() const LOG_ERROR(match[1].str() + " is not an environment variable"); return paths; } - text.replace( match.position(0), match.length(0), s); + text.replace(match.position(0), match.length(0), s); } char environmentVariablePathSeparator = ':'; @@ -145,7 +187,7 @@ std::vector FilePath::expandEnvironmentVariables() const { if (str.size()) { - paths.push_back(str); + paths.push_back(FilePath(str)); } } @@ -159,7 +201,7 @@ FilePath FilePath::relativeTo(const FilePath& other) const if (a.root_path() != b.root_path()) { - return str(); + return *this; } boost::filesystem::path::const_iterator itA = a.begin(); @@ -196,12 +238,12 @@ FilePath FilePath::relativeTo(const FilePath& other) const r = "./"; } - return r; + return FilePath(r); } FilePath FilePath::concat(const FilePath& other) const { - return boost::filesystem::path(m_path) / other.m_path; + return FilePath(boost::filesystem::path(m_path) / other.m_path); } bool FilePath::contains(const FilePath& other) const diff --git a/src/lib/utility/file/FilePath.h b/src/lib/utility/file/FilePath.h index 73b1a195..da3aa245 100644 --- a/src/lib/utility/file/FilePath.h +++ b/src/lib/utility/file/FilePath.h @@ -2,6 +2,7 @@ #define FILE_PATH_H #include +#include #include "boost/filesystem.hpp" @@ -9,15 +10,16 @@ class FilePath { public: FilePath(); - FilePath(const char* filePath); - FilePath(const std::string& filePath); - FilePath(const boost::filesystem::path& filePath); + explicit FilePath(const char* filePath); + explicit FilePath(const std::string& filePath); + explicit FilePath(const boost::filesystem::path& filePath); FilePath(const std::string& filePath, const std::string& base); boost::filesystem::path path() const; bool empty() const; bool exists() const; + bool recheckExists() const; bool isDirectory() const; bool isAbsolute() const; @@ -49,6 +51,9 @@ private: mutable bool m_exists; mutable bool m_checkedExists; + mutable bool m_isDirectory; + mutable bool m_checkedIsDirectory; + mutable bool m_canonicalized; }; #endif // FILE_PATH_H diff --git a/src/lib/utility/file/FileRegister.cpp b/src/lib/utility/file/FileRegister.cpp index d476316f..8f581532 100644 --- a/src/lib/utility/file/FileRegister.cpp +++ b/src/lib/utility/file/FileRegister.cpp @@ -1,11 +1,14 @@ #include "utility/file/FileRegister.h" +#include "utility/file/FilePath.h" + FileRegister::FileRegister(const FileRegisterStateData& stateData, const std::set& indexedPaths, const std::set& excludedPaths) : m_stateData(stateData) , m_indexedPaths(indexedPaths) , m_excludedPaths(excludedPaths) , m_hasFilePathCache( - [&](std::string filePath){ + [&](std::string f){ + const FilePath filePath(f); bool ret = false; for (const FilePath& indexedPath: m_indexedPaths) { diff --git a/src/lib/utility/file/FileRegisterStateData.cpp b/src/lib/utility/file/FileRegisterStateData.cpp index ef75d6a2..4a90f987 100644 --- a/src/lib/utility/file/FileRegisterStateData.cpp +++ b/src/lib/utility/file/FileRegisterStateData.cpp @@ -1,5 +1,7 @@ #include "utility/file/FileRegisterStateData.h" +#include "utility/file/FilePath.h" + FileRegisterStateData::FileRegisterStateData() { } diff --git a/src/lib/utility/file/FileSystem.cpp b/src/lib/utility/file/FileSystem.cpp index de3849ab..99d962cf 100644 --- a/src/lib/utility/file/FileSystem.cpp +++ b/src/lib/utility/file/FileSystem.cpp @@ -6,14 +6,14 @@ #include "boost/filesystem.hpp" std::vector FileSystem::getFileNamesFromDirectory( - const std::string& path, const std::vector& extensions + const FilePath& path, const std::vector& extensions ){ std::set ext(extensions.begin(), extensions.end()); std::vector files; - if (boost::filesystem::is_directory(path)) + if (boost::filesystem::is_directory(path.path())) { - boost::filesystem::recursive_directory_iterator it(path); + boost::filesystem::recursive_directory_iterator it(path.path()); boost::filesystem::recursive_directory_iterator endit; while (it != endit) { @@ -38,7 +38,7 @@ std::vector FileSystem::getFileNamesFromDirectory( return files; } -FileInfo FileSystem::getFileInfoForPath(FilePath filePath) +FileInfo FileSystem::getFileInfoForPath(const FilePath& filePath) { if (filePath.exists()) { @@ -110,7 +110,7 @@ std::vector FileSystem::getFileInfosFromPaths( std::time_t t = boost::filesystem::last_write_time(*it); boost::posix_time::ptime lastWriteTime = boost::posix_time::from_time_t(t); - files.push_back(FileInfo(it->path(), lastWriteTime)); + files.push_back(FileInfo(FilePath(it->path()), lastWriteTime)); } } } @@ -135,7 +135,7 @@ std::vector FileSystem::getFileInfosFromPaths( TimePoint FileSystem::getLastWriteTime(const FilePath& filePath) { boost::posix_time::ptime lastWriteTime; - if (FileSystem::exists(filePath.str())) + if (filePath.exists()) { std::time_t t = boost::filesystem::last_write_time(filePath.path()); lastWriteTime = boost::posix_time::from_time_t(t); @@ -235,13 +235,3 @@ std::string FileSystem::filePathWithoutExtension(const std::string& path) { return boost::filesystem::path(path).replace_extension().generic_string(); } - -bool FileSystem::equivalent(const std::string& pathA, const std::string& pathB) -{ - if (exists(pathA) && exists(pathB)) - { - return boost::filesystem::equivalent(boost::filesystem::path(pathA), boost::filesystem::path(pathB)); - } - - return boost::filesystem::path(pathA).compare(boost::filesystem::path(pathB)) == 0; -} diff --git a/src/lib/utility/file/FileSystem.h b/src/lib/utility/file/FileSystem.h index ecc6e78e..99ba8c95 100644 --- a/src/lib/utility/file/FileSystem.h +++ b/src/lib/utility/file/FileSystem.h @@ -11,9 +11,9 @@ class FileSystem { public: static std::vector getFileNamesFromDirectory( - const std::string& path, const std::vector& extensions); + const FilePath& path, const std::vector& extensions); - static FileInfo getFileInfoForPath(FilePath filePath); + static FileInfo getFileInfoForPath(const FilePath& filePath); static std::vector getFileInfosFromPaths( const std::vector& paths, const std::vector& fileExtensions, bool followSymLinks = true); @@ -36,8 +36,6 @@ public: static std::string extension(const std::string& path); static std::string filePathWithoutExtension(const std::string& path); - - static bool equivalent(const std::string& pathA, const std::string& pathB); }; #endif // FILE_SYSTEM_H diff --git a/src/lib/utility/interprocess/SharedUUIDManager.cpp b/src/lib/utility/interprocess/SharedUUIDManager.cpp index a5f487b8..5302b2b4 100644 --- a/src/lib/utility/interprocess/SharedUUIDManager.cpp +++ b/src/lib/utility/interprocess/SharedUUIDManager.cpp @@ -19,7 +19,7 @@ std::shared_ptr SharedUUIDManager::getInstance() // m_instance = std::make_shared(); SharedUUIDManager* sharedUUIDManager = new SharedUUIDManager(); m_instance = std::shared_ptr(sharedUUIDManager); - m_instance->setFilePath(UserPaths::getUserDataPath()); + m_instance->setFilePath(UserPaths::getUserDataPath().str()); m_instance->saveInstanceUUID(); } @@ -33,7 +33,7 @@ SharedUUIDManager::~SharedUUIDManager() void SharedUUIDManager::setFilePath(const std::string& filePath) { m_filePath = filePath; - FileSystem::createDirectory(m_filePath); + FileSystem::createDirectory(FilePath(m_filePath)); refreshUUIDs(); } @@ -121,6 +121,6 @@ void SharedUUIDManager::refreshUUIDs() { if (FilePath(m_filePath + m_fileName).exists()) { - m_uuids = ConfigManager::createAndLoad(TextAccess::createFromFile(m_filePath + m_fileName)); + m_uuids = ConfigManager::createAndLoad(TextAccess::createFromFile(FilePath(m_filePath + m_fileName))); } } diff --git a/src/lib/utility/logging/FileLogger.cpp b/src/lib/utility/logging/FileLogger.cpp index 25c6b56e..0689b95d 100644 --- a/src/lib/utility/logging/FileLogger.cpp +++ b/src/lib/utility/logging/FileLogger.cpp @@ -22,7 +22,7 @@ FileLogger::~FileLogger() { } -void FileLogger::setLogDirectory(const std::string& filePath) +void FileLogger::setLogDirectory(const FilePath& filePath) { m_logDirectory = filePath; FileSystem::createDirectory(m_logDirectory); @@ -90,14 +90,14 @@ void FileLogger::updateLogFileName() if (fileChanged) { - FileSystem::remove(m_logDirectory + m_currentLogFileName); + FileSystem::remove(m_logDirectory.concat(FilePath(m_currentLogFileName))); } } void FileLogger::logMessage(const std::string& type, const LogMessage& message) { std::ofstream fileStream; - fileStream.open(m_logDirectory + m_currentLogFileName, std::ios::app); + fileStream.open(m_logDirectory.concat(FilePath(m_currentLogFileName)).str(), std::ios::app); fileStream << message.getTimeString("%H:%M:%S") << " | "; fileStream << message.threadId << " | "; diff --git a/src/lib/utility/logging/FileLogger.h b/src/lib/utility/logging/FileLogger.h index 0bc8c1e6..6e20e4ef 100644 --- a/src/lib/utility/logging/FileLogger.h +++ b/src/lib/utility/logging/FileLogger.h @@ -3,6 +3,7 @@ #include +#include "utility/file/FilePath.h" #include "utility/logging/Logger.h" #include "utility/logging/LogMessage.h" @@ -12,7 +13,7 @@ public: FileLogger(); virtual ~FileLogger(); - void setLogDirectory(const std::string& filePath); + void setLogDirectory(const FilePath& filePath); void setFileName(const std::string& fileName); void setMaxLogLineCount(unsigned int logCount); @@ -28,7 +29,7 @@ private: void updateLogFileName(); std::string m_logFileName; - std::string m_logDirectory; + FilePath m_logDirectory; unsigned int m_maxLogLineCount; unsigned int m_maxLogFileCount; unsigned int m_currentLogLineCount; diff --git a/src/lib/utility/text/TextAccess.cpp b/src/lib/utility/text/TextAccess.cpp index eff2fe83..3e5e7c80 100644 --- a/src/lib/utility/text/TextAccess.cpp +++ b/src/lib/utility/text/TextAccess.cpp @@ -4,7 +4,7 @@ #include "utility/logging/logging.h" -std::shared_ptr TextAccess::createFromFile(const std::string& filePath) +std::shared_ptr TextAccess::createFromFile(const FilePath& filePath) { std::shared_ptr result(new TextAccess()); @@ -32,7 +32,7 @@ unsigned int TextAccess::getLineCount() const return m_lines.size(); } -std::string TextAccess::getFilePath() const +FilePath TextAccess::getFilePath() const { return m_filePath; } @@ -76,16 +76,16 @@ std::string TextAccess::getText() const return result; } -std::vector TextAccess::readFile(const std::string& filePath) +std::vector TextAccess::readFile(const FilePath& filePath) { std::vector result; std::ifstream srcFile; - srcFile.open(filePath); + srcFile.open(filePath.str()); if (srcFile.fail()) { - LOG_ERROR("Could not open file " + filePath); + LOG_ERROR("Could not open file " + filePath.str()); return result; } diff --git a/src/lib/utility/text/TextAccess.h b/src/lib/utility/text/TextAccess.h index 8d40cc60..7960d522 100644 --- a/src/lib/utility/text/TextAccess.h +++ b/src/lib/utility/text/TextAccess.h @@ -5,17 +5,19 @@ #include #include +#include "utility/file/FilePath.h" + class TextAccess { public: - static std::shared_ptr createFromFile(const std::string& filePath); + static std::shared_ptr createFromFile(const FilePath& filePath); static std::shared_ptr createFromString(const std::string& text); virtual ~TextAccess(); unsigned int getLineCount() const; - std::string getFilePath() const; + FilePath getFilePath() const; /** * @param lineNumber: starts with 1 @@ -30,7 +32,7 @@ public: std::string getText() const; private: - static std::vector readFile(const std::string& filePath); + static std::vector readFile(const FilePath& filePath); static std::vector splitStringByLines(const std::string& text); TextAccess(); @@ -40,7 +42,7 @@ private: bool checkIndexInRange(const unsigned int index) const; bool checkIndexIntervalInRange(const unsigned int firstIndex, const unsigned int lastIndex) const; - std::string m_filePath; + FilePath m_filePath; std::vector m_lines; }; diff --git a/src/lib/utility/utilityLibrary.h b/src/lib/utility/utilityLibrary.h index d9da7609..35b59079 100644 --- a/src/lib/utility/utilityLibrary.h +++ b/src/lib/utility/utilityLibrary.h @@ -15,7 +15,6 @@ #include "utility/file/FilePath.h" - namespace utility { template diff --git a/src/lib_cxx/CMakeLists.txt b/src/lib_cxx/CMakeLists.txt index 5423a9cb..f6d7de44 100644 --- a/src/lib_cxx/CMakeLists.txt +++ b/src/lib_cxx/CMakeLists.txt @@ -56,6 +56,7 @@ add_files( data/parser/cxx/CxxAstVisitorComponentIndexer.h data/parser/cxx/CxxAstVisitorComponentTypeRefKind.cpp data/parser/cxx/CxxAstVisitorComponentTypeRefKind.h + data/parser/cxx/cxxCacheTypes.h data/parser/cxx/CxxCompilationDatabaseSingle.cpp data/parser/cxx/CxxCompilationDatabaseSingle.h data/parser/cxx/CxxContext.cpp diff --git a/src/lib_cxx/data/indexer/IndexerCommandCxx.h b/src/lib_cxx/data/indexer/IndexerCommandCxx.h index b8800d5f..321e4208 100644 --- a/src/lib_cxx/data/indexer/IndexerCommandCxx.h +++ b/src/lib_cxx/data/indexer/IndexerCommandCxx.h @@ -5,7 +5,8 @@ #include #include "data/indexer/IndexerCommand.h" -#include "utility/file/FilePath.h" + +class FilePath; class IndexerCommandCxx : public IndexerCommand diff --git a/src/lib_cxx/data/indexer/IndexerCommandCxxManual.cpp b/src/lib_cxx/data/indexer/IndexerCommandCxxManual.cpp index 6fa8c1b3..524b3de1 100644 --- a/src/lib_cxx/data/indexer/IndexerCommandCxxManual.cpp +++ b/src/lib_cxx/data/indexer/IndexerCommandCxxManual.cpp @@ -1,6 +1,5 @@ #include "data/indexer/IndexerCommandCxxManual.h" - std::string IndexerCommandCxxManual::getIndexerKindString() { return "CxxManual"; diff --git a/src/lib_cxx/data/indexer/IndexerCommandCxxManual.h b/src/lib_cxx/data/indexer/IndexerCommandCxxManual.h index e72270ca..824bf6e7 100644 --- a/src/lib_cxx/data/indexer/IndexerCommandCxxManual.h +++ b/src/lib_cxx/data/indexer/IndexerCommandCxxManual.h @@ -2,7 +2,8 @@ #define INDEXER_COMMAND_CXX_MANUAL_H #include "data/indexer/IndexerCommandCxx.h" -#include "utility/file/FilePath.h" + +class FilePath; class IndexerCommandCxxManual : public IndexerCommandCxx diff --git a/src/lib_cxx/data/parser/cxx/ASTAction.h b/src/lib_cxx/data/parser/cxx/ASTAction.h index 65c9dbe5..a2ba831f 100644 --- a/src/lib_cxx/data/parser/cxx/ASTAction.h +++ b/src/lib_cxx/data/parser/cxx/ASTAction.h @@ -8,6 +8,7 @@ #include "clang/Lex/Preprocessor.h" #include "data/parser/cxx/ASTConsumer.h" +#include "data/parser/cxx/cxxCacheTypes.h" #include "data/parser/cxx/CommentHandler.h" #include "data/parser/cxx/PreprocessorCallbacks.h" #include "utility/file/FileRegister.h" @@ -17,10 +18,15 @@ class ASTAction : public ASTActionBase { public: - explicit ASTAction(std::shared_ptr client, std::shared_ptr fileRegister) + explicit ASTAction( + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache + ) : m_client(client) , m_fileRegister(fileRegister) - , m_commentHandler(client, fileRegister) + , m_canonicalFilePathCache(canonicalFilePathCache) + , m_commentHandler(client, fileRegister, canonicalFilePathCache) {} virtual ~ASTAction() {} @@ -29,14 +35,14 @@ protected: virtual std::unique_ptr CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef inFile) { return std::unique_ptr( - new ASTConsumer(&compiler.getASTContext(), &compiler.getPreprocessor(), m_client, m_fileRegister)); + new ASTConsumer(&compiler.getASTContext(), &compiler.getPreprocessor(), m_client, m_fileRegister, m_canonicalFilePathCache)); } virtual bool BeginSourceFileAction(clang::CompilerInstance& compiler, llvm::StringRef filePath) { clang::Preprocessor& preprocessor = compiler.getPreprocessor(); preprocessor.addPPCallbacks( - llvm::make_unique(compiler.getSourceManager(), m_client, m_fileRegister)); + llvm::make_unique(compiler.getSourceManager(), m_client, m_fileRegister, m_canonicalFilePathCache)); preprocessor.addCommentHandler(&m_commentHandler); return true; } @@ -44,6 +50,7 @@ protected: private: std::shared_ptr m_client; std::shared_ptr m_fileRegister; + std::shared_ptr m_canonicalFilePathCache; CommentHandler m_commentHandler; }; diff --git a/src/lib_cxx/data/parser/cxx/ASTActionFactory.cpp b/src/lib_cxx/data/parser/cxx/ASTActionFactory.cpp index a9fb1ed0..a0a33753 100644 --- a/src/lib_cxx/data/parser/cxx/ASTActionFactory.cpp +++ b/src/lib_cxx/data/parser/cxx/ASTActionFactory.cpp @@ -3,10 +3,14 @@ #include "clang/Frontend/FrontendActions.h" ASTActionFactory::ASTActionFactory( - std::shared_ptr client, std::shared_ptr fileRegister, bool preprocessorOnly + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache, + bool preprocessorOnly ) : m_client(client) , m_fileRegister(fileRegister) + , m_canonicalFilePathCache(canonicalFilePathCache) , m_preprocessorOnly(preprocessorOnly) { } @@ -19,10 +23,10 @@ clang::FrontendAction* ASTActionFactory::create() { if (m_preprocessorOnly) { - return new ASTAction(m_client, m_fileRegister); + return new ASTAction(m_client, m_fileRegister, m_canonicalFilePathCache); } else { - return new ASTAction(m_client, m_fileRegister); + return new ASTAction(m_client, m_fileRegister, m_canonicalFilePathCache); } } diff --git a/src/lib_cxx/data/parser/cxx/ASTActionFactory.h b/src/lib_cxx/data/parser/cxx/ASTActionFactory.h index 7a7ee837..ece9fb41 100644 --- a/src/lib_cxx/data/parser/cxx/ASTActionFactory.h +++ b/src/lib_cxx/data/parser/cxx/ASTActionFactory.h @@ -4,6 +4,7 @@ #include "clang/Tooling/Tooling.h" #include "data/parser/cxx/ASTAction.h" +#include "data/parser/cxx/cxxCacheTypes.h" #include "utility/file/FileRegister.h" class ASTActionFactory @@ -11,7 +12,12 @@ class ASTActionFactory { public: explicit ASTActionFactory( - std::shared_ptr client, std::shared_ptr fileRegister, bool preprocessorOnly); + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache, + bool preprocessorOnly + ); + virtual ~ASTActionFactory(); virtual clang::FrontendAction* create(); @@ -19,6 +25,7 @@ public: private: std::shared_ptr m_client; std::shared_ptr m_fileRegister; + std::shared_ptr m_canonicalFilePathCache; bool m_preprocessorOnly; }; diff --git a/src/lib_cxx/data/parser/cxx/ASTConsumer.cpp b/src/lib_cxx/data/parser/cxx/ASTConsumer.cpp index 704e6812..9d3e7cce 100644 --- a/src/lib_cxx/data/parser/cxx/ASTConsumer.cpp +++ b/src/lib_cxx/data/parser/cxx/ASTConsumer.cpp @@ -3,15 +3,21 @@ #include "data/parser/cxx/CxxVerboseAstVisitor.h" #include "settings/ApplicationSettings.h" -ASTConsumer::ASTConsumer(clang::ASTContext* context, clang::Preprocessor* preprocessor, std::shared_ptr client, std::shared_ptr fileRegister) +ASTConsumer::ASTConsumer( + clang::ASTContext* context, + clang::Preprocessor* preprocessor, + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache +) { if (ApplicationSettings::getInstance()->getLoggingEnabled() && ApplicationSettings::getInstance()->getVerboseIndexerLoggingEnabled()) { - m_visitor = std::make_shared(context, preprocessor, client, fileRegister); + m_visitor = std::make_shared(context, preprocessor, client, fileRegister, canonicalFilePathCache); } else { - m_visitor = std::make_shared(context, preprocessor, client, fileRegister); + m_visitor = std::make_shared(context, preprocessor, client, fileRegister, canonicalFilePathCache); } } diff --git a/src/lib_cxx/data/parser/cxx/ASTConsumer.h b/src/lib_cxx/data/parser/cxx/ASTConsumer.h index 3ff2416d..a114485b 100644 --- a/src/lib_cxx/data/parser/cxx/ASTConsumer.h +++ b/src/lib_cxx/data/parser/cxx/ASTConsumer.h @@ -4,6 +4,7 @@ #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" +#include "data/parser/cxx/cxxCacheTypes.h" class CxxAstVisitor; class FileRegister; @@ -13,7 +14,14 @@ class ASTConsumer : public clang::ASTConsumer { public: - explicit ASTConsumer(clang::ASTContext* context, clang::Preprocessor* preprocessor, std::shared_ptr client, std::shared_ptr fileRegister); + explicit ASTConsumer( + clang::ASTContext* context, + clang::Preprocessor* preprocessor, + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache + ); + virtual ~ASTConsumer(); virtual void HandleTranslationUnit(clang::ASTContext& context); diff --git a/src/lib_cxx/data/parser/cxx/CommentHandler.cpp b/src/lib_cxx/data/parser/cxx/CommentHandler.cpp index d3ab4f69..7eb9a0e7 100644 --- a/src/lib_cxx/data/parser/cxx/CommentHandler.cpp +++ b/src/lib_cxx/data/parser/cxx/CommentHandler.cpp @@ -4,9 +4,14 @@ #include "data/parser/ParserClient.h" #include "utility/file/FileRegister.h" -CommentHandler::CommentHandler(std::shared_ptr client, std::shared_ptr fileRegister) +CommentHandler::CommentHandler( + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache +) : m_client(client) , m_fileRegister(fileRegister) + , m_canonicalFilePathCache(canonicalFilePathCache) { } @@ -20,11 +25,11 @@ bool CommentHandler::HandleComment(clang::Preprocessor& preprocessor, clang::Sou const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(sourceRange.getBegin(), false); const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(sourceRange.getEnd(), false); - FilePath filePath = FilePath(presumedBegin.getFilename()); + FilePath filePath = m_canonicalFilePathCache->getValue(presumedBegin.getFilename()); if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsIndexed(filePath)) { m_client->onCommentParsed(ParseLocation( - presumedBegin.getFilename(), + filePath, presumedBegin.getLine(), presumedBegin.getColumn(), presumedEnd.getLine(), diff --git a/src/lib_cxx/data/parser/cxx/CommentHandler.h b/src/lib_cxx/data/parser/cxx/CommentHandler.h index 11afbd48..0a3982ab 100644 --- a/src/lib_cxx/data/parser/cxx/CommentHandler.h +++ b/src/lib_cxx/data/parser/cxx/CommentHandler.h @@ -3,6 +3,8 @@ #include "clang/Lex/Preprocessor.h" +#include "data/parser/cxx/cxxCacheTypes.h" + class FileRegister; class ParserClient; @@ -10,7 +12,12 @@ class CommentHandler : public clang::CommentHandler { public: - CommentHandler(std::shared_ptr client, std::shared_ptr fileRegister); + CommentHandler( + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache + ); + virtual ~CommentHandler(); virtual bool HandleComment(clang::Preprocessor& preprocessor, clang::SourceRange sourceRange); @@ -18,6 +25,7 @@ public: private: std::shared_ptr m_client; std::shared_ptr m_fileRegister; + std::shared_ptr m_canonicalFilePathCache; }; #endif // COMMENT_HANDLER_H diff --git a/src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp b/src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp index 9eb0f4e6..3b227aa2 100644 --- a/src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxAstVisitor.cpp @@ -17,36 +17,45 @@ #include "data/parser/ParseLocation.h" -CxxAstVisitor::CxxAstVisitor(clang::ASTContext* astContext, clang::Preprocessor* preprocessor, std::shared_ptr client, std::shared_ptr fileRegister) +CxxAstVisitor::CxxAstVisitor( + clang::ASTContext* astContext, + clang::Preprocessor* preprocessor, + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache +) : m_astContext(astContext) , m_preprocessor(preprocessor) , m_client(client) , m_fileRegister(fileRegister) + , m_canonicalFilePathCache(canonicalFilePathCache) { m_declNameCache = std::make_shared([](const clang::NamedDecl* decl) -> NameHierarchy - { - if (decl) { - CxxDeclNameResolver resolver; - if (std::shared_ptr declName = resolver.getName(decl)) + if (decl) { - return declName->toNameHierarchy(); + CxxDeclNameResolver resolver; + if (std::shared_ptr declName = resolver.getName(decl)) + { + return declName->toNameHierarchy(); + } } + return NameHierarchy("global"); } - return NameHierarchy("global"); - }); + ); m_typeNameCache = std::make_shared([](const clang::Type* type) -> NameHierarchy - { - if (type) { - CxxTypeNameResolver resolver; - if (std::shared_ptr typeName = resolver.getName(type)) + if (type) { - return typeName->toNameHierarchy(); + CxxTypeNameResolver resolver; + if (std::shared_ptr typeName = resolver.getName(type)) + { + return typeName->toNameHierarchy(); + } } + return NameHierarchy("global"); } - return NameHierarchy("global"); - }); + ); m_contextComponent = std::make_shared(this); m_components.push_back(m_contextComponent); @@ -98,6 +107,11 @@ std::shared_ptr CxxAstVisitor::getTypeNameCache() return m_typeNameCache; } +std::shared_ptr CxxAstVisitor::getCanonicalFilePathCache() +{ + return m_canonicalFilePathCache; +} + void CxxAstVisitor::indexDecl(clang::Decl* d) { this->TraverseDecl(d); @@ -638,7 +652,7 @@ ParseLocation CxxAstVisitor::getParseLocation(const clang::SourceLocation& loc) const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId); if (fileEntry != NULL) { - parseLocation.filePath = FilePath(fileEntry->getName()).canonical(); + parseLocation.filePath = m_canonicalFilePathCache->getValue(fileEntry->getName()); } } @@ -672,7 +686,7 @@ ParseLocation CxxAstVisitor::getParseLocation(const clang::SourceRange& sourceRa const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(sourceRange.getEnd(), false); parseLocation = ParseLocation( - presumedBegin.getFilename(), + m_canonicalFilePathCache->getValue(presumedBegin.getFilename()), presumedBegin.getLine(), presumedBegin.getColumn(), presumedEnd.getLine(), diff --git a/src/lib_cxx/data/parser/cxx/CxxAstVisitor.h b/src/lib_cxx/data/parser/cxx/CxxAstVisitor.h index 0b6ce404..f7eaef62 100644 --- a/src/lib_cxx/data/parser/cxx/CxxAstVisitor.h +++ b/src/lib_cxx/data/parser/cxx/CxxAstVisitor.h @@ -5,13 +5,14 @@ #include +#include "data/parser/cxx/cxxCacheTypes.h" #include "data/parser/cxx/CxxContext.h" #include "utility/messaging/MessageInterruptTasksCounter.h" -#include "utility/Cache.h" class ParserClient; struct ParseLocation; class FileRegister; +class FilePath; class CxxAstVisitorComponent; class CxxAstVisitorComponentContext; @@ -20,6 +21,7 @@ class CxxAstVisitorComponentTypeRefKind; class CxxAstVisitorComponentImplicitCode; class CxxAstVisitorComponentIndexer; + // methods are called in this order: // TraverseDecl() // `- TraverseFunctionDecl() @@ -34,7 +36,13 @@ class CxxAstVisitorComponentIndexer; class CxxAstVisitor: public clang::RecursiveASTVisitor { public: - CxxAstVisitor(clang::ASTContext* astContext, clang::Preprocessor* preprocessor, std::shared_ptr client, std::shared_ptr fileRegister); + CxxAstVisitor( + clang::ASTContext* astContext, + clang::Preprocessor* preprocessor, + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache + ); virtual ~CxxAstVisitor(); template @@ -42,6 +50,7 @@ public: std::shared_ptr getDeclNameCache(); std::shared_ptr getTypeNameCache(); + std::shared_ptr getCanonicalFilePathCache(); // Indexing entry point void indexDecl(clang::Decl *d); @@ -139,6 +148,7 @@ private: clang::Preprocessor* m_preprocessor; std::shared_ptr m_client; std::shared_ptr m_fileRegister; + std::shared_ptr m_canonicalFilePathCache; MessageInterruptTasksCounter m_interruptCounter; diff --git a/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp b/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp index e9618b1b..b105f926 100644 --- a/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp @@ -767,8 +767,7 @@ bool CxxAstVisitorComponentIndexer::isLocatedInUnparsedProjectFile(clang::Source const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId); if (fileEntry != NULL) { - std::string fileName = fileEntry->getName(); - FilePath filePath = FilePath(fileName).canonical(); + FilePath filePath = getAstVisitor()->getCanonicalFilePathCache()->getValue(fileEntry->getName()); if (m_fileRegister->hasFilePath(filePath)) { @@ -807,8 +806,8 @@ bool CxxAstVisitorComponentIndexer::isLocatedInProjectFile(clang::SourceLocation if (fileEntry != NULL) { std::string fileName = fileEntry->getName(); - FilePath filePath = FilePath(fileName).canonical(); - bool ret = m_fileRegister->hasFilePath(filePath.str()); + FilePath filePath = getAstVisitor()->getCanonicalFilePathCache()->getValue(fileName); + bool ret = m_fileRegister->hasFilePath(filePath); m_inProjectFileMap[fileId] = ret; return ret; } diff --git a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp index 463e1580..47bd6df3 100644 --- a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.cpp @@ -12,11 +12,13 @@ CxxDiagnosticConsumer::CxxDiagnosticConsumer( clang::DiagnosticOptions *diags, std::shared_ptr client, std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache, bool useLogging ) : clang::TextDiagnosticPrinter(os, diags) , m_client(client) , m_register(fileRegister) + , m_canonicalFilePathCache(canonicalFilePathCache) , m_isParsingFile(false) , m_useLogging(useLogging) { @@ -79,7 +81,7 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev column = presumedLocation.getColumn(); } - ParseLocation location(filePath, line, column); + ParseLocation location(m_canonicalFilePathCache->getValue(filePath), line, column); m_client->onErrorParsed( location, diff --git a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.h b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.h index 40e72475..2fe74c19 100644 --- a/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.h +++ b/src/lib_cxx/data/parser/cxx/CxxDiagnosticConsumer.h @@ -3,6 +3,8 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" +#include "data/parser/cxx/cxxCacheTypes.h" + class FileRegister; class ParserClient; @@ -15,6 +17,7 @@ public: clang::DiagnosticOptions *diags, std::shared_ptr client, std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache, bool useLogging = true ); @@ -26,6 +29,7 @@ public: private: std::shared_ptr m_client; std::shared_ptr m_register; + std::shared_ptr m_canonicalFilePathCache; bool m_isParsingFile; bool m_useLogging; diff --git a/src/lib_cxx/data/parser/cxx/CxxParser.cpp b/src/lib_cxx/data/parser/cxx/CxxParser.cpp index d617a824..73ec913f 100644 --- a/src/lib_cxx/data/parser/cxx/CxxParser.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxParser.cpp @@ -2,6 +2,7 @@ #include "clang/Tooling/Tooling.h" +#include "utility/file/FilePath.h" #include "utility/file/FileRegister.h" #include "utility/logging/logging.h" #include "utility/text/TextAccess.h" @@ -81,10 +82,16 @@ void CxxParser::buildIndex(std::shared_ptr indexerCommand) CxxCompilationDatabaseSingle compilationDatabase(compileCommand); clang::tooling::ClangTool tool(compilationDatabase, std::vector(1, indexerCommand->getSourceFilePath().str())); - std::shared_ptr diagnostics = getDiagnostics(true); + std::shared_ptr canonicalFilePathCache = std::make_shared([](std::string fileName) -> FilePath + { + return FilePath(fileName).canonical(); + } + ); + + std::shared_ptr diagnostics = getDiagnostics(canonicalFilePathCache, true); tool.setDiagnosticConsumer(diagnostics.get()); - ASTActionFactory actionFactory(m_client, m_fileRegister, indexerCommand->preprocessorOnly()); + ASTActionFactory actionFactory(m_client, m_fileRegister, canonicalFilePathCache, indexerCommand->preprocessorOnly()); tool.run(&actionFactory); } @@ -94,17 +101,29 @@ void CxxParser::buildIndex(std::shared_ptr indexerComma clang::tooling::ClangTool tool(*compilationDatabase, std::vector(1, indexerCommand->getSourceFilePath().str())); - std::shared_ptr diagnostics = getDiagnostics(true); + std::shared_ptr canonicalFilePathCache = std::make_shared([](std::string fileName) -> FilePath + { + return FilePath(fileName).canonical(); + } + ); + + std::shared_ptr diagnostics = getDiagnostics(canonicalFilePathCache, true); tool.setDiagnosticConsumer(diagnostics.get()); - ASTActionFactory actionFactory(m_client, m_fileRegister, indexerCommand->preprocessorOnly()); + ASTActionFactory actionFactory(m_client, m_fileRegister, canonicalFilePathCache, indexerCommand->preprocessorOnly()); tool.run(&actionFactory); } void CxxParser::buildIndex(const std::string& fileName, std::shared_ptr fileContent) { - std::shared_ptr diagnostics = getDiagnostics(false); - ASTActionFactory actionFactory(m_client, m_fileRegister, false); + std::shared_ptr canonicalFilePathCache = std::make_shared([](std::string fileName) -> FilePath + { + return FilePath(fileName).canonical(); + } + ); + + std::shared_ptr diagnostics = getDiagnostics(canonicalFilePathCache, false); + ASTActionFactory actionFactory(m_client, m_fileRegister, canonicalFilePathCache, false); std::vector args = getCommandlineArgumentsEssential(std::vector(1, "-std=c++1z"), std::vector(), std::vector()); @@ -201,9 +220,9 @@ std::shared_ptr CxxParser::getCompilat return compilationDatabase; } -std::shared_ptr CxxParser::getDiagnostics(bool logErrors) const +std::shared_ptr CxxParser::getDiagnostics(std::shared_ptr canonicalFilePathCache, bool logErrors) const { llvm::IntrusiveRefCntPtr options = new clang::DiagnosticOptions(); return std::make_shared( - llvm::errs(), &*options, m_client, m_fileRegister, logErrors); + llvm::errs(), &*options, m_client, m_fileRegister, canonicalFilePathCache, logErrors); } diff --git a/src/lib_cxx/data/parser/cxx/CxxParser.h b/src/lib_cxx/data/parser/cxx/CxxParser.h index a8f84cd6..6b6aa7f0 100644 --- a/src/lib_cxx/data/parser/cxx/CxxParser.h +++ b/src/lib_cxx/data/parser/cxx/CxxParser.h @@ -1,10 +1,12 @@ #ifndef CXX_PARSER_H #define CXX_PARSER_H +#include "data/parser/cxx/cxxCacheTypes.h" #include "data/parser/cxx/CxxCompilationDatabaseSingle.h" #include "data/parser/Parser.h" class CxxDiagnosticConsumer; +class FilePath; class FileRegister; class IndexerCommandCxxCdb; class IndexerCommandCxxManual; @@ -29,7 +31,7 @@ private: std::vector getCommandlineArguments(std::shared_ptr indexerCommand) const; std::shared_ptr getCompilationDatabase(std::shared_ptr indexerCommand) const; - std::shared_ptr getDiagnostics(bool logErrors) const; + std::shared_ptr getDiagnostics(std::shared_ptr canonicalFilePathCache, bool logErrors) const; friend class TaskParseCxx; diff --git a/src/lib_cxx/data/parser/cxx/CxxVerboseAstVisitor.cpp b/src/lib_cxx/data/parser/cxx/CxxVerboseAstVisitor.cpp index 7f65b688..823d171e 100644 --- a/src/lib_cxx/data/parser/cxx/CxxVerboseAstVisitor.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxVerboseAstVisitor.cpp @@ -12,8 +12,14 @@ #include "utility/logging/logging.h" #include "utility/ScopedSwitcher.h" -CxxVerboseAstVisitor::CxxVerboseAstVisitor(clang::ASTContext* context, clang::Preprocessor* preprocessor, std::shared_ptr client, std::shared_ptr fileRegister) - : base(context, preprocessor, client, fileRegister) +CxxVerboseAstVisitor::CxxVerboseAstVisitor( + clang::ASTContext* context, + clang::Preprocessor* preprocessor, + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache +) + : base(context, preprocessor, client, fileRegister, canonicalFilePathCache) , m_currentFilePath("") , m_indentation(0) { diff --git a/src/lib_cxx/data/parser/cxx/CxxVerboseAstVisitor.h b/src/lib_cxx/data/parser/cxx/CxxVerboseAstVisitor.h index 69d00e4a..161cc4f8 100644 --- a/src/lib_cxx/data/parser/cxx/CxxVerboseAstVisitor.h +++ b/src/lib_cxx/data/parser/cxx/CxxVerboseAstVisitor.h @@ -11,7 +11,14 @@ class FileRegister; class CxxVerboseAstVisitor: public CxxAstVisitor { public: - CxxVerboseAstVisitor(clang::ASTContext* context, clang::Preprocessor* preprocessor, std::shared_ptr client, std::shared_ptr fileRegister); + CxxVerboseAstVisitor( + clang::ASTContext* context, + clang::Preprocessor* preprocessor, + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache + ); + virtual ~CxxVerboseAstVisitor(); private: diff --git a/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.cpp b/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.cpp index 7e8f20bc..4c265784 100644 --- a/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.cpp +++ b/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.cpp @@ -11,11 +11,15 @@ #include "data/parser/ParseLocation.h" PreprocessorCallbacks::PreprocessorCallbacks( - clang::SourceManager& sourceManager, std::shared_ptr client, std::shared_ptr fileRegister + clang::SourceManager& sourceManager, + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache ) : m_sourceManager(sourceManager) , m_client(client) , m_fileRegister(fileRegister) + , m_canonicalFilePathCache(canonicalFilePathCache) { } @@ -29,7 +33,7 @@ void PreprocessorCallbacks::FileChanged( const clang::FileEntry *fileEntry = m_sourceManager.getFileEntryForID(m_sourceManager.getFileID(location)); if (fileEntry) { - filePath = FilePath(fileEntry->getName()).canonical(); + filePath = m_canonicalFilePathCache->getValue(fileEntry->getName()); } if (!filePath.empty() && m_fileRegister->hasFilePath(filePath)) @@ -55,7 +59,7 @@ void PreprocessorCallbacks::InclusionDirective( ){ if (!m_currentPath.empty() && fileEntry) { - FilePath includedFilePath = FilePath(fileEntry->getName()).canonical(); + FilePath includedFilePath = m_canonicalFilePathCache->getValue(fileEntry->getName()); if (m_fileRegister->hasFilePath(includedFilePath)) { const NameHierarchy referencedNameHierarchy(includedFilePath.str()); @@ -148,7 +152,7 @@ ParseLocation PreprocessorCallbacks::getParseLocation(const clang::Token& macroN const clang::SourceLocation& endLocation = m_sourceManager.getSpellingLoc(macroNameTok.getEndLoc()); return ParseLocation( - m_sourceManager.getFilename(location).str(), + m_canonicalFilePathCache->getValue(m_sourceManager.getFilename(location).str()), m_sourceManager.getSpellingLineNumber(location), m_sourceManager.getSpellingColumnNumber(location), m_sourceManager.getSpellingLineNumber(endLocation), @@ -162,7 +166,7 @@ ParseLocation PreprocessorCallbacks::getParseLocation(const clang::MacroInfo* ma clang::SourceLocation endLocation = macroInfo->getDefinitionEndLoc(); return ParseLocation( - m_sourceManager.getFilename(location).str(), + m_canonicalFilePathCache->getValue(m_sourceManager.getFilename(location).str()), m_sourceManager.getSpellingLineNumber(location), m_sourceManager.getSpellingColumnNumber(location), m_sourceManager.getSpellingLineNumber(endLocation), @@ -181,7 +185,7 @@ ParseLocation PreprocessorCallbacks::getParseLocation(const clang::SourceRange& const clang::PresumedLoc& presumedEnd = m_sourceManager.getPresumedLoc(sourceRange.getEnd(), false); return ParseLocation( - presumedBegin.getFilename(), + m_canonicalFilePathCache->getValue(presumedBegin.getFilename()), presumedBegin.getLine(), presumedBegin.getColumn(), presumedEnd.getLine(), diff --git a/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.h b/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.h index c6de726b..8ab22f41 100644 --- a/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.h +++ b/src/lib_cxx/data/parser/cxx/PreprocessorCallbacks.h @@ -8,6 +8,7 @@ #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Token.h" +#include "data/parser/cxx/cxxCacheTypes.h" #include "utility/file/FilePath.h" class FileRegister; @@ -19,7 +20,11 @@ class PreprocessorCallbacks : public clang::PPCallbacks { public: - explicit PreprocessorCallbacks(clang::SourceManager& sourceManager, std::shared_ptr client, std::shared_ptr fileRegister); + explicit PreprocessorCallbacks( + clang::SourceManager& sourceManager, + std::shared_ptr client, + std::shared_ptr fileRegister, + std::shared_ptr canonicalFilePathCache); virtual void FileChanged( clang::SourceLocation location, FileChangeReason reason, clang::SrcMgr::CharacteristicKind, clang::FileID); @@ -54,6 +59,7 @@ private: const clang::SourceManager& m_sourceManager; std::shared_ptr m_client; std::shared_ptr m_fileRegister; + std::shared_ptr m_canonicalFilePathCache; FilePath m_currentPath; }; diff --git a/src/lib_cxx/data/parser/cxx/cxxCacheTypes.h b/src/lib_cxx/data/parser/cxx/cxxCacheTypes.h new file mode 100644 index 00000000..ee7d27d5 --- /dev/null +++ b/src/lib_cxx/data/parser/cxx/cxxCacheTypes.h @@ -0,0 +1,11 @@ +#ifndef CXX_CACHE_TYPES_H +#define CXX_CACHE_TYPES_H + +#include +#include "utility/Cache.h" + +class FilePath; + +typedef Cache FilePathCache; + +#endif // CXX_CACHE_TYPES_H diff --git a/src/lib_cxx/utility/CompilationDatabase.cpp b/src/lib_cxx/utility/CompilationDatabase.cpp index 72bae5cc..798339c3 100644 --- a/src/lib_cxx/utility/CompilationDatabase.cpp +++ b/src/lib_cxx/utility/CompilationDatabase.cpp @@ -1,8 +1,10 @@ #include "utility/CompilationDatabase.h" #include -#include "utility/utility.h" + #include "clang/Tooling/JSONCompilationDatabase.h" +#include "utility/file/FilePath.h" +#include "utility/utility.h" utility::CompilationDatabase::CompilationDatabase(std::string filename) : m_filename(filename) diff --git a/src/lib_cxx/utility/CompilationDatabase.h b/src/lib_cxx/utility/CompilationDatabase.h index 051a17e4..cefa2c8d 100644 --- a/src/lib_cxx/utility/CompilationDatabase.h +++ b/src/lib_cxx/utility/CompilationDatabase.h @@ -3,7 +3,7 @@ #include -#include "utility/file/FilePath.h" +class FilePath; namespace utility { diff --git a/src/lib_gui/platform_includes/includesWindows.h b/src/lib_gui/platform_includes/includesWindows.h index 583d1acc..bd1a1366 100644 --- a/src/lib_gui/platform_includes/includesWindows.h +++ b/src/lib_gui/platform_includes/includesWindows.h @@ -34,7 +34,7 @@ void setupApp(int argc, char *argv[]) #else std::string path = QDir::currentPath().toStdString(); path += "/user/"; - UserPaths::setUserDataPath(path); + UserPaths::setUserDataPath(FilePath(path)); #endif // This "copyFile" method does nothing if the copy destination already exist @@ -59,8 +59,8 @@ void setupApp(int argc, char *argv[]) #endif // use files in fallback folder if Coati has not been installed and used before - FileSystem::copyFile(ResourcePaths::getFallbackPath() + "ApplicationSettings.xml", UserPaths::getAppSettingsPath()); - FileSystem::copyFile(ResourcePaths::getFallbackPath() + "window_settings.ini", UserPaths::getWindowSettingsPath()); + FileSystem::copyFile(ResourcePaths::getFallbackPath().concat(FilePath("ApplicationSettings.xml")), UserPaths::getAppSettingsPath()); + FileSystem::copyFile(ResourcePaths::getFallbackPath().concat(FilePath("window_settings.ini")), UserPaths::getWindowSettingsPath()); } #endif // INCLUDES_WINDOWS_H diff --git a/src/lib_gui/qt/QtApplication.cpp b/src/lib_gui/qt/QtApplication.cpp index dca84d1f..1568b27d 100644 --- a/src/lib_gui/qt/QtApplication.cpp +++ b/src/lib_gui/qt/QtApplication.cpp @@ -35,7 +35,7 @@ bool QtApplication::event(QEvent *event) if (path.exists() && (path.extension() == ".srctrlprj" || path.extension() == ".coatiproject")) { - MessageLoadProject(path.str(), false).dispatch(); + MessageLoadProject(path, false).dispatch(); return true; } } diff --git a/src/lib_gui/qt/element/QtAutocompletionList.cpp b/src/lib_gui/qt/element/QtAutocompletionList.cpp index b9e221d3..6a01a359 100644 --- a/src/lib_gui/qt/element/QtAutocompletionList.cpp +++ b/src/lib_gui/qt/element/QtAutocompletionList.cpp @@ -330,7 +330,7 @@ void QtAutocompletionDelegate::calculateCharSizes(QFont font) ) / 500.0f; m_charHeight2 = metrics2.height(); - m_arrow = QtDeviceScaledPixmap(QString::fromStdString(ResourcePaths::getGuiPath() + "search_view/images/arrow.png")); + m_arrow = QtDeviceScaledPixmap(QString::fromStdString(ResourcePaths::getGuiPath().str() + "search_view/images/arrow.png")); m_arrow.scaleToWidth(m_charWidth2); m_arrow.colorize(ColorScheme::getInstance()->getColor("search/popup/by_text").c_str()); } diff --git a/src/lib_gui/qt/element/QtBookmark.cpp b/src/lib_gui/qt/element/QtBookmark.cpp index ada6de43..4e3f3c51 100644 --- a/src/lib_gui/qt/element/QtBookmark.cpp +++ b/src/lib_gui/qt/element/QtBookmark.cpp @@ -59,7 +59,7 @@ QtBookmark::QtBookmark() m_editButton->setToolTip("Edit bookmark"); m_editButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); m_editButton->setIconSize(QSize(20, 20)); - m_editButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_edit_icon.png").c_str())); + m_editButton->setIcon(QPixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/bookmark_edit_icon.png").c_str())); utility::setWidgetRetainsSpaceWhenHidden(m_editButton); m_editButton->hide(); buttonsLayout->addWidget(m_editButton); @@ -69,7 +69,7 @@ QtBookmark::QtBookmark() m_deleteButton->setToolTip("Delete bookmark"); m_deleteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); m_deleteButton->setIconSize(QSize(20, 20)); - m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_delete_icon.png").c_str())); + m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/bookmark_delete_icon.png").c_str())); utility::setWidgetRetainsSpaceWhenHidden(m_deleteButton); m_deleteButton->hide(); buttonsLayout->addWidget(m_deleteButton); @@ -235,7 +235,7 @@ void QtBookmark::elideButtonText() void QtBookmark::updateArrow() { - QPixmap pixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/" + m_arrowImageName).c_str()); + QPixmap pixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/" + m_arrowImageName).c_str()); m_toggleCommentButton->setIcon(QIcon(utility::colorizePixmap(pixmap, m_hovered ? "#707070" : "black"))); } diff --git a/src/lib_gui/qt/element/QtBookmarkCategory.cpp b/src/lib_gui/qt/element/QtBookmarkCategory.cpp index cd50e6bf..ef644880 100644 --- a/src/lib_gui/qt/element/QtBookmarkCategory.cpp +++ b/src/lib_gui/qt/element/QtBookmarkCategory.cpp @@ -23,7 +23,7 @@ QtBookmarkCategory::QtBookmarkCategory() m_expandButton->setObjectName("category_expand_button"); m_expandButton->setToolTip("Show/Hide bookmarks in this category"); m_expandButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - m_expandButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png").c_str())); + m_expandButton->setIcon(QPixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/arrow_down.png").c_str())); m_expandButton->setIconSize(QSize(8, 8)); layout->addWidget(m_expandButton); @@ -40,7 +40,7 @@ QtBookmarkCategory::QtBookmarkCategory() m_deleteButton->setToolTip("Delete this Bookmark Category and the containing Bookmarks"); m_deleteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); m_deleteButton->setIconSize(QSize(20, 20)); - m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_delete_icon.png").c_str())); + m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/bookmark_delete_icon.png").c_str())); utility::setWidgetRetainsSpaceWhenHidden(m_deleteButton); m_deleteButton->hide(); layout->addWidget(m_deleteButton); @@ -83,12 +83,12 @@ void QtBookmarkCategory::updateArrow() { if (m_treeItem->isExpanded()) { - QPixmap pixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png").c_str()); + QPixmap pixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/arrow_down.png").c_str()); m_expandButton->setIcon(QIcon(utility::colorizePixmap(pixmap, "black"))); } else { - QPixmap pixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_right.png").c_str()); + QPixmap pixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/arrow_right.png").c_str()); m_expandButton->setIcon(QIcon(utility::colorizePixmap(pixmap, "black"))); } } diff --git a/src/lib_gui/qt/element/QtCodeFileList.cpp b/src/lib_gui/qt/element/QtCodeFileList.cpp index cb4e74af..2e34b6ea 100644 --- a/src/lib_gui/qt/element/QtCodeFileList.cpp +++ b/src/lib_gui/qt/element/QtCodeFileList.cpp @@ -3,6 +3,7 @@ #include #include +#include "utility/file/FilePath.h" #include "utility/file/FileSystem.h" #include "data/location/SourceLocationFile.h" diff --git a/src/lib_gui/qt/element/QtCodeFileSingle.cpp b/src/lib_gui/qt/element/QtCodeFileSingle.cpp index 000e3945..4eebea97 100644 --- a/src/lib_gui/qt/element/QtCodeFileSingle.cpp +++ b/src/lib_gui/qt/element/QtCodeFileSingle.cpp @@ -6,6 +6,7 @@ #include #include +#include "utility/file/FilePath.h" #include "utility/logging/logging.h" #include "utility/messaging/type/MessageChangeFileView.h" #include "utility/ResourcePaths.h" diff --git a/src/lib_gui/qt/element/QtCodeFileSingle.h b/src/lib_gui/qt/element/QtCodeFileSingle.h index 5f92b858..d48cb7ca 100644 --- a/src/lib_gui/qt/element/QtCodeFileSingle.h +++ b/src/lib_gui/qt/element/QtCodeFileSingle.h @@ -6,6 +6,7 @@ #include +#include "utility/file/FilePath.h" #include "utility/TimePoint.h" #include "qt/element/QtCodeNavigateable.h" diff --git a/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp b/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp index b50eff9a..69a9d28e 100644 --- a/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp +++ b/src/lib_gui/qt/element/QtCodeFileTitleButton.cpp @@ -37,7 +37,7 @@ void QtCodeFileTitleButton::setFilePath(const FilePath& filePath) setText(filePath.fileName().c_str()); setToolTip(filePath.str().c_str()); - std::string text = ResourcePaths::getGuiPath() + "code_view/images/file.png"; + std::string text = ResourcePaths::getGuiPath().str() + "code_view/images/file.png"; setIcon(utility::colorizePixmap( QPixmap(text.c_str()), @@ -67,7 +67,7 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete) if (!isComplete) { setStyleSheet(( - "background-image: url(" + ResourcePaths::getGuiPath() + "code_view/images/pattern_" + + "background-image: url(" + ResourcePaths::getGuiPath().str() + "code_view/images/pattern_" + ColorScheme::getInstance()->getColor("code/file/title/hatching") + ".png);" ).c_str()); } @@ -90,7 +90,7 @@ void QtCodeFileTitleButton::setProject(const std::string& name) } else { - std::string text = ResourcePaths::getGuiPath() + "code_view/images/edit.png"; + std::string text = ResourcePaths::getGuiPath().str() + "code_view/images/edit.png"; setToolTip("edit project"); setIcon(utility::colorizePixmap( @@ -110,8 +110,7 @@ void QtCodeFileTitleButton::updateTexts() std::string title = m_filePath.fileName(); std::string toolTip = "file: " + m_filePath.str(); - // cannot use m_filePath.exists() here since it is only checked when FilePath is constructed. - if ((!FileSystem::exists(m_filePath.str())) || + if ((!m_filePath.recheckExists()) || (FileSystem::getLastWriteTime(m_filePath) > m_modificationTime)) { title += "*"; diff --git a/src/lib_gui/qt/element/QtCodeNavigateable.h b/src/lib_gui/qt/element/QtCodeNavigateable.h index 03496071..cc954a7c 100644 --- a/src/lib_gui/qt/element/QtCodeNavigateable.h +++ b/src/lib_gui/qt/element/QtCodeNavigateable.h @@ -3,12 +3,12 @@ #include -#include "utility/file/FilePath.h" #include "utility/TimePoint.h" #include "utility/types.h" #include "component/view/helper/CodeSnippetParams.h" +class FilePath; class QRectF; class QAbstractScrollArea; class QWidget; diff --git a/src/lib_gui/qt/element/QtCodeNavigator.cpp b/src/lib_gui/qt/element/QtCodeNavigator.cpp index a6828247..27ce0375 100644 --- a/src/lib_gui/qt/element/QtCodeNavigator.cpp +++ b/src/lib_gui/qt/element/QtCodeNavigator.cpp @@ -525,22 +525,22 @@ void QtCodeNavigator::refreshStyle() m_fileButton->setFixedHeight(height); m_prevButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "code_view/images/arrow_left.png", + ResourcePaths::getGuiPath().str() + "code_view/images/arrow_left.png", "search/button" )); m_nextButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "code_view/images/arrow_right.png", + ResourcePaths::getGuiPath().str() + "code_view/images/arrow_right.png", "search/button" )); m_listButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "code_view/images/list.png", + ResourcePaths::getGuiPath().str() + "code_view/images/list.png", "search/button" )); m_fileButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "code_view/images/file.png", + ResourcePaths::getGuiPath().str() + "code_view/images/file.png", "search/button" )); diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.cpp b/src/lib_gui/qt/element/QtDirectoryListBox.cpp index ff4a963e..ad2067b5 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.cpp +++ b/src/lib_gui/qt/element/QtDirectoryListBox.cpp @@ -31,8 +31,8 @@ QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* it m_data->setObjectName("field"); m_button = new QtIconButton( - (ResourcePaths::getGuiPath() + "window/dots.png").c_str(), - (ResourcePaths::getGuiPath() + "window/dots_hover.png").c_str()); + (ResourcePaths::getGuiPath().str() + "window/dots.png").c_str(), + (ResourcePaths::getGuiPath().str() + "window/dots_hover.png").c_str()); m_button->setObjectName("dotsButton"); layout->addWidget(m_data); @@ -132,7 +132,7 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName, m_list->setAttribute(Qt::WA_MacShowFocusRect, 0); m_list->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/listbox.css").c_str()); + setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/listbox.css"))).c_str()); layout->addWidget(m_list); QWidget* buttonContainer = new QWidget(this); @@ -144,15 +144,15 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName, innerLayout->setSpacing(0); m_addButton = new QtIconButton( - (ResourcePaths::getGuiPath() + "window/plus.png").c_str(), - (ResourcePaths::getGuiPath() + "window/plus_hover.png").c_str()); + (ResourcePaths::getGuiPath().str() + "window/plus.png").c_str(), + (ResourcePaths::getGuiPath().str() + "window/plus_hover.png").c_str()); m_addButton->setObjectName("plusButton"); m_addButton->setToolTip("add line"); innerLayout->addWidget(m_addButton); m_removeButton = new QtIconButton( - (ResourcePaths::getGuiPath() + "window/minus.png").c_str(), - (ResourcePaths::getGuiPath() + "window/minus_hover.png").c_str()); + (ResourcePaths::getGuiPath().str() + "window/minus.png").c_str(), + (ResourcePaths::getGuiPath().str() + "window/minus_hover.png").c_str()); m_removeButton->setObjectName("minusButton"); m_removeButton->setToolTip("remove line"); innerLayout->addWidget(m_removeButton); @@ -166,7 +166,7 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName, innerLayout->addWidget(dropInfoText); QPushButton* editButton = new QtIconButton( - (ResourcePaths::getGuiPath() + "code_view/images/edit.png").c_str(), + (ResourcePaths::getGuiPath().str() + "code_view/images/edit.png").c_str(), QString()); editButton->setObjectName("editButton"); editButton->setToolTip("edit plain text"); @@ -242,7 +242,7 @@ std::vector QtDirectoryListBox::getList() std::vector list; for (const std::string& str : strList) { - list.push_back(str); + list.push_back(FilePath(str)); } return list; } diff --git a/src/lib_gui/qt/element/QtHelpButton.cpp b/src/lib_gui/qt/element/QtHelpButton.cpp index 273f4875..17cac05c 100644 --- a/src/lib_gui/qt/element/QtHelpButton.cpp +++ b/src/lib_gui/qt/element/QtHelpButton.cpp @@ -6,8 +6,8 @@ QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent) : QtIconButton( - (ResourcePaths::getGuiPath() + "window/help.png").c_str(), - (ResourcePaths::getGuiPath() + "window/help_hover.png").c_str(), + (ResourcePaths::getGuiPath().str() + "window/help.png").c_str(), + (ResourcePaths::getGuiPath().str() + "window/help_hover.png").c_str(), parent) , m_helpText(helpText) { diff --git a/src/lib_gui/qt/element/QtLocationPicker.cpp b/src/lib_gui/qt/element/QtLocationPicker.cpp index 39d93aef..d4897348 100644 --- a/src/lib_gui/qt/element/QtLocationPicker.cpp +++ b/src/lib_gui/qt/element/QtLocationPicker.cpp @@ -28,8 +28,8 @@ QtLocationPicker::QtLocationPicker(QWidget *parent) layout->addWidget(m_data); m_button = new QtIconButton( - (ResourcePaths::getGuiPath() + "window/dots.png").c_str(), - (ResourcePaths::getGuiPath() + "window/dots_hover.png").c_str()); + (ResourcePaths::getGuiPath().str() + "window/dots.png").c_str(), + (ResourcePaths::getGuiPath().str() + "window/dots_hover.png").c_str()); m_button->setObjectName("dotsButton"); m_button->setToolTip("pick file"); connect(m_button, SIGNAL(clicked()), this, SLOT(handleButtonPress())); diff --git a/src/lib_gui/qt/element/QtProgressBar.cpp b/src/lib_gui/qt/element/QtProgressBar.cpp index e004104a..bfa1e490 100644 --- a/src/lib_gui/qt/element/QtProgressBar.cpp +++ b/src/lib_gui/qt/element/QtProgressBar.cpp @@ -11,7 +11,7 @@ QtProgressBar::QtProgressBar(QWidget* parent) : QWidget(parent) , m_percent(0) , m_count(0) - , m_pixmap((ResourcePaths::getGuiPath() + "indexing_dialog/progress_bar_element.png").c_str()) + , m_pixmap((ResourcePaths::getGuiPath().str() + "indexing_dialog/progress_bar_element.png").c_str()) { m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(animate())); diff --git a/src/lib_gui/qt/element/QtRefreshBar.cpp b/src/lib_gui/qt/element/QtRefreshBar.cpp index 88e66e4c..b72863b6 100644 --- a/src/lib_gui/qt/element/QtRefreshBar.cpp +++ b/src/lib_gui/qt/element/QtRefreshBar.cpp @@ -49,7 +49,7 @@ void QtRefreshBar::refreshStyle() m_refreshButton->setFixedHeight(height); m_refreshButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "refresh_view/images/refresh.png", + ResourcePaths::getGuiPath().str() + "refresh_view/images/refresh.png", "search/button" )); } diff --git a/src/lib_gui/qt/element/QtSearchBar.cpp b/src/lib_gui/qt/element/QtSearchBar.cpp index 036407bd..3f7f5640 100644 --- a/src/lib_gui/qt/element/QtSearchBar.cpp +++ b/src/lib_gui/qt/element/QtSearchBar.cpp @@ -102,12 +102,12 @@ void QtSearchBar::refreshStyle() m_homeButton->setFixedHeight(m_searchBox->height() + 5); m_searchButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "search_view/images/search.png", + ResourcePaths::getGuiPath().str() + "search_view/images/search.png", "search/button" )); m_homeButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "search_view/images/home.png", + ResourcePaths::getGuiPath().str() + "search_view/images/home.png", "search/button" )); } diff --git a/src/lib_gui/qt/element/QtStatusBar.cpp b/src/lib_gui/qt/element/QtStatusBar.cpp index 6d799c87..658bf053 100644 --- a/src/lib_gui/qt/element/QtStatusBar.cpp +++ b/src/lib_gui/qt/element/QtStatusBar.cpp @@ -13,7 +13,7 @@ QtStatusBar::QtStatusBar() { addWidget(new QWidget()); // add some space - QMovie* movie = new QMovie((ResourcePaths::getGuiPath() + "statusbar_view/loader.gif").c_str()); + QMovie* movie = new QMovie((ResourcePaths::getGuiPath().str() + "statusbar_view/loader.gif").c_str()); // if movie doesn't loop forever, force it to. if (movie->loopCount() != -1) { @@ -37,7 +37,7 @@ QtStatusBar::QtStatusBar() m_errorButton.setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_errorButton.setStyleSheet("QPushButton { color: #D00000; margin-right: 0; spacing: none; }"); m_errorButton.setIcon(utility::colorizePixmap( - QPixmap((ResourcePaths::getGuiPath() + "statusbar_view/dot.png").c_str()), + QPixmap((ResourcePaths::getGuiPath().str() + "statusbar_view/dot.png").c_str()), "#D00000" ).scaledToHeight(12)); addPermanentWidget(&m_errorButton); diff --git a/src/lib_gui/qt/element/QtUndoRedo.cpp b/src/lib_gui/qt/element/QtUndoRedo.cpp index b37b0024..14ba97e0 100644 --- a/src/lib_gui/qt/element/QtUndoRedo.cpp +++ b/src/lib_gui/qt/element/QtUndoRedo.cpp @@ -76,12 +76,12 @@ void QtUndoRedo::refreshStyle() m_redoButton->setFixedHeight(height); m_undoButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "undoredo_view/images/arrow_left.png", + ResourcePaths::getGuiPath().str() + "undoredo_view/images/arrow_left.png", "search/button" )); m_redoButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "undoredo_view/images/arrow_right.png", + ResourcePaths::getGuiPath().str() + "undoredo_view/images/arrow_right.png", "search/button" )); } diff --git a/src/lib_gui/qt/graphics/QtGraphicsView.cpp b/src/lib_gui/qt/graphics/QtGraphicsView.cpp index faf0d2f8..de0d0889 100644 --- a/src/lib_gui/qt/graphics/QtGraphicsView.cpp +++ b/src/lib_gui/qt/graphics/QtGraphicsView.cpp @@ -139,12 +139,12 @@ void QtGraphicsView::updateZoom(float delta) void QtGraphicsView::refreshStyle() { m_zoomInButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "graph_view/images/zoom_in.png", + ResourcePaths::getGuiPath().str() + "graph_view/images/zoom_in.png", "search/button" )); m_zoomOutButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "graph_view/images/zoom_out.png", + ResourcePaths::getGuiPath().str() + "graph_view/images/zoom_out.png", "search/button" )); } diff --git a/src/lib_gui/qt/graphics/QtGraphicsView.h b/src/lib_gui/qt/graphics/QtGraphicsView.h index e0ed24a8..13dd2f0d 100644 --- a/src/lib_gui/qt/graphics/QtGraphicsView.h +++ b/src/lib_gui/qt/graphics/QtGraphicsView.h @@ -6,8 +6,6 @@ #include #include -#include "utility/file/FilePath.h" - class QTimer; class QtGraphNode; diff --git a/src/lib_gui/qt/utility/utilityQt.cpp b/src/lib_gui/qt/utility/utilityQt.cpp index 44c80379..7148e28d 100644 --- a/src/lib_gui/qt/utility/utilityQt.cpp +++ b/src/lib_gui/qt/utility/utilityQt.cpp @@ -9,6 +9,7 @@ #include #include +#include "utility/file/FilePath.h" #include "utility/file/FileSystem.h" #include "utility/logging/logging.h" #include "utility/ResourcePaths.h" @@ -35,7 +36,7 @@ namespace utility widget->setSizePolicy(pol); } - void loadFontsFromDirectory(const std::string& path, const std::string& extension) + void loadFontsFromDirectory(const FilePath& path, const std::string& extension) { std::vector extensions; extensions.push_back(extension); @@ -65,7 +66,7 @@ namespace utility } } - std::string getStyleSheet(const std::string& path) + std::string getStyleSheet(const FilePath& path) { std::string css = TextAccess::createFromFile(path)->getText(); @@ -84,7 +85,7 @@ namespace utility std::deque seq = utility::split(css.substr(posA + 1, posB - posA - 1), ':'); if (seq.size() != 2) { - LOG_ERROR("Syntax error in file: " + path); + LOG_ERROR("Syntax error in file: " + path.str()); return ""; } @@ -143,7 +144,7 @@ namespace utility } else if (val == "gui_path") { - val = ResourcePaths::getGuiPath(); + val = ResourcePaths::getGuiPath().str(); size_t index = 0; while (true) @@ -159,7 +160,7 @@ namespace utility } else { - LOG_ERROR("Syntax error in file: " + path); + LOG_ERROR("Syntax error in file: " + path.str()); return ""; } } @@ -169,7 +170,7 @@ namespace utility } else { - LOG_ERROR("Syntax error in file: " + path); + LOG_ERROR("Syntax error in file: " + path.str()); return ""; } diff --git a/src/lib_gui/qt/utility/utilityQt.h b/src/lib_gui/qt/utility/utilityQt.h index 3aa1d291..e821f99a 100644 --- a/src/lib_gui/qt/utility/utilityQt.h +++ b/src/lib_gui/qt/utility/utilityQt.h @@ -8,15 +8,16 @@ class QIcon; class QPixmap; class QString; class QWidget; +class FilePath; namespace utility { void setWidgetBackgroundColor(QWidget* widget, const std::string& color); void setWidgetRetainsSpaceWhenHidden(QWidget* widget); - void loadFontsFromDirectory(const std::string& path, const std::string& extension = ".otf"); + void loadFontsFromDirectory(const FilePath& path, const std::string& extension = ".otf"); - std::string getStyleSheet(const std::string& path); + std::string getStyleSheet(const FilePath& path); QPixmap colorizePixmap(const QPixmap& pixmap, QColor color); QIcon createButtonIcon(const std::string& iconPath, const std::string& colorId); diff --git a/src/lib_gui/qt/view/QtBookmarkView.cpp b/src/lib_gui/qt/view/QtBookmarkView.cpp index ba767260..64441a46 100644 --- a/src/lib_gui/qt/view/QtBookmarkView.cpp +++ b/src/lib_gui/qt/view/QtBookmarkView.cpp @@ -88,7 +88,7 @@ void QtBookmarkView::setCreateButtonState(const CreateButtonState& state) m_createButtonState = state; m_createBookmarkButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "bookmark_view/images/edit_bookmark_icon.png", + ResourcePaths::getGuiPath().str() + "bookmark_view/images/edit_bookmark_icon.png", "search/button" )); @@ -105,7 +105,7 @@ void QtBookmarkView::setCreateButtonState(const CreateButtonState& state) m_createBookmarkButton->setEnabled(true); m_createBookmarkButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_active.png", + ResourcePaths::getGuiPath().str() + "bookmark_view/images/bookmark_active.png", "search/button" )); } @@ -240,7 +240,7 @@ void QtBookmarkView::displayBookmarkEditor(std::shared_ptr bookmark, c void QtBookmarkView::setStyleSheet() { - m_widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css").c_str()); + m_widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css"))).c_str()); } void QtBookmarkView::refreshStyle() @@ -251,12 +251,12 @@ void QtBookmarkView::refreshStyle() m_showBookmarksButton->setFixedHeight(height); m_createBookmarkButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "bookmark_view/images/edit_bookmark_icon.png", + ResourcePaths::getGuiPath().str() + "bookmark_view/images/edit_bookmark_icon.png", "search/button" )); m_showBookmarksButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_list_icon.png", + ResourcePaths::getGuiPath().str() + "bookmark_view/images/bookmark_list_icon.png", "search/button" )); } diff --git a/src/lib_gui/qt/view/QtCodeView.cpp b/src/lib_gui/qt/view/QtCodeView.cpp index c1256aa6..1b13d58c 100644 --- a/src/lib_gui/qt/view/QtCodeView.cpp +++ b/src/lib_gui/qt/view/QtCodeView.cpp @@ -267,7 +267,7 @@ void QtCodeView::setStyleSheet() const { utility::setWidgetBackgroundColor(m_widget, ColorScheme::getInstance()->getColor("code/background")); - std::string styleSheet = utility::getStyleSheet(ResourcePaths::getGuiPath() + "code_view/code_view.css"); + std::string styleSheet = utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("code_view/code_view.css"))); m_widget->setStyleSheet(styleSheet.c_str()); } diff --git a/src/lib_gui/qt/view/QtErrorView.cpp b/src/lib_gui/qt/view/QtErrorView.cpp index 90e21d02..b3c7b448 100644 --- a/src/lib_gui/qt/view/QtErrorView.cpp +++ b/src/lib_gui/qt/view/QtErrorView.cpp @@ -50,7 +50,7 @@ QtErrorView::QtErrorView(ViewLayout* viewLayout) , m_setErrorIdFunctor(std::bind(&QtErrorView::doSetErrorId, this, std::placeholders::_1)) , m_ignoreRowSelection(false) { - s_errorIcon = QIcon(QString((ResourcePaths::getGuiPath() + "/indexing_dialog/error.png").c_str())); + s_errorIcon = QIcon(QString((ResourcePaths::getGuiPath().str() + "/indexing_dialog/error.png").c_str())); } QtErrorView::~QtErrorView() diff --git a/src/lib_gui/qt/view/QtGraphView.cpp b/src/lib_gui/qt/view/QtGraphView.cpp index 87d72c3b..ddc4fc74 100644 --- a/src/lib_gui/qt/view/QtGraphView.cpp +++ b/src/lib_gui/qt/view/QtGraphView.cpp @@ -441,12 +441,12 @@ void QtGraphView::updateTrailButtons() } m_backwardTrailButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "graph_view/images/" + backwardImagePath, + ResourcePaths::getGuiPath().str() + "graph_view/images/" + backwardImagePath, "search/button" )); m_forwardTrailButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "graph_view/images/" + forwardImagePath, + ResourcePaths::getGuiPath().str() + "graph_view/images/" + forwardImagePath, "search/button" )); } @@ -646,19 +646,19 @@ void QtGraphView::doRefreshView() QtGraphicsView* view = getView(); - std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath() + "graph_view/graph_view.css"); + std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("graph_view/graph_view.css"))); view->setStyleSheet(css.c_str()); view->setAppZoomFactor(GraphViewStyle::getZoomFactor()); m_trailWidget->setStyleSheet(css.c_str()); m_expandButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "graph_view/images/graph.png", + ResourcePaths::getGuiPath().str() + "graph_view/images/graph.png", "search/button" )); m_collapseButton->setIcon(utility::createButtonIcon( - ResourcePaths::getGuiPath() + "graph_view/images/graph_arrow.png", + ResourcePaths::getGuiPath().str() + "graph_view/images/graph_arrow.png", "search/button" )); diff --git a/src/lib_gui/qt/view/QtLogView.cpp b/src/lib_gui/qt/view/QtLogView.cpp index 01494d39..917a3c62 100644 --- a/src/lib_gui/qt/view/QtLogView.cpp +++ b/src/lib_gui/qt/view/QtLogView.cpp @@ -216,7 +216,7 @@ void QtLogView::setStyleSheet() const //m_showNonIndexedFatals->setPalette(palette); widget->setStyleSheet( - utility::getStyleSheet(ResourcePaths::getGuiPath() + "error_view/error_view.css").c_str() + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("error_view/error_view.css"))).c_str() ); m_table->updateRows(); diff --git a/src/lib_gui/qt/view/QtRefreshView.cpp b/src/lib_gui/qt/view/QtRefreshView.cpp index 05d95684..b7f31e08 100644 --- a/src/lib_gui/qt/view/QtRefreshView.cpp +++ b/src/lib_gui/qt/view/QtRefreshView.cpp @@ -41,5 +41,5 @@ void QtRefreshView::doRefreshView() void QtRefreshView::setStyleSheet() { - m_widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "refresh_view/refresh_view.css").c_str()); + m_widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("refresh_view/refresh_view.css"))).c_str()); } diff --git a/src/lib_gui/qt/view/QtSearchView.cpp b/src/lib_gui/qt/view/QtSearchView.cpp index 42482caf..9190c89b 100644 --- a/src/lib_gui/qt/view/QtSearchView.cpp +++ b/src/lib_gui/qt/view/QtSearchView.cpp @@ -93,7 +93,7 @@ void QtSearchView::doSetAutocompletionList(const std::vector& autoc void QtSearchView::setStyleSheet() { - std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath() + "search_view/search_view.css"); + std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("search_view/search_view.css"))); m_widget->setStyleSheet(css.c_str()); diff --git a/src/lib_gui/qt/view/QtTabbedView.cpp b/src/lib_gui/qt/view/QtTabbedView.cpp index 8ca2cef3..d84610a0 100644 --- a/src/lib_gui/qt/view/QtTabbedView.cpp +++ b/src/lib_gui/qt/view/QtTabbedView.cpp @@ -68,6 +68,6 @@ void QtTabbedView::setStyleSheet() utility::setWidgetBackgroundColor(QtViewWidgetWrapper::getWidgetOfView(this), ColorScheme::getInstance()->getColor("tab/background")); m_widget->setStyleSheet( - utility::getStyleSheet(ResourcePaths::getGuiPath() + "tabbed_view/tabbed_view.css").c_str() + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("tabbed_view/tabbed_view.css"))).c_str() ); } diff --git a/src/lib_gui/qt/view/QtUndoRedoView.cpp b/src/lib_gui/qt/view/QtUndoRedoView.cpp index 987f7230..d99407a2 100644 --- a/src/lib_gui/qt/view/QtUndoRedoView.cpp +++ b/src/lib_gui/qt/view/QtUndoRedoView.cpp @@ -37,7 +37,7 @@ void QtUndoRedoView::refreshView() void QtUndoRedoView::setStyleSheet() { - m_widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "undoredo_view/undoredo_view.css").c_str()); + m_widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("undoredo_view/undoredo_view.css"))).c_str()); } void QtUndoRedoView::doRefreshView() diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp b/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp index 0af2b6b9..fe9c8773 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp +++ b/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp @@ -428,7 +428,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style) if (style.hasHatching) { - QtDeviceScaledPixmap pattern((ResourcePaths::getGuiPath() + "graph_view/images/pattern.png").c_str()); + QtDeviceScaledPixmap pattern((ResourcePaths::getGuiPath().str() + "graph_view/images/pattern.png").c_str()); pattern.scaleToHeight(12); QPixmap pixmap = utility::colorizePixmap(pattern.pixmap(), style.color.hatching.c_str()); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeAccess.cpp b/src/lib_gui/qt/view/graphElements/QtGraphNodeAccess.cpp index 86c8b7e1..6601e112 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeAccess.cpp +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeAccess.cpp @@ -47,7 +47,7 @@ QtGraphNodeAccess::QtGraphNodeAccess(AccessKind accessKind) if (iconFileName.size() > 0) { QtDeviceScaledPixmap pixmap( - QString::fromStdString(ResourcePaths::getGuiPath() + "graph_view/images/" + iconFileName + ".png")); + QString::fromStdString(ResourcePaths::getGuiPath().str() + "graph_view/images/" + iconFileName + ".png")); pixmap.scaleToHeight(m_accessIconSize); m_accessIcon = new QGraphicsPixmapItem(pixmap.pixmap(), this); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeData.cpp b/src/lib_gui/qt/view/graphElements/QtGraphNodeData.cpp index 25a89936..59b5f8fb 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeData.cpp +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeData.cpp @@ -1,5 +1,6 @@ #include "qt/view/graphElements/QtGraphNodeData.h" +#include "utility/file/FilePath.h" #include "utility/messaging/type/MessageActivateNodes.h" #include "utility/messaging/type/MessageDeactivateEdge.h" #include "utility/messaging/type/MessageFocusIn.h" diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeData.h b/src/lib_gui/qt/view/graphElements/QtGraphNodeData.h index cd741340..cc38a4f3 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeData.h +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeData.h @@ -1,10 +1,10 @@ #ifndef QT_GRAPH_NODE_DATA_H #define QT_GRAPH_NODE_DATA_H -#include "utility/file/FilePath.h" - #include "qt/view/graphElements/QtGraphNode.h" +class FilePath; + class QtGraphNodeData : public QtGraphNode { diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeExpandToggle.cpp b/src/lib_gui/qt/view/graphElements/QtGraphNodeExpandToggle.cpp index 26aefa53..2499aa83 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeExpandToggle.cpp +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeExpandToggle.cpp @@ -26,7 +26,7 @@ QtGraphNodeExpandToggle::QtGraphNodeExpandToggle(bool expanded, int invisibleSub m_icon->setTransformationMode(Qt::SmoothTransformation); m_icon->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); - QtDeviceScaledPixmap pixmap((ResourcePaths::getGuiPath() + "graph_view/images/arrow.png").c_str()); + QtDeviceScaledPixmap pixmap((ResourcePaths::getGuiPath().str() + "graph_view/images/arrow.png").c_str()); pixmap.scaleToHeight(iconHeight); if (invisibleSubNodeCount) diff --git a/src/lib_gui/qt/window/QtAbout.cpp b/src/lib_gui/qt/window/QtAbout.cpp index 808289b6..9a836bb2 100644 --- a/src/lib_gui/qt/window/QtAbout.cpp +++ b/src/lib_gui/qt/window/QtAbout.cpp @@ -31,7 +31,7 @@ void QtAbout::setupAbout() "}" ); - setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "about/about.css").c_str()); + setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("about/about.css"))).c_str()); QVBoxLayout* windowLayout = new QVBoxLayout(); windowLayout->setContentsMargins(10, 10, 10, 0); @@ -45,7 +45,7 @@ void QtAbout::setupAbout() QVBoxLayout* column = new QVBoxLayout(); row->addLayout(column); - QtDeviceScaledPixmap sourcetrailLogo((ResourcePaths::getGuiPath() + "about/logo_sourcetrail.png").c_str()); + QtDeviceScaledPixmap sourcetrailLogo((ResourcePaths::getGuiPath().str() + "about/logo_sourcetrail.png").c_str()); sourcetrailLogo.scaleToHeight(150); QLabel* sourcetrailLogoLabel = new QLabel(this); sourcetrailLogoLabel->setPixmap(sourcetrailLogo.pixmap()); @@ -59,7 +59,7 @@ void QtAbout::setupAbout() QVBoxLayout* column = new QVBoxLayout(); row->addLayout(column); - QtDeviceScaledPixmap closePixmap((ResourcePaths::getGuiPath() + "about/icon_close.png").c_str()); + QtDeviceScaledPixmap closePixmap((ResourcePaths::getGuiPath().str() + "about/icon_close.png").c_str()); closePixmap.scaleToHeight(20); QPushButton* closeButton = new QPushButton(this); closeButton->setIcon(QIcon(closePixmap.pixmap())); @@ -139,14 +139,14 @@ void QtAbout::setupAbout() QHBoxLayout* rowAcknowledgementsLogos = new QHBoxLayout(); column->addLayout(rowAcknowledgementsLogos); - QtDeviceScaledPixmap fhsLogo((ResourcePaths::getGuiPath() + "about/logo_fhs.png").c_str()); + QtDeviceScaledPixmap fhsLogo((ResourcePaths::getGuiPath().str() + "about/logo_fhs.png").c_str()); fhsLogo.scaleToHeight(30); QLabel* fhsLabel = new QLabel(this); fhsLabel->setPixmap(fhsLogo.pixmap()); fhsLabel->resize(fhsLogo.width(), fhsLogo.height()); rowAcknowledgementsLogos->addWidget(fhsLabel); - QtDeviceScaledPixmap awsLogo((ResourcePaths::getGuiPath() + "about/logo_aws.png").c_str()); + QtDeviceScaledPixmap awsLogo((ResourcePaths::getGuiPath().str() + "about/logo_aws.png").c_str()); awsLogo.scaleToHeight(30); QLabel* awsLabel = new QLabel(this); awsLabel->setPixmap(awsLogo.pixmap()); diff --git a/src/lib_gui/qt/window/QtBookmarkBrowser.cpp b/src/lib_gui/qt/window/QtBookmarkBrowser.cpp index 2b8da034..15e1fb17 100644 --- a/src/lib_gui/qt/window/QtBookmarkBrowser.cpp +++ b/src/lib_gui/qt/window/QtBookmarkBrowser.cpp @@ -24,8 +24,8 @@ QtBookmarkBrowser::~QtBookmarkBrowser() void QtBookmarkBrowser::setupBookmarkBrowser() { setStyleSheet(( - utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") + - utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css") + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) + + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css"))) ).c_str()); m_headerBackground = new QWidget(m_window); diff --git a/src/lib_gui/qt/window/QtBookmarkCreator.cpp b/src/lib_gui/qt/window/QtBookmarkCreator.cpp index 3bcc12ff..19b45af2 100644 --- a/src/lib_gui/qt/window/QtBookmarkCreator.cpp +++ b/src/lib_gui/qt/window/QtBookmarkCreator.cpp @@ -113,8 +113,8 @@ void QtBookmarkCreator::setupBookmarkCreator() void QtBookmarkCreator::refreshStyle() { setStyleSheet(( - utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") + - utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css") + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) + + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("bookmark_view/bookmark_view.css"))) ).c_str()); } diff --git a/src/lib_gui/qt/window/QtIndexingDialog.cpp b/src/lib_gui/qt/window/QtIndexingDialog.cpp index 655a3129..1e8261e7 100644 --- a/src/lib_gui/qt/window/QtIndexingDialog.cpp +++ b/src/lib_gui/qt/window/QtIndexingDialog.cpp @@ -340,8 +340,8 @@ QBoxLayout* QtIndexingDialog::createLayout() ); setStyleSheet(( - utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") + - utility::getStyleSheet(ResourcePaths::getGuiPath() + "indexing_dialog/indexing_dialog.css") + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))) + + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("indexing_dialog/indexing_dialog.css"))) ).c_str()); QVBoxLayout* layout = new QVBoxLayout(this); @@ -419,7 +419,7 @@ void QtIndexingDialog::addErrorLabel(QBoxLayout* layout) m_errorLabel->setObjectName("errorCount"); m_errorLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac - std::string text = ResourcePaths::getGuiPath() + "indexing_dialog/error.png"; + std::string text = ResourcePaths::getGuiPath().str() + "indexing_dialog/error.png"; m_errorLabel->setIcon(QPixmap(text.c_str())); layout->addWidget(m_errorLabel, 0, Qt::AlignRight); @@ -448,7 +448,7 @@ void QtIndexingDialog::addButtons(QBoxLayout* layout) void QtIndexingDialog::addFlag() { - QtDeviceScaledPixmap flag((ResourcePaths::getGuiPath() + "indexing_dialog/flag.png").c_str()); + QtDeviceScaledPixmap flag((ResourcePaths::getGuiPath().str() + "indexing_dialog/flag.png").c_str()); flag.scaleToWidth(120); QLabel* flagLabel = new QLabel(this); diff --git a/src/lib_gui/qt/window/QtKeyboardShortcuts.cpp b/src/lib_gui/qt/window/QtKeyboardShortcuts.cpp index b178b6b8..6a8b39cf 100644 --- a/src/lib_gui/qt/window/QtKeyboardShortcuts.cpp +++ b/src/lib_gui/qt/window/QtKeyboardShortcuts.cpp @@ -72,7 +72,7 @@ void QtKeyboardShortcuts::populateWindow(QWidget* widget) widget->setLayout(layout); - widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "keyboard_shortcuts/keyboard_shortcuts.css").c_str()); + widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("keyboard_shortcuts/keyboard_shortcuts.css"))).c_str()); } void QtKeyboardShortcuts::windowReady() diff --git a/src/lib_gui/qt/window/QtLicense.cpp b/src/lib_gui/qt/window/QtLicense.cpp index 5f29b4c1..994f08d8 100644 --- a/src/lib_gui/qt/window/QtLicense.cpp +++ b/src/lib_gui/qt/window/QtLicense.cpp @@ -7,7 +7,6 @@ #include "LicenseChecker.h" #include "qt/utility/utilityQt.h" -#include "utility/file/FilePath.h" #include "utility/ResourcePaths.h" QtLicense::QtLicense(QWidget *parent) @@ -121,7 +120,7 @@ void QtLicense::populateWindow(QWidget* widget) void QtLicense::windowReady() { - m_content->setStyleSheet(m_content->styleSheet() + utility::getStyleSheet(ResourcePaths::getGuiPath() + "license/license.css").c_str()); + m_content->setStyleSheet(m_content->styleSheet() + utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("license/license.css"))).c_str()); addLogo(); diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index 5ba6f07c..7f4d4f85 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -102,13 +102,13 @@ QtMainWindow::QtMainWindow() setCentralWidget(nullptr); setDockNestingEnabled(true); - setWindowIcon(QIcon((ResourcePaths::getGuiPath() + "icon/logo_1024_1024.png").c_str())); + setWindowIcon(QIcon((ResourcePaths::getGuiPath().str() + "icon/logo_1024_1024.png").c_str())); setWindowFlags(Qt::Widget); QApplication* app = dynamic_cast(QCoreApplication::instance()); app->installEventFilter(new MouseReleaseFilter(this)); - app->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "main.css").c_str()); + app->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("main.css"))).c_str()); m_recentProjectAction = new QAction*[ApplicationSettings::getInstance()->getMaxRecentProjectsCount()]; @@ -187,7 +187,7 @@ void QtMainWindow::hideView(View* view) void QtMainWindow::loadLayout() { - QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat); + QSettings settings(UserPaths::getWindowSettingsPath().str().c_str(), QSettings::IniFormat); settings.beginGroup("MainWindow"); resize(settings.value("size", QSize(600, 400)).toSize()); @@ -203,7 +203,7 @@ void QtMainWindow::loadLayout() void QtMainWindow::loadDockWidgetLayout() { - QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat); + QSettings settings(UserPaths::getWindowSettingsPath().str().c_str(), QSettings::IniFormat); this->restoreState(settings.value("DOCK_LOCATIONS").toByteArray()); for (DockWidget dock : m_dockWidgets) @@ -215,7 +215,7 @@ void QtMainWindow::loadDockWidgetLayout() void QtMainWindow::saveLayout() { - QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat); + QSettings settings(UserPaths::getWindowSettingsPath().str().c_str(), QSettings::IniFormat); settings.beginGroup("MainWindow"); settings.setValue("maximized", isMaximized()); @@ -362,12 +362,12 @@ void QtMainWindow::enteredLicense() void QtMainWindow::showDataFolder() { - QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getUserDataPath()).c_str(), QUrl::TolerantMode)); + QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getUserDataPath().str()).c_str(), QUrl::TolerantMode)); } void QtMainWindow::showLogFolder() { - QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getLogPath()).c_str(), QUrl::TolerantMode)); + QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getLogPath().str()).c_str(), QUrl::TolerantMode)); } void QtMainWindow::showStartScreen() @@ -416,7 +416,7 @@ void QtMainWindow::newProject() void QtMainWindow::newProjectFromSolution(const std::string& ideId, const std::string& solutionPath) { QtProjectWizzard* wizzard = createWindow(); - wizzard->newProjectFromSolution(ideId, solutionPath); + wizzard->newProjectFromSolution(ideId, FilePath(solutionPath)); } void QtMainWindow::newProjectFromCDB(const std::string& filePath, const std::vector& headerPaths) @@ -438,7 +438,7 @@ void QtMainWindow::openProject() if (!fileName.isEmpty()) { - MessageLoadProject(fileName.toStdString(), false).dispatch(); + MessageLoadProject(FilePath(fileName.toStdString()), false).dispatch(); m_windowStack.clearWindows(); } } @@ -528,7 +528,7 @@ void QtMainWindow::resetZoom() void QtMainWindow::resetWindowLayout() { FileSystem::remove(UserPaths::getWindowSettingsPath()); - FileSystem::copyFile(ResourcePaths::getFallbackPath() + "window_settings.ini", UserPaths::getWindowSettingsPath()); + FileSystem::copyFile(ResourcePaths::getFallbackPath().concat(FilePath("window_settings.ini")), UserPaths::getWindowSettingsPath()); loadDockWidgetLayout(); } @@ -537,7 +537,7 @@ void QtMainWindow::openRecentProject() QAction *action = qobject_cast(sender()); if (action) { - MessageLoadProject(action->data().toString().toStdString(), false).dispatch(); + MessageLoadProject(FilePath(action->data().toString().toStdString()), false).dispatch(); m_windowStack.clearWindows(); } } diff --git a/src/lib_gui/qt/window/QtSelectPathsDialog.cpp b/src/lib_gui/qt/window/QtSelectPathsDialog.cpp index 58934772..5c60367d 100644 --- a/src/lib_gui/qt/window/QtSelectPathsDialog.cpp +++ b/src/lib_gui/qt/window/QtSelectPathsDialog.cpp @@ -4,6 +4,8 @@ #include #include +#include "utility/file/FilePath.h" + QtSelectPathsDialog::QtSelectPathsDialog(const QString& title, const QString& description, QWidget* parent) : QtTextEditDialog(title, description, parent) { @@ -17,7 +19,7 @@ std::vector QtSelectPathsDialog::getPathsList() const { if (m_list->item(i)->checkState() == Qt::Checked) { - checkedPaths.push_back(m_list->item(i)->text().toStdString()); + checkedPaths.push_back(FilePath(m_list->item(i)->text().toStdString())); } } diff --git a/src/lib_gui/qt/window/QtSelectPathsDialog.h b/src/lib_gui/qt/window/QtSelectPathsDialog.h index 3712970c..3fd8f0ff 100644 --- a/src/lib_gui/qt/window/QtSelectPathsDialog.h +++ b/src/lib_gui/qt/window/QtSelectPathsDialog.h @@ -2,8 +2,8 @@ #define QT_SELECT_PATHS_DIALOG_H #include "qt/window/QtTextEditDialog.h" -#include "utility/file/FilePath.h" +class FilePath; class QListWidget; class QtSelectPathsDialog diff --git a/src/lib_gui/qt/window/QtSplashScreen.cpp b/src/lib_gui/qt/window/QtSplashScreen.cpp index baeaf6fa..4ac44205 100644 --- a/src/lib_gui/qt/window/QtSplashScreen.cpp +++ b/src/lib_gui/qt/window/QtSplashScreen.cpp @@ -25,11 +25,11 @@ QtSplashScreen::QtSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) : QSplashScreen(pixmap, f) , m_state(0) { - QtDeviceScaledPixmap foreground((ResourcePaths::getGuiPath() + "splash_white.png").c_str()); + QtDeviceScaledPixmap foreground((ResourcePaths::getGuiPath().str() + "splash_white.png").c_str()); foreground.scaleToHeight(pixmap.size().height() * 0.8); m_foreground = foreground.pixmap(); - QtDeviceScaledPixmap background((ResourcePaths::getGuiPath() + "splash_blue.png").c_str()); + QtDeviceScaledPixmap background((ResourcePaths::getGuiPath().str() + "splash_blue.png").c_str()); background.scaleToHeight(pixmap.size().height() * 0.9); m_background = background.pixmap(); } diff --git a/src/lib_gui/qt/window/QtStartScreen.cpp b/src/lib_gui/qt/window/QtStartScreen.cpp index 0d30d9e4..36ae8b54 100644 --- a/src/lib_gui/qt/window/QtStartScreen.cpp +++ b/src/lib_gui/qt/window/QtStartScreen.cpp @@ -49,7 +49,7 @@ void QtRecentProjectButton::handleButtonClick() { if (m_projectExists) { - MessageLoadProject(m_projectFilePath.str(), false).dispatch(); + MessageLoadProject(m_projectFilePath, false).dispatch(); } else { @@ -139,12 +139,12 @@ size_t i = 0; } i++; } - setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "startscreen/startscreen.css").c_str()); + setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("startscreen/startscreen.css"))).c_str()); } void QtStartScreen::setupStartScreen(bool unlocked) { - setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "startscreen/startscreen.css").c_str()); + setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("startscreen/startscreen.css"))).c_str()); addLogo(); QHBoxLayout* layout = new QHBoxLayout(); @@ -261,10 +261,10 @@ void QtStartScreen::setupStartScreen(bool unlocked) col->addSpacing(20); - m_cppIcon = new QIcon((ResourcePaths::getGuiPath() + "icon/cpp_icon.png").c_str()); - m_cIcon = new QIcon((ResourcePaths::getGuiPath() + "icon/c_icon.png").c_str()); - m_javaIcon = new QIcon((ResourcePaths::getGuiPath() + "icon/java_icon.png").c_str()); - m_projectIcon = new QIcon((ResourcePaths::getGuiPath() + "icon/empty_icon.png").c_str()); + m_cppIcon = new QIcon((ResourcePaths::getGuiPath().str() + "icon/cpp_icon.png").c_str()); + m_cIcon = new QIcon((ResourcePaths::getGuiPath().str() + "icon/c_icon.png").c_str()); + m_javaIcon = new QIcon((ResourcePaths::getGuiPath().str() + "icon/java_icon.png").c_str()); + m_projectIcon = new QIcon((ResourcePaths::getGuiPath().str() + "icon/empty_icon.png").c_str()); for (int i = 0 ; i < ApplicationSettings::getInstance()->getMaxRecentProjectsCount() ; i++) diff --git a/src/lib_gui/qt/window/QtWindow.cpp b/src/lib_gui/qt/window/QtWindow.cpp index 672b3f05..9151fe7f 100644 --- a/src/lib_gui/qt/window/QtWindow.cpp +++ b/src/lib_gui/qt/window/QtWindow.cpp @@ -77,7 +77,7 @@ QSize QtWindow::sizeHint() const void QtWindow::setup() { - m_content->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css").c_str()); + m_content->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("window/window.css"))).c_str()); QVBoxLayout* layout = new QVBoxLayout(); layout->setContentsMargins(25, 30, 25, 0); @@ -140,7 +140,7 @@ void QtWindow::setSizeGripStyle(bool isBlack) "QSizeGrip {" " max-height: 16px;" " max-width: 16px;" - " border-image: url(" + ResourcePaths::getGuiPath() + "window/" + path + ");" + " border-image: url(" + ResourcePaths::getGuiPath().str() + "window/" + path + ");" "}" )); } @@ -426,7 +426,7 @@ void QtWindow::setupDone() void QtWindow::addLogo() { - QtDeviceScaledPixmap sourcetrailLogo((ResourcePaths::getGuiPath() + "window/logo.png").c_str()); + QtDeviceScaledPixmap sourcetrailLogo((ResourcePaths::getGuiPath().str() + "window/logo.png").c_str()); sourcetrailLogo.scaleToWidth(240); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index 65830d98..6e211be0 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -467,7 +467,7 @@ void QtProjectWizzard::sourcePathsJava() void QtProjectWizzard::sourcePathsJavaMaven() { std::dynamic_pointer_cast(m_sourceGroupSettings)->setMavenDependenciesDirectory( - "./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/maven" + FilePath("./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/maven") ); QtProjectWizzardWindow* window = createWindowWithSummary( diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp index 8da61049..c40885f0 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp @@ -85,7 +85,7 @@ void QtProjectWizzardContentData::save() if (m_projectName) { m_projectSettings->setProjectName(m_projectName->text().toStdString()); - m_projectSettings->setProjectFileLocation(m_projectFileLocation->getText().toStdString()); + m_projectSettings->setProjectFileLocation(FilePath(m_projectFileLocation->getText().toStdString())); } if (m_standard) @@ -239,7 +239,7 @@ void QtProjectWizzardContentDataCDB::save() { QtProjectWizzardContentData::save(); - FilePath path = m_buildFilePicker->getText().toStdString(); + FilePath path(m_buildFilePicker->getText().toStdString()); FilePath absPath = m_projectSettings->makePathAbsolute(m_projectSettings->expandPath(path)); // maybe we can use SourceGroupSettings for this... that's where the the cdb path is stored. if (!absPath.exists() || absPath.extension() != ".json") { @@ -260,7 +260,7 @@ bool QtProjectWizzardContentDataCDB::check() return false; } - FilePath path = m_buildFilePicker->getText().toStdString(); + FilePath path(m_buildFilePicker->getText().toStdString()); FilePath absPath = m_projectSettings->makePathAbsolute(m_projectSettings->expandPath(path)); if (!absPath.exists() || absPath.extension() != ".json") { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp index caf02f9d..e9607f52 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp @@ -115,7 +115,7 @@ void QtProjectWizzardContentPathSourceMaven::save() std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { - javaSettings->setMavenProjectFilePath(m_picker->getText().toStdString()); + javaSettings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdString())); javaSettings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked()); } } @@ -202,6 +202,6 @@ void QtProjectWizzardContentPathDependenciesMaven::save() std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { - javaSettings->setMavenDependenciesDirectory(m_picker->getText().toStdString()); + javaSettings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdString())); } } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp index f6d9aaa4..4461f184 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp @@ -271,7 +271,7 @@ void QtProjectWizzardContentPreferences::load() if (m_mavenPath) { - m_mavenPath->setText(QString::fromStdString(appSettings->getMavenPath())); + m_mavenPath->setText(QString::fromStdString(appSettings->getMavenPath().str())); } } @@ -316,7 +316,7 @@ void QtProjectWizzardContentPreferences::save() if (m_mavenPath) { - appSettings->setMavenPath(m_mavenPath->getText().toStdString()); + appSettings->setMavenPath(FilePath(m_mavenPath->getText().toStdString())); } } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp index 0cb212b7..6e6ccc1d 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp @@ -111,7 +111,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) { QToolButton* b = createProjectButton( utility::insertLineBreaksAtBlankSpaces(sourceGroupTypeToProjectSetupString(projectIt.type), 15).c_str(), - (ResourcePaths::getGuiPath() + "icon/" + m_projectTypeIconName[projectIt.type] + ".png").c_str() + (ResourcePaths::getGuiPath().str() + "icon/" + m_projectTypeIconName[projectIt.type] + ".png").c_str() ); b->setProperty("source_group_type", int(projectIt.type)); projectButtons->addButton(b); diff --git a/src/lib_gui/utility/path_detector/CombinedPathDetector.cpp b/src/lib_gui/utility/path_detector/CombinedPathDetector.cpp index 037a5cc6..8c3e3d24 100644 --- a/src/lib_gui/utility/path_detector/CombinedPathDetector.cpp +++ b/src/lib_gui/utility/path_detector/CombinedPathDetector.cpp @@ -1,5 +1,7 @@ #include "utility/path_detector/CombinedPathDetector.h" +#include "utility/file/FilePath.h" + CombinedPathDetector::CombinedPathDetector() : PathDetector("combined") { diff --git a/src/lib_gui/utility/path_detector/PathDetector.cpp b/src/lib_gui/utility/path_detector/PathDetector.cpp index cba79416..d882babb 100644 --- a/src/lib_gui/utility/path_detector/PathDetector.cpp +++ b/src/lib_gui/utility/path_detector/PathDetector.cpp @@ -1,5 +1,7 @@ #include "utility/path_detector/PathDetector.h" +#include "utility/file/FilePath.h" + PathDetector::PathDetector(const std::string& name) : m_name(name) { diff --git a/src/lib_gui/utility/path_detector/PathDetector.h b/src/lib_gui/utility/path_detector/PathDetector.h index fdc1f775..5a8d8cf6 100644 --- a/src/lib_gui/utility/path_detector/PathDetector.h +++ b/src/lib_gui/utility/path_detector/PathDetector.h @@ -4,7 +4,7 @@ #include #include -#include "utility/file/FilePath.h" +class FilePath; class PathDetector { diff --git a/src/lib_gui/utility/path_detector/cxx_header/CxxFrameworkPathDetector.cpp b/src/lib_gui/utility/path_detector/cxx_header/CxxFrameworkPathDetector.cpp index 21d3fa16..666b014f 100644 --- a/src/lib_gui/utility/path_detector/cxx_header/CxxFrameworkPathDetector.cpp +++ b/src/lib_gui/utility/path_detector/cxx_header/CxxFrameworkPathDetector.cpp @@ -1,5 +1,6 @@ #include "utility/path_detector/cxx_header/CxxFrameworkPathDetector.h" +#include "utility/file/FilePath.h" #include "utility/path_detector/cxx_header/utilityCxxHeaderDetection.h" #include "utility/utilityApp.h" #include "utility/utilityString.h" diff --git a/src/lib_gui/utility/path_detector/cxx_header/CxxHeaderPathDetector.cpp b/src/lib_gui/utility/path_detector/cxx_header/CxxHeaderPathDetector.cpp index ea899d7d..b35aeecb 100644 --- a/src/lib_gui/utility/path_detector/cxx_header/CxxHeaderPathDetector.cpp +++ b/src/lib_gui/utility/path_detector/cxx_header/CxxHeaderPathDetector.cpp @@ -1,5 +1,6 @@ #include "utility/path_detector/cxx_header/CxxHeaderPathDetector.h" +#include "utility/file/FilePath.h" #include "utility/path_detector/cxx_header/utilityCxxHeaderDetection.h" #include "utility/utilityApp.h" #include "utility/utilityString.h" diff --git a/src/lib_gui/utility/path_detector/cxx_header/CxxVsHeaderPathDetector.cpp b/src/lib_gui/utility/path_detector/cxx_header/CxxVsHeaderPathDetector.cpp index 0d6f986f..c18e20dd 100644 --- a/src/lib_gui/utility/path_detector/cxx_header/CxxVsHeaderPathDetector.cpp +++ b/src/lib_gui/utility/path_detector/cxx_header/CxxVsHeaderPathDetector.cpp @@ -34,10 +34,10 @@ std::vector CxxVsHeaderPathDetector::getPaths() const for (size_t i = 0; i < subdirectories.size(); i++) { - FilePath headerSearchPath = vsInstallPath.concat(subdirectories[i]); + FilePath headerSearchPath = vsInstallPath.concat(FilePath(subdirectories[i])); if (headerSearchPath.exists()) { - headerPaths.push_back(headerSearchPath.canonical().str()); + headerPaths.push_back(headerSearchPath.canonical()); } } } @@ -56,7 +56,7 @@ std::vector CxxVsHeaderPathDetector::getPaths() const FilePath sdkPath = getWindowsSdkPathUsingRegistry(windowsSdkVersions[i]); if (sdkPath.exists()) { - FilePath sdkIncludePath = sdkPath.concat("include/"); + FilePath sdkIncludePath = sdkPath.concat(FilePath("include/")); if (sdkIncludePath.exists()) { std::vector subdirectories; @@ -67,7 +67,7 @@ std::vector CxxVsHeaderPathDetector::getPaths() const bool usingSubdirectories = false; for (size_t j = 0; j < subdirectories.size(); j++) { - FilePath sdkSubdirectory = sdkPath.concat(subdirectories[j]); + FilePath sdkSubdirectory = sdkPath.concat(FilePath(subdirectories[j])); if (sdkSubdirectory.exists()) { headerPaths.push_back(sdkSubdirectory); diff --git a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetector.h b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetector.h index 58a7dc30..ad6e7f1e 100644 --- a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetector.h +++ b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetector.h @@ -2,7 +2,6 @@ #define JAVA_PATH_DETECTOR_H #include "utility/path_detector/PathDetector.h" -#include "utility/file/FilePath.h" class JavaPathDetector: public PathDetector { diff --git a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp index 0a5e17d1..baeda328 100644 --- a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp +++ b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp @@ -1,5 +1,6 @@ #include "utility/path_detector/java_runtime/JavaPathDetectorLinux.h" +#include "utility/file/FilePath.h" #include "utility/utilityApp.h" #include "utility/utilityString.h" @@ -43,7 +44,7 @@ FilePath JavaPathDetectorLinux::readLink(const FilePath& path) const { std::string command = "readlink -f " + path.str(); FilePath javaPath( utility::executeProcess(command.c_str())); - if ( !javaPath.empty() ) + if (!javaPath.empty()) { return javaPath; } diff --git a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorMac.cpp b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorMac.cpp index 2b34a599..04ade598 100644 --- a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorMac.cpp +++ b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorMac.cpp @@ -1,5 +1,6 @@ #include "utility/path_detector/java_runtime/JavaPathDetectorMac.h" +#include "utility/file/FilePath.h" #include "utility/utilityApp.h" #include "utility/utilityString.h" diff --git a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorWindows.cpp b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorWindows.cpp index 025e751d..957d7189 100644 --- a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorWindows.cpp +++ b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorWindows.cpp @@ -3,6 +3,7 @@ #include #include +#include "utility/file/FilePath.h" #include "utility/utilityApp.h" JavaPathDetectorWindows::JavaPathDetectorWindows(const std::string javaVersion) diff --git a/src/lib_gui/utility/path_detector/maven_executable/MavenPathDetectorUnix.cpp b/src/lib_gui/utility/path_detector/maven_executable/MavenPathDetectorUnix.cpp index 964dfde8..99b34a92 100644 --- a/src/lib_gui/utility/path_detector/maven_executable/MavenPathDetectorUnix.cpp +++ b/src/lib_gui/utility/path_detector/maven_executable/MavenPathDetectorUnix.cpp @@ -1,5 +1,6 @@ #include "utility/path_detector/maven_executable/MavenPathDetectorUnix.h" +#include "utility/file/FilePath.h" #include "utility/utilityApp.h" MavenPathDetectorUnix::MavenPathDetectorUnix() diff --git a/src/lib_gui/utility/path_detector/maven_executable/MavenPathDetectorWindows.cpp b/src/lib_gui/utility/path_detector/maven_executable/MavenPathDetectorWindows.cpp index 6f303665..e697edfe 100644 --- a/src/lib_gui/utility/path_detector/maven_executable/MavenPathDetectorWindows.cpp +++ b/src/lib_gui/utility/path_detector/maven_executable/MavenPathDetectorWindows.cpp @@ -1,5 +1,6 @@ #include "utility/path_detector/maven_executable/MavenPathDetectorWindows.h" +#include "utility/file/FilePath.h" #include "utility/utilityApp.h" MavenPathDetectorWindows::MavenPathDetectorWindows() diff --git a/src/lib_java/data/indexer/IndexerCommandJava.h b/src/lib_java/data/indexer/IndexerCommandJava.h index 6a8024ac..6a4db9fb 100644 --- a/src/lib_java/data/indexer/IndexerCommandJava.h +++ b/src/lib_java/data/indexer/IndexerCommandJava.h @@ -4,7 +4,8 @@ #include #include "data/indexer/IndexerCommand.h" -#include "utility/file/FilePath.h" + +class FilePath; class IndexerCommandJava : public IndexerCommand diff --git a/src/lib_java/data/parser/java/JavaParser.cpp b/src/lib_java/data/parser/java/JavaParser.cpp index 1329ba3d..1e1fdee6 100644 --- a/src/lib_java/data/parser/java/JavaParser.cpp +++ b/src/lib_java/data/parser/java/JavaParser.cpp @@ -14,7 +14,6 @@ JavaParser::JavaParser(std::shared_ptr client, std::shared_ptr fileRegister) : Parser(client) , m_id(s_nextParserId++) - , m_currentFilePath("") { std::shared_ptr factory = JavaEnvironmentFactory::getInstance(); if (factory) @@ -56,7 +55,7 @@ void JavaParser::buildIndex(std::shared_ptr indexerCommand) classPath += path.str() + ";"; } - buildIndex(indexerCommand->getSourceFilePath(), classPath, TextAccess::createFromFile(indexerCommand->getSourceFilePath().str())); + buildIndex(indexerCommand->getSourceFilePath(), classPath, TextAccess::createFromFile(indexerCommand->getSourceFilePath())); } void JavaParser::buildIndex(const FilePath& filePath, std::shared_ptr textAccess) @@ -68,7 +67,7 @@ void JavaParser::buildIndex(const FilePath& sourceFilePath, const std::string& c { if (m_javaEnvironment) { - m_currentFilePath = sourceFilePath.str(); + m_currentFilePath = sourceFilePath; m_client->onFileParsed(FileSystem::getFileInfoForPath(sourceFilePath)); @@ -82,7 +81,7 @@ void JavaParser::buildIndex(const FilePath& sourceFilePath, const std::string& c "com/sourcetrail/JavaIndexer", "processFile", m_id, - m_currentFilePath, + m_currentFilePath.str(), fileContent, classPath, verbose diff --git a/src/lib_java/data/parser/java/JavaParser.h b/src/lib_java/data/parser/java/JavaParser.h index 710748a2..8130bc85 100644 --- a/src/lib_java/data/parser/java/JavaParser.h +++ b/src/lib_java/data/parser/java/JavaParser.h @@ -7,6 +7,7 @@ #include "data/indexer/IndexerCommandJava.h" #include "data/parser/Parser.h" #include "data/parser/java/JavaEnvironment.h" +#include "utility/file/FilePath.h" #include "utility/logging/logging.h" struct JNIEnv_; @@ -24,6 +25,7 @@ typedef int jint; class _jstring; typedef _jstring *jstring; +class FilePath; class FileRegister; class JavaParser: public Parser @@ -171,7 +173,7 @@ private: std::shared_ptr m_javaEnvironment; const int m_id; - std::string m_currentFilePath; + FilePath m_currentFilePath; }; #endif // JAVA_PARSER_H diff --git a/src/lib_java/project/SourceGroupJava.cpp b/src/lib_java/project/SourceGroupJava.cpp index 9db69bb5..41c5ea82 100644 --- a/src/lib_java/project/SourceGroupJava.cpp +++ b/src/lib_java/project/SourceGroupJava.cpp @@ -114,14 +114,14 @@ bool SourceGroupJava::prepareJavaEnvironment() const std::string separator = ":"; #endif JavaEnvironmentFactory::createInstance( - ResourcePaths::getJavaPath() + "guava-18.0.jar" + separator + - ResourcePaths::getJavaPath() + "java-indexer.jar" + separator + - ResourcePaths::getJavaPath() + "javaparser-core.jar" + separator + - ResourcePaths::getJavaPath() + "javaslang-2.0.3.jar" + separator + - ResourcePaths::getJavaPath() + "javassist-3.19.0-GA.jar" + separator + - ResourcePaths::getJavaPath() + "java-symbol-solver-core.jar" + separator + - ResourcePaths::getJavaPath() + "java-symbol-solver-logic.jar" + separator + - ResourcePaths::getJavaPath() + "java-symbol-solver-model.jar", + ResourcePaths::getJavaPath().str() + "guava-18.0.jar" + separator + + ResourcePaths::getJavaPath().str() + "java-indexer.jar" + separator + + ResourcePaths::getJavaPath().str() + "javaparser-core.jar" + separator + + ResourcePaths::getJavaPath().str() + "javaslang-2.0.3.jar" + separator + + ResourcePaths::getJavaPath().str() + "javassist-3.19.0-GA.jar" + separator + + ResourcePaths::getJavaPath().str() + "java-symbol-solver-core.jar" + separator + + ResourcePaths::getJavaPath().str() + "java-symbol-solver-logic.jar" + separator + + ResourcePaths::getJavaPath().str() + "java-symbol-solver-model.jar", errorString ); } @@ -205,12 +205,12 @@ std::vector SourceGroupJava::getClassPath() if (m_settings->getAbsoluteMavenDependenciesDirectory().exists()) { const std::vector dependencies = FileSystem::getFileNamesFromDirectory( - m_settings->getAbsoluteMavenDependenciesDirectory().str(), + m_settings->getAbsoluteMavenDependenciesDirectory(), utility::createVectorFromElements(".jar") ); for (const std::string& dependency: dependencies) { - classPath.push_back(dependency); + classPath.push_back(FilePath(dependency)); } } @@ -218,7 +218,7 @@ std::vector SourceGroupJava::getClassPath() { if (rootDirectory.exists()) { - classPath.push_back(rootDirectory.str()); + classPath.push_back(rootDirectory); } } @@ -239,7 +239,7 @@ std::set SourceGroupJava::fetchRootDirectories() std::shared_ptr javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment(); for (FilePath filePath: m_allSourceFilePaths) { - std::shared_ptr textAccess = TextAccess::createFromFile(filePath.str()); + std::shared_ptr textAccess = TextAccess::createFromFile(filePath); std::string packageName = ""; javaEnvironment->callStaticMethod("com/sourcetrail/JavaIndexer", "getPackageName", packageName, textAccess->getText()); diff --git a/src/lib_java/utility/utilityMaven.cpp b/src/lib_java/utility/utilityMaven.cpp index c6cd1449..2198f3de 100644 --- a/src/lib_java/utility/utilityMaven.cpp +++ b/src/lib_java/utility/utilityMaven.cpp @@ -1,5 +1,6 @@ #include "utility/utilityMaven.h" +#include "utility/file/FilePath.h" #include "utility/text/TextAccess.h" #include "utility/utilityApp.h" #include "utility/utilityString.h" @@ -61,12 +62,12 @@ namespace utility for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements("project", "build", "directory"))) { - uncheckedDirectories.push_back(FilePath(value).concat("generated-sources")); + uncheckedDirectories.push_back(FilePath(value).concat(FilePath("generated-sources"))); } for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements("projects", "project", "build", "directory"))) { - uncheckedDirectories.push_back(FilePath(value).concat("generated-sources")); + uncheckedDirectories.push_back(FilePath(value).concat(FilePath("generated-sources"))); } if (addTestDirectories) @@ -82,12 +83,12 @@ namespace utility for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements("project", "build", "directory"))) { - uncheckedDirectories.push_back(FilePath(value).concat("generated-test-sources")); + uncheckedDirectories.push_back(FilePath(value).concat(FilePath("generated-test-sources"))); } for (std::string value: utility::getValuesOfAllXmlElementsOnPath(xmlAccess, utility::createVectorFromElements("projects", "project", "build", "directory"))) { - uncheckedDirectories.push_back(FilePath(value).concat("generated-test-sources")); + uncheckedDirectories.push_back(FilePath(value).concat(FilePath("generated-test-sources"))); } } diff --git a/src/lib_java/utility/utilityMaven.h b/src/lib_java/utility/utilityMaven.h index 497aef06..feddc1f1 100644 --- a/src/lib_java/utility/utilityMaven.h +++ b/src/lib_java/utility/utilityMaven.h @@ -1,7 +1,9 @@ #ifndef UTILITY_MAVEN_H #define UTILITY_MAVEN_H -#include "utility/file/FilePath.h" +#include + +class FilePath; namespace utility { diff --git a/src/test/ConfigManagerTestSuite.h b/src/test/ConfigManagerTestSuite.h index 0cc7939b..f659b0ff 100644 --- a/src/test/ConfigManagerTestSuite.h +++ b/src/test/ConfigManagerTestSuite.h @@ -116,7 +116,7 @@ public: { std::shared_ptr config = ConfigManager::createAndLoad(getConfigTextAccess()); config->save("data/temp.xml"); - std::shared_ptr config2 = ConfigManager::createAndLoad(TextAccess::createFromFile("data/temp.xml")); + std::shared_ptr config2 = ConfigManager::createAndLoad(TextAccess::createFromFile(FilePath("data/temp.xml"))); TS_ASSERT_EQUALS(config->toString(), config2->toString()); } diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index 200f9ea9..065bcc52 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -3319,7 +3319,7 @@ public: void test_cxx_parser_parses_multiple_files() { std::set indexedPaths; - indexedPaths.insert("data/CxxParserTestSuite/"); + indexedPaths.insert(FilePath("data/CxxParserTestSuite/")); std::shared_ptr indexerCommand = std::make_shared( FilePath("data/CxxParserTestSuite/code.cpp"), diff --git a/src/test/FileManagerTestSuite.h b/src/test/FileManagerTestSuite.h index f53a402f..78b6ce70 100644 --- a/src/test/FileManagerTestSuite.h +++ b/src/test/FileManagerTestSuite.h @@ -8,8 +8,8 @@ public: void test_file_manager_has_added_file_paths_after_first_fetch() { std::vector sourcePaths; - sourcePaths.push_back("./data/FileManagerTestSuite/src/"); - sourcePaths.push_back("./data/FileManagerTestSuite/include/"); + sourcePaths.push_back(FilePath("./data/FileManagerTestSuite/src/")); + sourcePaths.push_back(FilePath("./data/FileManagerTestSuite/include/")); std::vector headerPaths; std::vector excludePaths; std::vector sourceExtensions; diff --git a/src/test/FilePathTestSuite.h b/src/test/FilePathTestSuite.h index 24c4b59d..960b73d4 100644 --- a/src/test/FilePathTestSuite.h +++ b/src/test/FilePathTestSuite.h @@ -124,7 +124,7 @@ public: { FilePath path("data/FilePathTestSuite/a.h"); - TS_ASSERT_EQUALS(path.withoutExtension(), "data/FilePathTestSuite/a"); + TS_ASSERT_EQUALS(path.withoutExtension(), FilePath("data/FilePathTestSuite/a")); } void test_file_path_has_extension() diff --git a/src/test/FileSystemTestSuite.h b/src/test/FileSystemTestSuite.h index 8fbca866..0e06d85a 100644 --- a/src/test/FileSystemTestSuite.h +++ b/src/test/FileSystemTestSuite.h @@ -16,7 +16,7 @@ public: extensions.push_back(".cpp"); std::vector cppFiles = - FileSystem::getFileNamesFromDirectory("data/FileSystemTestSuite", extensions); + FileSystem::getFileNamesFromDirectory(FilePath("data/FileSystemTestSuite"), extensions); TS_ASSERT_EQUALS(cppFiles.size(), 4); TS_ASSERT(isInVector(cppFiles, "data/FileSystemTestSuite/main.cpp")); @@ -31,7 +31,7 @@ public: extensions.push_back(".h"); std::vector headerFiles = - FileSystem::getFileNamesFromDirectory("data/FileSystemTestSuite", extensions); + FileSystem::getFileNamesFromDirectory(FilePath("data/FileSystemTestSuite"), extensions); TS_ASSERT_EQUALS(headerFiles.size(), 3); TS_ASSERT(isInVector(headerFiles, "data/FileSystemTestSuite/tictactoe.h")); @@ -47,7 +47,7 @@ public: extensions.push_back(".cpp"); std::vector sourceFiles = - FileSystem::getFileNamesFromDirectory("data/FileSystemTestSuite", extensions); + FileSystem::getFileNamesFromDirectory(FilePath("data/FileSystemTestSuite"), extensions); TS_ASSERT_EQUALS(sourceFiles.size(), 8); } @@ -105,14 +105,14 @@ public: void test_filesystem_finds_existing_files() { - TS_ASSERT(FileSystem::exists("data/FileSystemTestSuite")); - TS_ASSERT(FileSystem::exists("data/FileSystemTestSuite/tictactoe.h")); + TS_ASSERT(FileSystem::exists(FilePath("data/FileSystemTestSuite"))); + TS_ASSERT(FileSystem::exists(FilePath("data/FileSystemTestSuite/tictactoe.h"))); } void test_filesystem_does_not_find_non_existing_files() { - TS_ASSERT(!FileSystem::exists("data/FileSystemTestSuite/foo")); - TS_ASSERT(!FileSystem::exists("data/FileSystemTestSuite/blabla.h")); + TS_ASSERT(!FileSystem::exists(FilePath("data/FileSystemTestSuite/foo"))); + TS_ASSERT(!FileSystem::exists(FilePath("data/FileSystemTestSuite/blabla.h"))); } void test_filesystem_extracts_filename() diff --git a/src/test/JavaParserTestSuite.h b/src/test/JavaParserTestSuite.h index 4f6ad8dc..0ff3a341 100644 --- a/src/test/JavaParserTestSuite.h +++ b/src/test/JavaParserTestSuite.h @@ -842,7 +842,7 @@ private: setupJavaEnvironmentFactory(); JavaParser parser(parserClient, nullptr); - parser.buildIndex("input.cc", textAccess); + parser.buildIndex(FilePath("input.cc"), textAccess); return parserClient; } diff --git a/src/test/SettingsTestSuite.h b/src/test/SettingsTestSuite.h index a9913fc6..59df5ee1 100644 --- a/src/test/SettingsTestSuite.h +++ b/src/test/SettingsTestSuite.h @@ -10,19 +10,19 @@ public: void test_settings_get_loaded_from_file() { TestSettings settings; - TS_ASSERT(settings.load("data/SettingsTestSuite/settings.xml")); + TS_ASSERT(settings.load(FilePath("data/SettingsTestSuite/settings.xml"))); } void test_settings_get_not_loaded_from_file() { TestSettings settings; - TS_ASSERT(!settings.load("data/SettingsTestSuite/wrong_settings.xml")); + TS_ASSERT(!settings.load(FilePath("data/SettingsTestSuite/wrong_settings.xml"))); } void test_settings_get_loaded_value() { TestSettings settings; - TS_ASSERT(settings.load("data/SettingsTestSuite/settings.xml")); + TS_ASSERT(settings.load(FilePath("data/SettingsTestSuite/settings.xml"))); TS_ASSERT_EQUALS(settings.getBool(), true); TS_ASSERT_EQUALS(settings.getInt(), 42); @@ -42,7 +42,7 @@ public: void test_settings_get_default_value_when_wrongly_loaded() { TestSettings settings; - TS_ASSERT(!settings.load("data/SettingsTestSuite/wrong_settings.xml")); + TS_ASSERT(!settings.load(FilePath("data/SettingsTestSuite/wrong_settings.xml"))); TS_ASSERT_EQUALS(settings.getBool(), false); TS_ASSERT_EQUALS(settings.getInt(), -1); @@ -53,7 +53,7 @@ public: void test_settings_get_default_value_after_clearing() { TestSettings settings; - TS_ASSERT(settings.load("data/SettingsTestSuite/settings.xml")); + TS_ASSERT(settings.load(FilePath("data/SettingsTestSuite/settings.xml"))); settings.clear(); TS_ASSERT_EQUALS(settings.getBool(), false); @@ -82,7 +82,7 @@ public: void test_settings_can_be_replaced_when_loaded() { TestSettings settings; - TS_ASSERT(settings.load("data/SettingsTestSuite/settings.xml")); + TS_ASSERT(settings.load(FilePath("data/SettingsTestSuite/settings.xml"))); TS_ASSERT(settings.setBool(false)); TS_ASSERT_EQUALS(settings.getBool(), false); @@ -100,7 +100,7 @@ public: void test_settings_can_be_added_when_loaded() { TestSettings settings; - TS_ASSERT(settings.load("data/SettingsTestSuite/settings.xml")); + TS_ASSERT(settings.load(FilePath("data/SettingsTestSuite/settings.xml"))); TS_ASSERT_EQUALS(settings.getNewBool(), false); TS_ASSERT(settings.setNewBool(true)); diff --git a/src/test/SourceLocationCollectionTestSuite.h b/src/test/SourceLocationCollectionTestSuite.h index d133fd49..890524a1 100644 --- a/src/test/SourceLocationCollectionTestSuite.h +++ b/src/test/SourceLocationCollectionTestSuite.h @@ -10,7 +10,7 @@ public: void test_source_locations_get_created_with_other_end() { SourceLocationCollection collection; - const SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, "file.c", 2, 3, 4, 5); + const SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, FilePath("file.c"), 2, 3, 4, 5); TS_ASSERT(a); TS_ASSERT(a->isStartLocation()); @@ -32,8 +32,8 @@ public: void test_source_locations_do_not_get_created_with_wrong_input() { SourceLocationCollection collection; - SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, "file.c", 2, 3, 2, 1); - SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {1}, "file.c", 4, 1, 1, 10); + SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, FilePath("file.c"), 2, 3, 2, 1); + SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {1}, FilePath("file.c"), 4, 1, 1, 10); TS_ASSERT(!a); TS_ASSERT(!b); @@ -42,9 +42,9 @@ public: void test_source_locations_get_unique_id_but_both_ends_have_the_same() { SourceLocationCollection collection; - SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, "file.c", 1, 1, 1, 1); - SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {2}, "file.c", 1, 1, 1, 1); - SourceLocation* c = collection.addSourceLocation(LOCATION_TOKEN, 3, {3}, "file.c", 1, 1, 1, 1); + SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, FilePath("file.c"), 1, 1, 1, 1); + SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {2}, FilePath("file.c"), 1, 1, 1, 1); + SourceLocation* c = collection.addSourceLocation(LOCATION_TOKEN, 3, {3}, FilePath("file.c"), 1, 1, 1, 1); TS_ASSERT_EQUALS(1, collection.getSourceLocationFileCount()); TS_ASSERT_EQUALS(3, collection.getSourceLocationCount()); @@ -65,7 +65,7 @@ public: void test_source_locations_have_right_file_path_line_column_and_token_id() { SourceLocationCollection collection; - SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, "file.c", 2, 3, 4, 5); + SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, FilePath("file.c"), 2, 3, 4, 5); TS_ASSERT_EQUALS(1, a->getTokenIds()[0]); TS_ASSERT_EQUALS(2, a->getLineNumber()); @@ -78,8 +78,8 @@ public: void test_finding_source_locations_by_id() { SourceLocationCollection collection; - SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, "file.c", 2, 3, 4, 5); - SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {6}, "file.c", 7, 8, 9, 10); + SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, FilePath("file.c"), 2, 3, 4, 5); + SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {6}, FilePath("file.c"), 7, 8, 9, 10); TS_ASSERT_EQUALS(a, collection.getSourceLocationById(a->getLocationId())); TS_ASSERT_EQUALS(b, collection.getSourceLocationById(b->getLocationId())); @@ -88,10 +88,10 @@ public: void test_creating_plain_copy_of_all_locations_in_line_range() { SourceLocationCollection collection; - SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, "file.c", 2, 3, 4, 5); - SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {1}, "file.c", 3, 3, 4, 5); - SourceLocation* c = collection.addSourceLocation(LOCATION_TOKEN, 3, {1}, "file.c", 1, 3, 5, 5); - SourceLocation* d = collection.addSourceLocation(LOCATION_TOKEN, 4, {1}, "file.c", 1, 5, 4, 5); + SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, FilePath("file.c"), 2, 3, 4, 5); + SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {1}, FilePath("file.c"), 3, 3, 4, 5); + SourceLocation* c = collection.addSourceLocation(LOCATION_TOKEN, 3, {1}, FilePath("file.c"), 1, 3, 5, 5); + SourceLocation* d = collection.addSourceLocation(LOCATION_TOKEN, 4, {1}, FilePath("file.c"), 1, 5, 4, 5); Id ida = a->getLocationId(); Id idb = b->getLocationId(); @@ -135,13 +135,13 @@ public: void test_get_source_locations_filtered_by_lines() { SourceLocationCollection collection; - SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, "file.c", 1, 3, 1, 5); - SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {1}, "file.c", 1, 3, 2, 5); - SourceLocation* c = collection.addSourceLocation(LOCATION_TOKEN, 3, {1}, "file.c", 2, 3, 2, 5); - SourceLocation* d = collection.addSourceLocation(LOCATION_TOKEN, 4, {1}, "file.c", 3, 3, 4, 5); - SourceLocation* e = collection.addSourceLocation(LOCATION_TOKEN, 5, {1}, "file.c", 3, 5, 5, 5); - SourceLocation* f = collection.addSourceLocation(LOCATION_TOKEN, 6, {1}, "file.c", 1, 5, 5, 5); - SourceLocation* g = collection.addSourceLocation(LOCATION_TOKEN, 7, {1}, "file.c", 5, 5, 5, 5); + SourceLocation* a = collection.addSourceLocation(LOCATION_TOKEN, 1, {1}, FilePath("file.c"), 1, 3, 1, 5); + SourceLocation* b = collection.addSourceLocation(LOCATION_TOKEN, 2, {1}, FilePath("file.c"), 1, 3, 2, 5); + SourceLocation* c = collection.addSourceLocation(LOCATION_TOKEN, 3, {1}, FilePath("file.c"), 2, 3, 2, 5); + SourceLocation* d = collection.addSourceLocation(LOCATION_TOKEN, 4, {1}, FilePath("file.c"), 3, 3, 4, 5); + SourceLocation* e = collection.addSourceLocation(LOCATION_TOKEN, 5, {1}, FilePath("file.c"), 3, 5, 5, 5); + SourceLocation* f = collection.addSourceLocation(LOCATION_TOKEN, 6, {1}, FilePath("file.c"), 1, 5, 5, 5); + SourceLocation* g = collection.addSourceLocation(LOCATION_TOKEN, 7, {1}, FilePath("file.c"), 5, 5, 5, 5); SourceLocationCollection copy; copy.addSourceLocationFile( diff --git a/src/test/SqliteBookmarkStorageTestSuite.h b/src/test/SqliteBookmarkStorageTestSuite.h index 8a881642..2c552de7 100644 --- a/src/test/SqliteBookmarkStorageTestSuite.h +++ b/src/test/SqliteBookmarkStorageTestSuite.h @@ -11,11 +11,11 @@ class SqliteBookmarkStorageTestSuite: public CxxTest::TestSuite public: void test_add_bookmarks() { - std::string databasePath = "data/SQLiteTestSuite/bookmarkTest.sqlite"; + FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite"); int bookmarkCount = 4; int result = -1; { - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); SqliteBookmarkStorage storage(databasePath); storage.setup(); @@ -28,18 +28,18 @@ public: result = storage.getAllBookmarks().size(); } - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); TS_ASSERT_EQUALS(result, bookmarkCount); } void test_add_bookmarked_node() { - std::string databasePath = "data/SQLiteTestSuite/bookmarkTest.sqlite"; + FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite"); int bookmarkCount = 4; int result = -1; { - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); SqliteBookmarkStorage storage(databasePath); storage.setup(); @@ -54,18 +54,18 @@ public: result = storage.getAllBookmarkedNodes().size(); } - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); TS_ASSERT_EQUALS(result, bookmarkCount); } void test_remove_bookmark_also_removes_bookmarked_node() { - std::string databasePath = "data/SQLiteTestSuite/bookmarkTest.sqlite"; + FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite"); int bookmarkCount = 4; int result = -1; { - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); SqliteBookmarkStorage storage(databasePath); storage.setup(); @@ -78,21 +78,21 @@ public: result = storage.getAllBookmarkedNodes().size(); } - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); TS_ASSERT_EQUALS(result, 0); } void test_edit_nodeBookmark() { - std::string databasePath = "data/SQLiteTestSuite/bookmarkTest.sqlite"; + FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite"); const std::string updatedName = "updated name"; const std::string updatedComment = "updated comment"; StorageBookmark storageBookmark; { - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); SqliteBookmarkStorage storage(databasePath); storage.setup(); @@ -105,6 +105,8 @@ public: storageBookmark = storage.getAllBookmarks().front(); } + boost::filesystem::remove(databasePath.path()); + TS_ASSERT_EQUALS(updatedName, storageBookmark.name); TS_ASSERT_EQUALS(updatedComment, storageBookmark.comment); } diff --git a/src/test/SqliteIndexStorageTestSuite.h b/src/test/SqliteIndexStorageTestSuite.h index db37b165..c407ccf5 100644 --- a/src/test/SqliteIndexStorageTestSuite.h +++ b/src/test/SqliteIndexStorageTestSuite.h @@ -10,7 +10,7 @@ class SqliteIndexStorageTestSuite: public CxxTest::TestSuite public: void test_storage_adds_node_successfully() { - std::string databasePath = "data/SQLiteTestSuite/test.sqlite"; + FilePath databasePath("data/SQLiteTestSuite/test.sqlite"); int nodeCount = -1; { SqliteIndexStorage storage(databasePath); @@ -20,14 +20,14 @@ public: storage.commitTransaction(); nodeCount = storage.getNodeCount(); } - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); TS_ASSERT_EQUALS(1, nodeCount); } void test_storage_removes_node_successfully() { - std::string databasePath = "data/SQLiteTestSuite/test.sqlite"; + FilePath databasePath("data/SQLiteTestSuite/test.sqlite"); int nodeCount = -1; { SqliteIndexStorage storage(databasePath); @@ -38,14 +38,14 @@ public: storage.commitTransaction(); nodeCount = storage.getNodeCount(); } - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); TS_ASSERT_EQUALS(0, nodeCount); } void test_storage_adds_edge_successfully() { - std::string databasePath = "data/SQLiteTestSuite/test.sqlite"; + FilePath databasePath("data/SQLiteTestSuite/test.sqlite"); int edgeCount = -1; { SqliteIndexStorage storage(databasePath); @@ -57,14 +57,14 @@ public: storage.commitTransaction(); edgeCount = storage.getEdgeCount(); } - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); TS_ASSERT_EQUALS(1, edgeCount); } void test_storage_removes_edge_successfully() { - std::string databasePath = "data/SQLiteTestSuite/test.sqlite"; + FilePath databasePath("data/SQLiteTestSuite/test.sqlite"); int edgeCount = -1; { SqliteIndexStorage storage(databasePath); @@ -77,7 +77,7 @@ public: storage.commitTransaction(); edgeCount = storage.getEdgeCount(); } - boost::filesystem::remove(databasePath); + boost::filesystem::remove(databasePath.path()); TS_ASSERT_EQUALS(0, edgeCount); } diff --git a/src/test/StorageTestSuite.h b/src/test/StorageTestSuite.h index 1063e9b3..5a75205f 100644 --- a/src/test/StorageTestSuite.h +++ b/src/test/StorageTestSuite.h @@ -13,7 +13,7 @@ class StorageTestSuite: public CxxTest::TestSuite public: void setUp() { - m_filePath = "file.cpp"; + m_filePath = FilePath("file.cpp"); } void test_storage_saves_file() @@ -232,7 +232,7 @@ private: { public: TestStorage() - : PersistentStorage("data/test.sqlite", "data/testBookmarks.sqlite") + : PersistentStorage(FilePath("data/test.sqlite"), FilePath("data/testBookmarks.sqlite")) { clear(); } @@ -279,5 +279,5 @@ private: return nameHierarchy; } - std::string m_filePath; + FilePath m_filePath; }; diff --git a/src/test/TextAccessTestSuite.h b/src/test/TextAccessTestSuite.h index 1e9eb539..6829baaf 100644 --- a/src/test/TextAccessTestSuite.h +++ b/src/test/TextAccessTestSuite.h @@ -87,7 +87,7 @@ public: void test_textAccessFile_constructor() { - std::string filePath = "data/TextAccessTestSuite/text.txt"; + FilePath filePath("data/TextAccessTestSuite/text.txt"); std::shared_ptr textAccess = TextAccess::createFromFile(filePath); @@ -96,7 +96,7 @@ public: void test_textAccessFile_lines_count() { - std::string filePath = "data/TextAccessTestSuite/text.txt"; + FilePath filePath("data/TextAccessTestSuite/text.txt"); unsigned int lineCount = 7; std::shared_ptr textAccess = TextAccess::createFromFile(filePath); @@ -106,7 +106,7 @@ public: void test_textAccessFile_lines_content() { - std::string filePath = "data/TextAccessTestSuite/text.txt"; + FilePath filePath("data/TextAccessTestSuite/text.txt"); std::shared_ptr textAccess = TextAccess::createFromFile(filePath); std::vector lines = textAccess->getLines(1, 4); @@ -120,7 +120,7 @@ public: void test_textAccessFile_get_filePath() { - std::string filePath = "data/TextAccessTestSuite/text.txt"; + FilePath filePath("data/TextAccessTestSuite/text.txt"); std::shared_ptr textAccess = TextAccess::createFromFile(filePath); TS_ASSERT_EQUALS(textAccess->getFilePath(), filePath);