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
This commit is contained in:
malte_langkabel
2017-05-04 10:55:16 +02:00
parent 55d3f9c189
commit 054b8fab17
156 changed files with 656 additions and 444 deletions
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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<ApplicationSettings> settings = ApplicationSettings::getInstance();
settings->load(FilePath(UserPaths::getAppSettingsPath()));
settings->load(UserPaths::getAppSettingsPath());
LogManager::getInstance()->setLoggingEnabled(settings->getLoggingEnabled());
+2 -1
View File
@@ -3,8 +3,9 @@
#include <mutex>
#include <set>
#include <vector>
#include "utility/file/FilePath.h"
class FilePath;
class ApplicationStateMonitor
{
@@ -2,6 +2,7 @@
#include <memory>
#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<SourceLocationFile> file =
m_storageAccess->getSourceLocationsForFile(message->filePath.str());
m_storageAccess->getSourceLocationsForFile(message->filePath);
SourceLocationFile* activeLocations = m_collection->getSourceLocationFileByPath(message->filePath).get();
if (activeLocations)
@@ -4,6 +4,7 @@
#include <map>
#include <string>
#include "utility/file/FilePath.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageActivateAll.h"
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
@@ -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> sourceLocationFile = m_storageAccess->getSourceLocationsForLinesInFile(
message.fileLocation, message.row, message.row
FilePath(message.fileLocation), message.row, message.row
);
std::vector<Id> 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
+1 -1
View File
@@ -4,12 +4,12 @@
#include <memory>
#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
+2
View File
@@ -1,6 +1,8 @@
#ifndef ERROR_VIEW_H
#define ERROR_VIEW_H
#include <vector>
#include "component/view/View.h"
#include "data/ErrorInfo.h"
+6 -6
View File
@@ -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;
+3 -3
View File
@@ -48,15 +48,15 @@ void IntermediateStorage::setAllFilesIncomplete()
void IntermediateStorage::setFilesWithErrorsIncomplete()
{
std::set<FilePath> errorFiles;
std::set<std::string> 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;
}
+5 -3
View File
@@ -4,6 +4,8 @@
#include <queue>
#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<SourceLocationCollection> PersistentStorage::getSourceLocationsF
for (const StorageFile& file : m_sqliteIndexStorage.getAllByIds<StorageFile>(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<SourceLocationFile> PersistentStorage::getSourceLocationsForFile
}
std::shared_ptr<SourceLocationFile> 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())
{
+1 -3
View File
@@ -4,8 +4,6 @@
#include <memory>
#include <vector>
#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<SourceLocationFile> getSourceLocationsForFile(const FilePath& filePath) const;
virtual std::shared_ptr<SourceLocationFile> getSourceLocationsForLinesInFile(
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
const FilePath& filePath, uint firstLineNumber, uint lastLineNumber
) const;
virtual std::shared_ptr<SourceLocationFile> getCommentLocationsInFile(const FilePath& filePath) const;
-1
View File
@@ -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
+3 -3
View File
@@ -74,7 +74,7 @@ void SqliteIndexStorage::addFile(const int id, const std::string& filePath, cons
return;
}
std::shared_ptr<TextAccess> content = TextAccess::createFromFile(filePath);
std::shared_ptr<TextAccess> content = TextAccess::createFromFile(FilePath(filePath));
const size_t lineCount = content->getLineCount();
const bool success = executeStatement(
@@ -589,7 +589,7 @@ std::shared_ptr<TextAccess> 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<StorageError> SqliteIndexStorage::doGetAll<StorageError>(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++;
}
+2 -3
View File
@@ -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;
+1
View File
@@ -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"
+1 -1
View File
@@ -3,11 +3,11 @@
#include <vector>
#include "utility/file/FilePath.h"
#include "utility/scheduling/Task.h"
#include "utility/TimePoint.h"
class DialogView;
class FilePath;
class PersistentStorage;
class TaskCleanStorage
-1
View File
@@ -3,7 +3,6 @@
#include <vector>
#include "utility/file/FilePath.h"
#include "utility/scheduling/Task.h"
class DialogView;
+3 -3
View File
@@ -6,8 +6,6 @@
#include <vector>
#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<Id>& locationIds) const = 0;
virtual std::shared_ptr<SourceLocationFile> getSourceLocationsForFile(const FilePath& filePath) const = 0;
virtual std::shared_ptr<SourceLocationFile> getSourceLocationsForLinesInFile(
const std::string& filePath, uint firstLineNumber, uint lastLineNumber) const = 0;
const FilePath& filePath, uint firstLineNumber, uint lastLineNumber) const = 0;
virtual std::shared_ptr<SourceLocationFile> getCommentLocationsInFile(const FilePath& filePath) const = 0;
+6 -5
View File
@@ -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<SourceLocationFile> StorageAccessProxy::getSourceLocationsForFil
return m_subject->getSourceLocationsForFile(filePath);
}
return std::make_shared<SourceLocationFile>("", false, false);
return std::make_shared<SourceLocationFile>(FilePath(), false, false);
}
std::shared_ptr<SourceLocationFile> 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<SourceLocationFile> StorageAccessProxy::getSourceLocationsForLin
return m_subject->getSourceLocationsForLinesInFile(filePath, firstLineNumber, lastLineNumber);
}
return std::make_shared<SourceLocationFile>("", false, false);
return std::make_shared<SourceLocationFile>(FilePath(), false, false);
}
std::shared_ptr<SourceLocationFile> StorageAccessProxy::getCommentLocationsInFile(const FilePath& filePath) const
@@ -246,7 +247,7 @@ std::shared_ptr<SourceLocationFile> StorageAccessProxy::getCommentLocationsInFil
return m_subject->getCommentLocationsInFile(filePath);
}
return std::make_shared<SourceLocationFile>("", false, false);
return std::make_shared<SourceLocationFile>(FilePath(), false, false);
}
std::shared_ptr<TextAccess> StorageAccessProxy::getFileContent(const FilePath& filePath) const
+1 -1
View File
@@ -51,7 +51,7 @@ public:
) const;
virtual std::shared_ptr<SourceLocationFile> getSourceLocationsForFile(const FilePath& filePath) const;
virtual std::shared_ptr<SourceLocationFile> getSourceLocationsForLinesInFile(
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
const FilePath& filePath, uint firstLineNumber, uint lastLineNumber
) const;
virtual std::shared_ptr<SourceLocationFile> getCommentLocationsInFile(const FilePath& filePath) const;
@@ -2,6 +2,7 @@
#define SOURCE_LOCATION_FILE_H
#include <map>
#include <memory>
#include <ostream>
#include <set>
-2
View File
@@ -5,8 +5,6 @@
#include <string>
#include <vector>
#include "utility/file/FilePath.h"
class ParserClient;
class TextAccess;
+2 -2
View File
@@ -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<FilePath>& filesToClean, bool fullRefres
m_storage->clear();
}
m_storage->setProjectSettingsText(TextAccess::createFromFile(getProjectSettingsFilePath().str())->getText());
m_storage->setProjectSettingsText(TextAccess::createFromFile(getProjectSettingsFilePath())->getText());
std::shared_ptr<TaskGroupSequence> taskSequential = std::make_shared<TaskGroupSequence>();
+2
View File
@@ -1,5 +1,7 @@
#include "project/SourceGroup.h"
#include "utility/file/FilePath.h"
SourceGroup::~SourceGroup()
{
}
+1 -1
View File
@@ -5,10 +5,10 @@
#include <set>
#include <vector>
#include "utility/file/FilePath.h"
#include "settings/LanguageType.h"
#include "settings/SourceGroupType.h"
class FilePath;
class IndexerCommand;
class SourceGroup
+6 -6
View File
@@ -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<std::string>("application/color_scheme", defaultPath.str()));
if (path != defaultPath && !path.exists())
@@ -276,14 +276,14 @@ void ApplicationSettings::setJavaMaximumMemory(int size)
setValue<int>("indexing/java/java_maximum_memory", size);
}
std::string ApplicationSettings::getMavenPath() const
FilePath ApplicationSettings::getMavenPath() const
{
return getValue<std::string>("indexing/java/maven_path", "");
return FilePath(getValue<std::string>("indexing/java/maven_path", ""));
}
void ApplicationSettings::setMavenPath(const std::string path)
void ApplicationSettings::setMavenPath(const FilePath& path)
{
setValue<std::string>("indexing/java/maven_path", path);
setValue<std::string>("indexing/java/maven_path", path.str());
}
std::vector<FilePath> ApplicationSettings::getHeaderSearchPaths() const
@@ -369,7 +369,7 @@ std::vector<FilePath> ApplicationSettings::getRecentProjects() const
}
else
{
recentProjects.push_back(UserPaths::getSampleProjectsPath() + project.str());
recentProjects.push_back(UserPaths::getSampleProjectsPath().concat(project));
}
}
return recentProjects;
+2 -2
View File
@@ -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<FilePath> getHeaderSearchPaths() const;
std::vector<FilePath> getHeaderSearchPathsExpanded() const;
+1 -1
View File
@@ -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;
}
+7
View File
@@ -14,11 +14,16 @@ public:
private:
std::function<ValType(KeyType)> m_calculator;
std::unordered_map<KeyType, ValType, Hasher> m_map;
size_t m_hitCount;
size_t m_missCount;
};
template <typename KeyType, typename ValType, typename Hasher>
Cache<KeyType, ValType, Hasher>::Cache(std::function<ValType(KeyType)> calculator)
: m_calculator(calculator)
, m_hitCount(0)
, m_missCount(0)
{
}
@@ -28,8 +33,10 @@ ValType Cache<KeyType, ValType, Hasher>::getValue(KeyType key)
typename std::unordered_map<KeyType, ValType>::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;
+10 -10
View File
@@ -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/");
}
+7 -5
View File
@@ -3,14 +3,16 @@
#include <string>
#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
+13 -13
View File
@@ -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/"));
}
+11 -9
View File
@@ -3,22 +3,24 @@
#include <string>
#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
@@ -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 = 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();
}
}
+59 -17
View File
@@ -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> FilePath::expandEnvironmentVariables() const
@@ -132,7 +174,7 @@ std::vector<FilePath> 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> 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
+8 -3
View File
@@ -2,6 +2,7 @@
#define FILE_PATH_H
#include <string>
#include <vector>
#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
+4 -1
View File
@@ -1,11 +1,14 @@
#include "utility/file/FileRegister.h"
#include "utility/file/FilePath.h"
FileRegister::FileRegister(const FileRegisterStateData& stateData, const std::set<FilePath>& indexedPaths, const std::set<FilePath>& 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)
{
@@ -1,5 +1,7 @@
#include "utility/file/FileRegisterStateData.h"
#include "utility/file/FilePath.h"
FileRegisterStateData::FileRegisterStateData()
{
}
+6 -16
View File
@@ -6,14 +6,14 @@
#include "boost/filesystem.hpp"
std::vector<std::string> FileSystem::getFileNamesFromDirectory(
const std::string& path, const std::vector<std::string>& extensions
const FilePath& path, const std::vector<std::string>& extensions
){
std::set<std::string> ext(extensions.begin(), extensions.end());
std::vector<std::string> 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<std::string> FileSystem::getFileNamesFromDirectory(
return files;
}
FileInfo FileSystem::getFileInfoForPath(FilePath filePath)
FileInfo FileSystem::getFileInfoForPath(const FilePath& filePath)
{
if (filePath.exists())
{
@@ -110,7 +110,7 @@ std::vector<FileInfo> 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<FileInfo> 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;
}
+2 -4
View File
@@ -11,9 +11,9 @@ class FileSystem
{
public:
static std::vector<std::string> getFileNamesFromDirectory(
const std::string& path, const std::vector<std::string>& extensions);
const FilePath& path, const std::vector<std::string>& extensions);
static FileInfo getFileInfoForPath(FilePath filePath);
static FileInfo getFileInfoForPath(const FilePath& filePath);
static std::vector<FileInfo> getFileInfosFromPaths(
const std::vector<FilePath>& paths, const std::vector<std::string>& 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
@@ -19,7 +19,7 @@ std::shared_ptr<SharedUUIDManager> SharedUUIDManager::getInstance()
// m_instance = std::make_shared<SharedUUIDManager>();
SharedUUIDManager* sharedUUIDManager = new SharedUUIDManager();
m_instance = std::shared_ptr<SharedUUIDManager>(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)));
}
}
+3 -3
View File
@@ -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 << " | ";
+3 -2
View File
@@ -3,6 +3,7 @@
#include <string>
#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;
+5 -5
View File
@@ -4,7 +4,7 @@
#include "utility/logging/logging.h"
std::shared_ptr<TextAccess> TextAccess::createFromFile(const std::string& filePath)
std::shared_ptr<TextAccess> TextAccess::createFromFile(const FilePath& filePath)
{
std::shared_ptr<TextAccess> 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<std::string> TextAccess::readFile(const std::string& filePath)
std::vector<std::string> TextAccess::readFile(const FilePath& filePath)
{
std::vector<std::string> 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;
}
+6 -4
View File
@@ -5,17 +5,19 @@
#include <string>
#include <vector>
#include "utility/file/FilePath.h"
class TextAccess
{
public:
static std::shared_ptr<TextAccess> createFromFile(const std::string& filePath);
static std::shared_ptr<TextAccess> createFromFile(const FilePath& filePath);
static std::shared_ptr<TextAccess> 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<std::string> readFile(const std::string& filePath);
static std::vector<std::string> readFile(const FilePath& filePath);
static std::vector<std::string> 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<std::string> m_lines;
};
-1
View File
@@ -15,7 +15,6 @@
#include "utility/file/FilePath.h"
namespace utility
{
template <typename Ret, typename... Args>
+1
View File
@@ -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
+2 -1
View File
@@ -5,7 +5,8 @@
#include <string>
#include "data/indexer/IndexerCommand.h"
#include "utility/file/FilePath.h"
class FilePath;
class IndexerCommandCxx
: public IndexerCommand
@@ -1,6 +1,5 @@
#include "data/indexer/IndexerCommandCxxManual.h"
std::string IndexerCommandCxxManual::getIndexerKindString()
{
return "CxxManual";
@@ -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
+11 -4
View File
@@ -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<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
explicit ASTAction(
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> 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<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef inFile)
{
return std::unique_ptr<clang::ASTConsumer>(
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<PreprocessorCallbacks>(compiler.getSourceManager(), m_client, m_fileRegister));
llvm::make_unique<PreprocessorCallbacks>(compiler.getSourceManager(), m_client, m_fileRegister, m_canonicalFilePathCache));
preprocessor.addCommentHandler(&m_commentHandler);
return true;
}
@@ -44,6 +50,7 @@ protected:
private:
std::shared_ptr<ParserClient> m_client;
std::shared_ptr<FileRegister> m_fileRegister;
std::shared_ptr<FilePathCache> m_canonicalFilePathCache;
CommentHandler m_commentHandler;
};
@@ -3,10 +3,14 @@
#include "clang/Frontend/FrontendActions.h"
ASTActionFactory::ASTActionFactory(
std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister, bool preprocessorOnly
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> 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<clang::PreprocessOnlyAction>(m_client, m_fileRegister);
return new ASTAction<clang::PreprocessOnlyAction>(m_client, m_fileRegister, m_canonicalFilePathCache);
}
else
{
return new ASTAction<clang::ASTFrontendAction>(m_client, m_fileRegister);
return new ASTAction<clang::ASTFrontendAction>(m_client, m_fileRegister, m_canonicalFilePathCache);
}
}
@@ -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<ParserClient> client, std::shared_ptr<FileRegister> fileRegister, bool preprocessorOnly);
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache,
bool preprocessorOnly
);
virtual ~ASTActionFactory();
virtual clang::FrontendAction* create();
@@ -19,6 +25,7 @@ public:
private:
std::shared_ptr<ParserClient> m_client;
std::shared_ptr<FileRegister> m_fileRegister;
std::shared_ptr<FilePathCache> m_canonicalFilePathCache;
bool m_preprocessorOnly;
};
+9 -3
View File
@@ -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<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
ASTConsumer::ASTConsumer(
clang::ASTContext* context,
clang::Preprocessor* preprocessor,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache
)
{
if (ApplicationSettings::getInstance()->getLoggingEnabled() && ApplicationSettings::getInstance()->getVerboseIndexerLoggingEnabled())
{
m_visitor = std::make_shared<CxxVerboseAstVisitor>(context, preprocessor, client, fileRegister);
m_visitor = std::make_shared<CxxVerboseAstVisitor>(context, preprocessor, client, fileRegister, canonicalFilePathCache);
}
else
{
m_visitor = std::make_shared<CxxAstVisitor>(context, preprocessor, client, fileRegister);
m_visitor = std::make_shared<CxxAstVisitor>(context, preprocessor, client, fileRegister, canonicalFilePathCache);
}
}
+9 -1
View File
@@ -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<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
explicit ASTConsumer(
clang::ASTContext* context,
clang::Preprocessor* preprocessor,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache
);
virtual ~ASTConsumer();
virtual void HandleTranslationUnit(clang::ASTContext& context);
@@ -4,9 +4,14 @@
#include "data/parser/ParserClient.h"
#include "utility/file/FileRegister.h"
CommentHandler::CommentHandler(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
CommentHandler::CommentHandler(
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> 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(),
+9 -1
View File
@@ -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<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
CommentHandler(
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache
);
virtual ~CommentHandler();
virtual bool HandleComment(clang::Preprocessor& preprocessor, clang::SourceRange sourceRange);
@@ -18,6 +25,7 @@ public:
private:
std::shared_ptr<ParserClient> m_client;
std::shared_ptr<FileRegister> m_fileRegister;
std::shared_ptr<FilePathCache> m_canonicalFilePathCache;
};
#endif // COMMENT_HANDLER_H
+31 -17
View File
@@ -17,36 +17,45 @@
#include "data/parser/ParseLocation.h"
CxxAstVisitor::CxxAstVisitor(clang::ASTContext* astContext, clang::Preprocessor* preprocessor, std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
CxxAstVisitor::CxxAstVisitor(
clang::ASTContext* astContext,
clang::Preprocessor* preprocessor,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache
)
: m_astContext(astContext)
, m_preprocessor(preprocessor)
, m_client(client)
, m_fileRegister(fileRegister)
, m_canonicalFilePathCache(canonicalFilePathCache)
{
m_declNameCache = std::make_shared<DeclNameCache>([](const clang::NamedDecl* decl) -> NameHierarchy
{
if (decl)
{
CxxDeclNameResolver resolver;
if (std::shared_ptr<CxxDeclName> declName = resolver.getName(decl))
if (decl)
{
return declName->toNameHierarchy();
CxxDeclNameResolver resolver;
if (std::shared_ptr<CxxDeclName> declName = resolver.getName(decl))
{
return declName->toNameHierarchy();
}
}
return NameHierarchy("global");
}
return NameHierarchy("global");
});
);
m_typeNameCache = std::make_shared<TypeNameCache>([](const clang::Type* type) -> NameHierarchy
{
if (type)
{
CxxTypeNameResolver resolver;
if (std::shared_ptr<CxxTypeName> typeName = resolver.getName(type))
if (type)
{
return typeName->toNameHierarchy();
CxxTypeNameResolver resolver;
if (std::shared_ptr<CxxTypeName> typeName = resolver.getName(type))
{
return typeName->toNameHierarchy();
}
}
return NameHierarchy("global");
}
return NameHierarchy("global");
});
);
m_contextComponent = std::make_shared<CxxAstVisitorComponentContext>(this);
m_components.push_back(m_contextComponent);
@@ -98,6 +107,11 @@ std::shared_ptr<TypeNameCache> CxxAstVisitor::getTypeNameCache()
return m_typeNameCache;
}
std::shared_ptr<FilePathCache> 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(),
+12 -2
View File
@@ -5,13 +5,14 @@
#include <clang/AST/RecursiveASTVisitor.h>
#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<CxxAstVisitor>
{
public:
CxxAstVisitor(clang::ASTContext* astContext, clang::Preprocessor* preprocessor, std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
CxxAstVisitor(
clang::ASTContext* astContext,
clang::Preprocessor* preprocessor,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache
);
virtual ~CxxAstVisitor();
template <typename T>
@@ -42,6 +50,7 @@ public:
std::shared_ptr<DeclNameCache> getDeclNameCache();
std::shared_ptr<TypeNameCache> getTypeNameCache();
std::shared_ptr<FilePathCache> getCanonicalFilePathCache();
// Indexing entry point
void indexDecl(clang::Decl *d);
@@ -139,6 +148,7 @@ private:
clang::Preprocessor* m_preprocessor;
std::shared_ptr<ParserClient> m_client;
std::shared_ptr<FileRegister> m_fileRegister;
std::shared_ptr<FilePathCache> m_canonicalFilePathCache;
MessageInterruptTasksCounter m_interruptCounter;
@@ -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;
}
@@ -12,11 +12,13 @@ CxxDiagnosticConsumer::CxxDiagnosticConsumer(
clang::DiagnosticOptions *diags,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> 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,
@@ -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<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache,
bool useLogging = true
);
@@ -26,6 +29,7 @@ public:
private:
std::shared_ptr<ParserClient> m_client;
std::shared_ptr<FileRegister> m_register;
std::shared_ptr<FilePathCache> m_canonicalFilePathCache;
bool m_isParsingFile;
bool m_useLogging;
+27 -8
View File
@@ -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<IndexerCommandCxxCdb> indexerCommand)
CxxCompilationDatabaseSingle compilationDatabase(compileCommand);
clang::tooling::ClangTool tool(compilationDatabase, std::vector<std::string>(1, indexerCommand->getSourceFilePath().str()));
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(true);
std::shared_ptr<FilePathCache> canonicalFilePathCache = std::make_shared<FilePathCache>([](std::string fileName) -> FilePath
{
return FilePath(fileName).canonical();
}
);
std::shared_ptr<CxxDiagnosticConsumer> 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<IndexerCommandCxxManual> indexerComma
clang::tooling::ClangTool tool(*compilationDatabase, std::vector<std::string>(1, indexerCommand->getSourceFilePath().str()));
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(true);
std::shared_ptr<FilePathCache> canonicalFilePathCache = std::make_shared<FilePathCache>([](std::string fileName) -> FilePath
{
return FilePath(fileName).canonical();
}
);
std::shared_ptr<CxxDiagnosticConsumer> 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<TextAccess> fileContent)
{
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(false);
ASTActionFactory actionFactory(m_client, m_fileRegister, false);
std::shared_ptr<FilePathCache> canonicalFilePathCache = std::make_shared<FilePathCache>([](std::string fileName) -> FilePath
{
return FilePath(fileName).canonical();
}
);
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(canonicalFilePathCache, false);
ASTActionFactory actionFactory(m_client, m_fileRegister, canonicalFilePathCache, false);
std::vector<std::string> args = getCommandlineArgumentsEssential(std::vector<std::string>(1, "-std=c++1z"), std::vector<FilePath>(), std::vector<FilePath>());
@@ -201,9 +220,9 @@ std::shared_ptr<clang::tooling::FixedCompilationDatabase> CxxParser::getCompilat
return compilationDatabase;
}
std::shared_ptr<CxxDiagnosticConsumer> CxxParser::getDiagnostics(bool logErrors) const
std::shared_ptr<CxxDiagnosticConsumer> CxxParser::getDiagnostics(std::shared_ptr<FilePathCache> canonicalFilePathCache, bool logErrors) const
{
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
return std::make_shared<CxxDiagnosticConsumer>(
llvm::errs(), &*options, m_client, m_fileRegister, logErrors);
llvm::errs(), &*options, m_client, m_fileRegister, canonicalFilePathCache, logErrors);
}
+3 -1
View File
@@ -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<std::string> getCommandlineArguments(std::shared_ptr<IndexerCommandCxxManual> indexerCommand) const;
std::shared_ptr<clang::tooling::FixedCompilationDatabase> getCompilationDatabase(std::shared_ptr<IndexerCommandCxxManual> indexerCommand) const;
std::shared_ptr<CxxDiagnosticConsumer> getDiagnostics(bool logErrors) const;
std::shared_ptr<CxxDiagnosticConsumer> getDiagnostics(std::shared_ptr<FilePathCache> canonicalFilePathCache, bool logErrors) const;
friend class TaskParseCxx;
@@ -12,8 +12,14 @@
#include "utility/logging/logging.h"
#include "utility/ScopedSwitcher.h"
CxxVerboseAstVisitor::CxxVerboseAstVisitor(clang::ASTContext* context, clang::Preprocessor* preprocessor, std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
: base(context, preprocessor, client, fileRegister)
CxxVerboseAstVisitor::CxxVerboseAstVisitor(
clang::ASTContext* context,
clang::Preprocessor* preprocessor,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache
)
: base(context, preprocessor, client, fileRegister, canonicalFilePathCache)
, m_currentFilePath("")
, m_indentation(0)
{
@@ -11,7 +11,14 @@ class FileRegister;
class CxxVerboseAstVisitor: public CxxAstVisitor
{
public:
CxxVerboseAstVisitor(clang::ASTContext* context, clang::Preprocessor* preprocessor, std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
CxxVerboseAstVisitor(
clang::ASTContext* context,
clang::Preprocessor* preprocessor,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache
);
virtual ~CxxVerboseAstVisitor();
private:
@@ -11,11 +11,15 @@
#include "data/parser/ParseLocation.h"
PreprocessorCallbacks::PreprocessorCallbacks(
clang::SourceManager& sourceManager, std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister
clang::SourceManager& sourceManager,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> 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(),
@@ -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<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
explicit PreprocessorCallbacks(
clang::SourceManager& sourceManager,
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> 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<ParserClient> m_client;
std::shared_ptr<FileRegister> m_fileRegister;
std::shared_ptr<FilePathCache> m_canonicalFilePathCache;
FilePath m_currentPath;
};
@@ -0,0 +1,11 @@
#ifndef CXX_CACHE_TYPES_H
#define CXX_CACHE_TYPES_H
#include <string>
#include "utility/Cache.h"
class FilePath;
typedef Cache<std::string, FilePath> FilePathCache;
#endif // CXX_CACHE_TYPES_H
+3 -1
View File
@@ -1,8 +1,10 @@
#include "utility/CompilationDatabase.h"
#include <set>
#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)
+1 -1
View File
@@ -3,7 +3,7 @@
#include <vector>
#include "utility/file/FilePath.h"
class FilePath;
namespace utility
{
@@ -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
+1 -1
View File
@@ -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;
}
}
@@ -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());
}
+3 -3
View File
@@ -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")));
}
@@ -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")));
}
}
@@ -3,6 +3,7 @@
#include <QScrollBar>
#include <QVBoxLayout>
#include "utility/file/FilePath.h"
#include "utility/file/FileSystem.h"
#include "data/location/SourceLocationFile.h"
@@ -6,6 +6,7 @@
#include <QScrollBar>
#include <QVBoxLayout>
#include "utility/file/FilePath.h"
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageChangeFileView.h"
#include "utility/ResourcePaths.h"
@@ -6,6 +6,7 @@
#include <QFrame>
#include "utility/file/FilePath.h"
#include "utility/TimePoint.h"
#include "qt/element/QtCodeNavigateable.h"
@@ -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 += "*";
+1 -1
View File
@@ -3,12 +3,12 @@
#include <set>
#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;
+4 -4
View File
@@ -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"
));
@@ -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<FilePath> QtDirectoryListBox::getList()
std::vector<FilePath> list;
for (const std::string& str : strList)
{
list.push_back(str);
list.push_back(FilePath(str));
}
return list;
}
+2 -2
View File
@@ -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)
{
+2 -2
View File
@@ -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()));
+1 -1
View File
@@ -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()));
+1 -1
View File
@@ -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"
));
}
+2 -2
View File
@@ -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"
));
}
+2 -2
View File
@@ -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);
+2 -2
View File
@@ -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"
));
}
+2 -2
View File
@@ -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"
));
}
-2
View File
@@ -6,8 +6,6 @@
#include <QGraphicsView>
#include <QPushButton>
#include "utility/file/FilePath.h"
class QTimer;
class QtGraphNode;
+7 -6
View File
@@ -9,6 +9,7 @@
#include <QPainter>
#include <QWidget>
#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<std::string> 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<std::string> 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 "";
}
+3 -2
View File
@@ -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);
+5 -5
View File
@@ -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> 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"
));
}
+1 -1
View File
@@ -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());
}
+1 -1
View File
@@ -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()
+5 -5
View File
@@ -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"
));
+1 -1
View File
@@ -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();

Some files were not shown because too many files have changed in this diff Show More