src: refactored lib/utility

* removed unused utilityMath
* removed some unused functions from utility
* moved time related utility functions to TimeStamp
* moved path objects from utility to app/paths
* moved objects in lib to lib/app
* removed duplicate confirm methods in DialogView
* moved utilityFile to utility/file
* removed uint typedef and replaced with size_t everywhere
* removed boost header in utilityUuid
This commit is contained in:
Eberhard Graether
2019-07-17 15:10:05 +02:00
parent 70febae55b
commit 8e3ca182b9
92 changed files with 306 additions and 438 deletions
+19 -21
View File
@@ -2,6 +2,20 @@
add_files(
LIB
app/paths/AppPath.cpp
app/paths/AppPath.h
app/paths/ResourcePaths.cpp
app/paths/ResourcePaths.h
app/paths/UserPaths.cpp
app/paths/UserPaths.h
app/Application.cpp
app/Application.h
app/LanguagePackage.h
app/LanguagePackageManager.cpp
app/LanguagePackageManager.h
app/UpdateChecker.h
component/controller/helper/BucketLayouter.cpp
component/controller/helper/BucketLayouter.h
component/controller/helper/DummyEdge.h
@@ -107,10 +121,6 @@ add_files(
component/TabId.cpp
component/TabId.h
data/access/StorageAccess.h
data/access/StorageAccessProxy.cpp
data/access/StorageAccessProxy.h
data/bookmark/Bookmark.cpp
data/bookmark/Bookmark.h
data/bookmark/BookmarkCategory.cpp
@@ -268,6 +278,9 @@ add_files(
data/storage/PersistentStorage.h
data/storage/Storage.cpp
data/storage/Storage.h
data/storage/StorageAccess.h
data/storage/StorageAccessProxy.cpp
data/storage/StorageAccessProxy.h
data/storage/StorageCache.cpp
data/storage/StorageCache.h
data/storage/StorageProvider.cpp
@@ -423,6 +436,8 @@ add_files(
utility/file/FileSystem.h
utility/file/FileTree.cpp
utility/file/FileTree.h
utility/file/utilityFile.cpp
utility/file/utilityFile.h
utility/interprocess/SharedMemory.cpp
utility/interprocess/SharedMemory.h
@@ -619,8 +634,6 @@ add_files(
utility/text/TextAccess.h
utility/ApplicationArchitectureType.h
utility/AppPath.cpp
utility/AppPath.h
utility/ConfigManager.cpp
utility/ConfigManager.h
utility/LowMemoryStringMap.h
@@ -628,8 +641,6 @@ add_files(
utility/OrderedCache.h
utility/OsType.h
utility/Property.h
utility/ResourcePaths.cpp
utility/ResourcePaths.h
utility/ScopedFunctor.cpp
utility/ScopedFunctor.h
utility/ScopedSwitcher.h
@@ -641,26 +652,13 @@ add_files(
utility/Tree.h
utility/types.h
utility/UnorderedCache.h
utility/UserPaths.cpp
utility/UserPaths.h
utility/utility.cpp
utility/utility.h
utility/utilityFile.cpp
utility/utilityFile.h
utility/utilityLibrary.h
utility/utilityMath.cpp
utility/utilityMath.h
utility/utilityUuid.cpp
utility/utilityUuid.h
utility/utilityWindows.cpp
utility/utilityWindows.h
utility/utilityXml.cpp
utility/utilityXml.h
Application.cpp
Application.h
LanguagePackage.h
LanguagePackageManager.cpp
LanguagePackageManager.h
UpdateChecker.h
)
@@ -165,16 +165,6 @@ bool Application::hasGUI()
return m_hasGUI;
}
int Application::handleDialog(const std::string& message)
{
return getDialogView(DialogView::UseCase::GENERAL)->confirm(message);
}
int Application::handleDialog(const std::string& message, const std::vector<std::string>& options)
{
return getDialogView(DialogView::UseCase::GENERAL)->confirm(message, options);
}
int Application::handleDialog(const std::wstring& message)
{
return getDialogView(DialogView::UseCase::GENERAL)->confirm(message);
@@ -53,8 +53,6 @@ public:
bool hasGUI();
int handleDialog(const std::string& message);
int handleDialog(const std::string& message, const std::vector<std::string>& options);
int handleDialog(const std::wstring& message);
int handleDialog(const std::wstring& message, const std::vector<std::wstring>& options);
std::shared_ptr<DialogView> getDialogView(DialogView::UseCase useCase);
@@ -2,19 +2,20 @@
#include <memory>
#include "StorageAccess.h"
#include "SourceLocation.h"
#include "SourceLocationCollection.h"
#include "SourceLocationFile.h"
#include "Application.h"
#include "ApplicationSettings.h"
#include "FileInfo.h"
#include "logging.h"
#include "MessageMoveIDECursor.h"
#include "MessageStatus.h"
#include "StorageAccess.h"
#include "SourceLocation.h"
#include "SourceLocationCollection.h"
#include "SourceLocationFile.h"
#include "TextAccess.h"
#include "tracing.h"
#include "utility.h"
#include "utilityString.h"
#include "Application.h"
CodeController::CodeController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
@@ -26,8 +27,6 @@ Id CodeController::getSchedulerId() const
return Controller::getTabId();
}
const uint CodeController::s_lineRadius = 2;
void CodeController::handleMessage(MessageActivateAll* message)
{
TRACE("code all");
@@ -63,8 +63,6 @@ public:
Id getSchedulerId() const override;
private:
static const uint s_lineRadius;
void handleMessage(MessageActivateAll* message) override;
void handleMessage(MessageActivateErrors* message) override;
void handleMessage(MessageActivateFullTextSearch* message) override;
+1 -1
View File
@@ -1,4 +1,4 @@
#include "component/controller/Controller.h"
#include "Controller.h"
Controller::Controller()
: m_component(nullptr)
@@ -127,8 +127,8 @@ void ErrorController::handleMessage(MessageErrorsForFile* message)
Project* project = Application::getInstance()->getCurrentProject().get();
if (project && project->isIndexing())
{
Application::getInstance()->getDialogView(DialogView::UseCase::GENERAL)->confirm(
"Showing errors for a file is not possible while indexing."
Application::getInstance()->handleDialog(
L"Showing errors for a file is not possible while indexing."
);
return;
}
@@ -244,11 +244,11 @@ void GraphController::handleMessage(MessageActivateTrail* message)
if (graph->getNodeCount() > 1000)
{
int r = Application::getInstance()->handleDialog(
"Warning!\n\nThe resulting depth graph will contain " + std::to_string(graph->getNodeCount()) + " nodes. "
"Layouting and drawing might take a while and the resulting graph diagram could be unclear. Please "
"consider reducing graph depth with the slider on the left.\n\n"
"Do you want to proceed?",
{"Yes", "No"}
L"Warning!\n\nThe resulting depth graph will contain " + std::to_wstring(graph->getNodeCount()) + " nodes. "
L"Layouting and drawing might take a while and the resulting graph diagram could be unclear. Please "
L"consider reducing graph depth with the slider on the left.\n\n"
L"Do you want to proceed?",
{ L"Yes", L"No" }
);
if (r == 1)
@@ -515,9 +515,7 @@ void UndoRedoController::replayCommand(std::list<Command>::iterator it)
Project* project = Application::getInstance()->getCurrentProject().get();
if (project && project->isIndexing())
{
Application::getInstance()->getDialogView(DialogView::UseCase::GENERAL)->confirm(
"Errors cannot be activated while indexing."
);
Application::getInstance()->handleDialog(L"Errors cannot be activated while indexing.");
ErrorFilter filter;
filter.error = false;
-10
View File
@@ -64,16 +64,6 @@ DatabasePolicy DialogView::finishedIndexingDialog(
return DATABASE_POLICY_KEEP; // used in non-gui mode
}
int DialogView::confirm(const std::string& message)
{
return confirm(message, std::vector<std::string>());
}
int DialogView::confirm(const std::string& message, const std::vector<std::string>& options)
{
return -1;
}
int DialogView::confirm(const std::wstring& message)
{
return confirm(message, std::vector<std::wstring>());
-2
View File
@@ -55,8 +55,6 @@ public:
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
float time, ErrorCountInfo errorInfo, bool interrupted);
int confirm(const std::string& message);
virtual int confirm(const std::string& message, const std::vector<std::string>& options);
int confirm(const std::wstring& message);
virtual int confirm(const std::wstring& message, const std::vector<std::wstring>& options);
@@ -16,8 +16,8 @@ struct CodeSnippetParams
static bool sort(const CodeSnippetParams& a, const CodeSnippetParams& b);
static bool sortById(const CodeSnippetParams& a, const CodeSnippetParams& b);
uint startLineNumber;
uint endLineNumber;
size_t startLineNumber;
size_t endLineNumber;
std::wstring title;
std::wstring footer;
+4 -4
View File
@@ -21,8 +21,8 @@ struct ErrorInfo
Id id,
std::wstring message,
std::wstring filePath,
uint lineNumber,
uint columnNumber,
size_t lineNumber,
size_t columnNumber,
std::wstring translationUnit,
bool fatal,
bool indexed
@@ -42,8 +42,8 @@ struct ErrorInfo
std::wstring message;
std::wstring filePath;
uint lineNumber;
uint columnNumber;
size_t lineNumber;
size_t columnNumber;
std::wstring translationUnit;
bool fatal;
-1
View File
@@ -2,7 +2,6 @@
#include "NodeType.h"
#include "utility.h"
#include "utilityMath.h"
NodeTypeSet NodeTypeSet::all()
{
+2 -3
View File
@@ -4,7 +4,6 @@
#include "PersistentStorage.h"
#include "FilePath.h"
#include "Blackboard.h"
#include "utility.h"
#include "Application.h"
TaskCleanStorage::TaskCleanStorage(
@@ -22,7 +21,7 @@ void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
{
m_dialogView->showUnknownProgressDialog(L"Clearing Files", std::to_wstring(m_filePaths.size()) + L" Files");
m_start = utility::durationStart();
m_start = TimeStamp::now();
if (!m_filePaths.empty() || m_clearAllErrors)
{
@@ -56,7 +55,7 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboar
void TaskCleanStorage::doExit(std::shared_ptr<Blackboard> blackboard)
{
blackboard->set("clear_time", utility::duration(m_start));
blackboard->set("clear_time", TimeStamp::durationSeconds(m_start));
m_dialogView->hideProgressDialog();
}
+6 -8
View File
@@ -1,15 +1,13 @@
#include "TaskFinishParsing.h"
#include "Blackboard.h"
#include "DialogView.h"
#include "PersistentStorage.h"
#include "MessageIndexingFinished.h"
#include "MessageIndexingStatus.h"
#include "MessageQuitApplication.h"
#include "MessageStatus.h"
#include "Blackboard.h"
#include "utility.h"
#include "PersistentStorage.h"
#include "TimeStamp.h"
#include "utilityString.h"
#include "Application.h"
TaskFinishParsing::TaskFinishParsing(std::shared_ptr<PersistentStorage> storage, std::shared_ptr<DialogView> dialogView)
: m_storage(storage)
@@ -32,13 +30,13 @@ void TaskFinishParsing::doEnter(std::shared_ptr<Blackboard> blackboard)
Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboard)
{
TimeStamp start = utility::durationStart();
TimeStamp start = TimeStamp::now();
m_dialogView->showUnknownProgressDialog(L"Finish Indexing", L"Optimizing database");
m_storage->optimizeMemory();
m_dialogView->hideUnknownProgressDialog();
float time = utility::duration(start);
float time = TimeStamp::durationSeconds(start);
if (blackboard->exists("clear_time"))
{
@@ -68,7 +66,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
std::wstring status;
status += L"Finished indexing: ";
status += std::to_wstring(indexedSourceFileCount) + L"/" + std::to_wstring(sourceFileCount) + L" source files indexed; ";
status += utility::decodeFromUtf8(utility::timeToString(time));
status += utility::decodeFromUtf8(TimeStamp::secondsToString(time));
status += L"; " + std::to_wstring(errorInfo.total) + L" error" + (errorInfo.total != 1 ? L"s" : L"");
if (errorInfo.fatal > 0)
{
@@ -1,5 +1,6 @@
#include "CombinedIndexerCommandProvider.h"
#include "logging.h"
#include "utility.h"
void CombinedIndexerCommandProvider::addProvider(std::shared_ptr<IndexerCommandProvider> provider)
@@ -5,14 +5,17 @@
#include "IndexerCommandProvider.h"
class CombinedIndexerCommandProvider : public IndexerCommandProvider
class CombinedIndexerCommandProvider
: public IndexerCommandProvider
{
public:
void addProvider(std::shared_ptr<IndexerCommandProvider> provider);
std::vector<FilePath> getAllSourceFilePaths() const override;
std::shared_ptr<IndexerCommand> consumeCommand() override;
std::shared_ptr<IndexerCommand> consumeCommandForSourceFilePath(const FilePath& filePath) override;
std::vector<std::shared_ptr<IndexerCommand>> consumeAllCommands() override;
void clear() override;
size_t size() const override;
@@ -39,7 +39,7 @@ TaskExecuteCustomCommands::TaskExecuteCustomCommands(
void TaskExecuteCustomCommands::doEnter(std::shared_ptr<Blackboard> blackboard)
{
m_dialogView->hideUnknownProgressDialog();
m_start = utility::durationStart();
m_start = TimeStamp::now();
if (m_indexerCommandProvider)
{
@@ -134,7 +134,7 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr<Blackboard>
void TaskExecuteCustomCommands::doExit(std::shared_ptr<Blackboard> blackboard)
{
m_storage.reset();
const float duration = utility::duration(m_start);
const float duration = TimeStamp::durationSeconds(m_start);
blackboard->update<float>("index_time", [duration](float currentDuration) { return currentDuration + duration; });
}
+4 -4
View File
@@ -11,8 +11,8 @@ ParseLocation::ParseLocation()
ParseLocation::ParseLocation(
Id fileId,
uint lineNumber,
uint columnNumber
size_t lineNumber,
size_t columnNumber
)
: fileId(fileId)
, startLineNumber(lineNumber)
@@ -24,8 +24,8 @@ ParseLocation::ParseLocation(
ParseLocation::ParseLocation(
Id fileId,
uint startLineNumber, uint startColumnNumber,
uint endLineNumber, uint endColumnNumber
size_t startLineNumber, size_t startColumnNumber,
size_t endLineNumber, size_t endColumnNumber
)
: fileId(fileId)
, startLineNumber(startLineNumber)
+8 -8
View File
@@ -20,22 +20,22 @@ struct ParseLocation
ParseLocation();
ParseLocation(
Id fileId,
uint lineNumber,
uint columnNumber
size_t lineNumber,
size_t columnNumber
);
ParseLocation(
Id fileId,
uint startLineNumber, uint startColumnNumber,
uint endLineNumber, uint endColumnNumber
size_t startLineNumber, size_t startColumnNumber,
size_t endLineNumber, size_t endColumnNumber
);
bool isValid() const;
Id fileId;
uint startLineNumber;
uint startColumnNumber;
uint endLineNumber;
uint endColumnNumber;
size_t startLineNumber;
size_t startColumnNumber;
size_t endLineNumber;
size_t endColumnNumber;
};
#endif // PARSE_LOCATION_H
+2 -3
View File
@@ -3,7 +3,6 @@
#include "DialogView.h"
#include "PersistentStorage.h"
#include "Blackboard.h"
#include "utility.h"
TaskParseWrapper::TaskParseWrapper(std::weak_ptr<PersistentStorage> storage, std::shared_ptr<DialogView> dialogView)
: m_storage(storage)
@@ -19,7 +18,7 @@ void TaskParseWrapper::doEnter(std::shared_ptr<Blackboard> blackboard)
m_dialogView->clearDialogs();
m_dialogView->updateIndexingDialog(0, 0, sourceFileCount, { });
m_start = utility::durationStart();
m_start = TimeStamp::now();
if (sourceFileCount > 0)
{
@@ -37,7 +36,7 @@ Task::TaskState TaskParseWrapper::doUpdate(std::shared_ptr<Blackboard> blackboar
void TaskParseWrapper::doExit(std::shared_ptr<Blackboard> blackboard)
{
float duration = utility::duration(m_start);
float duration = TimeStamp::durationSeconds(m_start);
blackboard->update<float>("index_time", [duration](float currentDuration) { return currentDuration + duration; });
}
@@ -14,7 +14,7 @@ struct StorageSourceLocationData
, type(0)
{}
StorageSourceLocationData(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type)
StorageSourceLocationData(Id fileNodeId, size_t startLine, size_t startCol, size_t endLine, size_t endCol, int type)
: fileNodeId(fileNodeId)
, startLine(startLine)
, startCol(startCol)
@@ -52,10 +52,10 @@ struct StorageSourceLocationData
}
Id fileNodeId;
uint startLine;
uint startCol;
uint endLine;
uint endCol;
size_t startLine;
size_t startCol;
size_t endLine;
size_t endCol;
int type;
};
@@ -71,7 +71,7 @@ struct StorageSourceLocation: public StorageSourceLocationData
, id(id)
{}
StorageSourceLocation(Id id, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type)
StorageSourceLocation(Id id, Id fileNodeId, size_t startLine, size_t startCol, size_t endLine, size_t endCol, int type)
: StorageSourceLocationData(fileNodeId, startLine, startCol, endLine, endCol, type)
, id(id)
{}
+26 -25
View File
@@ -131,10 +131,10 @@ void Project::load(std::shared_ptr<DialogView> dialogView)
if (dbPath.exists())
{
if (dialogView->confirm(
"Sourcetrail has been closed unexpectedly while indexing this project. You can either choose to keep "
"the data that has already been indexed or discard that data and restore the state of your project "
"before indexing?",
{ "Keep and Continue", "Discard and Restore" }) == 0)
L"Sourcetrail has been closed unexpectedly while indexing this project. You can either choose to keep "
L"the data that has already been indexed or discard that data and restore the state of your project "
L"before indexing?",
{ L"Keep and Continue", L"Discard and Restore" }) == 0)
{
LOG_INFO("Switching to temporary indexing data on user's decision");
if (!swapToTempStorageFile(dbPath, tempDbPath, dialogView))
@@ -261,7 +261,7 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialo
bool needsFullRefresh = false;
bool fullRefresh = false;
std::string question;
std::wstring question;
switch (m_state)
{
@@ -274,31 +274,31 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialo
case PROJECT_STATE_OUTDATED:
question =
"The project file was changed after the last indexing. The project needs to get fully reindexed to "
"reflect the current project state. Alternatively you can also choose to just reindex updated or "
"incomplete files. Do you want to reindex the project?";
L"The project file was changed after the last indexing. The project needs to get fully reindexed to "
L"reflect the current project state. Alternatively you can also choose to just reindex updated or "
L"incomplete files. Do you want to reindex the project?";
fullRefresh = true;
break;
case PROJECT_STATE_OUTVERSIONED:
question =
"This project was indexed with a different version of Sourcetrail. It needs to be fully reindexed to "
"be used with this version of Sourcetrail. Do you want to reindex the project?";
L"This project was indexed with a different version of Sourcetrail. It needs to be fully reindexed to "
L"be used with this version of Sourcetrail. Do you want to reindex the project?";
needsFullRefresh = true;
break;
case PROJECT_STATE_NEEDS_MIGRATION:
question =
"This project was created with a different version and uses an old project file format. "
"The project can still be opened and used with this version, but needs to be fully reindexed. "
"Do you want Sourcetrail to update the project file and reindex the project?";
L"This project was created with a different version and uses an old project file format. "
L"The project can still be opened and used with this version, but needs to be fully reindexed. "
L"Do you want Sourcetrail to update the project file and reindex the project?";
needsFullRefresh = true;
break;
case PROJECT_STATE_DB_CORRUPTED:
question =
"There was a problem loading the index of this project. The project needs to get fully reindexed. "
"Do you want to reindex the project?";
L"There was a problem loading the index of this project. The project needs to get fully reindexed. "
L"Do you want to reindex the project?";
needsFullRefresh = true;
break;
@@ -308,7 +308,7 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialo
if (question.size() && m_hasGUI)
{
if (dialogView->confirm(question, { "Reindex", "Cancel" }) == 1)
if (dialogView->confirm(question, { L"Reindex", L"Cancel" }) == 1)
{
return;
}
@@ -318,9 +318,9 @@ void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialo
ApplicationSettings::getInstance()->getVerboseIndexerLoggingEnabled() && m_hasGUI)
{
if (dialogView->confirm(
"Warning: You are about to index your project with the \"verbose indexer logging\" setting "
"enabled. This will cause a significant slowdown in indexing performance. Do you want to proceed?",
{ "Yes", "No" }) == 1)
L"Warning: You are about to index your project with the \"verbose indexer logging\" setting "
L"enabled. This will cause a significant slowdown in indexing performance. Do you want to proceed?",
{ L"Yes", L"No" }) == 1)
{
return;
}
@@ -440,9 +440,10 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
if (abortIndexing)
{
if (m_hasGUI && dialogView->confirm(
"<p>This project contains a source group of type \"" + sourceGroupTypeToString(sourceGroup->getType()) + "\" "
"that cannot be partially cleared. Do you want to re-index the whole project instead?</p>",
{ "Full Re-Index", "Cancel" }
L"<p>This project contains a source group of type \"" +
utility::decodeFromUtf8(sourceGroupTypeToString(sourceGroup->getType())) +
L"\" that cannot be partially cleared. Do you want to re-index the whole project instead?</p>",
{ L"Full Re-Index", L"Cancel" }
) == 1)
{
MessageStatus(L"Cannot partially clear project. Indexing aborted.").dispatch();
@@ -715,9 +716,9 @@ bool Project::swapToTempStorageFile(const FilePath& indexDbFilePath, const FileP
if (m_hasGUI)
{
dialogView->confirm(
"<p>The old index database file of this project seems to be used by a different process and cannot "
"be updated.</p><p>Please close all processes that are using this database and re-load this project to "
"apply or discard the changes pending from the current indexer run.</p>"
L"<p>The old index database file of this project seems to be used by a different process and cannot "
L"be updated.</p><p>Please close all processes that are using this database and re-load this project to "
L"apply or discard the changes pending from the current indexer run.</p>"
);
}
return false;
+3 -2
View File
@@ -1,11 +1,12 @@
#include "ApplicationSettings.h"
#include "AppPath.h"
#include "License.h"
#include "Logger.h"
#include "ResourcePaths.h"
#include "SettingsMigrator.h"
#include "SettingsMigrationLambda.h"
#include "SettingsMigrationMoveKey.h"
#include "AppPath.h"
#include "ResourcePaths.h"
#include "Status.h"
#include "TimeStamp.h"
#include "UserPaths.h"
+39
View File
@@ -5,6 +5,45 @@ TimeStamp TimeStamp::now()
return TimeStamp(boost::posix_time::microsec_clock::local_time());
}
double TimeStamp::durationSeconds(const TimeStamp& start)
{
return double(TimeStamp::now().deltaMS(start)) / 1000.0;
}
std::string TimeStamp::secondsToString(double secs)
{
std::stringstream ss;
int hours = int(secs / 3600);
secs -= hours * 3600;
int minutes = int(secs / 60);
secs -= minutes * 60;
int seconds = int(secs);
secs -= seconds;
int milliSeconds = secs * 1000;
if (hours > 9)
{
ss << hours;
}
else
{
ss << std::setw(2) << std::setfill('0') << hours;
}
ss << ":" << std::setw(2) << std::setfill('0') << minutes;
ss << ":" << std::setw(2) << std::setfill('0') << seconds;
if (!hours && !minutes)
{
ss << ":" << std::setw(3) << std::setfill('0') << milliSeconds;
}
return ss.str();
}
TimeStamp::TimeStamp()
: m_time(boost::posix_time::not_a_date_time)
{
+3
View File
@@ -8,6 +8,9 @@ class TimeStamp
public:
static TimeStamp now();
static double durationSeconds(const TimeStamp& start);
static std::string secondsToString(double seconds);
TimeStamp();
TimeStamp(boost::posix_time::ptime t);
TimeStamp(std::string s);
@@ -1,13 +1,14 @@
#include "CommandlineCommandConfig.h"
#include <functional>
#include <iostream>
#include <utility>
#include "ApplicationSettings.h"
#include "CommandlineHelper.h"
#include "CommandLineParser.h"
#include "FilePath.h"
#include "ApplicationSettings.h"
#include "logging.h"
namespace commandline {
@@ -1,5 +1,7 @@
#include "CommandlineCommandIndex.h"
#include <iostream>
#include "CommandlineHelper.h"
#include "CommandLineParser.h"
@@ -3,6 +3,7 @@
#include "FilePath.h"
#include "FileSystem.h"
#include "logging.h"
#include "utility.h"
std::vector<FilePath> utility::partitionFilePathsBySize(std::vector<FilePath> filePaths, int partitionCount)
@@ -16,6 +16,7 @@ namespace utility
FilePath getExpandedPath(const FilePath& path);
std::vector<FilePath> getExpandedPaths(const std::vector<FilePath>& paths);
FilePath getExpandedAndAbsolutePath(const FilePath& path, const FilePath& baseDirectory);
FilePath getAsRelativeIfShorter(const FilePath& absolutePath, const FilePath& baseDirectory);
std::vector<FilePath> getAsRelativeIfShorter(const std::vector<FilePath>& absolutePaths, const FilePath& baseDirectory);
}
@@ -4,7 +4,7 @@
#include "logging.h"
#include "TimeStamp.h"
#include "utility.h"
#include "utilityApp.h"
std::string SharedMemoryGarbageCollector::s_memoryNamePrefix = "grbg_cllctr_";
std::string SharedMemoryGarbageCollector::s_instancesKeyName = "running_instances";
+2 -2
View File
@@ -4,9 +4,9 @@
#include "logging.h"
#include "MessageStatus.h"
#include "utility.h"
#include "Version.h"
#include "utilityApp.h"
#include "utilityString.h"
#include "Version.h"
std::shared_ptr<LogManager> LogManager::getInstance()
{
@@ -2,14 +2,15 @@
#include "tinyxml.h"
#include "IndexerCommandCxx.h"
#include "ApplicationSettings.h"
#include "SourceGroupSettingsCxxSonargraph.h"
#include "IndexerCommandCxx.h"
#include "FileSystem.h"
#include "logging.h"
#include "SonargraphSoftwareSystem.h"
#include "utilitySonargraph.h"
#include "SourceGroupSettingsCxxSonargraph.h"
#include "utility.h"
#include "utilityFile.h"
#include "utilitySonargraph.h"
#include "utilityXml.h"
namespace Sonargraph
@@ -2,16 +2,17 @@
#include "tinyxml.h"
#include "FileSystem.h"
#include "IndexerCommandJava.h"
#include "LanguageType.h"
#include "SourceGroupSettingsJavaSonargraph.h"
#include "FileSystem.h"
#include "SonargraphSoftwareSystem.h"
#include "logging.h"
#include "SonargraphSourceRootPath.h"
#include "SonargraphSoftwareSystem.h"
#include "SonargraphXsdRootPath.h"
#include "utilitySonargraph.h"
#include "SourceGroupSettingsJavaSonargraph.h"
#include "utility.h"
#include "utilityFile.h"
#include "utilitySonargraph.h"
#include "utilityXml.h"
namespace Sonargraph
+8 -7
View File
@@ -10,9 +10,10 @@
#include <stack>
#include <thread>
#include "FilePath.h"
#include "TimeStamp.h"
#include "types.h"
#include "utility.h"
#include "utilityString.h"
struct TraceEvent
{
@@ -21,7 +22,7 @@ public:
: eventName("")
, id(0)
, depth(0)
, time(0.0f)
, time(0.0)
{
}
@@ -29,7 +30,7 @@ public:
: eventName(eventName)
, id(id)
, depth(depth)
, time(0.0f)
, time(0.0)
{
}
@@ -40,7 +41,7 @@ public:
std::string functionName;
std::string locationName;
float time;
double time;
};
@@ -84,7 +85,7 @@ private:
{
TraceEvent event;
size_t count;
float time;
double time;
};
static std::shared_ptr<AccumulatingTracer> s_instance;
@@ -121,13 +122,13 @@ ScopedTrace<TracerType>::ScopedTrace(
m_event->functionName = functionName;
m_event->locationName = utility::encodeToUtf8(FilePath(fileName).fileName()) + ":" + std::to_string(lineNumber);
m_timeStamp = utility::durationStart();
m_timeStamp = TimeStamp::now();
}
template <typename TracerType>
ScopedTrace<TracerType>::~ScopedTrace()
{
m_event->time = utility::duration(m_timeStamp);
m_event->time = TimeStamp::durationSeconds(m_timeStamp);
TracerType::getInstance()->finishEvent(m_event);
}
-2
View File
@@ -5,6 +5,4 @@
typedef size_t Id;
typedef unsigned int uint;
#endif // TYPES_H
-107
View File
@@ -1,107 +1,5 @@
#include "utility.h"
#include <iomanip>
#include <sstream>
#include <boost/date_time/time_clock.hpp>
ApplicationArchitectureType utility::getApplicationArchitectureType()
{
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) || defined(WIN64)
return APPLICATION_ARCHITECTURE_X86_64;
#else
return APPLICATION_ARCHITECTURE_X86_32;
#endif
return APPLICATION_ARCHITECTURE_UNKNOWN;
}
TimeStamp utility::durationStart()
{
return TimeStamp::now();
}
float utility::duration(const TimeStamp& start)
{
TimeStamp now = durationStart();
return float(now.deltaMS(start)) / 1000.0f;
}
float utility::duration(std::function<void()> func)
{
const TimeStamp start = durationStart();
func();
return duration(start);
}
std::string utility::timeToString(const time_t time)
{
char buff[20];
strftime(buff, 20, "%Y-%m-%d %H:%M:%S", localtime(&time));
return std::string(buff);
}
std::string utility::timeToString(const boost::posix_time::ptime time)
{
return TimeStamp(time).toString();
}
std::string utility::timeToString(float secondsTotal)
{
std::stringstream ss;
int hours = int(secondsTotal / 3600);
secondsTotal -= hours * 3600;
int minutes = int(secondsTotal / 60);
secondsTotal -= minutes * 60;
int seconds = int(secondsTotal);
secondsTotal -= seconds;
int milliSeconds = secondsTotal * 1000;
if (hours > 9)
{
ss << hours;
}
else
{
ss << std::setw(2) << std::setfill('0') << hours;
}
ss << ":" << std::setw(2) << std::setfill('0') << minutes;
ss << ":" << std::setw(2) << std::setfill('0') << seconds;
if (!hours && !minutes)
{
ss << ":" << std::setw(3) << std::setfill('0') << milliSeconds;
}
return ss.str();
}
bool utility::intersectionPoint(Vec2f a1, Vec2f b1, Vec2f a2, Vec2f b2, Vec2f* i)
{
Vec2f p = a1;
Vec2f v = b1 - a1;
Vec2f q = a2;
Vec2f w = b2 - a2;
float denominator = v.x * w.y - v.y * w.x;
if (denominator != 0)
{
float t = (p.y * w.x - p.x * w.y + q.x * w.y - q.y * w.x) / denominator;
float s = (q.y * v.x - q.x * v.y + p.x * v.y - p.y * v.x) / -denominator;
if (t >= 0 && t <= 1 && s >= 0 && s <= 1)
{
*i = p + v * t;
return true;
}
}
return false;
}
size_t utility::digits(size_t n)
{
int digits = 1;
@@ -114,8 +12,3 @@ size_t utility::digits(size_t n)
return digits;
}
int utility::roundToInt(float n)
{
return (n > 0.0f) ? (n + 0.5f) : (n - 0.5f);
}
+9 -24
View File
@@ -5,29 +5,16 @@
#include <cstdarg>
#include <deque>
#include <functional>
#include <map>
#include <set>
#include <time.h>
#include <vector>
#include <unordered_set>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "ApplicationArchitectureType.h"
#include "FilePath.h"
#include "Vector2.h"
#include "TimeStamp.h"
#include "utilityString.h"
namespace utility
{
TimeStamp durationStart();
float duration(const TimeStamp& start);
float duration(std::function<void()> func);
std::string timeToString(const time_t time);
std::string timeToString(const boost::posix_time::ptime time);
std::string timeToString(float seconds);
template<typename T>
std::vector<std::vector<T>> splitToEqualySizedParts(const std::vector<T>& values, const size_t desiredPartCount);
@@ -74,13 +61,15 @@ namespace utility
std::vector<T> createVectorFromElements(const Args&... args);
template<typename SourceType, typename TargetType>
std::vector<TargetType> convert(const std::vector<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion);
std::vector<TargetType> convert(
const std::vector<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion);
template<typename SourceType, typename TargetType>
std::vector<TargetType> convert(const std::vector<SourceType>& sourceContainer);
template<typename SourceType, typename TargetType>
std::set<TargetType> convert(const std::set<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion);
std::set<TargetType> convert(
const std::set<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion);
template<typename SourceType, typename TargetType>
std::set<TargetType> convert(const std::set<SourceType>& sourceContainer);
@@ -134,13 +123,7 @@ namespace utility
return false;
}
ApplicationArchitectureType getApplicationArchitectureType();
bool intersectionPoint(Vec2f a1, Vec2f b1, Vec2f a2, Vec2f b2, Vec2f* i);
size_t digits(size_t n);
int roundToInt(float n);
}
template<typename T>
@@ -286,7 +269,8 @@ std::vector<T> utility::createVectorFromElements(const Args&... args)
}
template<typename SourceType, typename TargetType>
std::vector<TargetType> utility::convert(const std::vector<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion)
std::vector<TargetType> utility::convert(
const std::vector<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion)
{
std::vector<TargetType> targetContainer;
targetContainer.reserve(sourceContainer.size());
@@ -310,7 +294,8 @@ std::vector<TargetType> utility::convert(const std::vector<SourceType>& sourceCo
}
template<typename SourceType, typename TargetType>
std::set<TargetType> utility::convert(const std::set<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion)
std::set<TargetType> utility::convert(
const std::set<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion)
{
std::set<TargetType> targetContainer;
for (const SourceType& sourceElement : sourceContainer)
-13
View File
@@ -1,13 +0,0 @@
#include "utilityMath.h"
unsigned long int utility::getPowerOfTwo(unsigned int exponent)
{
static const long int powerOfTwos[] =
{
1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7,
1 << 8, 1 << 9, 1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15,
1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 21, 1 << 22, 1 << 23,
1 << 24, 1 << 25, 1 << 26, 1 << 27, 1 << 28, 1 << 29, 1 << 30, 1 << 31
};
return powerOfTwos[exponent];
}
-9
View File
@@ -1,9 +0,0 @@
#ifndef UTILITY_MATH_H
#define UTILITY_MATH_H
namespace utility
{
unsigned long int getPowerOfTwo(unsigned int exponent);
}
#endif // UTILITY_MATH_H
+14 -10
View File
@@ -1,20 +1,24 @@
#include "utilityUuid.h"
#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
boost::uuids::uuid utility::getUuid()
namespace utility
{
return boost::uuids::random_generator()();
}
boost::uuids::uuid getUuid()
{
return boost::uuids::random_generator()();
}
std::string utility::uuidToString(const boost::uuids::uuid& uuid)
{
return boost::lexical_cast<std::string>(uuid);
}
std::string uuidToString(const boost::uuids::uuid& uuid)
{
return boost::lexical_cast<std::string>(uuid);
}
std::string utility::getUuidString()
{
return utility::uuidToString(utility::getUuid());
std::string getUuidString()
{
return utility::uuidToString(utility::getUuid());
}
}
+4 -3
View File
@@ -1,13 +1,14 @@
#ifndef UTILITY_UUID_H
#define UTILITY_UUID_H
#include <boost/uuid/uuid.hpp>
#include <string>
// #include <boost/uuid/uuid.hpp>
namespace utility
{
boost::uuids::uuid getUuid();
std::string uuidToString(const boost::uuids::uuid& uuid);
// boost::uuids::uuid getUuid();
// std::string uuidToString(const boost::uuids::uuid& uuid);
std::string getUuidString();
}
@@ -65,8 +65,8 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
Id fileId = 0;
FilePath filePath;
uint lineNumber = 0;
uint columnNumber = 0;
size_t lineNumber = 0;
size_t columnNumber = 0;
if (info.getLocation().isValid() && info.hasSourceManager())
{
const clang::SourceManager& sourceManager = info.getSourceManager();
+5 -3
View File
@@ -2,13 +2,15 @@
#include <clang/Tooling/Tooling.h>
#include <clang/Tooling/JSONCompilationDatabase.h>
#include "Application.h"
#include "ApplicationSettings.h"
#include "CxxIndexerCommandProvider.h"
#include "IndexerCommandCxx.h"
#include "SourceGroupSettingsCxxCdb.h"
#include "ApplicationSettings.h"
#include "logging.h"
#include "MessageStatus.h"
#include "SourceGroupSettingsCxxCdb.h"
#include "utility.h"
#include "Application.h"
SourceGroupCxxCdb::SourceGroupCxxCdb(std::shared_ptr<SourceGroupSettingsCxxCdb> settings)
: m_settings(settings)
@@ -9,6 +9,7 @@
#include "FileSystem.h"
#include "GeneratePCHAction.h"
#include "IndexerCommandCxx.h"
#include "logging.h"
#include "SingleFrontendActionFactory.h"
#include "SourceGroupSettingsCEmpty.h"
#include "SourceGroupSettingsCppEmpty.h"
+3 -1
View File
@@ -4,9 +4,11 @@
#include <clang/Tooling/JSONCompilationDatabase.h>
#include <clang/Tooling/CompilationDatabase.h>
#include "FilePath.h"
#include "utilityString.h"
#include "logging.h"
#include "utility.h"
#include "utilityString.h"
utility::CompilationDatabase::CompilationDatabase(const FilePath& filePath)
: m_filePath(filePath)
+8 -8
View File
@@ -75,7 +75,7 @@ void QtLineNumberArea::paintEvent(QPaintEvent *event)
QtCodeArea::QtCodeArea(
uint startLineNumber,
size_t startLineNumber,
const std::string& code,
std::shared_ptr<SourceLocationFile> locationFile,
QtCodeNavigator* navigator,
@@ -319,7 +319,7 @@ void QtCodeArea::setIsActiveFile(bool isActiveFile)
m_isActiveFile = isActiveFile;
}
uint QtCodeArea::getLineNumberForLocationId(Id locationId) const
size_t QtCodeArea::getLineNumberForLocationId(Id locationId) const
{
for (const Annotation& annotation : m_annotations)
{
@@ -332,17 +332,17 @@ uint QtCodeArea::getLineNumberForLocationId(Id locationId) const
return 0;
}
std::pair<uint, uint> QtCodeArea::getLineNumbersForLocationId(Id locationId) const
std::pair<size_t, size_t> QtCodeArea::getLineNumbersForLocationId(Id locationId) const
{
for (const Annotation& annotation : m_annotations)
{
if (annotation.locationId == locationId)
{
return std::pair<uint, uint>(annotation.startLine, annotation.endLine);
return std::pair<size_t, size_t>(annotation.startLine, annotation.endLine);
}
}
return std::pair<uint, uint>(0, 0);
return std::pair<size_t, size_t>(0, 0);
}
Id QtCodeArea::getLocationIdOfFirstActiveLocation(Id tokenId) const
@@ -403,7 +403,7 @@ std::vector<Id> QtCodeArea::getLocationIdsForTokenIds(const std::set<Id>& tokenI
size_t QtCodeArea::getActiveLocationCount() const
{
uint count = 0;
size_t count = 0;
for (const Annotation& annotation : m_annotations)
{
@@ -428,7 +428,7 @@ size_t QtCodeArea::getActiveLocationCount() const
return count;
}
QRectF QtCodeArea::getLineRectForLineNumber(uint lineNumber) const
QRectF QtCodeArea::getLineRectForLineNumber(size_t lineNumber) const
{
if (lineNumber < getStartLineNumber())
{
@@ -680,7 +680,7 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
QScrollBar* scrollbar = horizontalScrollBar();
int visibleContentWidth = width() - lineNumberAreaWidth();
float deltaPosRatio = float(deltaX) / (visibleContentWidth);
scrollbar->setValue(scrollbar->value() - utility::roundToInt(deltaPosRatio * scrollbar->pageStep()));
scrollbar->setValue(scrollbar->value() - std::round(deltaPosRatio * scrollbar->pageStep()));
}
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(event->pos());
+4 -4
View File
@@ -53,7 +53,7 @@ class QtCodeArea
public:
QtCodeArea(
uint startLineNumber,
size_t startLineNumber,
const std::string& code,
std::shared_ptr<SourceLocationFile> locationFile,
QtCodeNavigator* navigator,
@@ -74,8 +74,8 @@ public:
void setIsActiveFile(bool isActiveFile);
uint getLineNumberForLocationId(Id locationId) const;
std::pair<uint, uint> getLineNumbersForLocationId(Id locationId) const;
size_t getLineNumberForLocationId(Id locationId) const;
std::pair<size_t, size_t> getLineNumbersForLocationId(Id locationId) const;
Id getLocationIdOfFirstActiveLocation(Id tokenId) const;
Id getLocationIdOfFirstActiveScopeLocation(Id tokenId) const;
@@ -85,7 +85,7 @@ public:
size_t getActiveLocationCount() const;
QRectF getLineRectForLineNumber(uint lineNumber) const;
QRectF getLineRectForLineNumber(size_t lineNumber) const;
void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
void clearScreenMatches();
+4 -4
View File
@@ -28,7 +28,7 @@ void QtCodeField::clearAnnotationColors()
}
QtCodeField::QtCodeField(
uint startLineNumber,
size_t startLineNumber,
const std::string& code,
std::shared_ptr<SourceLocationFile> locationFile,
bool convertLocationsOnDemand,
@@ -128,12 +128,12 @@ QSize QtCodeField::sizeHint() const
return QSize(width + 1, height + 5);
}
uint QtCodeField::getStartLineNumber() const
size_t QtCodeField::getStartLineNumber() const
{
return m_startLineNumber;
}
uint QtCodeField::getEndLineNumber() const
size_t QtCodeField::getEndLineNumber() const
{
return m_startLineNumber + blockCount() - 1;
}
@@ -382,7 +382,7 @@ void QtCodeField::createAnnotations(std::shared_ptr<SourceLocationFile> location
m_locationFile = locationFile;
m_annotations.clear();
uint endLineNumber = getEndLineNumber();
size_t endLineNumber = getEndLineNumber();
std::set<Id> locationIds;
locationFile->forEachSourceLocation(
+4 -4
View File
@@ -22,7 +22,7 @@ public:
static void clearAnnotationColors();
QtCodeField(
uint startLineNumber,
size_t startLineNumber,
const std::string& code,
std::shared_ptr<SourceLocationFile> locationFile,
bool convertLocationsOnDemand = true,
@@ -32,8 +32,8 @@ public:
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
uint getStartLineNumber() const;
uint getEndLineNumber() const;
size_t getStartLineNumber() const;
size_t getEndLineNumber() const;
int totalLineHeight() const;
@@ -122,7 +122,7 @@ private:
void createMultibyteCharacterLocationCache(const QString& code);
int getColumnCorrectedForMultibyteCharacters(int line, int column) const;
const uint m_startLineNumber;
const size_t m_startLineNumber;
const std::string m_code;
std::shared_ptr<SourceLocationFile> m_locationFile;
+3 -3
View File
@@ -126,8 +126,8 @@ QtCodeSnippet* QtCodeFile::insertCodeSnippet(const CodeSnippetParams& params)
size_t i = 0;
while (i < m_snippets.size())
{
uint start = newSnippet->getStartLineNumber();
uint end = newSnippet->getEndLineNumber();
size_t start = newSnippet->getStartLineNumber();
size_t end = newSnippet->getEndLineNumber();
QtCodeSnippet* oldSnippet = m_snippets[i];
@@ -434,7 +434,7 @@ void QtCodeFile::clickedSnippetButton()
void QtCodeFile::clickedMaximizeButton()
{
uint lineNumber = 0;
size_t lineNumber = 0;
Id locationId = 0;
std::pair<QtCodeSnippet*, Id> snippet = getFirstSnippetWithActiveLocationId(0);
@@ -158,7 +158,7 @@ void QtCodeFileList::requestFileContent(const FilePath& filePath)
getFile(filePath)->requestContent();
}
bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target)
bool QtCodeFileList::requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target)
{
QtCodeFile* file = getFile(filePath);
if (!file)
@@ -199,12 +199,12 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id
return true;
}
uint endLineNumber = 0;
size_t endLineNumber = 0;
if (!lineNumber)
{
if (locationId)
{
std::pair<uint, uint> lineNumbers = snippet->getLineNumbersForLocationId(locationId);
std::pair<size_t, size_t> lineNumbers = snippet->getLineNumbersForLocationId(locationId);
lineNumber = lineNumbers.first;
+1 -1
View File
@@ -38,7 +38,7 @@ public:
void updateCodeSnippet(const CodeSnippetParams& params) override;
void requestFileContent(const FilePath& filePath) override;
bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target) override;
bool requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) override;
void updateFiles() override;
void showContents() override;
@@ -153,7 +153,7 @@ void QtCodeFileSingle::requestFileContent(const FilePath& filePath)
}
bool QtCodeFileSingle::requestScroll(
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target)
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target)
{
FileData file = getFileData(filePath);
if (file.area)
@@ -171,12 +171,12 @@ bool QtCodeFileSingle::requestScroll(
animated = false;
}
uint endLineNumber = 0;
size_t endLineNumber = 0;
if (!lineNumber)
{
if (locationId)
{
std::pair<uint, uint> lineNumbers = m_area->getLineNumbersForLocationId(locationId);
std::pair<size_t, size_t> lineNumbers = m_area->getLineNumbersForLocationId(locationId);
lineNumber = lineNumbers.first;
@@ -38,7 +38,7 @@ public:
void requestFileContent(const FilePath& filePath) override;
bool requestScroll(
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target) override;
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) override;
void updateFiles() override;
void showContents() override;
@@ -32,7 +32,7 @@ public:
virtual void updateCodeSnippet(const CodeSnippetParams& params) = 0;
virtual void requestFileContent(const FilePath& filePath) = 0;
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target) = 0;
virtual bool requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) = 0;
virtual void updateFiles() = 0;
virtual void showContents() = 0;
@@ -838,7 +838,7 @@ void QtCodeNavigator::scrollToSnippetIfRequested()
}
void QtCodeNavigator::requestScroll(
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target)
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target)
{
ScrollRequest req;
req.filePath = filePath;
@@ -114,7 +114,7 @@ public:
void scrollToSnippetIfRequested();
void requestScroll(
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target);
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target);
signals:
void scrollRequest();
@@ -172,7 +172,7 @@ private:
}
FilePath filePath;
uint lineNumber;
size_t lineNumber;
Id locationId;
bool animated;
@@ -40,7 +40,7 @@ QtCodeSnippet* QtCodeSnippet::merged(
std::string secondCode = second->getCode();
int secondCodeStartIndex = 0;
for (uint i = second->getStartLineNumber(); i <= first->getEndLineNumber(); i++)
for (size_t i = second->getStartLineNumber(); i <= first->getEndLineNumber(); i++)
{
secondCodeStartIndex = secondCode.find("\n", secondCodeStartIndex) + 1;
}
@@ -124,12 +124,12 @@ QtCodeArea* QtCodeSnippet::getArea() const
return m_codeArea;
}
uint QtCodeSnippet::getStartLineNumber() const
size_t QtCodeSnippet::getStartLineNumber() const
{
return m_codeArea->getStartLineNumber();
}
uint QtCodeSnippet::getEndLineNumber() const
size_t QtCodeSnippet::getEndLineNumber() const
{
return m_codeArea->getEndLineNumber();
}
@@ -163,12 +163,12 @@ void QtCodeSnippet::setIsActiveFile(bool isActiveFile)
m_codeArea->setIsActiveFile(isActiveFile);
}
uint QtCodeSnippet::getLineNumberForLocationId(Id locationId) const
size_t QtCodeSnippet::getLineNumberForLocationId(Id locationId) const
{
return m_codeArea->getLineNumberForLocationId(locationId);
}
std::pair<uint, uint> QtCodeSnippet::getLineNumbersForLocationId(Id locationId) const
std::pair<size_t, size_t> QtCodeSnippet::getLineNumbersForLocationId(Id locationId) const
{
return m_codeArea->getLineNumbersForLocationId(locationId);
}
@@ -184,7 +184,7 @@ Id QtCodeSnippet::getFirstActiveLocationId(Id tokenId) const
return m_codeArea->getLocationIdOfFirstActiveLocation(tokenId);
}
QRectF QtCodeSnippet::getLineRectForLineNumber(uint lineNumber) const
QRectF QtCodeSnippet::getLineRectForLineNumber(size_t lineNumber) const
{
return m_codeArea->getLineRectForLineNumber(lineNumber);
}
+5 -5
View File
@@ -32,8 +32,8 @@ public:
QtCodeFile* getFile() const;
QtCodeArea* getArea() const;
uint getStartLineNumber() const;
uint getEndLineNumber() const;
size_t getStartLineNumber() const;
size_t getEndLineNumber() const;
int lineNumberDigits() const;
@@ -44,11 +44,11 @@ public:
void setIsActiveFile(bool isActiveFile);
uint getLineNumberForLocationId(Id locationId) const;
std::pair<uint, uint> getLineNumbersForLocationId(Id locationId) const;
size_t getLineNumberForLocationId(Id locationId) const;
std::pair<size_t, size_t> getLineNumbersForLocationId(Id locationId) const;
Id getFirstActiveLocationId(Id tokenId) const;
QRectF getLineRectForLineNumber(uint lineNumber) const;
QRectF getLineRectForLineNumber(size_t lineNumber) const;
std::string getCode() const;
+2 -1
View File
@@ -8,9 +8,10 @@
#include "ApplicationSettings.h"
#include "LicenseChecker.h"
#include "logging.h"
#include "MessageStatus.h"
#include "QtRequest.h"
#include "utility.h"
#include "TimeStamp.h"
#include "utilityApp.h"
#include "utilityUuid.h"
#include "Version.h"
@@ -8,14 +8,15 @@
#include <QTextCodec>
#include <QTimer>
#include "utilityQt.h"
#include "ApplicationSettings.h"
#include "logging.h"
#include "FileSystem.h"
#include "MessageSwitchColorScheme.h"
#include "ResourcePaths.h"
#include "utilityPathDetection.h"
#include "utilityApp.h"
#include "utility.h"
#include "utilityApp.h"
#include "utilityPathDetection.h"
#include "utilityQt.h"
QtProjectWizardContentPreferences::QtProjectWizardContentPreferences(
QtProjectWizardWindow* window
@@ -4,6 +4,7 @@
#include "Application.h"
#include "ApplicationSettings.h"
#include "logging.h"
#include "MessageStatus.h"
#include "QtDialogView.h"
#include "ScopedFunctor.h"
+1
View File
@@ -9,6 +9,7 @@
#include "ColorScheme.h"
#include "FileSystem.h"
#include "logging.h"
#include "ResourcePaths.h"
#include "TextAccess.h"
#include "tracing.h"
-39
View File
@@ -329,45 +329,6 @@ DatabasePolicy QtDialogView::finishedIndexingDialog(
return policy;
}
int QtDialogView::confirm(const std::string& message, const std::vector<std::string>& options)
{
int result = -1;
m_resultReady = false;
m_onQtThread2(
[=, &result]()
{
QMessageBox msgBox;
msgBox.setText(QString::fromStdString(message));
for (const std::string& option : options)
{
msgBox.addButton(QString::fromStdString(option), QMessageBox::AcceptRole);
}
msgBox.exec();
for (int i = 0; i < msgBox.buttons().size(); i++)
{
if (msgBox.clickedButton() == msgBox.buttons().at(i))
{
result = i;
break;
}
}
m_resultReady = true;
}
);
while (!m_resultReady)
{
std::this_thread::sleep_for(std::chrono::milliseconds(25));
}
return result;
}
int QtDialogView::confirm(const std::wstring& message, const std::vector<std::wstring>& options)
{
int result = -1;
-1
View File
@@ -48,7 +48,6 @@ public:
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
float time, ErrorCountInfo errorInfo, bool interrupted) override;
int confirm(const std::string& message, const std::vector<std::string>& options) override;
int confirm(const std::wstring& message, const std::vector<std::wstring>& options) override;
void setParentWindow(QtWindow* window);
+1 -1
View File
@@ -341,7 +341,7 @@ void QtErrorView::addErrorToTable(const ErrorInfo& error)
m_model->item(rowNumber, Column::FILE)->setToolTip(QString::fromStdWString(error.filePath));
item = new QStandardItem();
item->setData(QVariant(error.lineNumber), Qt::DisplayRole);
item->setData(QVariant(qlonglong(error.lineNumber)), Qt::DisplayRole);
m_model->setItem(rowNumber, Column::LINE, item);
m_model->setItem(rowNumber, Column::INDEXED, new QStandardItem(error.indexed ? "yes" : "no"));
+1 -1
View File
@@ -8,7 +8,7 @@
#include "QtDeviceScaledPixmap.h"
#include "ResourcePaths.h"
#include "SqliteIndexStorage.h"
#include "utility.h"
#include "utilityApp.h"
#include "utilityQt.h"
#include "Version.h"
+5 -5
View File
@@ -5,13 +5,13 @@
#include <QRadioButton>
#include <QPushButton>
#include "utilityQt.h"
#include "QtHelpButton.h"
#include "QtProgressBar.h"
#include "MessageErrorsHelpMessage.h"
#include "MessageIndexingInterrupted.h"
#include "QtHelpButton.h"
#include "QtProgressBar.h"
#include "ResourcePaths.h"
#include "utility.h"
#include "TimeStamp.h"
#include "utilityQt.h"
QtIndexingDialog::QtIndexingDialog(QWidget* parent)
: QtWindow(true, parent)
@@ -206,7 +206,7 @@ void QtIndexingDialog::setupReport(
);
layout->addSpacing(12);
createMessageLabel(layout)->setText("Time: " + QString::fromStdString(utility::timeToString(time)));
createMessageLabel(layout)->setText("Time: " + QString::fromStdString(TimeStamp::secondsToString(time)));
layout->addSpacing(12);
addErrorWidget(layout);
@@ -77,9 +77,9 @@ void QtPreferencesWindow::handleNext()
if (needsRestart)
{
app->getDialogView(DialogView::UseCase::PROJECT_SETUP)->confirm(
"<p>Please restart the application for all changes to take effect.</p><p>Note: These changes may harm "
"the execution of the application. In case the application is not useable anymore, please run the "
"'resetPreferences.sh' script located in your install directory.</p>"
L"<p>Please restart the application for all changes to take effect.</p><p>Note: These changes may harm "
L"the execution of the application. In case the application is not useable anymore, please run the "
L"'resetPreferences.sh' script located in your install directory.</p>"
);
}
@@ -6,8 +6,9 @@
#include <QSysInfo>
#include "FilePath.h"
#include "utilityCxxHeaderDetection.h"
#include "logging.h"
#include "utility.h"
#include "utilityCxxHeaderDetection.h"
CxxVs10To14HeaderPathDetector::CxxVs10To14HeaderPathDetector(VisualStudioType type, bool isExpress, ApplicationArchitectureType architecture)
: PathDetector(visualStudioTypeToString(type) + (isExpress ? " Express" : "") + (architecture == APPLICATION_ARCHITECTURE_X86_64 ? " 64 Bit" : ""))
@@ -4,7 +4,7 @@
#include <QSysInfo>
#include "FilePath.h"
#include "utility.h"
#include "utilityApp.h"
JavaPathDetectorWindows::JavaPathDetectorWindows(const std::string javaVersion)
: JavaPathDetector("Java " + javaVersion + " for Windows", javaVersion)
+13
View File
@@ -1,5 +1,8 @@
#include "utilityApp.h"
#include <mutex>
#include <set>
#include <QProcess>
#include <QSysInfo>
#include <QThread>
@@ -281,3 +284,13 @@ std::string utility::getOsTypeString()
}
return "unknown";
}
ApplicationArchitectureType utility::getApplicationArchitectureType()
{
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) || defined(WIN64)
return APPLICATION_ARCHITECTURE_X86_64;
#else
return APPLICATION_ARCHITECTURE_X86_32;
#endif
return APPLICATION_ARCHITECTURE_UNKNOWN;
}
+6 -4
View File
@@ -1,10 +1,9 @@
#ifndef UTILITY_APP_H
#define UTILITY_APP_H
#include <mutex>
#include <set>
#include <string>
#include "ApplicationArchitectureType.h"
#include "OsType.h"
#include "FilePath.h"
@@ -12,8 +11,10 @@ class License;
namespace utility
{
std::pair<int, std::string> executeProcess(const std::string& command, const FilePath& workingDirectory = FilePath(), const int timeout = 30000);
std::string executeProcessUntilNoOutput(const std::string& command, const FilePath& workingDirectory, int waitTime = 10000);
std::pair<int, std::string> executeProcess(
const std::string& command, const FilePath& workingDirectory = FilePath(), const int timeout = 30000);
std::string executeProcessUntilNoOutput(
const std::string& command, const FilePath& workingDirectory, int waitTime = 10000);
int executeProcessAndGetExitCode(
const std::wstring& commandPath,
const std::vector<std::wstring>& commandArguments,
@@ -28,6 +29,7 @@ namespace utility
OsType getOsType();
std::string getOsTypeString();
ApplicationArchitectureType getApplicationArchitectureType();
}
#endif // UTILITY_APP_H
@@ -1,13 +1,14 @@
#include "SourceGroupJavaGradle.h"
#include "Application.h"
#include "DialogView.h"
#include "SourceGroupSettingsJavaGradle.h"
#include "FileSystem.h"
#include "logging.h"
#include "SourceGroupSettingsJavaGradle.h"
#include "ScopedFunctor.h"
#include "utility.h"
#include "utilityGradle.h"
#include "utilityJava.h"
#include "Application.h"
SourceGroupJavaGradle::SourceGroupJavaGradle(std::shared_ptr<SourceGroupSettingsJavaGradle> settings)
: m_settings(settings)
@@ -1,15 +1,16 @@
#include "SourceGroupJavaMaven.h"
#include "DialogView.h"
#include "Application.h"
#include "ApplicationSettings.h"
#include "SourceGroupSettingsJavaMaven.h"
#include "DialogView.h"
#include "FileSystem.h"
#include "logging.h"
#include "MessageStatus.h"
#include "ScopedFunctor.h"
#include "SourceGroupSettingsJavaMaven.h"
#include "utility.h"
#include "utilityJava.h"
#include "utilityMaven.h"
#include "Application.h"
SourceGroupJavaMaven::SourceGroupJavaMaven(std::shared_ptr<SourceGroupSettingsJavaMaven> settings)
: m_settings(settings)
+1
View File
@@ -5,6 +5,7 @@
#include "Application.h"
#include "ApplicationSettings.h"
#include "FilePath.h"
#include "logging.h"
#include "MessageStatus.h"
#include "TextAccess.h"
#include "utility.h"
@@ -11,6 +11,7 @@
#include "ParserClientImpl.h"
#include "TestIntermediateStorage.h"
#include "TextAccess.h"
#include "TimeStamp.h"
#include "utility.h"
#include "utilityString.h"