src: Apply clang-format and extend use to Java code (#973)

This commit is contained in:
Louis St-Amour
2020-04-19 14:11:48 +02:00
committed by GitHub
parent a6e02cc249
commit 224c89182a
94 changed files with 1998 additions and 1773 deletions
+4 -4
View File
@@ -4,6 +4,7 @@
#include "ApplicationSettings.h"
#include "ColorScheme.h"
#include "DialogView.h"
#include "FileLogger.h"
#include "FileSystem.h"
#include "GraphViewStyle.h"
#include "IDECommunicationController.h"
@@ -30,7 +31,6 @@
#include "tracing.h"
#include "utilityString.h"
#include "utilityUuid.h"
#include "FileLogger.h"
std::shared_ptr<Application> Application::s_instance;
std::string Application::s_uuid;
@@ -333,8 +333,7 @@ void Application::handleMessage(MessageRefresh* message)
{
TRACE("app refresh");
refreshProject(
message->all ? REFRESH_ALL_FILES : REFRESH_UPDATED_FILES, false);
refreshProject(message->all ? REFRESH_ALL_FILES : REFRESH_UPDATED_FILES, false);
}
void Application::handleMessage(MessageRefreshUI* message)
@@ -424,7 +423,8 @@ void Application::refreshProject(RefreshMode refreshMode, bool shallowIndexingRe
{
if (m_project && checkSharedMemory())
{
m_project->refresh(getDialogView(DialogView::UseCase::INDEXING), refreshMode, shallowIndexingRequested);
m_project->refresh(
getDialogView(DialogView::UseCase::INDEXING), refreshMode, shallowIndexingRequested);
if (!m_hasGUI && !m_project->isIndexing())
{
+2 -2
View File
@@ -21,9 +21,9 @@ bool AppPath::setSharedDataPath(const FilePath& path)
FilePath AppPath::getCxxIndexerPath()
{
#if _WIN32
const std::wstring cxxIndexerName(L"sourcetrail_indexer.exe");
const std::wstring cxxIndexerName(L"sourcetrail_indexer.exe");
#else
const std::wstring cxxIndexerName(L"sourcetrail_indexer");
const std::wstring cxxIndexerName(L"sourcetrail_indexer");
#endif
if (!m_cxxIndexerPath.empty())
+2 -2
View File
@@ -18,9 +18,9 @@
namespace
{
template <class Container>
void reverseErase(Container & container)
void reverseErase(Container& container)
{
while(!container.empty())
while (!container.empty())
container.pop_back();
}
} // namespace
@@ -577,10 +577,15 @@ void CodeController::handleMessage(MessageToNextCodeReference* message)
}
else if (referenceFileIndex == 0)
{
if (m_references[referenceIndex].lineNumber == m_localReferences[localReferenceIndex].lineNumber)
if (m_references[referenceIndex].lineNumber ==
m_localReferences[localReferenceIndex].lineNumber)
{
if ((next && m_references[referenceIndex].columnNumber < m_localReferences[localReferenceIndex].columnNumber) ||
(!next && m_references[referenceIndex].columnNumber > m_localReferences[localReferenceIndex].columnNumber))
if ((next &&
m_references[referenceIndex].columnNumber <
m_localReferences[localReferenceIndex].columnNumber) ||
(!next &&
m_references[referenceIndex].columnNumber >
m_localReferences[localReferenceIndex].columnNumber))
{
localReferenceIndex = -1;
}
@@ -591,8 +596,12 @@ void CodeController::handleMessage(MessageToNextCodeReference* message)
}
else
{
if ((next && m_references[referenceIndex].lineNumber < m_localReferences[localReferenceIndex].lineNumber) ||
(!next && m_references[referenceIndex].lineNumber > m_localReferences[localReferenceIndex].lineNumber))
if ((next &&
m_references[referenceIndex].lineNumber <
m_localReferences[localReferenceIndex].lineNumber) ||
(!next &&
m_references[referenceIndex].lineNumber >
m_localReferences[localReferenceIndex].lineNumber))
{
localReferenceIndex = -1;
}
@@ -1200,7 +1209,8 @@ std::pair<int, int> CodeController::findClosestReferenceIndex(
if (!next)
{
if (references[i].lineNumber < currentLineNumber ||
(references[i].lineNumber == currentLineNumber && references[i].columnNumber < currentColumnNumber))
(references[i].lineNumber == currentLineNumber &&
references[i].columnNumber < currentColumnNumber))
{
referenceIndex = static_cast<int>(i);
}
@@ -1209,8 +1219,10 @@ std::pair<int, int> CodeController::findClosestReferenceIndex(
return {referenceIndex, beforeCurrentFile ? -1 : 0};
}
}
else if (references[i].lineNumber > currentLineNumber ||
(references[i].lineNumber == currentLineNumber && references[i].columnNumber > currentColumnNumber))
else if (
references[i].lineNumber > currentLineNumber ||
(references[i].lineNumber == currentLineNumber &&
references[i].columnNumber > currentColumnNumber))
{
return {static_cast<int>(i), 0};
}
@@ -19,8 +19,8 @@
#include "MessageCodeShowDefinition.h"
#include "MessageDeactivateEdge.h"
#include "MessageErrorCountClear.h"
#include "MessageFocusChanged.h"
#include "MessageFlushUpdates.h"
#include "MessageFocusChanged.h"
#include "MessageFocusIn.h"
#include "MessageFocusOut.h"
#include "MessageListener.h"
@@ -12,8 +12,8 @@
#include "MessageActivateTrail.h"
#include "MessageActivateTrailEdge.h"
#include "MessageDeactivateEdge.h"
#include "MessageFocusChanged.h"
#include "MessageFlushUpdates.h"
#include "MessageFocusChanged.h"
#include "MessageFocusIn.h"
#include "MessageFocusOut.h"
#include "MessageGraphNodeBundleSplit.h"
+2 -1
View File
@@ -2,7 +2,8 @@
#include <algorithm>
CompositeView::CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId)
CompositeView::CompositeView(
ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId)
: View(viewLayout), m_direction(direction), m_name(name), m_tabId(tabId)
{
}
+2 -1
View File
@@ -20,7 +20,8 @@ public:
DIRECTION_VERTICAL
};
CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId);
CompositeView(
ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId);
virtual ~CompositeView();
Id getSchedulerId() const override;
+9 -2
View File
@@ -371,7 +371,13 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfGroupNode(GroupType type
}
GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
NodeType type, bool defined, bool isActive, bool isFocused, bool isCoFocused, bool hasChildren, bool hasQualifier)
NodeType type,
bool defined,
bool isActive,
bool isFocused,
bool isCoFocused,
bool hasChildren,
bool hasQualifier)
{
return getStyleForNodeType(
type.getNodeStyle(),
@@ -685,7 +691,8 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
if (isTrailEdge && isActive)
{
style.width = 3;
style.color = ColorScheme::getInstance()->getColor("graph/edge/call_trail_focus", style.color);
style.color = ColorScheme::getInstance()->getColor(
"graph/edge/call_trail_focus", style.color);
}
break;
@@ -22,9 +22,11 @@ struct CodeScrollParams
TOP
};
static CodeScrollParams toReference(const FilePath& filePath, Id locationId, Id scopeLocationId, Target target)
static CodeScrollParams toReference(
const FilePath& filePath, Id locationId, Id scopeLocationId, Target target)
{
return CodeScrollParams(Type::TO_REFERENCE, target, filePath, locationId, scopeLocationId, 0, 0, false);
return CodeScrollParams(
Type::TO_REFERENCE, target, filePath, locationId, scopeLocationId, 0, 0, false);
}
static CodeScrollParams toFile(const FilePath& filePath, Target target)
@@ -39,7 +41,8 @@ struct CodeScrollParams
static CodeScrollParams toValue(size_t value, bool inListMode)
{
return CodeScrollParams(Type::TO_VALUE, Target::VISIBLE, FilePath(), 0, 0, 0, value, inListMode);
return CodeScrollParams(
Type::TO_VALUE, Target::VISIBLE, FilePath(), 0, 0, 0, value, inListMode);
}
CodeScrollParams(
@@ -50,8 +53,7 @@ struct CodeScrollParams
Id scopeLocationId,
size_t line,
size_t value,
bool inListMode
)
bool inListMode)
: type(type)
, target(target)
, filePath(filePath)
+7 -10
View File
@@ -166,13 +166,10 @@ NodeTypeSet::MaskType NodeTypeSet::nodeTypeToMask(const NodeType& nodeType)
}
const std::vector<NodeType> NodeTypeSet::s_allNodeTypes = {
NodeType(NODE_SYMBOL), NodeType(NODE_TYPE),
NodeType(NODE_BUILTIN_TYPE), NodeType(NODE_MODULE),
NodeType(NODE_NAMESPACE), NodeType(NODE_PACKAGE),
NodeType(NODE_STRUCT), NodeType(NODE_CLASS),
NodeType(NODE_INTERFACE), NodeType(NODE_GLOBAL_VARIABLE),
NodeType(NODE_FIELD), NodeType(NODE_FUNCTION),
NodeType(NODE_METHOD), NodeType(NODE_ENUM),
NodeType(NODE_ENUM_CONSTANT), NodeType(NODE_TYPEDEF),
NodeType(NODE_TYPE_PARAMETER), NodeType(NODE_FILE),
NodeType(NODE_MACRO), NodeType(NODE_UNION)};
NodeType(NODE_SYMBOL), NodeType(NODE_TYPE), NodeType(NODE_BUILTIN_TYPE),
NodeType(NODE_MODULE), NodeType(NODE_NAMESPACE), NodeType(NODE_PACKAGE),
NodeType(NODE_STRUCT), NodeType(NODE_CLASS), NodeType(NODE_INTERFACE),
NodeType(NODE_GLOBAL_VARIABLE), NodeType(NODE_FIELD), NodeType(NODE_FUNCTION),
NodeType(NODE_METHOD), NodeType(NODE_ENUM), NodeType(NODE_ENUM_CONSTANT),
NodeType(NODE_TYPEDEF), NodeType(NODE_TYPE_PARAMETER), NodeType(NODE_FILE),
NodeType(NODE_MACRO), NodeType(NODE_UNION)};
+1 -1
View File
@@ -1,9 +1,9 @@
#ifndef TOKEN_H
#define TOKEN_H
#include <string>
#include <typeinfo>
#include <vector>
#include <string>
#include "TokenComponent.h"
#include "types.h"
@@ -361,7 +361,8 @@ std::vector<Id> SqliteIndexStorage::addSourceLocations(const std::vector<Storage
static_cast<uint16_t>(data.endCol),
data.type);
std::map<TempSourceLocation, uint32_t>& index = m_tempSourceLocationIndices[static_cast<uint32_t>(data.fileNodeId)];
std::map<TempSourceLocation, uint32_t>& index =
m_tempSourceLocationIndices[static_cast<uint32_t>(data.fileNodeId)];
std::map<TempSourceLocation, uint32_t>::const_iterator it = index.find(tempLoc);
if (it != index.end())
{
+2 -1
View File
@@ -272,7 +272,8 @@ void Project::load(std::shared_ptr<DialogView> dialogView)
}
}
void Project::refresh(std::shared_ptr<DialogView> dialogView, RefreshMode refreshMode, bool shallowIndexingRequested)
void Project::refresh(
std::shared_ptr<DialogView> dialogView, RefreshMode refreshMode, bool shallowIndexingRequested)
{
if (m_refreshStage != RefreshStageType::NONE)
{
+2 -1
View File
@@ -37,7 +37,8 @@ public:
void load(std::shared_ptr<DialogView> dialogView);
void refresh(std::shared_ptr<DialogView> dialogView, RefreshMode refreshMode, bool shallowIndexingRequested);
void refresh(
std::shared_ptr<DialogView> dialogView, RefreshMode refreshMode, bool shallowIndexingRequested);
RefreshInfo getRefreshInfo(RefreshMode mode) const;
+2 -2
View File
@@ -82,8 +82,8 @@ RefreshInfo RefreshInfoGenerator::getRefreshInfoForUpdatedFiles(
// 2.3) Handle files that are referenced by the files that will be cleared. These will be
// re-indexed on the fly. However, we do not
// need to clear files that are also referenced by unchanged source files, because otherwise
//we will lose these connections.
// need to clear files that are also referenced by unchanged source files, because
//otherwise we will lose these connections.
// 2.3.1) Get all source file paths that will not be cleared.
// - Initially this list contains all source file paths the project would index right now.
// - Then we remove all source files that will be cleared
+2 -2
View File
@@ -340,10 +340,10 @@ void ApplicationSettings::setVerboseIndexerLoggingEnabled(bool value)
FilePath ApplicationSettings::getLogDirectoryPath() const
{
return FilePath(getValue<std::wstring>(
"application/log_directory_path", UserPaths::getLogPath().getAbsolute().wstr()));
"application/log_directory_path", UserPaths::getLogPath().getAbsolute().wstr()));
}
void ApplicationSettings::setLogDirectoryPath(const FilePath &path)
void ApplicationSettings::setLogDirectoryPath(const FilePath& path)
{
setValue<std::wstring>("application/log_directory_path", path.wstr());
}
@@ -19,10 +19,9 @@ namespace commandline
CommandLineParser::CommandLineParser(const std::string& version): m_version(version)
{
po::options_description options("Options");
options.add_options()
("help,h", "Print this help message")
("version,v", "Version of Sourcetrail")
("project-file", po::value<std::string>(), "Open Sourcetrail with this project (.srctrlprj)");
options.add_options()("help,h", "Print this help message")(
"version,v", "Version of Sourcetrail")(
"project-file", po::value<std::string>(), "Open Sourcetrail with this project (.srctrlprj)");
m_options.add(options);
m_positional.add("project-file", 1);
@@ -30,7 +29,7 @@ CommandLineParser::CommandLineParser(const std::string& version): m_version(vers
m_commands.push_back(std::make_unique<commandline::CommandlineCommandConfig>(this));
m_commands.push_back(std::make_unique<commandline::CommandlineCommandIndex>(this));
for (auto& command : m_commands)
for (auto& command: m_commands)
{
command->setup();
}
@@ -19,12 +19,11 @@ CommandlineCommandIndex::~CommandlineCommandIndex() {}
void CommandlineCommandIndex::setup()
{
po::options_description options("Config Options");
options.add_options()
("help,h", "Print this help message")
("incomplete,i", "Also reindex incomplete files (files with errors)")
("full,f", "Index full project (omit to only index new/changed files)")
("shallow,s", "Build a shallow index is supported by the project")
("project-file", po::value<std::string>(), "Project file to index (.srctrlprj)");
options.add_options()("help,h", "Print this help message")(
"incomplete,i", "Also reindex incomplete files (files with errors)")(
"full,f", "Index full project (omit to only index new/changed files)")(
"shallow,s", "Build a shallow index is supported by the project")(
"project-file", po::value<std::string>(), "Project file to index (.srctrlprj)");
m_options.add(options);
m_positional.add("project-file", 1);
@@ -14,16 +14,17 @@ SharedMemory::ScopedAccess::ScopedAccess(SharedMemory* memory)
{
try
{
m_memory = boost::interprocess::managed_shared_memory(boost::interprocess::open_only, memory->getMemoryName().c_str());
m_memory = boost::interprocess::managed_shared_memory(
boost::interprocess::open_only, memory->getMemoryName().c_str());
}
catch (boost::interprocess::interprocess_exception& e)
{
LOG_ERROR_STREAM(
<< "boost exception thrown at ScopedAccess constructor - " << memory->getMemoryName() << ": "
<< e.what());
<< "boost exception thrown at ScopedAccess constructor - " << memory->getMemoryName()
<< ": " << e.what());
// Behaves the same as the initializer construction, with the error printed out
//throw e;
// throw e;
boost::interprocess::permissions permissions;
permissions.set_unrestricted();
@@ -32,10 +33,8 @@ SharedMemory::ScopedAccess::ScopedAccess(SharedMemory* memory)
memory->getMemoryName().c_str(),
memory->getInitialMemorySize(),
0,
permissions
);
permissions);
}
}
SharedMemory::ScopedAccess::~ScopedAccess() {}
@@ -10,7 +10,10 @@ class MessageLoadProject: public Message<MessageLoadProject>
{
public:
MessageLoadProject(
const FilePath& filePath, bool settingsChanged = false, RefreshMode refreshMode = REFRESH_NONE, bool shallowIndexingRequested = false)
const FilePath& filePath,
bool settingsChanged = false,
RefreshMode refreshMode = REFRESH_NONE,
bool shallowIndexingRequested = false)
: projectSettingsFilePath(filePath)
, settingsChanged(settingsChanged)
, refreshMode(refreshMode)
@@ -11,7 +11,7 @@ public:
return "MessageRefreshUIState";
}
MessageRefreshUIState(bool isAfterIndexing) : isAfterIndexing(isAfterIndexing) {}
MessageRefreshUIState(bool isAfterIndexing): isAfterIndexing(isAfterIndexing) {}
bool isAfterIndexing = false;
};
@@ -14,8 +14,7 @@ public:
};
MessageFocusChanged(ViewType type, Id tokenOrLocationId)
: type(type)
, tokenOrLocationId(tokenOrLocationId)
: type(type), tokenOrLocationId(tokenOrLocationId)
{
setIsLogged(false);
setSchedulerId(TabId::currentTab());
@@ -7,8 +7,7 @@
class MessageFocusedSearchView: public Message<MessageFocusedSearchView>
{
public:
MessageFocusedSearchView(bool focusIn)
: focusIn(focusIn)
MessageFocusedSearchView(bool focusIn): focusIn(focusIn)
{
setIsLogged(false);
setSchedulerId(TabId::currentTab());