diff --git a/CMakeLists.txt b/CMakeLists.txt index 9254ef8b..93763b59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,13 @@ ENDIF(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) set(PROJECT_NAME Sourcetrail) set(PROJECT_NAME_LOWER_CASE sourcetrail) +# speed up recompiling on unix with ccache +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + # Support Unix Makefiles and Ninja + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") +endif() + set(APP_PROJECT_NAME "${PROJECT_NAME}") set(LIB_LICENSE_PROJECT_NAME "${PROJECT_NAME}_lib_license") set(LIB_GUI_PROJECT_NAME "${PROJECT_NAME}_lib_gui") diff --git a/cmake/PrivateKey.h.in b/cmake/PrivateKey.h.in index 4814520f..aeb08000 100644 --- a/cmake/PrivateKey.h.in +++ b/cmake/PrivateKey.h.in @@ -5,6 +5,6 @@ #include -const std::string PRIVATE_KEY = "@KEY@"; +const char PRIVATE_KEY[] = "@KEY@"; #endif // PRIVATE_KEY_H diff --git a/cmake/PublicKey.h.in b/cmake/PublicKey.h.in index ba94e0a7..7872a6e8 100644 --- a/cmake/PublicKey.h.in +++ b/cmake/PublicKey.h.in @@ -5,6 +5,6 @@ #include -const std::string PUBLIC_KEY = "@KEY@"; +const char PUBLIC_KEY[] = "@KEY@"; #endif // PUBLIC_KEY_H diff --git a/script/clean.sh b/script/clean.sh index 4aef2ad7..0178737e 100755 --- a/script/clean.sh +++ b/script/clean.sh @@ -42,7 +42,6 @@ fi # Remove folders and contents rm -rf java_indexer/bin -rm -rf java_indexer/lib rm -rf build # Remove log files diff --git a/src/app/main.cpp b/src/app/main.cpp index 78f9e993..161f4ace 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -1,7 +1,5 @@ #include "includes.h" // defines 'void setup(int argc, char *argv[])' -#include - #include "Application.h" #include "data/indexer/IndexerFactory.h" #include "data/indexer/IndexerFactoryModuleJava.h" @@ -36,12 +34,6 @@ #include "utility/Version.h" #include "version.h" -void signalHandler(int signum) -{ - std::cout << "interrupt running tasks" << std::endl; - MessageInterruptTasks().dispatch(); -} - void setupLogging() { LogManager* logManager = LogManager::getInstance().get(); @@ -269,24 +261,6 @@ int main(int argc, char *argv[]) { MessageEnteredLicense(checker->getCurrentLicenseType()).dispatch(); } -#ifdef _WIN32 - signal(SIGINT, signalHandler); - signal(SIGTERM, signalHandler); - signal(SIGABRT, signalHandler); -#else - struct sigaction sa; - sa.sa_handler = signalHandler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_RESTART; - if (sigaction(SIGINT, &sa, NULL)) - { - std::cout << "Cant install SIGINT handler" << std::endl; - } - if (sigaction(SIGHUP, &sa, NULL)) - { - std::cout << "Cant install SIGHUP handler" << std::endl; - } -#endif } if (commandLineParser.hasError() ) diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 56b12759..119fbe00 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -277,25 +277,14 @@ void Application::handleMessage(MessageLoadProject* message) if (m_project && projectSettingsFilePath == m_project->getProjectSettingsFilePath()) { - if (message->forceRefresh && m_hasGUI) + if (message->forceRefresh) { m_project->setStateSettingsUpdated(); refreshProject(false); } - return; } - createAndLoadProject(projectSettingsFilePath); - - if (message->forceRefresh) - { - refreshProject(true); - } - else if (!m_hasGUI) - { - refreshProject(false); - } } void Application::handleMessage(MessageRefresh* message) diff --git a/src/lib/component/ComponentManager.cpp b/src/lib/component/ComponentManager.cpp index 9449b287..62b35eaa 100644 --- a/src/lib/component/ComponentManager.cpp +++ b/src/lib/component/ComponentManager.cpp @@ -71,7 +71,7 @@ void ComponentManager::setup(ViewLayout* viewLayout) void ComponentManager::clearComponents() { - for (std::shared_ptr component : m_components) + for (const std::shared_ptr& component : m_components) { Controller* controller = component->getController(); @@ -84,7 +84,7 @@ void ComponentManager::clearComponents() void ComponentManager::refreshViews() { - for (std::shared_ptr component : m_components) + for (const std::shared_ptr& component : m_components) { View* view = component->getView(); @@ -94,12 +94,12 @@ void ComponentManager::refreshViews() } } - for (std::shared_ptr view : m_compositeViews) + for (const std::shared_ptr& view : m_compositeViews) { view->refreshView(); } - for (std::shared_ptr view : m_tabbedViews) + for (const std::shared_ptr& view : m_tabbedViews) { view->refreshView(); } diff --git a/src/lib/component/controller/BookmarkController.cpp b/src/lib/component/controller/BookmarkController.cpp index 021eec53..089e58be 100644 --- a/src/lib/component/controller/BookmarkController.cpp +++ b/src/lib/component/controller/BookmarkController.cpp @@ -76,7 +76,7 @@ std::shared_ptr BookmarkController::getBookmarkForActiveToken() const { if (!m_activeEdgeIds.empty()) { - for (std::shared_ptr edgeBookmark: getAllEdgeBookmarks()) + for (const std::shared_ptr& edgeBookmark: getAllEdgeBookmarks()) { if (!m_activeNodeIds.empty() && edgeBookmark->getActiveNodeId() == m_activeNodeIds.front() && utility::isPermutation(edgeBookmark->getEdgeIds(), m_activeEdgeIds)) @@ -87,7 +87,7 @@ std::shared_ptr BookmarkController::getBookmarkForActiveToken() const } else { - for (std::shared_ptr nodeBookmark: getAllNodeBookmarks()) + for (const std::shared_ptr& nodeBookmark: getAllNodeBookmarks()) { if (utility::isPermutation(nodeBookmark->getNodeIds(), m_activeNodeIds)) { @@ -101,7 +101,7 @@ std::shared_ptr BookmarkController::getBookmarkForActiveToken() const std::shared_ptr BookmarkController::getBookmarkForNodeId(Id nodeId) const { - for (std::shared_ptr nodeBookmark: getAllNodeBookmarks()) + for (const std::shared_ptr& nodeBookmark: getAllNodeBookmarks()) { if (nodeBookmark->getNodeIds().size() == 1 && nodeBookmark->getNodeIds()[0] == nodeId) { @@ -376,11 +376,11 @@ std::vector> BookmarkController::getAllBookmarks() con std::vector> bookmarks; - for (std::shared_ptr nodeBookmark: getAllNodeBookmarks()) + for (const std::shared_ptr& nodeBookmark: getAllNodeBookmarks()) { bookmarks.push_back(nodeBookmark); } - for (std::shared_ptr edgeBookmark: getAllEdgeBookmarks()) + for (const std::shared_ptr& edgeBookmark: getAllEdgeBookmarks()) { bookmarks.push_back(edgeBookmark); } @@ -455,7 +455,7 @@ std::vector> BookmarkController::getFilteredBookmarks( } else if (filter == MessageDisplayBookmarks::BookmarkFilter::NODES) { - for (std::shared_ptr bookmark: bookmarks) + for (const std::shared_ptr& bookmark: bookmarks) { if (std::dynamic_pointer_cast(bookmark)) { @@ -465,7 +465,7 @@ std::vector> BookmarkController::getFilteredBookmarks( } else if (filter == MessageDisplayBookmarks::BookmarkFilter::EDGES) { - for (std::shared_ptr bookmark: bookmarks) + for (const std::shared_ptr& bookmark: bookmarks) { if (std::dynamic_pointer_cast(bookmark)) { diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index 2564dfb0..980ccf69 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -431,7 +431,7 @@ void CodeController::expandVisibleSnippets(std::vector* snipp continue; } - for (CodeSnippetParams newSnippet : newSnippets) + for (CodeSnippetParams& newSnippet : newSnippets) { newSnippet.isDeclaration = oldSnippet.isDeclaration; newSnippet.isDefinition = oldSnippet.isDefinition; diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index 45c213a6..540078eb 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -106,7 +106,7 @@ void GraphController::handleMessage(MessageActivateTokens* message) else if (message->isAggregation) { bool isInheritanceChain = true; - for (auto edge : m_dummyEdges) + for (const auto& edge : m_dummyEdges) { if (!edge->data->isType(Edge::EDGE_INHERITANCE)) { @@ -117,7 +117,7 @@ void GraphController::handleMessage(MessageActivateTokens* message) if (isInheritanceChain) { - for (auto node : m_dummyNodes) + for (auto& node : m_dummyNodes) { node->bundleInfo.layoutVertical = true; } @@ -472,7 +472,7 @@ void GraphController::createDummyGraphForTokenIds(const std::vector& tokenId } ); - for (std::shared_ptr node : dummyNodes) + for (const std::shared_ptr& node : dummyNodes) { node->hasParent = false; @@ -558,7 +558,7 @@ std::vector> GraphController::createDummyNodeTopDown( accessKind = access->getAccess(); } - for (std::shared_ptr dummy : result->subNodes) + for (const std::shared_ptr& dummy : result->subNodes) { if (dummy->accessKind == accessKind) { @@ -586,7 +586,7 @@ std::vector> GraphController::createDummyNodeTopDown( std::vector GraphController::getExpandedNodeIds() const { std::vector nodeIds; - for (std::pair> p : m_dummyGraphNodes) + for (const std::pair>& p : m_dummyGraphNodes) { DummyNode* oldNode = p.second.get(); if (oldNode->expanded && !oldNode->autoExpanded && oldNode->isGraphNode() && @@ -634,13 +634,13 @@ bool GraphController::setActive(const std::vector& activeTokenIds, bool show if (activeTokenIds.size() > 0) { noActive = true; - for (std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { setNodeActiveRecursive(node.get(), activeTokenIds, &noActive); } } - for (std::shared_ptr edge : m_dummyEdges) + for (const std::shared_ptr& edge : m_dummyEdges) { if (!edge->data) { @@ -673,7 +673,7 @@ void GraphController::setVisibility(bool noActive) { TRACE(); - for (std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { setNodeVisibilityRecursiveBottomUp(node.get(), noActive); } @@ -700,7 +700,7 @@ void GraphController::setNodeActiveRecursive(DummyNode* node, const std::vector< } } - for (std::shared_ptr subNode : node->subNodes) + for (const std::shared_ptr& subNode : node->subNodes) { setNodeActiveRecursive(subNode.get(), activeTokenIds, noActive); } @@ -727,7 +727,7 @@ bool GraphController::setNodeVisibilityRecursiveBottomUp(DummyNode* node, bool n return false; } - for (std::shared_ptr subNode : node->subNodes) + for (const std::shared_ptr& subNode : node->subNodes) { if (setNodeVisibilityRecursiveBottomUp(subNode.get(), noActive)) { @@ -759,7 +759,7 @@ void GraphController::setNodeVisibilityRecursiveTopDown(DummyNode* node, bool pa if ((node->isGraphNode() && node->isExpanded()) || (node->isAccessNode() && (node->accessKind == ACCESS_NONE || parentExpanded))) { - for (std::shared_ptr subNode : node->subNodes) + for (const std::shared_ptr& subNode : node->subNodes) { if (!subNode->isQualifierNode()) { @@ -775,7 +775,7 @@ void GraphController::bundleNodes() TRACE(); // evaluate top level nodes - for (std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { if (!node->isGraphNode() || !node->visible) { @@ -876,7 +876,7 @@ void GraphController::bundleNodes() // bundle bool fileOrMacroActive = false; - for (std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { if (node->bundleInfo.isActive && ( node->data->isType(Node::NODE_FILE | Node::NODE_MACRO) || @@ -1045,7 +1045,7 @@ void GraphController::bundleNodesAndEdgesMatching( std::vector bundledNodes = bundleNode->getAllBundledNodes(); for (const DummyNode* node : bundledNodes) { - for (std::shared_ptr edge : m_dummyEdges) + for (const std::shared_ptr& edge : m_dummyEdges) { bool owner = (edge->ownerId == node->data->getId()); bool target = (edge->targetId == node->data->getId()); @@ -1056,7 +1056,7 @@ void GraphController::bundleNodesAndEdgesMatching( } DummyEdge* bundleEdgePtr = nullptr; - for (std::shared_ptr bundleEdge : bundleEdges) + for (const std::shared_ptr& bundleEdge : bundleEdges) { if ((owner && bundleEdge->ownerId == edge->targetId) || (target && bundleEdge->ownerId == edge->ownerId)) @@ -1185,7 +1185,7 @@ void GraphController::bundleNodesByType() LOG_ERROR("Nodes left after bundling for overview"); } - for (std::shared_ptr bundleNode : m_dummyNodes) + for (const std::shared_ptr& bundleNode : m_dummyNodes) { if (!bundleNode->isBundleNode()) { @@ -1195,7 +1195,7 @@ void GraphController::bundleNodesByType() if (bundleNode->name == "Namespaces") { std::list> nodes; - for (std::shared_ptr node : bundleNode->bundledNodes) + for (const std::shared_ptr& node : bundleNode->bundledNodes) { nodes.push_back(node); } @@ -1210,7 +1210,7 @@ void GraphController::bundleNodesByType() "Anonymous Namespaces" ); - for (std::shared_ptr node : nodes) + for (const std::shared_ptr& node : nodes) { bundleNode->bundledNodes.insert(node); } @@ -1229,7 +1229,7 @@ void GraphController::addCharacterIndex() { // Remove index characters from last time DummyNode::BundledNodesSet newNodes; - for (const std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { if (!node->isTextNode()) { @@ -1266,12 +1266,12 @@ void GraphController::layoutNesting() { TRACE(); - for (std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { layoutNestingRecursive(node.get()); } - for (std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { layoutToGrid(node.get()); } @@ -1351,7 +1351,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const // Horizontal layouting is currently not used, but left in place for experimentation. bool layoutHorizontal = false; - for (std::shared_ptr subNode : node->subNodes) + for (const std::shared_ptr& subNode : node->subNodes) { if (!subNode->visible) { @@ -1366,7 +1366,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const } } - for (std::shared_ptr subNode : node->subNodes) + for (const std::shared_ptr& subNode : node->subNodes) { if (!subNode->visible || subNode->isExpandToggleNode()) { @@ -1417,7 +1417,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const node->size.x = margins.left + width + margins.right; node->size.y = margins.top + margins.charHeight + margins.spacingA + y + height + margins.bottom; - for (std::shared_ptr subNode : node->subNodes) + for (const std::shared_ptr& subNode : node->subNodes) { if (!subNode->visible) { @@ -1459,7 +1459,7 @@ void GraphController::addExpandToggleNode(DummyNode* node) const continue; } - for (std::shared_ptr subSubNode : subNode->subNodes) + for (const std::shared_ptr& subSubNode : subNode->subNodes) { if (subSubNode->visible && (!subSubNode->isGraphNode() || !subSubNode->data->isImplicit())) { @@ -1493,7 +1493,7 @@ void GraphController::layoutToGrid(DummyNode* node) const DummyNode* lastAccessNode = nullptr; DummyNode* expandToggleNode = nullptr; - for (std::shared_ptr subNode : node->subNodes) + for (const std::shared_ptr& subNode : node->subNodes) { if (!subNode->visible) { @@ -1565,7 +1565,7 @@ DummyNode* GraphController::getDummyGraphNodeById(Id tokenId) const return it->second.get(); } - for (std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { if (node->tokenId == tokenId) { @@ -1594,7 +1594,7 @@ void GraphController::buildGraph( void GraphController::forEachDummyNodeRecursive(std::function func) { - for (std::shared_ptr node : m_dummyNodes) + for (const std::shared_ptr& node : m_dummyNodes) { node->forEachDummyNodeRecursive(func); } @@ -1602,7 +1602,7 @@ void GraphController::forEachDummyNodeRecursive(std::function void GraphController::forEachDummyEdge(std::function func) { - for (std::shared_ptr edge : m_dummyEdges) + for (const std::shared_ptr& edge : m_dummyEdges) { func(edge.get()); } diff --git a/src/lib/component/controller/LogController.cpp b/src/lib/component/controller/LogController.cpp index 2ec99a29..cf0eb53a 100644 --- a/src/lib/component/controller/LogController.cpp +++ b/src/lib/component/controller/LogController.cpp @@ -119,7 +119,7 @@ void LogController::syncLogs() } std::vector logs; - for (Log log : m_logs) + for (const Log& log : m_logs) { if (log.type & m_logLevel) { diff --git a/src/lib/component/controller/helper/BucketLayouter.cpp b/src/lib/component/controller/helper/BucketLayouter.cpp index 614a7f02..c0056aae 100644 --- a/src/lib/component/controller/helper/BucketLayouter.cpp +++ b/src/lib/component/controller/helper/BucketLayouter.cpp @@ -31,7 +31,7 @@ int Bucket::getHeight() const bool Bucket::hasNode(std::shared_ptr node) const { - for (std::shared_ptr n : m_nodes) + for (const std::shared_ptr& n : m_nodes) { if (node == n) { @@ -66,7 +66,7 @@ void Bucket::preLayout(Vec2i viewSize) m_height = 0; - for (std::shared_ptr node : m_nodes) + for (const std::shared_ptr& node : m_nodes) { node->position.x = x; node->position.y = y; @@ -93,7 +93,7 @@ void Bucket::layout(int x, int y, int width, int height) int cx = GraphViewStyle::toGridOffset(x + (width - m_width) / 2); int cy = GraphViewStyle::toGridOffset(y + (height - m_height) / 2); - for (std::shared_ptr node : m_nodes) + for (const std::shared_ptr& node : m_nodes) { node->position.x = node->position.x + cx; node->position.y = node->position.y + cy; @@ -120,7 +120,7 @@ void BucketLayouter::createBuckets( } bool activeNodeAdded = false; - for (std::shared_ptr node : nodes) + for (const std::shared_ptr& node : nodes) { if (node->hasActiveSubNode() || !edges.size()) { @@ -140,7 +140,7 @@ void BucketLayouter::createBuckets( } std::vector remainingEdges; - for (std::shared_ptr edge : edges) + for (const std::shared_ptr& edge : edges) { remainingEdges.push_back(edge.get()); } @@ -264,7 +264,7 @@ std::vector> BucketLayouter::getSortedNodes() std::shared_ptr BucketLayouter::findTopMostDummyNodeRecursive( std::vector>& nodes, Id tokenId, std::shared_ptr top ){ - for (std::shared_ptr node : nodes) + for (const std::shared_ptr& node : nodes) { std::shared_ptr t = (top ? top : node); diff --git a/src/lib/component/controller/helper/DummyNode.h b/src/lib/component/controller/helper/DummyNode.h index a131e4a7..555c6297 100644 --- a/src/lib/component/controller/helper/DummyNode.h +++ b/src/lib/component/controller/helper/DummyNode.h @@ -110,7 +110,7 @@ public: bool hasVisibleSubNode() const { - for (std::shared_ptr node : subNodes) + for (const std::shared_ptr& node : subNodes) { if (node->visible) { @@ -128,7 +128,7 @@ public: return true; } - for (std::shared_ptr node : subNodes) + for (const std::shared_ptr& node : subNodes) { if (node->hasActiveSubNode()) { @@ -148,7 +148,7 @@ public: count += 1; } - for (std::shared_ptr node : subNodes) + for (const std::shared_ptr& node : subNodes) { count += node->getActiveSubNodeCount(); } @@ -163,7 +163,7 @@ public: return true; } - for (std::shared_ptr node : subNodes) + for (const std::shared_ptr& node : subNodes) { if (node->hasConnectedSubNode()) { @@ -183,7 +183,7 @@ public: nodes.push_back(this); } - for (std::shared_ptr node : subNodes) + for (const std::shared_ptr& node : subNodes) { utility::append(nodes, node->getConnectedSubNodes()); } @@ -194,7 +194,7 @@ public: std::vector getAllBundledNodes() const { std::vector nodes; - for (std::shared_ptr node : bundledNodes) + for (const std::shared_ptr& node : bundledNodes) { utility::append(nodes, node->getConnectedSubNodes()); } @@ -215,7 +215,7 @@ public: { func(this); - for (std::shared_ptr node : subNodes) + for (const std::shared_ptr& node : subNodes) { node->forEachDummyNodeRecursive(func); } @@ -230,7 +230,7 @@ public: this->bundleId = bundleId; - for (std::shared_ptr node : bundledNodes) + for (const std::shared_ptr& node : bundledNodes) { bundleId = node->setBundleIdRecursive(bundleId); } @@ -247,11 +247,11 @@ public: } size_t subNodeCount = 0; - for (std::shared_ptr subNode : subNodes) + for (const std::shared_ptr& subNode : subNodes) { if (subNode->isAccessNode()) { - for (std::shared_ptr subSubNode : subNode->subNodes) + for (const std::shared_ptr& subSubNode : subNode->subNodes) { if (subSubNode->isGraphNode() && !subSubNode->data->isImplicit()) { @@ -268,11 +268,11 @@ public: { std::map> subGraphNodes; - for (std::shared_ptr subNode : subNodes) + for (const std::shared_ptr& subNode : subNodes) { if (subNode->isAccessNode()) { - for (std::shared_ptr subSubNode : subNode->subNodes) + for (const std::shared_ptr& subSubNode : subNode->subNodes) { if (subSubNode->isGraphNode()) { @@ -287,7 +287,7 @@ public: void replaceSubGraphNodes(std::map> subGraphNodes) const { - for (std::shared_ptr subNode : subNodes) + for (const std::shared_ptr& subNode : subNodes) { if (subNode->isAccessNode()) { @@ -313,7 +313,7 @@ public: std::vector> getAccessNodes() const { std::vector> accessNodes; - for (std::shared_ptr subNode : subNodes) + for (const std::shared_ptr& subNode : subNodes) { if (subNode->isAccessNode()) { diff --git a/src/lib/component/controller/helper/TrailLayouter.cpp b/src/lib/component/controller/helper/TrailLayouter.cpp index 68d843ce..2f94bd45 100644 --- a/src/lib/component/controller/helper/TrailLayouter.cpp +++ b/src/lib/component/controller/helper/TrailLayouter.cpp @@ -42,12 +42,12 @@ void TrailLayouter::buildGraph( const std::vector>& dummyEdges, const std::map& topLevelAncestorIds) { - for (const std::shared_ptr dummyNode : dummyNodes) + for (const std::shared_ptr& dummyNode : dummyNodes) { addNode(dummyNode); } - for (const std::shared_ptr dummyEdge : dummyEdges) + for (const std::shared_ptr& dummyEdge : dummyEdges) { dummyEdge->path.clear(); @@ -267,7 +267,7 @@ void TrailLayouter::addVirtualNodes() { std::vector> newEdges; - for (std::shared_ptr edge : m_allEdges) + for (const std::shared_ptr& edge : m_allEdges) { for (int i = edge->origin->level + 1; i < edge->target->level; i++) { @@ -304,7 +304,7 @@ void TrailLayouter::addVirtualNodes() void TrailLayouter::buildColumns() { - for (std::shared_ptr node : m_allNodes) + for (const std::shared_ptr& node : m_allNodes) { int level = node->level + 1; for (int i = m_nodesPerCol.size(); i <= level; i++) @@ -501,7 +501,7 @@ void TrailLayouter::moveNodesToAveragePosition(std::vector nodes, bo } int averagePosition = 0; - for (std::pair> p : averagePositions) + for (const std::pair>& p : averagePositions) { averagePosition += p.first; } @@ -584,7 +584,7 @@ void TrailLayouter::moveNodesToAveragePosition(std::vector nodes, bo void TrailLayouter::retrievePositions(const std::map& topLevelAncestorIds) { - for (std::shared_ptr node : m_allNodes) + for (std::shared_ptr& node : m_allNodes) { if (node->dummyNode) { @@ -592,7 +592,7 @@ void TrailLayouter::retrievePositions(const std::map& topLevelAncestorId } } - for (std::shared_ptr edge : m_allEdges) + for (std::shared_ptr& edge : m_allEdges) { if (edge->virtualNodes.size()) { @@ -613,7 +613,7 @@ void TrailLayouter::retrievePositions(const std::map& topLevelAncestorId void TrailLayouter::print() { std::cout << "graph: " << std::endl; - for (std::shared_ptr node : m_allNodes) + for (std::shared_ptr& node : m_allNodes) { if (node->id) { @@ -624,7 +624,7 @@ void TrailLayouter::print() } std::cout << std::endl; - for (std::shared_ptr edge : m_allEdges) + for (std::shared_ptr& edge : m_allEdges) { if (edge->origin->id || edge->target->id) { @@ -686,7 +686,7 @@ void TrailLayouter::addEdge(const std::shared_ptr dummyEdge, const st edge->origin = origin->second; edge->target = target->second; - for (std::shared_ptr e : m_allEdges) + for (std::shared_ptr& e : m_allEdges) { if ((e->origin == edge->origin && e->target == edge->target) || (e->origin == edge->target && e->target == edge->origin)) diff --git a/src/lib/data/TaskFinishParsing.cpp b/src/lib/data/TaskFinishParsing.cpp index 1eeac33f..46f3c96a 100644 --- a/src/lib/data/TaskFinishParsing.cpp +++ b/src/lib/data/TaskFinishParsing.cpp @@ -4,6 +4,8 @@ #include "data/storage/PersistentStorage.h" #include "utility/messaging/type/MessageFinishedParsing.h" #include "utility/messaging/type/MessageStatus.h" +#include "utility/messaging/type/MessageQuitApplication.h" +#include "utility/messaging/type/MessageStatus.h" #include "utility/scheduling/Blackboard.h" #include "utility/utility.h" #include "Application.h" @@ -66,6 +68,19 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa bool interruptedIndexing = false; blackboard->get("interrupted_indexing", interruptedIndexing); + ErrorCountInfo errorInfo = m_storageAccess->getErrorCount(); + + std::stringstream ss; + ss << "Finished indexing: "; + ss << indexedSourceFileCount << "/" << sourceFileCount << " source files indexed; "; + ss << utility::timeToString(time); + ss << "; " << errorInfo.total << " error" << (errorInfo.total != 1 ? "s" : ""); + if (errorInfo.fatal > 0) + { + ss << " (" << errorInfo.fatal << " fatal)"; + } + MessageStatus(ss.str(), false, false).dispatch(); + StorageStats stats = m_storageAccess->getStorageStats(); dialogView->finishedIndexingDialog( indexedSourceFileCount, @@ -73,7 +88,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa stats.completedFileCount, stats.fileCount, time, - m_storageAccess->getErrorCount(), + errorInfo, interruptedIndexing ); diff --git a/src/lib/data/fulltextsearch/FullTextSearchIndex.cpp b/src/lib/data/fulltextsearch/FullTextSearchIndex.cpp index 03d49fa1..b51e96c0 100644 --- a/src/lib/data/fulltextsearch/FullTextSearchIndex.cpp +++ b/src/lib/data/fulltextsearch/FullTextSearchIndex.cpp @@ -26,7 +26,7 @@ std::vector FullTextSearchIndex::searchForTerm(const std:: std::vector ret; FullTextSearchResult hit; - for (auto f : m_files) + for (auto& f : m_files) { hit.fileId = f.fileId; hit.positions = f.array.searchForTerm(term); diff --git a/src/lib/data/graph/Token.cpp b/src/lib/data/graph/Token.cpp index 8123632a..c3eda8ba 100644 --- a/src/lib/data/graph/Token.cpp +++ b/src/lib/data/graph/Token.cpp @@ -43,7 +43,7 @@ void Token::removeLocationId(Id locationId) Token::Token(const Token& other) : m_id(other.m_id) { - for (std::shared_ptr component: other.m_components) + for (const std::shared_ptr& component: other.m_components) { addComponent(component->copy()); } diff --git a/src/lib/data/indexer/IndexerComposite.cpp b/src/lib/data/indexer/IndexerComposite.cpp index b872d2e8..c39ae70d 100644 --- a/src/lib/data/indexer/IndexerComposite.cpp +++ b/src/lib/data/indexer/IndexerComposite.cpp @@ -33,7 +33,7 @@ std::shared_ptr IndexerComposite::index( void IndexerComposite::interrupt() { - for (auto it: m_indexers) + for (auto& it: m_indexers) { it.second->interrupt(); } diff --git a/src/lib/data/indexer/interprocess/InterprocessIndexerCommandManager.cpp b/src/lib/data/indexer/interprocess/InterprocessIndexerCommandManager.cpp index 63f77051..e5327151 100644 --- a/src/lib/data/indexer/interprocess/InterprocessIndexerCommandManager.cpp +++ b/src/lib/data/indexer/interprocess/InterprocessIndexerCommandManager.cpp @@ -22,7 +22,7 @@ void InterprocessIndexerCommandManager::setIndexerCommands( const unsigned int overestimationMultiplier = 2; size_t estimatedSize = 1048576; /* 1 MB */ - for (auto command : indexerCommands) + for (auto& command : indexerCommands) { estimatedSize += command->getByteSize() + sizeof(SharedIndexerCommand); } @@ -49,7 +49,7 @@ void InterprocessIndexerCommandManager::setIndexerCommands( return; } - for (auto command : indexerCommands) + for (auto& command : indexerCommands) { queue->push_back(SharedIndexerCommand(access.getAllocator())); SharedIndexerCommand& sharedCommand = queue->back(); diff --git a/src/lib/data/indexer/interprocess/InterprocessIndexingStatusManager.cpp b/src/lib/data/indexer/interprocess/InterprocessIndexingStatusManager.cpp index 69583b35..472dccc2 100644 --- a/src/lib/data/indexer/interprocess/InterprocessIndexingStatusManager.cpp +++ b/src/lib/data/indexer/interprocess/InterprocessIndexingStatusManager.cpp @@ -176,7 +176,7 @@ std::set InterprocessIndexingStatusManager::getIndexedFiles() return result; } - for (auto file : *files) + for (auto& file : *files) { result.insert(FilePath(file.c_str())); } @@ -198,7 +198,7 @@ void InterprocessIndexingStatusManager::addIndexedFiles(std::set fileP } std::set oldFiles; - for (auto indexedFile : *indexedFiles) + for (auto& indexedFile : *indexedFiles) { oldFiles.insert(indexedFile.c_str()); } @@ -213,7 +213,7 @@ void InterprocessIndexingStatusManager::addIndexedFiles(std::set fileP } size_t estimatedSize = 262144; - for (auto newFile : newFiles) + for (auto& newFile : newFiles) { estimatedSize += sizeof(std::string) + newFile.size(); } diff --git a/src/lib/data/location/SourceLocationCollection.cpp b/src/lib/data/location/SourceLocationCollection.cpp index 1378d865..80ecf05e 100644 --- a/src/lib/data/location/SourceLocationCollection.cpp +++ b/src/lib/data/location/SourceLocationCollection.cpp @@ -19,7 +19,7 @@ const std::map>& SourceLocationCol size_t SourceLocationCollection::getSourceLocationCount() const { size_t count = 0; - for (auto p : m_files) + for (auto& p : m_files) { count += p.second->getSourceLocationCount(); } @@ -44,7 +44,7 @@ std::shared_ptr SourceLocationCollection::getSourceLocationF SourceLocation* SourceLocationCollection::getSourceLocationById(Id locationId) const { - for (auto p : m_files) + for (auto& p : m_files) { SourceLocation* location = p.second->getSourceLocationById(locationId); if (location) @@ -91,7 +91,7 @@ void SourceLocationCollection::addSourceLocationFile(std::shared_ptr)> func) const { - for (auto p : m_files) + for (auto& p : m_files) { func(p.second); } @@ -99,7 +99,7 @@ void SourceLocationCollection::forEachSourceLocationFile( void SourceLocationCollection::forEachSourceLocation(std::function func) const { - for (auto p : m_files) + for (auto& p : m_files) { p.second->forEachSourceLocation(func); } diff --git a/src/lib/data/location/SourceLocationFile.cpp b/src/lib/data/location/SourceLocationFile.cpp index 36683bdf..623a8cca 100644 --- a/src/lib/data/location/SourceLocationFile.cpp +++ b/src/lib/data/location/SourceLocationFile.cpp @@ -49,7 +49,7 @@ size_t SourceLocationFile::getSourceLocationCount() const size_t SourceLocationFile::getUnscopedStartLocationCount() const { size_t count = 0; - for (std::shared_ptr location : m_locations) + for (const std::shared_ptr& location : m_locations) { if (location->isStartLocation() && !location->isScopeLocation()) { @@ -129,7 +129,7 @@ SourceLocation* SourceLocationFile::getSourceLocationById(Id locationId) const void SourceLocationFile::forEachSourceLocation(std::function func) const { - for (std::shared_ptr location : m_locations) + for (const std::shared_ptr& location : m_locations) { func(location.get()); } @@ -137,7 +137,7 @@ void SourceLocationFile::forEachSourceLocation(std::function func) const { - for (std::shared_ptr location : m_locations) + for (const std::shared_ptr& location : m_locations) { if (location->isStartLocation()) { @@ -148,7 +148,7 @@ void SourceLocationFile::forEachStartSourceLocation(std::function func) const { - for (std::shared_ptr location : m_locations) + for (const std::shared_ptr& location : m_locations) { if (location->isEndLocation()) { @@ -161,7 +161,7 @@ std::shared_ptr SourceLocationFile::getFilteredByLines(size_ { std::shared_ptr ret = std::make_shared(getFilePath(), false, isComplete()); - for (std::shared_ptr location : m_locations) + for (const std::shared_ptr& location : m_locations) { if (location->getLineNumber() >= firstLineNumber && location->getLineNumber() <= lastLineNumber) { @@ -176,7 +176,7 @@ std::shared_ptr SourceLocationFile::getFilteredByType(Locati { std::shared_ptr ret = std::make_shared(getFilePath(), false, isComplete()); - for (std::shared_ptr location : m_locations) + for (const std::shared_ptr& location : m_locations) { if (location->getType() == type) { diff --git a/src/lib/data/storage/IntermediateStorage.cpp b/src/lib/data/storage/IntermediateStorage.cpp index a048be46..d73287d5 100644 --- a/src/lib/data/storage/IntermediateStorage.cpp +++ b/src/lib/data/storage/IntermediateStorage.cpp @@ -85,7 +85,7 @@ void IntermediateStorage::setAllFilesIncomplete() void IntermediateStorage::setFilesWithErrorsIncomplete() { std::set errorFileNames; - for (StorageError& error : m_errors) + for (const StorageError& error : m_errors) { errorFileNames.insert(error.filePath.str()); } @@ -373,7 +373,7 @@ std::vector IntermediateStorage::getStorageLocalSymbols() co { std::vector localSymbol; localSymbol.reserve(m_localSymbols.size()); - for (auto it: m_localSymbols) + for (const auto& it: m_localSymbols) { localSymbol.push_back(it.second); } @@ -384,7 +384,7 @@ std::vector IntermediateStorage::getStorageSourceLocation { std::vector sourceLocations; sourceLocations.reserve(m_sourceLocations.size()); - for (auto it: m_sourceLocations) + for (const auto& it: m_sourceLocations) { sourceLocations.push_back(it.second); } diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 0fb45f1c..85b5e151 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -608,12 +608,12 @@ std::vector PersistentStorage::getAutocompletionSymbolMatches( elementIds.insert(elementIds.end(), result.elementIds.begin(), result.elementIds.end()); } - for (StorageNode& node : m_sqliteIndexStorage.getAllByIds(elementIds)) + for (const StorageNode& node : m_sqliteIndexStorage.getAllByIds(elementIds)) { storageNodeMap[node.id] = node; } - for (StorageSymbol& symbol : m_sqliteIndexStorage.getAllByIds(elementIds)) + for (const StorageSymbol& symbol : m_sqliteIndexStorage.getAllByIds(elementIds)) { storageSymbolMap[symbol.id] = symbol; } @@ -786,7 +786,7 @@ std::shared_ptr PersistentStorage::getGraphForAll() const std::shared_ptr graph = std::make_shared(); std::vector tokenIds; - for (StorageNode node: m_sqliteIndexStorage.getAll()) + for (StorageNode& node: m_sqliteIndexStorage.getAll()) { auto it = m_symbolDefinitionKinds.find(node.id); if (it != m_symbolDefinitionKinds.end() && it->second == DEFINITION_EXPLICIT && @@ -799,7 +799,7 @@ std::shared_ptr PersistentStorage::getGraphForAll() const } } - for (auto p : m_fileNodePaths) + for (const auto& p : m_fileNodePaths) { tokenIds.push_back(p.first); } @@ -1538,7 +1538,7 @@ std::vector PersistentStorage::getAllEdgeBookmarks() const std::vector PersistentStorage::getAllBookmarkCategories() const { std::vector categories; - for (const StorageBookmarkCategory storageBookmarkCategoriy: m_sqliteBookmarkStorage.getAllBookmarkCategories()) + for (const StorageBookmarkCategory& storageBookmarkCategoriy : m_sqliteBookmarkStorage.getAllBookmarkCategories()) { categories.push_back(BookmarkCategory(storageBookmarkCategoriy.id, storageBookmarkCategoriy.name)); } @@ -1616,7 +1616,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector& info.count = 0; info.countText = "reference"; - for (auto edge : m_sqliteIndexStorage.getEdgesByTargetId(node.id)) + for (const auto& edge : m_sqliteIndexStorage.getEdgesByTargetId(node.id)) { if (Edge::intToType(edge.type) != Edge::EDGE_MEMBER) { @@ -1659,7 +1659,7 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no ); std::vector typeNodeIds; - for (auto edge : m_sqliteIndexStorage.getEdgesBySourceId(node.id)) + for (const auto& edge : m_sqliteIndexStorage.getEdgesBySourceId(node.id)) { if (Edge::intToType(edge.type) == Edge::EDGE_TYPE_USAGE) { @@ -1680,7 +1680,7 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no ); typeNames.insert(std::make_pair(nameHierarchy.getQualifiedName(), node.id)); - for (auto typeNode : m_sqliteIndexStorage.getAllByIds(typeNodeIds)) + for (const auto& typeNode : m_sqliteIndexStorage.getAllByIds(typeNodeIds)) { typeNames.insert(std::make_pair( NameHierarchy::deserialize(typeNode.serializedName).getQualifiedName(), @@ -1689,7 +1689,7 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no } std::vector> locationRanges; - for (auto p : typeNames) + for (const auto& p : typeNames) { size_t pos = 0; while (pos != std::string::npos) @@ -1701,7 +1701,7 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no } bool inRange = false; - for (auto p : locationRanges) + for (const auto& p : locationRanges) { if (pos + 1 >= p.first && pos + 1 <= p.second) { @@ -1747,7 +1747,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForSourceLocationIdsAndLocalSymbolI { std::vector tokenIds = getNodeIdsForLocationIds(locationIds); - for (StorageNode node : m_sqliteIndexStorage.getAllByIds(tokenIds)) + for (const StorageNode& node : m_sqliteIndexStorage.getAllByIds(tokenIds)) { TooltipSnippet snippet; @@ -1916,7 +1916,7 @@ std::set PersistentStorage::getReferenced( const std::set& ids, std::unordered_map> idToReferencingIdMap) const { std::unordered_map> idToReferencedIdMap; - for (auto it: idToReferencingIdMap) + for (const auto& it: idToReferencingIdMap) { for (Id referencingId: it.second) { @@ -2223,7 +2223,7 @@ void PersistentStorage::addAggregationEdgesToGraph( // add hierarchies of these parents std::vector nodeIdsToAdd; - for (const std::pair> p : connectedParentNodeIds) + for (const std::pair>& p : connectedParentNodeIds) { const Id aggregationTargetNodeId = p.first; if (!graph->getNodeById(aggregationTargetNodeId)) @@ -2235,7 +2235,7 @@ void PersistentStorage::addAggregationEdgesToGraph( // create aggregation edges between parents and active node Node* sourceNode = graph->getNodeById(nodeId); - for (const std::pair> p : connectedParentNodeIds) + for (const std::pair>& p : connectedParentNodeIds) { const Id aggregationTargetNodeId = p.first; @@ -2364,14 +2364,14 @@ void PersistentStorage::buildFilePathMaps() { TRACE(); - for (StorageFile file: m_sqliteIndexStorage.getAll()) + for (StorageFile& file: m_sqliteIndexStorage.getAll()) { m_fileNodeIds.emplace(FilePath(file.filePath), file.id); m_fileNodePaths.emplace(file.id, FilePath(file.filePath)); m_fileNodeComplete.emplace(file.id, file.complete); } - for (StorageSymbol symbol : m_sqliteIndexStorage.getAll()) + for (StorageSymbol& symbol : m_sqliteIndexStorage.getAll()) { m_symbolDefinitionKinds.emplace(symbol.id, intToDefinitionKind(symbol.definitionKind)); } @@ -2383,7 +2383,7 @@ void PersistentStorage::buildSearchIndex() FilePath dbPath = getDbFilePath(); - for (StorageNode node : m_sqliteIndexStorage.getAll()) + for (StorageNode& node : m_sqliteIndexStorage.getAll()) { if (Node::intToType(node.type) == Node::NODE_FILE) { @@ -2419,7 +2419,7 @@ void PersistentStorage::buildFullTextSearchIndex() const { TRACE(); - for (StorageFile file : m_sqliteIndexStorage.getAll()) + for (StorageFile& file : m_sqliteIndexStorage.getAll()) { m_fullTextSearchIndex.addFile(file.id, m_sqliteIndexStorage.getFileContentById(file.id)->getText()); } diff --git a/src/lib/data/storage/StorageProvider.cpp b/src/lib/data/storage/StorageProvider.cpp index 2e53fa77..8c6d6b24 100644 --- a/src/lib/data/storage/StorageProvider.cpp +++ b/src/lib/data/storage/StorageProvider.cpp @@ -60,7 +60,7 @@ void StorageProvider::logCurrentState() const std::string logString = "Storages waiting for injection:"; { std::lock_guard lock(m_storagesMutex); - for (std::shared_ptr storage: m_storages) + for (const std::shared_ptr& storage: m_storages) { logString += " " + std::to_string(storage->getSourceLocationCount()) + ";"; } diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index b04c1bd0..92f23eca 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -53,7 +53,7 @@ Project::~Project() bool Project::refresh(bool forceRefresh) { if (m_state == PROJECT_STATE_NOT_LOADED) - { + { return false; } @@ -157,7 +157,7 @@ bool Project::refresh(bool forceRefresh) m_settings->reload(); m_sourceGroups = SourceGroupFactory::getInstance()->createSourceGroups(m_settings->getAllSourceGroupSettings()); - for (std::shared_ptr sourceGroup: m_sourceGroups) + for (const std::shared_ptr& sourceGroup: m_sourceGroups) { if (!sourceGroup->prepareRefresh()) { @@ -275,7 +275,7 @@ void Project::load() bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh) { std::set allSourceFilePaths; - for (std::shared_ptr sourceGroup: m_sourceGroups) + for (const std::shared_ptr& sourceGroup: m_sourceGroups) { if (!sourceGroup->prepareIndexing()) { @@ -357,7 +357,7 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh) } std::set filesToIndex; - for (std::shared_ptr sourceGroup: m_sourceGroups) + for (const std::shared_ptr& sourceGroup: m_sourceGroups) { sourceGroup->fetchSourceFilePathsToIndex(staticSourceFilePaths); utility::append(filesToIndex, sourceGroup->getSourceFilePathsToIndex()); @@ -432,9 +432,9 @@ void Project::buildIndex( std::set filesToIndexTemp = filesToIndex; std::shared_ptr indexerCommandList = std::make_shared(); - for (std::shared_ptr sourceGroup: m_sourceGroups) + for (const std::shared_ptr& sourceGroup : m_sourceGroups) { - for (std::shared_ptr command: sourceGroup->getIndexerCommands(&filesToIndexTemp, fullRefresh)) + for (const std::shared_ptr& command : sourceGroup->getIndexerCommands(&filesToIndexTemp, fullRefresh)) { indexerCommandList->addCommand(command); } @@ -533,7 +533,7 @@ void Project::buildIndex( bool Project::hasCxxSourceGroup() const { - for (std::shared_ptr sourceGroup: m_sourceGroups) + for (const std::shared_ptr& sourceGroup: m_sourceGroups) { if (sourceGroup->getLanguage() == LANGUAGE_C || sourceGroup->getLanguage() == LANGUAGE_CPP) { diff --git a/src/lib/project/SourceGroupFactory.cpp b/src/lib/project/SourceGroupFactory.cpp index 3187d02a..8fa7fc18 100644 --- a/src/lib/project/SourceGroupFactory.cpp +++ b/src/lib/project/SourceGroupFactory.cpp @@ -21,7 +21,7 @@ void SourceGroupFactory::addModule(std::shared_ptr mod std::vector> SourceGroupFactory::createSourceGroups(std::vector> allSourceGroupSettings) { std::vector> sourceGroups; - for (std::shared_ptr sourceGroupSettings: allSourceGroupSettings) + for (const std::shared_ptr& sourceGroupSettings: allSourceGroupSettings) { std::shared_ptr sourceGroup = createSourceGroup(sourceGroupSettings); if (sourceGroup) @@ -36,7 +36,7 @@ std::shared_ptr SourceGroupFactory::createSourceGroup(std::shared_p { std::shared_ptr sourceGroup; - for (std::shared_ptr module: m_modules) + for (const std::shared_ptr& module: m_modules) { if (module->supports(settings->getType())) { diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index 5267d5ba..8183a2ca 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -377,7 +377,7 @@ std::vector ApplicationSettings::getRecentProjects() const std::vector recentProjects; std::vector loadedRecentProjects = getPathValues("user/recent_projects/recent_project"); - for (FilePath project: loadedRecentProjects) + for (const FilePath& project: loadedRecentProjects) { if (project.isAbsolute()) { diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index 86226746..1dd0547a 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -9,7 +9,7 @@ #include "utility/utilityUuid.h" const size_t ProjectSettings::VERSION = 4; -const std::string PROJECT_FILE_EXTENSION = ".srctrlprj"; +const char PROJECT_FILE_EXTENSION[] = ".srctrlprj"; LanguageType ProjectSettings::getLanguageOfProject(const FilePath& filePath) { @@ -17,7 +17,7 @@ LanguageType ProjectSettings::getLanguageOfProject(const FilePath& filePath) ProjectSettings projectSettings; projectSettings.load(filePath); - for (std::shared_ptr sourceGroupSettings: projectSettings.getAllSourceGroupSettings()) + for (const std::shared_ptr& sourceGroupSettings: projectSettings.getAllSourceGroupSettings()) { const LanguageType currentLanguageType = getLanguageTypeForSourceGroupType(sourceGroupSettings->getType()); if (languageType == LANGUAGE_UNKNOWN) @@ -63,10 +63,10 @@ bool ProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) return false; } - for (std::shared_ptr mySourceGroup: allMySettings) + for (const std::shared_ptr& mySourceGroup : allMySettings) { bool matched = false; - for (std::shared_ptr otherSourceGroup: allOtherSettings) + for (const std::shared_ptr& otherSourceGroup : allOtherSettings) { if (mySourceGroup->equals(otherSourceGroup)) { @@ -211,7 +211,7 @@ void ProjectSettings::setAllSourceGroupSettings(const std::vectorremoveValues(key); } - for (std::shared_ptr settings: allSettings) + for (const std::shared_ptr& settings: allSettings) { const std::string key = "source_groups/source_group_" + settings->getId(); const SourceGroupType type = settings->getType(); diff --git a/src/lib/utility/ConfigManager.cpp b/src/lib/utility/ConfigManager.cpp index dab15676..0cfc95e7 100644 --- a/src/lib/utility/ConfigManager.cpp +++ b/src/lib/utility/ConfigManager.cpp @@ -113,7 +113,7 @@ bool ConfigManager::getValues(const std::string& key, std::vector& values) std::vector valuesStringVector; if (getValues(key, valuesStringVector)) { - for (std::string valueString : valuesStringVector) + for (const std::string& valueString : valuesStringVector) { values.push_back(atoi(valueString.c_str())); } @@ -127,7 +127,7 @@ bool ConfigManager::getValues(const std::string& key, std::vector& values std::vector valuesStringVector; if (getValues(key, valuesStringVector)) { - for (std::string valueString : valuesStringVector) + for (const std::string& valueString : valuesStringVector) { values.push_back(static_cast(atof(valueString.c_str()))); } @@ -141,7 +141,7 @@ bool ConfigManager::getValues(const std::string& key, std::vector& values) std::vector valuesStringVector; if (getValues(key, valuesStringVector)) { - for (std::string valueString : valuesStringVector) + for (const std::string& valueString : valuesStringVector) { values.push_back(atoi(valueString.c_str()) != 0); } diff --git a/src/lib/utility/commandline/CommandlineHelper.cpp b/src/lib/utility/commandline/CommandlineHelper.cpp index 9fb4fb03..2797cc99 100644 --- a/src/lib/utility/commandline/CommandlineHelper.cpp +++ b/src/lib/utility/commandline/CommandlineHelper.cpp @@ -46,15 +46,15 @@ void conflicting_options(const boost::program_options::variables_map& vm, std::vector extractPaths(const std::vector& vector) { std::vector v; - for (std::string s : vector) + for (const std::string& s : vector) { std::vector temp= utility::splitToVector(s, ','); - for (std::string path : temp) + for (const std::string& path : temp) { v.push_back(FilePath(path)); } } - return std::move(v); + return v; } } // namespace cmd diff --git a/src/lib/utility/file/FileManager.cpp b/src/lib/utility/file/FileManager.cpp index b55c3591..8f5007a9 100644 --- a/src/lib/utility/file/FileManager.cpp +++ b/src/lib/utility/file/FileManager.cpp @@ -24,7 +24,7 @@ void FileManager::update( m_allSourceFilePaths.clear(); - for (FileInfo fileInfo: FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions)) + for (const FileInfo& fileInfo : FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions)) { const FilePath& filePath = fileInfo.path; if (isExcluded(filePath)) @@ -76,7 +76,7 @@ std::set FileManager::getAllSourceFilePathsRelative(const FilePath& ba std::vector FileManager::makeCanonical(const std::vector& filePaths) { std::vector ret; - for (const FilePath filePath: filePaths) + for (const FilePath& filePath: filePaths) { ret.push_back(filePath.canonical()); } @@ -85,7 +85,7 @@ std::vector FileManager::makeCanonical(const std::vector& fi bool FileManager::isExcluded(const FilePath& filePath) const { - for (FilePath path : m_excludePaths) + for (const FilePath& path : m_excludePaths) { if (path == filePath || path.contains(filePath)) { diff --git a/src/lib/utility/file/FilePath.cpp b/src/lib/utility/file/FilePath.cpp index 07c37500..418eda8d 100644 --- a/src/lib/utility/file/FilePath.cpp +++ b/src/lib/utility/file/FilePath.cpp @@ -322,7 +322,7 @@ FilePath FilePath::replaceExtension(const std::string& extension) const bool FilePath::hasExtension(const std::vector& extensions) const { std::string e = extension(); - for (std::string ext : extensions) + for (const std::string& ext : extensions) { if (e == ext) { diff --git a/src/lib/utility/file/FileRegisterStateData.cpp b/src/lib/utility/file/FileRegisterStateData.cpp index 6a1477ba..f2e64a65 100644 --- a/src/lib/utility/file/FileRegisterStateData.cpp +++ b/src/lib/utility/file/FileRegisterStateData.cpp @@ -51,7 +51,7 @@ bool FileRegisterStateData::fileIsIndexed(const FilePath& filePath) const void FileRegisterStateData::setIndexedFiles(const std::set& filePaths) { - for (auto path : filePaths) + for (auto& path : filePaths) { m_filePaths[path] = STATE_INDEXED; } diff --git a/src/lib/utility/tracing.cpp b/src/lib/utility/tracing.cpp index ccdbc559..a314c57e 100644 --- a/src/lib/utility/tracing.cpp +++ b/src/lib/utility/tracing.cpp @@ -42,7 +42,7 @@ void Tracer::printTraces() std::lock_guard lock(m_mutex); size_t unfinishEvents = 0; - for (auto p : m_startedEvents) + for (auto& p : m_startedEvents) { unfinishEvents += p.second.size(); } @@ -67,11 +67,11 @@ void Tracer::printTraces() std::cout << "-----------------------------------------------------------------"; std::cout << "------------------------------------------------------------\n"; - for (auto p : m_events) + for (auto& p : m_events) { std::cout << "thread: " << p.first << std::endl; - for (const std::shared_ptr event : p.second) + for (const std::shared_ptr& event : p.second) { std::cout.width(8 + 2 * event->depth); std::cout << std::right << std::setprecision(3) << std::fixed << event->time; @@ -104,9 +104,9 @@ void Tracer::printTraces() std::map accumulatedEvents; - for (auto p : m_events) + for (auto& p : m_events) { - for (const std::shared_ptr event : p.second) + for (const std::shared_ptr& event : p.second) { std::string name = event->eventName + event->functionName + event->locationName; @@ -136,7 +136,7 @@ void Tracer::printTraces() } ); - for (const std::pair p : accumulatedEvents) + for (const std::pair& p : accumulatedEvents) { sortedEvents.insert(p.second); } diff --git a/src/lib/utility/utilityString.cpp b/src/lib/utility/utilityString.cpp index ab6833d0..43ec6965 100644 --- a/src/lib/utility/utilityString.cpp +++ b/src/lib/utility/utilityString.cpp @@ -88,7 +88,7 @@ namespace utility { std::deque c; - for (std::string str : list) + for (const std::string& str : list) { if (str.size()) { @@ -322,7 +322,7 @@ namespace utility } paramPart = ""; - for (std::string str : paramLines) + for (const std::string& str : paramLines) { paramPart += "\n\t" + str; size_t length = tabWidth + str.size(); diff --git a/src/lib_cxx/data/indexer/IndexerCommandCxx.cpp b/src/lib_cxx/data/indexer/IndexerCommandCxx.cpp index fd24e760..c252dcd2 100644 --- a/src/lib_cxx/data/indexer/IndexerCommandCxx.cpp +++ b/src/lib_cxx/data/indexer/IndexerCommandCxx.cpp @@ -25,17 +25,17 @@ size_t IndexerCommandCxx::getByteSize() const { size_t size = IndexerCommand::getByteSize(); - for (auto i : m_systemHeaderSearchPaths) + for (auto& i : m_systemHeaderSearchPaths) { size += sizeof(std::string) + i.str().size(); } - for (auto i : m_frameworkSearchPaths) + for (auto& i : m_frameworkSearchPaths) { size += sizeof(std::string) + i.str().size(); } - for (auto i : m_compilerFlags) + for (auto& i : m_compilerFlags) { size += sizeof(std::string) + i.size(); } diff --git a/src/lib_cxx/data/parser/cxx/ASTActionFactory.cpp b/src/lib_cxx/data/parser/cxx/ASTActionFactory.cpp index 061f1ada..d2c61fa6 100644 --- a/src/lib_cxx/data/parser/cxx/ASTActionFactory.cpp +++ b/src/lib_cxx/data/parser/cxx/ASTActionFactory.cpp @@ -26,8 +26,5 @@ clang::FrontendAction* ASTActionFactory::create() { return new ASTAction(m_client, m_fileRegister, m_canonicalFilePathCache); } - else - { - return new ASTAction(m_client, m_fileRegister, m_canonicalFilePathCache); - } + return new ASTAction(m_client, m_fileRegister, m_canonicalFilePathCache); } diff --git a/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentContext.cpp b/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentContext.cpp index a6f6ae53..0eec4d6c 100644 --- a/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentContext.cpp +++ b/src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentContext.cpp @@ -58,10 +58,7 @@ NameHierarchy CxxAstVisitorComponentContext::getContextName(const NameHierarchy& { return (*it)->getName(); } - else - { - skipped++; - } + skipped++; } } return fallback; diff --git a/src/lib_cxx/data/parser/cxx/name/CxxFunctionDeclName.cpp b/src/lib_cxx/data/parser/cxx/name/CxxFunctionDeclName.cpp index e3c7c66a..3c2869ad 100644 --- a/src/lib_cxx/data/parser/cxx/name/CxxFunctionDeclName.cpp +++ b/src/lib_cxx/data/parser/cxx/name/CxxFunctionDeclName.cpp @@ -39,7 +39,7 @@ CxxFunctionDeclName::~CxxFunctionDeclName() NameHierarchy CxxFunctionDeclName::toNameHierarchy() const { - std::string signaturePrefix = ""; + std::string signaturePrefix; if (m_isStatic) { signaturePrefix += "static "; diff --git a/src/lib_cxx/data/parser/cxx/name/CxxTypeName.cpp b/src/lib_cxx/data/parser/cxx/name/CxxTypeName.cpp index 427d20cd..3312e6d4 100644 --- a/src/lib_cxx/data/parser/cxx/name/CxxTypeName.cpp +++ b/src/lib_cxx/data/parser/cxx/name/CxxTypeName.cpp @@ -70,7 +70,7 @@ std::string CxxTypeName::toString() const } ret += toNameHierarchy().getQualifiedName(); - for (Modifier modifier: m_modifiers) + for (const Modifier& modifier: m_modifiers) { ret += " " + modifier.symbol; if (!modifier.qualifierFlags.empty()) diff --git a/src/lib_cxx/data/parser/cxx/name/CxxVariableDeclName.cpp b/src/lib_cxx/data/parser/cxx/name/CxxVariableDeclName.cpp index 6dbeba5c..2d0f156a 100644 --- a/src/lib_cxx/data/parser/cxx/name/CxxVariableDeclName.cpp +++ b/src/lib_cxx/data/parser/cxx/name/CxxVariableDeclName.cpp @@ -31,14 +31,14 @@ CxxVariableDeclName::~CxxVariableDeclName() NameHierarchy CxxVariableDeclName::toNameHierarchy() const { - std::string signaturePrefix = ""; + std::string signaturePrefix; if (m_isStatic) { signaturePrefix += "static "; } signaturePrefix += CxxTypeName::makeUnsolvedIfNull(m_typeName)->toString(); - const std::string signaturePostfix = ""; + const std::string signaturePostfix; NameHierarchy ret = CxxDeclName::toNameHierarchy(); std::shared_ptr nameElement = std::make_shared( diff --git a/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp b/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp index ebef59af..aed077c0 100644 --- a/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp +++ b/src/lib_cxx/data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp @@ -123,7 +123,7 @@ std::shared_ptr CxxDeclNameResolver::getDeclName(const clang::Named // we skip this node because its child (the lambda call operator) has already been recorded. return std::shared_ptr(); } - else if (declNameString.size() == 0) + else if (declNameString.empty()) { const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager(); const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart()); @@ -285,7 +285,7 @@ std::shared_ptr CxxDeclNameResolver::getDeclName(const clang::Named const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart()); return std::make_shared(getNameForAnonymousSymbol("namespace", presumedBegin), std::vector()); } - else if (clang::isa(declaration) && declNameString.size() == 0) + else if (clang::isa(declaration) && declNameString.empty()) { const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager(); const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart()); @@ -296,13 +296,13 @@ std::shared_ptr CxxDeclNameResolver::getDeclName(const clang::Named clang::isa(declaration) || clang::isa(declaration) || clang::isa(declaration) - ) && declNameString.size() == 0) + ) && declNameString.empty()) { const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager(); const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart()); return std::make_shared(getNameForAnonymousSymbol("template parameter", presumedBegin), std::vector()); } - else if (clang::isa(declaration) && declNameString.size() == 0) + else if (clang::isa(declaration) && declNameString.empty()) { const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager(); const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(declaration->getLocStart()); @@ -331,7 +331,7 @@ std::shared_ptr CxxDeclNameResolver::getDeclName(const clang::Named } } - if (declNameString.size() > 0) + if (!declNameString.empty()) { return std::make_shared(declNameString, std::vector(), std::shared_ptr()); } @@ -355,7 +355,7 @@ std::string CxxDeclNameResolver::getNameForAnonymousSymbol(const std::string& sy std::string CxxDeclNameResolver::getTemplateParameterString(const clang::NamedDecl* parameter) { - std::string templateParameterTypeString = ""; + std::string templateParameterTypeString; if (parameter) { @@ -398,7 +398,7 @@ std::string CxxDeclNameResolver::getTemplateParameterTypeString(const clang::Non typeNameResolver.ignoreContextDecl(m_currentDecl); } - std::string typeString = ""; + std::string typeString; std::shared_ptr typeName = CxxTypeName::makeUnsolvedIfNull(typeNameResolver.getName(parameter->getType())); typeString = typeName->toString(); diff --git a/src/lib_cxx/project/SourceGroupCxx.cpp b/src/lib_cxx/project/SourceGroupCxx.cpp index 7387f1e8..cb15d471 100644 --- a/src/lib_cxx/project/SourceGroupCxx.cpp +++ b/src/lib_cxx/project/SourceGroupCxx.cpp @@ -118,7 +118,7 @@ std::vector> SourceGroupCxx::getIndexerCommands( utility::append(compilerFlags, m_settings->getCompilerFlags()); std::set indexedPaths; - for (FilePath p: m_settings->getSourcePathsExpandedAndAbsolute()) + for (const FilePath& p : m_settings->getSourcePathsExpandedAndAbsolute()) { if (p.exists()) { @@ -127,7 +127,7 @@ std::vector> SourceGroupCxx::getIndexerCommands( } std::set excludedPaths; - for (FilePath p: m_settings->getExcludePathsExpandedAndAbsolute()) + for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute()) { if (p.exists()) { @@ -152,7 +152,7 @@ std::vector> SourceGroupCxx::getIndexerCommands( MessageStatus(message, true).dispatch(); } - for (clang::tooling::CompileCommand command: cdb->getAllCompileCommands()) + for (const clang::tooling::CompileCommand& command: cdb->getAllCompileCommands()) { FilePath sourcePath = FilePath(command.Filename).canonical(); if (!sourcePath.isAbsolute()) diff --git a/src/lib_cxx/utility/CompilationDatabase.cpp b/src/lib_cxx/utility/CompilationDatabase.cpp index 6cb31eea..1ddc62ff 100644 --- a/src/lib_cxx/utility/CompilationDatabase.cpp +++ b/src/lib_cxx/utility/CompilationDatabase.cpp @@ -47,7 +47,7 @@ void utility::CompilationDatabase::getHeaders() std::set systemHeaders; std::set headers; - for (clang::tooling::CompileCommand command : commands) + for (clang::tooling::CompileCommand& command : commands) { for( size_t i = 0; i < command.CommandLine.size(); i++) { diff --git a/src/lib_gui/qt/element/QtAutocompletionList.cpp b/src/lib_gui/qt/element/QtAutocompletionList.cpp index b7e9e149..19f452f2 100644 --- a/src/lib_gui/qt/element/QtAutocompletionList.cpp +++ b/src/lib_gui/qt/element/QtAutocompletionList.cpp @@ -122,7 +122,6 @@ QString QtAutocompletionModel::longestType() const QtAutocompletionDelegate::QtAutocompletionDelegate(QtAutocompletionModel* model, QObject* parent) : QStyledItemDelegate(parent) , m_model(model) - , m_arrow() { resetCharSizes(); } @@ -145,8 +144,10 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt // define highlight colors ColorScheme* scheme = ColorScheme::getInstance().get(); - QColor fillColor("#FFFFFF"); - QColor textColor("#000000"); +// QColor fillColor("#FFFFFF"); + QColor fillColor(0xFF, 0xFF, 0xFF); +// QColor textColor("#000000"); + QColor textColor(0, 0, 0); if (type.size() && type != "command") { @@ -169,7 +170,7 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt // draw highlights at indices QString highlightText(text.size(), ' '); - if (indices.size()) + if (!indices.empty()) { for (int i = 0; i < indices.size(); i++) { diff --git a/src/lib_gui/qt/element/QtAutocompletionList.h b/src/lib_gui/qt/element/QtAutocompletionList.h index c55beb97..e8bd34ea 100644 --- a/src/lib_gui/qt/element/QtAutocompletionList.h +++ b/src/lib_gui/qt/element/QtAutocompletionList.h @@ -42,6 +42,7 @@ private: class QtAutocompletionDelegate : public QStyledItemDelegate { + Q_OBJECT public: explicit QtAutocompletionDelegate(QtAutocompletionModel* model, QObject* parent = 0); virtual ~QtAutocompletionDelegate(); diff --git a/src/lib_gui/qt/element/QtCodeArea.cpp b/src/lib_gui/qt/element/QtCodeArea.cpp index 88ec5cc8..530e3425 100644 --- a/src/lib_gui/qt/element/QtCodeArea.cpp +++ b/src/lib_gui/qt/element/QtCodeArea.cpp @@ -48,23 +48,23 @@ bool MouseWheelOverScrollbarFilter::eventFilter(QObject* obj, QEvent* event) return QObject::eventFilter(obj, event); } -QtCodeArea::LineNumberArea::LineNumberArea(QtCodeArea *codeArea) +QtLineNumberArea::QtLineNumberArea(QtCodeArea *codeArea) : QWidget(codeArea) , m_codeArea(codeArea) { setObjectName("line_number_area"); } -QtCodeArea::LineNumberArea::~LineNumberArea() +QtLineNumberArea::~QtLineNumberArea() { } -QSize QtCodeArea::LineNumberArea::sizeHint() const +QSize QtLineNumberArea::sizeHint() const { return QSize(m_codeArea->lineNumberAreaWidth(), 0); } -void QtCodeArea::LineNumberArea::paintEvent(QPaintEvent *event) +void QtLineNumberArea::paintEvent(QPaintEvent *event) { m_codeArea->lineNumberAreaPaintEvent(event); } @@ -90,7 +90,7 @@ QtCodeArea::QtCodeArea( { setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); - m_lineNumberArea = new LineNumberArea(this); + m_lineNumberArea = new QtLineNumberArea(this); m_digits = lineNumberDigits(); updateLineNumberAreaWidth(); diff --git a/src/lib_gui/qt/element/QtCodeArea.h b/src/lib_gui/qt/element/QtCodeArea.h index 947f60e9..3825e77d 100644 --- a/src/lib_gui/qt/element/QtCodeArea.h +++ b/src/lib_gui/qt/element/QtCodeArea.h @@ -13,6 +13,7 @@ class QResizeEvent; class QSize; class QtCodeNavigator; class QWidget; +class QtCodeArea; class MouseWheelOverScrollbarFilter : public QObject @@ -26,6 +27,23 @@ protected: bool eventFilter(QObject* obj, QEvent* event); }; +class QtLineNumberArea + : public QWidget +{ + Q_OBJECT +public: + QtLineNumberArea(QtCodeArea* codeArea); + virtual ~QtLineNumberArea(); + + QSize sizeHint() const Q_DECL_OVERRIDE; + +protected: + virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; + +private: + QtCodeArea* m_codeArea; +}; + class QtCodeArea : public QtCodeField @@ -33,21 +51,6 @@ class QtCodeArea Q_OBJECT public: - class LineNumberArea - : public QWidget - { - public: - LineNumberArea(QtCodeArea* codeArea); - virtual ~LineNumberArea(); - - QSize sizeHint() const Q_DECL_OVERRIDE; - - protected: - virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; - - private: - QtCodeArea* m_codeArea; - }; QtCodeArea( uint startLineNumber, diff --git a/src/lib_gui/qt/element/QtCodeFile.cpp b/src/lib_gui/qt/element/QtCodeFile.cpp index 493b07e9..2b74e1b0 100644 --- a/src/lib_gui/qt/element/QtCodeFile.cpp +++ b/src/lib_gui/qt/element/QtCodeFile.cpp @@ -62,7 +62,8 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator) m_minimizeButton = new QtIconStateButton(this); m_minimizeButton->addState(QtIconStateButton::STATE_DEFAULT, (ResourcePaths::getGuiPath().str() + "code_view/images/minimize_active.png").c_str()); - m_minimizeButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/minimize_inactive.png").c_str(), "#5E5D5D"); +// m_minimizeButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/minimize_inactive.png").c_str(), "#5E5D5D"); + m_minimizeButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/minimize_inactive.png").c_str(), QColor(0x5E, 0x5D, 0x5D)); m_minimizeButton->addState(QtIconStateButton::STATE_DISABLED, (ResourcePaths::getGuiPath().str() + "code_view/images/minimize_inactive.png").c_str()); m_minimizeButton->setObjectName("file_button"); m_minimizeButton->setToolTip("minimize"); @@ -70,7 +71,8 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator) m_snippetButton = new QtIconStateButton(this); m_snippetButton->addState(QtIconStateButton::STATE_DEFAULT, (ResourcePaths::getGuiPath().str() + "code_view/images/snippet_active.png").c_str()); - m_snippetButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/snippet_inactive.png").c_str(), "#5E5D5D"); +// m_snippetButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/snippet_inactive.png").c_str(), "#5E5D5D"); + m_snippetButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/snippet_inactive.png").c_str(), QColor(0x5E, 0x5D, 0x5D)); m_snippetButton->addState(QtIconStateButton::STATE_DISABLED, (ResourcePaths::getGuiPath().str() + "code_view/images/snippet_inactive.png").c_str()); m_snippetButton->setObjectName("file_button"); m_snippetButton->setToolTip("show snippets"); @@ -78,7 +80,8 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator) m_maximizeButton = new QtIconStateButton(this); m_maximizeButton->addState(QtIconStateButton::STATE_DEFAULT, (ResourcePaths::getGuiPath().str() + "code_view/images/maximize_active.png").c_str()); - m_maximizeButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/maximize_inactive.png").c_str(), "#5E5D5D"); +// m_maximizeButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/maximize_inactive.png").c_str(), "#5E5D5D"); + m_maximizeButton->addState(QtIconStateButton::STATE_HOVERED, (ResourcePaths::getGuiPath().str() + "code_view/images/maximize_inactive.png").c_str(), QColor(0x5E, 0x5D, 0x5D)); m_maximizeButton->addState(QtIconStateButton::STATE_DISABLED, (ResourcePaths::getGuiPath().str() + "code_view/images/maximize_inactive.png").c_str()); m_maximizeButton->setObjectName("file_button"); m_maximizeButton->setToolTip("maximize"); @@ -131,7 +134,7 @@ std::string QtCodeFile::getFileName() const QtCodeSnippet* QtCodeFile::addCodeSnippet(const CodeSnippetParams& params) { - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { if (snippet->getStartLineNumber() == params.startLineNumber && snippet->getEndLineNumber() == params.endLineNumber) @@ -226,7 +229,7 @@ QtCodeSnippet* QtCodeFile::insertCodeSnippet(const CodeSnippetParams& params) QtCodeSnippet* QtCodeFile::getSnippetForLocationId(Id locationId) const { - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { if (snippet->getLineNumberForLocationId(locationId)) { @@ -244,7 +247,7 @@ QtCodeSnippet* QtCodeFile::getSnippetForLine(unsigned int line) const return m_fileSnippet.get(); } - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { if (snippet->getStartLineNumber() <= line && line <= snippet->getEndLineNumber()) { @@ -264,7 +267,7 @@ std::pair QtCodeFile::getFirstSnippetWithActiveLocationId(Id { std::pair result(nullptr, 0); - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { Id locationId = snippet->getFirstActiveLocationId(tokenId); if (locationId != 0) @@ -303,7 +306,7 @@ void QtCodeFile::updateContent() { updateSnippets(); - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { snippet->updateContent(); } @@ -329,7 +332,7 @@ void QtCodeFile::setIsComplete(bool isComplete) void QtCodeFile::setMinimized() { - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { snippet->hide(); } @@ -352,7 +355,7 @@ void QtCodeFile::setMinimized() void QtCodeFile::setSnippets() { - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { snippet->show(); } @@ -375,7 +378,7 @@ void QtCodeFile::setSnippets() void QtCodeFile::setMaximized() { - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { snippet->hide(); } @@ -409,7 +412,7 @@ void QtCodeFile::updateSnippets() } int maxDigits = 1; - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { if (snippet != m_snippets.front() && snippet->styleSheet().size()) { @@ -419,7 +422,7 @@ void QtCodeFile::updateSnippets() maxDigits = qMax(maxDigits, snippet->lineNumberDigits()); } - for (std::shared_ptr snippet : m_snippets) + for (const std::shared_ptr& snippet : m_snippets) { snippet->updateLineNumberAreaWidthForDigits(maxDigits); } diff --git a/src/lib_gui/qt/element/QtCodeFileList.cpp b/src/lib_gui/qt/element/QtCodeFileList.cpp index 1207f455..b6f457af 100644 --- a/src/lib_gui/qt/element/QtCodeFileList.cpp +++ b/src/lib_gui/qt/element/QtCodeFileList.cpp @@ -47,7 +47,7 @@ QtCodeFile* QtCodeFileList::getFile(const FilePath filePath) { QtCodeFile* file = nullptr; - for (std::shared_ptr filePtr : m_files) + for (const std::shared_ptr& filePtr : m_files) { if (filePtr->getFilePath() == filePath) { @@ -177,7 +177,7 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id void QtCodeFileList::updateFiles() { - for (std::shared_ptr file : m_files) + for (const std::shared_ptr& file : m_files) { file->updateContent(); } @@ -185,7 +185,7 @@ void QtCodeFileList::updateFiles() void QtCodeFileList::showContents() { - for (std::shared_ptr filePtr : m_files) + for (const std::shared_ptr& filePtr : m_files) { filePtr->show(); } @@ -193,7 +193,7 @@ void QtCodeFileList::showContents() void QtCodeFileList::onWindowFocus() { - for (std::shared_ptr filePtr : m_files) + for (const std::shared_ptr& filePtr : m_files) { filePtr->updateTitleBar(); } @@ -218,7 +218,7 @@ std::pair QtCodeFileList::getFirstSnippetWithActiveLocationI { std::pair result(nullptr, 0); - for (std::shared_ptr filePtr : m_files) + for (const std::shared_ptr& filePtr : m_files) { if (filePtr->isCollapsed()) { diff --git a/src/lib_gui/qt/element/QtDirectoryListBox.cpp b/src/lib_gui/qt/element/QtDirectoryListBox.cpp index 04cb52a3..7bf72728 100644 --- a/src/lib_gui/qt/element/QtDirectoryListBox.cpp +++ b/src/lib_gui/qt/element/QtDirectoryListBox.cpp @@ -228,7 +228,6 @@ bool QtDirectoryListBox::event(QEvent* event) void QtDirectoryListBox::dropEvent(QDropEvent *event) { - QFileInfo fileInfo; foreach(QUrl url, event->mimeData()->urls()) { QtListItemWidget* widget = addListBoxItem(); diff --git a/src/lib_gui/qt/element/QtIconButton.h b/src/lib_gui/qt/element/QtIconButton.h index 8ae1bfe4..1ee706db 100644 --- a/src/lib_gui/qt/element/QtIconButton.h +++ b/src/lib_gui/qt/element/QtIconButton.h @@ -24,6 +24,7 @@ protected: class QtIconButton : public QPushButton { + Q_OBJECT public: QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent = nullptr); diff --git a/src/lib_gui/qt/element/QtSmartSearchBox.cpp b/src/lib_gui/qt/element/QtSmartSearchBox.cpp index b44f1d39..5c118282 100644 --- a/src/lib_gui/qt/element/QtSmartSearchBox.cpp +++ b/src/lib_gui/qt/element/QtSmartSearchBox.cpp @@ -862,7 +862,7 @@ void QtSmartSearchBox::layoutElements() bool QtSmartSearchBox::hasSelectedElements() const { - for (const std::shared_ptr element : m_elements) + for (const std::shared_ptr& element : m_elements) { if (element->isChecked()) { @@ -887,7 +887,7 @@ std::string QtSmartSearchBox::getSelectedString() const void QtSmartSearchBox::selectAllElementsWith(bool selected) { - for (const std::shared_ptr element : m_elements) + for (const std::shared_ptr& element : m_elements) { element->setChecked(selected); } diff --git a/src/lib_gui/qt/element/QtStatusBar.cpp b/src/lib_gui/qt/element/QtStatusBar.cpp index e88532af..2b8968d3 100644 --- a/src/lib_gui/qt/element/QtStatusBar.cpp +++ b/src/lib_gui/qt/element/QtStatusBar.cpp @@ -41,7 +41,8 @@ QtStatusBar::QtStatusBar() m_errorButton.setStyleSheet("QPushButton { color: #D00000; margin-right: 0; spacing: none; }"); m_errorButton.setIcon(utility::colorizePixmap( QPixmap((ResourcePaths::getGuiPath().str() + "statusbar_view/dot.png").c_str()), - "#D00000" +// "#D00000" + QColor(0xD0, 0, 0) ).scaledToHeight(12)); addPermanentWidget(&m_errorButton); diff --git a/src/lib_gui/qt/element/QtTable.cpp b/src/lib_gui/qt/element/QtTable.cpp index 5771c110..62f729d3 100644 --- a/src/lib_gui/qt/element/QtTable.cpp +++ b/src/lib_gui/qt/element/QtTable.cpp @@ -131,3 +131,4 @@ void QtTable::resizeEvent(QResizeEvent* event) updateRows(); } + diff --git a/src/lib_gui/qt/element/QtTooltip.cpp b/src/lib_gui/qt/element/QtTooltip.cpp index cd47fb1e..6949d1e3 100644 --- a/src/lib_gui/qt/element/QtTooltip.cpp +++ b/src/lib_gui/qt/element/QtTooltip.cpp @@ -37,7 +37,7 @@ void QtTooltip::setTooltipInfo(TooltipInfo info) addTitle(info.title.c_str(), info.count, info.countText.c_str()); } - for (TooltipSnippet snippet : info.snippets) + for (TooltipSnippet& snippet : info.snippets) { QtCodeField* field = new QtCodeField(1, snippet.code, snippet.locationFile); diff --git a/src/lib_gui/qt/graphics/QtGraphicsView.cpp b/src/lib_gui/qt/graphics/QtGraphicsView.cpp index 6ac5aa5c..a1cc8415 100644 --- a/src/lib_gui/qt/graphics/QtGraphicsView.cpp +++ b/src/lib_gui/qt/graphics/QtGraphicsView.cpp @@ -434,7 +434,7 @@ QString ShowSaveFileDialog(QWidget *parent, if (dialog.exec() == QDialog::Accepted) { - QString file_name = dialog.selectedFiles().first(); + QString file_name = dialog.selectedFiles().constFirst(); QFileInfo info(file_name); if (info.suffix().isEmpty() && !dialog.selectedNameFilter().isEmpty()) diff --git a/src/lib_gui/qt/network/QtRequest.cpp b/src/lib_gui/qt/network/QtRequest.cpp index 965f8aba..e90391b2 100644 --- a/src/lib_gui/qt/network/QtRequest.cpp +++ b/src/lib_gui/qt/network/QtRequest.cpp @@ -26,6 +26,9 @@ void QtRequest::finished(QNetworkReply *reply) QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); QVariant redirectionTargetUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + Q_UNUSED(statusCodeV); + Q_UNUSED(redirectionTargetUrl); + if (reply->error() != QNetworkReply::NoError) { LOG_ERROR_STREAM(<< "An error occured during http request. ERRORCODE: " << reply->error()); diff --git a/src/lib_gui/qt/network/QtTcpWrapper.cpp b/src/lib_gui/qt/network/QtTcpWrapper.cpp index aa900fc3..5696da67 100644 --- a/src/lib_gui/qt/network/QtTcpWrapper.cpp +++ b/src/lib_gui/qt/network/QtTcpWrapper.cpp @@ -16,8 +16,6 @@ QtTcpWrapper::QtTcpWrapper(QObject* parent, const std::string& ip, const quint16 void QtTcpWrapper::startListening() { - QHostAddress address(m_ip.c_str()); - if (!m_tcpServer->listen(QHostAddress::LocalHost, m_serverPort)) { LOG_ERROR_STREAM(<< "TCP server failed to start with error: \"" + m_tcpServer->errorString().toStdString() + "\". Unable to listen for IDE plugin messages."); diff --git a/src/lib_gui/qt/utility/QtThreadedFunctor.h b/src/lib_gui/qt/utility/QtThreadedFunctor.h index 6a3c56a7..c1d062ce 100644 --- a/src/lib_gui/qt/utility/QtThreadedFunctor.h +++ b/src/lib_gui/qt/utility/QtThreadedFunctor.h @@ -33,7 +33,7 @@ public: { m_freeCallbacks.acquire(); m_callback = callback; - signalExecution(); + emit signalExecution(); } private: diff --git a/src/lib_gui/qt/utility/utilityQt.cpp b/src/lib_gui/qt/utility/utilityQt.cpp index 0e83615b..a8cdd0f9 100644 --- a/src/lib_gui/qt/utility/utilityQt.cpp +++ b/src/lib_gui/qt/utility/utilityQt.cpp @@ -59,7 +59,7 @@ namespace utility for (int loadedFontId: loadedFontIds) { - for (QString family: QFontDatabase::applicationFontFamilies(loadedFontId)) + for (QString& family: QFontDatabase::applicationFontFamilies(loadedFontId)) { LOG_INFO("Loaded FontFamily: " + family.toStdString()); } diff --git a/src/lib_gui/qt/view/QtDialogView.cpp b/src/lib_gui/qt/view/QtDialogView.cpp index 1f5585af..b9cb60ea 100644 --- a/src/lib_gui/qt/view/QtDialogView.cpp +++ b/src/lib_gui/qt/view/QtDialogView.cpp @@ -179,16 +179,6 @@ void QtDialogView::finishedIndexingDialog( size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo, bool interrupted) { - std::stringstream ss; - ss << "Finished indexing: "; - ss << indexedFileCount << "/" << totalIndexedFileCount << " source files indexed; "; - ss << utility::timeToString(time); - ss << "; " << errorInfo.total << " error" << (errorInfo.total != 1 ? "s" : ""); - if (errorInfo.fatal > 0) - { - ss << " (" << errorInfo.fatal << " fatal)"; - } - MessageStatus(ss.str(), false, false).dispatch(); m_onQtThread( [=]() diff --git a/src/lib_gui/qt/view/QtErrorView.cpp b/src/lib_gui/qt/view/QtErrorView.cpp index 81a3a2bb..6cc7bcce 100644 --- a/src/lib_gui/qt/view/QtErrorView.cpp +++ b/src/lib_gui/qt/view/QtErrorView.cpp @@ -352,3 +352,4 @@ bool QtErrorView::isShownError(const ErrorInfo& error) } return false; } + diff --git a/src/lib_gui/qt/view/QtGraphView.cpp b/src/lib_gui/qt/view/QtGraphView.cpp index 5130872d..2a01262c 100644 --- a/src/lib_gui/qt/view/QtGraphView.cpp +++ b/src/lib_gui/qt/view/QtGraphView.cpp @@ -206,13 +206,13 @@ void QtGraphView::activateEdge(Id edgeId, bool centerOrigin) m_onQtThread( [=]() { - for (std::shared_ptr edge : m_oldEdges) + for (std::shared_ptr& edge : m_oldEdges) { edge->setIsActive(false); edge->setIsFocused(false); } - for (std::shared_ptr edge : m_oldEdges) + for (std::shared_ptr& edge : m_oldEdges) { if (edge->getData() && edge->getData()->getId() == edgeId) { @@ -264,7 +264,7 @@ void QtGraphView::finishedTransition() void QtGraphView::clickedInEmptySpace() { std::vector> activeEdges; - for (std::shared_ptr edge : m_oldEdges) + for (std::shared_ptr& edge : m_oldEdges) { if (edge->getIsActive()) { @@ -276,7 +276,7 @@ void QtGraphView::clickedInEmptySpace() if (m_graph && m_graph->getTrailMode() != Graph::TRAIL_NONE) { - for (std::shared_ptr edge : activeEdges) + for (std::shared_ptr& edge : activeEdges) { edge->setIsActive(false); } @@ -639,14 +639,14 @@ void QtGraphView::doRebuildGraph( // create edges Graph::TrailMode trailMode = m_graph ? m_graph->getTrailMode() : Graph::TRAIL_NONE; std::set visibleEdgeIds; - for (const std::shared_ptr edge : edges) + for (const std::shared_ptr& edge : edges) { if (!edge->data || !edge->data->isType(Edge::EDGE_AGGREGATION)) { createEdge(view, edge.get(), &visibleEdgeIds, trailMode, offset, params.bezierEdges); } } - for (const std::shared_ptr edge : edges) + for (const std::shared_ptr& edge : edges) { if (edge->data && edge->data->isType(Edge::EDGE_AGGREGATION)) { @@ -1025,7 +1025,7 @@ void QtGraphView::createTransition() vanish->addAnimation(anim); } - for (std::shared_ptr edge : m_oldEdges) + for (const std::shared_ptr& edge : m_oldEdges) { QPropertyAnimation* anim = new QPropertyAnimation(edge.get(), "opacity"); anim->setDuration(150); @@ -1105,7 +1105,7 @@ void QtGraphView::createTransition() node->blendOut(); } - for (std::shared_ptr edge : m_edges) + for (const std::shared_ptr& edge : m_edges) { QPropertyAnimation* anim = new QPropertyAnimation(edge.get(), "opacity"); anim->setDuration(150); diff --git a/src/lib_gui/qt/view/QtLogView.cpp b/src/lib_gui/qt/view/QtLogView.cpp index 917a3c62..2e367042 100644 --- a/src/lib_gui/qt/view/QtLogView.cpp +++ b/src/lib_gui/qt/view/QtLogView.cpp @@ -249,7 +249,7 @@ void QtLogView::updateTable() m_model->removeRows(0, m_model->rowCount()); } - for ( Log log : m_logs ) + for ( Log& log : m_logs ) { if (log.type & m_logLevel) { @@ -298,7 +298,7 @@ void QtLogView::doAddLog(Logger::LogLevel type, const LogMessage& message) void QtLogView::doAddLogs(const std::vector& logs) { doClear(); - for(Log log : logs) + for(const Log& log : logs) { if( log.type & m_logLevel ) { diff --git a/src/lib_gui/qt/view/QtLogView.h b/src/lib_gui/qt/view/QtLogView.h index d7befeda..bb98ef89 100644 --- a/src/lib_gui/qt/view/QtLogView.h +++ b/src/lib_gui/qt/view/QtLogView.h @@ -14,9 +14,10 @@ class QStandardItemModel; class QtTable; class QtLogView - : public LogView - , public QWidget + : public QWidget + , public LogView { + Q_OBJECT public: QtLogView(ViewLayout* viewLayout); virtual ~QtLogView(); diff --git a/src/lib_gui/qt/view/QtStatusView.cpp b/src/lib_gui/qt/view/QtStatusView.cpp index 849191c6..4f19134f 100644 --- a/src/lib_gui/qt/view/QtStatusView.cpp +++ b/src/lib_gui/qt/view/QtStatusView.cpp @@ -139,7 +139,7 @@ void QtStatusView::doRefreshView() void QtStatusView::doAddStatus(const std::vector& status) { - for (Status s : status) + for (const Status& s : status) { const int rowNumber = m_table->getFilledRowCount(); if (rowNumber < m_model->rowCount()) diff --git a/src/lib_gui/qt/view/QtStatusView.h b/src/lib_gui/qt/view/QtStatusView.h index 8c62a7aa..2172374d 100644 --- a/src/lib_gui/qt/view/QtStatusView.h +++ b/src/lib_gui/qt/view/QtStatusView.h @@ -12,9 +12,10 @@ class QStandardItemModel; class QtTable; class QtStatusView - : public StatusView - , public QWidget + : public QWidget + , public StatusView { + Q_OBJECT public: QtStatusView(ViewLayout* viewLayout); virtual ~QtStatusView(); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeAccess.h b/src/lib_gui/qt/view/graphElements/QtGraphNodeAccess.h index e47780c9..9893f15e 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeAccess.h +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeAccess.h @@ -8,6 +8,7 @@ class QtGraphNodeAccess : public QtGraphNode { + Q_OBJECT public: QtGraphNodeAccess(AccessKind accessKind); virtual ~QtGraphNodeAccess(); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeBundle.h b/src/lib_gui/qt/view/graphElements/QtGraphNodeBundle.h index 751efa55..4f94bece 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeBundle.h +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeBundle.h @@ -9,6 +9,7 @@ class QtCountCircleItem; class QtGraphNodeBundle : public QtGraphNode { + Q_OBJECT public: QtGraphNodeBundle(Id tokenId, size_t nodeCount, Node::NodeType type, std::string name); virtual ~QtGraphNodeBundle(); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeData.h b/src/lib_gui/qt/view/graphElements/QtGraphNodeData.h index cc38a4f3..e1d257fa 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeData.h +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeData.h @@ -8,6 +8,7 @@ class FilePath; class QtGraphNodeData : public QtGraphNode { + Q_OBJECT public: QtGraphNodeData(const Node* data, const std::string& name, bool hasParent, bool childVisible, bool hasQualifier); virtual ~QtGraphNodeData(); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeExpandToggle.h b/src/lib_gui/qt/view/graphElements/QtGraphNodeExpandToggle.h index 398ff7f5..d8162c01 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeExpandToggle.h +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeExpandToggle.h @@ -8,6 +8,7 @@ class QtGraphNodeExpandToggle : public QtGraphNode { + Q_OBJECT public: QtGraphNodeExpandToggle(bool expanded, int invisibleSubNodeCount); virtual ~QtGraphNodeExpandToggle(); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeQualifier.h b/src/lib_gui/qt/view/graphElements/QtGraphNodeQualifier.h index f5787b80..d53b2ad0 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeQualifier.h +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeQualifier.h @@ -9,6 +9,7 @@ class QtGraphNodeQualifier : public QtGraphNode { + Q_OBJECT public: QtGraphNodeQualifier(const NameHierarchy& name); virtual ~QtGraphNodeQualifier(); diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNodeText.h b/src/lib_gui/qt/view/graphElements/QtGraphNodeText.h index a890012a..176ea815 100644 --- a/src/lib_gui/qt/view/graphElements/QtGraphNodeText.h +++ b/src/lib_gui/qt/view/graphElements/QtGraphNodeText.h @@ -6,6 +6,7 @@ class QtGraphNodeText : public QtGraphNode { + Q_OBJECT public: QtGraphNodeText(const std::string& name); virtual ~QtGraphNodeText(); diff --git a/src/lib_gui/qt/window/QtAboutLicense.h b/src/lib_gui/qt/window/QtAboutLicense.h index ac288d77..4d37c949 100644 --- a/src/lib_gui/qt/window/QtAboutLicense.h +++ b/src/lib_gui/qt/window/QtAboutLicense.h @@ -6,6 +6,7 @@ class QtAboutLicense : public QtWindow { + Q_OBJECT public: QtAboutLicense(QWidget* parent = 0); QSize sizeHint() const override; diff --git a/src/lib_gui/qt/window/QtBookmarkBrowser.cpp b/src/lib_gui/qt/window/QtBookmarkBrowser.cpp index fdddc908..ca738f38 100644 --- a/src/lib_gui/qt/window/QtBookmarkBrowser.cpp +++ b/src/lib_gui/qt/window/QtBookmarkBrowser.cpp @@ -132,17 +132,17 @@ void QtBookmarkBrowser::setBookmarks(const std::vector m_bookmarkTree->clear(); std::map categoryNamesOrdered; - for (std::shared_ptr bookmark: bookmarks) + for (const std::shared_ptr& bookmark : bookmarks) { categoryNamesOrdered.emplace(bookmark->getCategory().getName(), bookmark->getCategory()); } - for (auto p : categoryNamesOrdered) + for (const auto& p : categoryNamesOrdered) { findOrCreateTreeCategory(p.second); } - for (std::shared_ptr bookmark: bookmarks) + for (const std::shared_ptr& bookmark : bookmarks) { QtBookmark* qtBookmark = new QtBookmark(); qtBookmark->setBookmark(bookmark); diff --git a/src/lib_gui/qt/window/QtEulaWindow.h b/src/lib_gui/qt/window/QtEulaWindow.h index b5bbb624..acfa7ad0 100644 --- a/src/lib_gui/qt/window/QtEulaWindow.h +++ b/src/lib_gui/qt/window/QtEulaWindow.h @@ -6,6 +6,7 @@ class QtEulaWindow : public QtWindow { + Q_OBJECT public: static const int EULA_VERSION = 2; diff --git a/src/lib_gui/qt/window/QtKeyboardShortcuts.h b/src/lib_gui/qt/window/QtKeyboardShortcuts.h index 202473b2..778c309c 100644 --- a/src/lib_gui/qt/window/QtKeyboardShortcuts.h +++ b/src/lib_gui/qt/window/QtKeyboardShortcuts.h @@ -9,6 +9,7 @@ class QtShortcutTable : public QTableWidget { + Q_OBJECT public: QtShortcutTable(QWidget* parent = nullptr); void updateSize(); diff --git a/src/lib_gui/qt/window/QtSelectPathsDialog.cpp b/src/lib_gui/qt/window/QtSelectPathsDialog.cpp index 4a891214..ed625513 100644 --- a/src/lib_gui/qt/window/QtSelectPathsDialog.cpp +++ b/src/lib_gui/qt/window/QtSelectPathsDialog.cpp @@ -32,7 +32,7 @@ void QtSelectPathsDialog::setPathsList(const std::vector& paths, const { std::set checked(checkedPaths.begin(), checkedPaths.end()); - for (FilePath s : paths) + for (const FilePath& s : paths) { QListWidgetItem* item = new QListWidgetItem(s.str().c_str(), m_list); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag @@ -61,7 +61,7 @@ void QtSelectPathsDialog::setPathsList(const std::vector& paths, const void QtSelectPathsDialog::checkSelected(bool checked) { - for(QListWidgetItem* item : m_list->selectedItems()) + for (QListWidgetItem* item : m_list->selectedItems()) { item->setCheckState( (checked ? Qt::Checked : Qt::Unchecked) ); } diff --git a/src/lib_gui/qt/window/QtSelectPathsDialog.h b/src/lib_gui/qt/window/QtSelectPathsDialog.h index 3fd8f0ff..b7f429d4 100644 --- a/src/lib_gui/qt/window/QtSelectPathsDialog.h +++ b/src/lib_gui/qt/window/QtSelectPathsDialog.h @@ -9,6 +9,7 @@ class QListWidget; class QtSelectPathsDialog : public QtTextEditDialog { + Q_OBJECT public: QtSelectPathsDialog(const QString& title, const QString& description, QWidget* parent = 0); diff --git a/src/lib_gui/qt/window/QtSplashScreen.cpp b/src/lib_gui/qt/window/QtSplashScreen.cpp index a439efb5..ddecb393 100644 --- a/src/lib_gui/qt/window/QtSplashScreen.cpp +++ b/src/lib_gui/qt/window/QtSplashScreen.cpp @@ -95,3 +95,4 @@ void QtSplashScreen::drawContents(QPainter *painter) painter->drawText(r, Qt::AlignLeft, m_string); } + diff --git a/src/lib_gui/qt/window/QtWindowStack.h b/src/lib_gui/qt/window/QtWindowStack.h index 62eb7387..4332bc7e 100644 --- a/src/lib_gui/qt/window/QtWindowStack.h +++ b/src/lib_gui/qt/window/QtWindowStack.h @@ -8,6 +8,7 @@ class QtWindowStackElement : public QWidget { + Q_OBJECT public: QtWindowStackElement(QWidget* parent = nullptr); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index a631a1d3..3e93c626 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -252,7 +252,7 @@ bool QtProjectWizzard::applicationSettingsContainVisualStudioHeaderSearchPaths() { std::vector expandedPaths; const std::shared_ptr headerPathDetector = utility::getCxxVsHeaderPathDetector(); - for (const std::string& detectorName: headerPathDetector->getWorkingDetectorNames()) + for (const std::string& detectorName : headerPathDetector->getWorkingDetectorNames()) { for (const FilePath& path: headerPathDetector->getPaths(detectorName)) { @@ -319,7 +319,7 @@ void QtProjectWizzard::updateSourceGroupList() { m_sourceGroupList->clear(); - for (const std::shared_ptr group : m_allSourceGroupSettings) + for (const std::shared_ptr& group : m_allSourceGroupSettings) { QListWidgetItem *item = new QListWidgetItem(QString::fromStdString(group->getName())); m_sourceGroupList->addItem(item); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp index e31c4fc9..e26139a9 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp @@ -44,10 +44,10 @@ void QtProjectWizzardContentCDBSource::load() std::vector filePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath); - for (FilePath path : filePaths) + for (FilePath& path : filePaths) { bool excluded = false; - for (FilePath p : excludePaths) + for (const FilePath& p : excludePaths) { if (p == path || p.contains(path)) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h index ab52d3d1..2aeb9efb 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h @@ -66,6 +66,7 @@ private slots: class QtProjectWizzardContentPathSourceMaven : public QtProjectWizzardContentPath { + Q_OBJECT public: QtProjectWizzardContentPathSourceMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); @@ -85,6 +86,7 @@ private: class QtProjectWizzardContentPathDependenciesMaven : public QtProjectWizzardContentPath { + Q_OBJECT public: QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h index 5ff0da1d..e6a2a0b1 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h @@ -56,6 +56,7 @@ private: class QtProjectWizzardContentPathsSource : public QtProjectWizzardContentPaths { + Q_OBJECT public: QtProjectWizzardContentPathsSource(std::shared_ptr settings, QtProjectWizzardWindow* window); @@ -89,6 +90,7 @@ private slots: class QtProjectWizzardContentPathsExclude : public QtProjectWizzardContentPaths { + Q_OBJECT public: QtProjectWizzardContentPathsExclude(std::shared_ptr settings, QtProjectWizzardWindow* window); @@ -101,7 +103,6 @@ class QtProjectWizzardContentPathsHeaderSearch : public QtProjectWizzardContentPaths { Q_OBJECT - public: QtProjectWizzardContentPathsHeaderSearch( std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB = false); @@ -123,6 +124,7 @@ private: class QtProjectWizzardContentPathsHeaderSearchGlobal : public QtProjectWizzardContentPaths { + Q_OBJECT public: QtProjectWizzardContentPathsHeaderSearchGlobal(QtProjectWizzardWindow* window); @@ -135,6 +137,7 @@ public: class QtProjectWizzardContentPathsFrameworkSearch : public QtProjectWizzardContentPaths { + Q_OBJECT public: QtProjectWizzardContentPathsFrameworkSearch( std::shared_ptr settings, QtProjectWizzardWindow* window, bool isCDB = false); @@ -149,6 +152,7 @@ public: class QtProjectWizzardContentPathsFrameworkSearchGlobal : public QtProjectWizzardContentPaths { + Q_OBJECT public: QtProjectWizzardContentPathsFrameworkSearchGlobal(QtProjectWizzardWindow* window); @@ -160,6 +164,7 @@ public: class QtProjectWizzardContentPathsClassJava : public QtProjectWizzardContentPaths { + Q_OBJECT public: QtProjectWizzardContentPathsClassJava(std::shared_ptr settings, QtProjectWizzardWindow* window); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp index b19edd07..86df9460 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp @@ -61,7 +61,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) vlayout->setSpacing(10); m_languages = new QButtonGroup(); - for (auto it: sourceGroupInfos) + for (auto& it: sourceGroupInfos) { QPushButton* b = new QPushButton(languageTypeToString(it.first).c_str(), this); b->setObjectName("menuButton"); @@ -85,10 +85,10 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) selectedLanguage = LanguageType(languageTypeInt); } - for (auto it: m_buttons) + for (auto& it: m_buttons) { it.second->setExclusive(false); - for (QAbstractButton* button: it.second->buttons()) + for (QAbstractButton* button : it.second->buttons()) { button->setChecked(false); button->setVisible(it.first == selectedLanguage); @@ -104,11 +104,11 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) QHBoxLayout* hlayout = new QHBoxLayout(); - for (auto languageIt: sourceGroupInfos) + for (auto& languageIt: sourceGroupInfos) { QButtonGroup* sourceGroupButtons = new QButtonGroup(this); - for (auto sourceGroupIt: languageIt.second) + for (auto& sourceGroupIt: languageIt.second) { QToolButton* b = createSourceGroupButton( utility::insertLineBreaksAtBlankSpaces(sourceGroupTypeToProjectSetupString(sourceGroupIt.type), 15).c_str(), @@ -122,7 +122,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) m_buttons[languageIt.first] = sourceGroupButtons; } - for (auto it: m_buttons) + for (auto& it: m_buttons) { connect(it.second, static_cast(&QButtonGroup::buttonClicked), [this](QAbstractButton* button) @@ -166,14 +166,14 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) layout->setColumnStretch(QtProjectWizzardWindow::BACK_COL, 1); layout->setHorizontalSpacing(0); - m_languages->buttons().first()->click(); + m_languages->buttons().constFirst()->click(); } void QtProjectWizzardContentSelect::save() { SourceGroupType selectedType; - for (auto it: m_buttons) + for (auto& it: m_buttons) { if (QAbstractButton* b = it.second->checkedButton()) { @@ -193,7 +193,7 @@ bool QtProjectWizzardContentSelect::check() { bool sourceGroupChosen = false; - for (auto it: m_buttons) + for (auto& it: m_buttons) { if (it.second->checkedId() != -1) { diff --git a/src/lib_gui/utility/path_detector/CombinedPathDetector.cpp b/src/lib_gui/utility/path_detector/CombinedPathDetector.cpp index 8c3e3d24..3ca957a5 100644 --- a/src/lib_gui/utility/path_detector/CombinedPathDetector.cpp +++ b/src/lib_gui/utility/path_detector/CombinedPathDetector.cpp @@ -19,7 +19,7 @@ void CombinedPathDetector::addDetector(std::shared_ptr detector) std::vector CombinedPathDetector::getWorkingDetectorNames() { std::vector names; - for (std::shared_ptr detector: m_detectors) + for (const std::shared_ptr& detector: m_detectors) { if (detector->isWorking()) { @@ -31,7 +31,7 @@ std::vector CombinedPathDetector::getWorkingDetectorNames() std::vector CombinedPathDetector::getPaths() const { - for (std::shared_ptr detector: m_detectors) + for (const std::shared_ptr& detector: m_detectors) { std::vector detectedPaths = detector->getPaths(); if (!detectedPaths.empty()) @@ -44,7 +44,7 @@ std::vector CombinedPathDetector::getPaths() const std::vector CombinedPathDetector::getPaths(std::string detectorName) const { - for (std::shared_ptr detector: m_detectors) + for (const std::shared_ptr& detector: m_detectors) { if (detector->getName() == detectorName) { diff --git a/src/lib_gui/utility/path_detector/cxx_header/utilityCxxHeaderDetection.cpp b/src/lib_gui/utility/path_detector/cxx_header/utilityCxxHeaderDetection.cpp index c7a4db22..04288d94 100644 --- a/src/lib_gui/utility/path_detector/cxx_header/utilityCxxHeaderDetection.cpp +++ b/src/lib_gui/utility/path_detector/cxx_header/utilityCxxHeaderDetection.cpp @@ -15,7 +15,7 @@ namespace utility if (!standardHeaders.empty()) { - for (std::string s : utility::splitToVector(standardHeaders, '\n')) + for (const std::string& s : utility::splitToVector(standardHeaders, '\n')) { paths.push_back(utility::trim(s)); } diff --git a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp index baeda328..26741ae5 100644 --- a/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp +++ b/src/lib_gui/utility/path_detector/java_runtime/JavaPathDetectorLinux.cpp @@ -5,12 +5,11 @@ #include "utility/utilityString.h" #ifdef __x86_64__ - const std::string arch = "amd64"; + const char jvmLibPathRelativeToJavaExecutable[] = "/../lib/amd64/server/libjvm.so"; #else - const std::string arch = "i386"; + const char jvmLibPathRelativeToJavaExecutable[] = "/../lib/i386/server/libjvm.so"; #endif -const std::string jvmLibPathRelativeToJavaExecutable = "/../lib/" + arch + "/server/libjvm.so"; JavaPathDetectorLinux::JavaPathDetectorLinux(const std::string javaVersion) : JavaPathDetector("Java " + javaVersion + " for Linux", javaVersion) @@ -109,7 +108,7 @@ std::vector JavaPathDetectorLinux::getPaths() const paths.push_back(FilePath("/usr/lib/jvm/default/bin/java")); paths.push_back(FilePath("/usr/lib/jvm/java-openjdk/bin/java")); - for ( FilePath path : paths ) + for (const FilePath& path : paths ) { if (checkVersion(path)) { diff --git a/src/lib_java/data/indexer/IndexerCommandJava.cpp b/src/lib_java/data/indexer/IndexerCommandJava.cpp index a3ed4d59..48d3c909 100644 --- a/src/lib_java/data/indexer/IndexerCommandJava.cpp +++ b/src/lib_java/data/indexer/IndexerCommandJava.cpp @@ -29,7 +29,7 @@ size_t IndexerCommandJava::getByteSize() const { size_t size = IndexerCommand::getByteSize(); - for (auto i : m_classPath) + for (auto& i : m_classPath) { size += sizeof(std::string) + i.str().size(); } diff --git a/src/lib_java/project/SourceGroupJava.cpp b/src/lib_java/project/SourceGroupJava.cpp index 7c5cb62b..025e65d8 100644 --- a/src/lib_java/project/SourceGroupJava.cpp +++ b/src/lib_java/project/SourceGroupJava.cpp @@ -76,7 +76,7 @@ std::vector> SourceGroupJava::getIndexerCommands std::vector classPath = getClassPath(); std::set indexedPaths; - for (FilePath p: m_settings->getSourcePathsExpandedAndAbsolute()) + for (const FilePath& p: m_settings->getSourcePathsExpandedAndAbsolute()) { if (p.exists()) { @@ -85,7 +85,7 @@ std::vector> SourceGroupJava::getIndexerCommands } std::set excludedPaths; - for (FilePath p: m_settings->getExcludePathsExpandedAndAbsolute()) + for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute()) { if (p.exists()) { @@ -242,7 +242,7 @@ std::set SourceGroupJava::fetchRootDirectories() std::set rootDirectories; std::shared_ptr javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment(); - for (FilePath filePath: m_allSourceFilePaths) + for (const FilePath& filePath: m_allSourceFilePaths) { std::shared_ptr textAccess = TextAccess::createFromFile(filePath); diff --git a/src/lib_license/License.cpp b/src/lib_license/License.cpp index f575c832..4db86828 100644 --- a/src/lib_license/License.cpp +++ b/src/lib_license/License.cpp @@ -154,7 +154,7 @@ bool License::isTestLicense() const bool License::isNonCommercialLicenseType() const { - for ( const std::string nonCommercialLicenseType : NON_COMMERCIAL_LICENSE_TYPES) + for ( const std::string& nonCommercialLicenseType : NON_COMMERCIAL_LICENSE_TYPES) { if (m_type == nonCommercialLicenseType) { @@ -440,12 +440,6 @@ bool License::loadPublicKeyFromFile(const std::string& filename) bool License::loadPublicKey() { - if (PUBLIC_KEY.empty()) - { - std::cout << "Public key is empty" << std::endl; - return false; - } - Botan::DataSource_Memory in(PUBLIC_KEY); Botan::RSA_PublicKey *rsaPublicKey = dynamic_cast(Botan::X509::load_key(in)); @@ -483,10 +477,12 @@ bool License::loadPublicKeyFromString(const std::string& publicKey) std::string License::getLicenseString() const { std::string license = ""; - license += LicenseConstants::BEGIN_LICENSE_STRING + "\n"; + license += LicenseConstants::BEGIN_LICENSE_STRING; + license += "\n"; license += getMessage(true) + "\n"; license += getSignature() + "\n"; - license += LicenseConstants::END_LICENSE_STRING + "\n"; + license += LicenseConstants::END_LICENSE_STRING; + license += "\n"; return license; } diff --git a/src/lib_license/License.h b/src/lib_license/License.h index 10db96f8..f73540a5 100644 --- a/src/lib_license/License.h +++ b/src/lib_license/License.h @@ -14,15 +14,15 @@ namespace Botan } namespace LicenseConstants { - const std::string BEGIN_LICENSE_STRING = "-----BEGIN LICENSE-----"; - const std::string END_LICENSE_STRING = "-----END LICENSE-----"; - const std::string TEST_LICENSE_STRING = "Test License"; - const std::string PRODUCT_STRING = "Product: Sourcetrail"; - const std::string LICENSED_TO_STRING = "Licensed to: "; - const std::string LICENSE_TYPE_STRING = "License type: "; - const std::string VALID_UNTIL_STRING = "Valid until: "; - const std::string VALID_UP_TO_STRING = "Valid up to version: "; - const std::string SEPARATOR_STRING = "-"; + const char BEGIN_LICENSE_STRING[] = "-----BEGIN LICENSE-----"; + const char END_LICENSE_STRING[] = "-----END LICENSE-----"; + const char TEST_LICENSE_STRING[] = "Test License"; + const char PRODUCT_STRING[] = "Product: Sourcetrail"; + const char LICENSED_TO_STRING[] = "Licensed to: "; + const char LICENSE_TYPE_STRING[] = "License type: "; + const char VALID_UNTIL_STRING[] = "Valid until: "; + const char VALID_UP_TO_STRING[] = "Valid up to version: "; + const char SEPARATOR_STRING[] = "-"; const int MINOR_VERSIONS_PER_YEAR = 4; } diff --git a/src/license_generator/Generator.cpp b/src/license_generator/Generator.cpp index 834aa377..04a6fe2e 100644 --- a/src/license_generator/Generator.cpp +++ b/src/license_generator/Generator.cpp @@ -21,8 +21,7 @@ #include "PrivateKey.h" #include "PublicKey.h" -const std::string KEY_FILEENDING = ".pem"; -const std::string PRIVATE_KEY_PASSWORD = "BA#jk5vbklAiKL9K3k$"; +const char PRIVATE_KEY_PASSWORD[] = "BA#jk5vbklAiKL9K3k$"; const char PRIVATE_KEY_FILE[] = "private-sourcetrail.pem"; const char PUBLIC_KEY_FILE[] = "public-sourcetrail.pem"; diff --git a/src/test/SharedMemoryTestSuite.h b/src/test/SharedMemoryTestSuite.h index fc0439b3..7c26cab8 100644 --- a/src/test/SharedMemoryTestSuite.h +++ b/src/test/SharedMemoryTestSuite.h @@ -51,7 +51,7 @@ public: )); } - for (auto thread : threads) + for (auto& thread : threads) { thread->join(); } @@ -74,7 +74,7 @@ public: SharedMemory::Vector* strings = access.accessValueWithAllocator>("strings"); TS_ASSERT_EQUALS(strings->size(), 4); - for (SharedMemory::String str : *strings) + for (SharedMemory::String& str : *strings) { TS_ASSERT_EQUALS(str, "ho"); }