From 03cf9eeb5f26c4019edf7354c9c411713716f061 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 16 Mar 2015 10:07:57 +0100 Subject: [PATCH] data: Fixes and features for loading Coati into Coati This change facilitates loading Coati into Coati: * removed error logs for TokenComponent setting * fixed edge checks regarding template stuff * separated CommonSettings to be inherited by Project- and ApplicationSettings for common settings * pluralized SourcePaths setting in xml to allow for loading multiple directories and single files * added CompilerFlags section to settings * passing Compiler arguments to Parser via struct Parser::Arguments * setting -isystem for all header search paths to avoid distinction between "" and <> headers * parsing all headers from the SourcePaths, even the ones that are not included * fixed parsing time measurement and display * added utility.h file for general utility functionality --- bin/app/data/ApplicationSettings_template.xml | 12 +- bin/app/data/ProjectSettings_template.xml | 16 +- bin/test/data/SettingsTestSuite/settings.xml | 6 +- src/app/platform_includes/includesMac.h | 1 + src/app/qt/element/QtAutocompletionList.cpp | 2 +- src/app/qt/element/QtCodeSnippet.cpp | 7 +- src/app/qt/element/QtSmartSearchBox.cpp | 5 +- src/app/qt/view/graphElements/QtGraphNode.cpp | 3 +- src/lib/Application.cpp | 9 +- src/lib/CMakeLists.txt | 15 +- src/lib/Project.cpp | 164 ++++++++---------- src/lib/Project.h | 4 +- src/lib/ProjectSettings.cpp | 38 ---- .../controller/StatusBarController.cpp | 10 +- src/lib/data/graph/Edge.cpp | 12 +- src/lib/data/graph/Node.cpp | 14 +- src/lib/data/graph/Node.h | 4 +- src/lib/data/parser/Parser.cpp | 5 + src/lib/data/parser/Parser.h | 21 ++- src/lib/data/parser/cxx/ASTVisitor.cpp | 2 +- src/lib/data/parser/cxx/CxxParser.cpp | 57 +++--- src/lib/data/parser/cxx/CxxParser.h | 14 +- .../{ => settings}/ApplicationSettings.cpp | 9 +- src/lib/{ => settings}/ApplicationSettings.h | 10 +- src/lib/settings/CommonSettings.cpp | 27 +++ src/lib/settings/CommonSettings.h | 21 +++ src/lib/settings/ProjectSettings.cpp | 32 ++++ src/lib/{ => settings}/ProjectSettings.h | 11 +- src/lib/{ => settings}/Settings.cpp | 12 +- src/lib/{ => settings}/Settings.h | 17 +- src/lib/utility/ConfigManager.cpp | 6 +- src/lib/utility/file/FileRegister.cpp | 30 +++- src/lib/utility/file/FileRegister.h | 4 +- src/lib/utility/file/FileSystem.cpp | 11 +- src/lib/utility/utility.h | 41 +++++ src/test/CxxParserTestSuite.h | 19 +- src/test/DataTypeTestSuite.h | 2 + src/test/GraphTestSuite.h | 2 + src/test/MessageQueueTestSuite.h | 1 + src/test/SearchIndexTestSuite.h | 4 +- src/test/SettingsTestSuite.h | 13 +- src/test/StorageGraphTestSuite.h | 4 +- src/test/StorageTestSuite.h | 2 + src/test/helper/TestStorage.cpp | 3 +- 44 files changed, 442 insertions(+), 260 deletions(-) delete mode 100644 src/lib/ProjectSettings.cpp rename src/lib/{ => settings}/ApplicationSettings.cpp (91%) rename src/lib/{ => settings}/ApplicationSettings.h (91%) create mode 100644 src/lib/settings/CommonSettings.cpp create mode 100644 src/lib/settings/CommonSettings.h create mode 100644 src/lib/settings/ProjectSettings.cpp rename src/lib/{ => settings}/ProjectSettings.h (65%) rename src/lib/{ => settings}/Settings.cpp (96%) rename src/lib/{ => settings}/Settings.h (82%) create mode 100644 src/lib/utility/utility.h diff --git a/bin/app/data/ApplicationSettings_template.xml b/bin/app/data/ApplicationSettings_template.xml index ee1b72fc..c0c70aea 100644 --- a/bin/app/data/ApplicationSettings_template.xml +++ b/bin/app/data/ApplicationSettings_template.xml @@ -7,9 +7,18 @@ + + + + - + + + + + + @@ -23,7 +32,6 @@ - diff --git a/bin/app/data/ProjectSettings_template.xml b/bin/app/data/ProjectSettings_template.xml index fcd103c3..312cd7d6 100644 --- a/bin/app/data/ProjectSettings_template.xml +++ b/bin/app/data/ProjectSettings_template.xml @@ -7,9 +7,21 @@ - + + + + + + + + - + + + + + + diff --git a/bin/test/data/SettingsTestSuite/settings.xml b/bin/test/data/SettingsTestSuite/settings.xml index 462cbcf7..ef745330 100644 --- a/bin/test/data/SettingsTestSuite/settings.xml +++ b/bin/test/data/SettingsTestSuite/settings.xml @@ -6,12 +6,14 @@ Hello World! - data + + data + data/ src/ - + diff --git a/src/app/platform_includes/includesMac.h b/src/app/platform_includes/includesMac.h index 6c00e725..b7d34bfa 100644 --- a/src/app/platform_includes/includesMac.h +++ b/src/app/platform_includes/includesMac.h @@ -2,6 +2,7 @@ #define INCLUDES_MAC_H #include +#include #include void setup(int argc, char *argv[]) diff --git a/src/app/qt/element/QtAutocompletionList.cpp b/src/app/qt/element/QtAutocompletionList.cpp index f5d2e553..1ccbc64d 100644 --- a/src/app/qt/element/QtAutocompletionList.cpp +++ b/src/app/qt/element/QtAutocompletionList.cpp @@ -3,7 +3,7 @@ #include #include -#include "ApplicationSettings.h" +#include "settings/ApplicationSettings.h" QtAutocompletionModel::QtAutocompletionModel(QObject* parent) : QAbstractTableModel(parent) diff --git a/src/app/qt/element/QtCodeSnippet.cpp b/src/app/qt/element/QtCodeSnippet.cpp index 89f20114..100fae08 100644 --- a/src/app/qt/element/QtCodeSnippet.cpp +++ b/src/app/qt/element/QtCodeSnippet.cpp @@ -6,13 +6,14 @@ #include #include -#include "ApplicationSettings.h" +#include "utility/messaging/type/MessageActivateTokenLocation.h" +#include "utility/messaging/type/MessageShowFile.h" + #include "data/location/TokenLocation.h" #include "data/location/TokenLocationFile.h" #include "qt/element/QtCodeFile.h" #include "qt/utility/QtHighlighter.h" -#include "utility/messaging/type/MessageActivateTokenLocation.h" -#include "utility/messaging/type/MessageShowFile.h" +#include "settings/ApplicationSettings.h" QtCodeSnippet::LineNumberArea::LineNumberArea(QtCodeSnippet *codeSnippet) : QWidget(codeSnippet) diff --git a/src/app/qt/element/QtSmartSearchBox.cpp b/src/app/qt/element/QtSmartSearchBox.cpp index dd4d6f07..a7a2a8b9 100644 --- a/src/app/qt/element/QtSmartSearchBox.cpp +++ b/src/app/qt/element/QtSmartSearchBox.cpp @@ -6,8 +6,6 @@ #include #include -#include "ApplicationSettings.h" - #include "utility/logging/logging.h" #include "utility/messaging/type/MessageSearch.h" #include "utility/messaging/type/MessageSearchAutocomplete.h" @@ -16,8 +14,7 @@ #include "data/query/QueryTree.h" #include "qt/element/QtAutocompletionList.h" - -#include +#include "settings/ApplicationSettings.h" QtQueryElement::QtQueryElement(const QString& text, QWidget* parent) : QPushButton(text, parent) diff --git a/src/app/qt/view/graphElements/QtGraphNode.cpp b/src/app/qt/view/graphElements/QtGraphNode.cpp index 936de980..1c114358 100644 --- a/src/app/qt/view/graphElements/QtGraphNode.cpp +++ b/src/app/qt/view/graphElements/QtGraphNode.cpp @@ -4,8 +4,6 @@ #include #include -#include "ApplicationSettings.h" - #include "utility/messaging/type/MessageActivateTokens.h" #include "utility/messaging/type/MessageGraphNodeMove.h" @@ -13,6 +11,7 @@ #include "qt/utility/QtDeviceScaledPixmap.h" #include "qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h" #include "qt/view/graphElements/QtGraphEdge.h" +#include "settings/ApplicationSettings.h" void QtGraphNode::blendIn() { diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index c6772979..a2bb92eb 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -1,13 +1,14 @@ #include "Application.h" -#include "ApplicationSettings.h" +#include "utility/logging/logging.h" +#include "utility/messaging/MessageQueue.h" +#include "utility/messaging/type/MessageActivateTokens.h" + #include "component/view/MainView.h" #include "component/view/ViewFactory.h" #include "data/access/GraphAccessProxy.h" #include "data/access/LocationAccessProxy.h" -#include "utility/logging/logging.h" -#include "utility/messaging/MessageQueue.h" -#include "utility/messaging/type/MessageActivateTokens.h" +#include "settings/ApplicationSettings.h" std::shared_ptr Application::create(ViewFactory* viewFactory) { diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index d17b62d9..090d0297 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -190,6 +190,15 @@ add_files( data/Storage.cpp data/Storage.h + settings/ApplicationSettings.cpp + settings/ApplicationSettings.h + settings/CommonSettings.cpp + settings/CommonSettings.h + settings/ProjectSettings.cpp + settings/ProjectSettings.h + settings/Settings.cpp + settings/Settings.h + utility/file/FileInfo.cpp utility/file/FileInfo.h utility/file/FileManager.cpp @@ -265,12 +274,6 @@ add_files( Application.cpp Application.h - ApplicationSettings.cpp - ApplicationSettings.h Project.cpp Project.h - ProjectSettings.cpp - ProjectSettings.h - Settings.cpp - Settings.h ) diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp index 95bf0642..844be464 100644 --- a/src/lib/Project.cpp +++ b/src/lib/Project.cpp @@ -1,19 +1,15 @@ #include "Project.h" -#include -#include -#include -#include -#include +#include "utility/logging/logging.h" +#include "utility/messaging/type/MessageFinishedParsing.h" +#include "utility/utility.h" -#include "ApplicationSettings.h" #include "data/access/GraphAccessProxy.h" #include "data/access/LocationAccessProxy.h" #include "data/graph/Token.h" #include "data/parser/cxx/CxxParser.h" -#include "utility/logging/logging.h" -#include "utility/messaging/type/MessageFinishedParsing.h" -#include "utility/file/FileSystem.h" +#include "settings/ApplicationSettings.h" +#include "settings/ProjectSettings.h" std::shared_ptr Project::create(GraphAccessProxy* graphAccessProxy, LocationAccessProxy* locationAccessProxy) { @@ -64,7 +60,7 @@ void Project::clearProjectSettings() bool Project::setSourceDirectoryPath(const std::string& sourceDirectoryPath) { m_projectSettingsFilepath = sourceDirectoryPath + "/ProjectSettings.xml"; - return ProjectSettings::getInstance()->setSourcePath(sourceDirectoryPath); + return ProjectSettings::getInstance()->setSourcePaths(std::vector(1, sourceDirectoryPath)); } void Project::clearStorage() @@ -79,86 +75,78 @@ void Project::clearStorage() void Project::parseCode() { - std::string sourcePath = ProjectSettings::getInstance()->getSourcePath(); - if (sourcePath.size()) + std::shared_ptr projSettings = ProjectSettings::getInstance(); + std::shared_ptr appSettings = ApplicationSettings::getInstance(); + + std::vector sourcePaths = projSettings->getSourcePaths(); + if (!sourcePaths.size()) { - std::vector includePaths; - includePaths.push_back(sourcePath); - - // TODO: move this creation to another place (after projectsettings have been loaded) - if (!m_fileManager) - { - std::vector sourcePaths; - sourcePaths.push_back(sourcePath); - - std::vector sourceExtensions; - sourceExtensions.push_back(".cpp"); - sourceExtensions.push_back(".cc"); - - std::vector includeExtensions; - includeExtensions.push_back(".h"); - includeExtensions.push_back(".hpp"); - - m_fileManager = std::make_shared(sourcePaths, includePaths, sourceExtensions, includeExtensions); - } - - m_fileManager->fetchFilePaths(); - std::set addedFilePaths = m_fileManager->getAddedFilePaths(); - std::set updatedFilePaths = m_fileManager->getUpdatedFilePaths(); - std::set removedFilePaths = m_fileManager->getRemovedFilePaths(); - - std::set dependingFilePaths; - dependingFilePaths = m_storage->getDependingFilePathsAndRemoveFileNodes(updatedFilePaths); - updatedFilePaths.insert(dependingFilePaths.begin(), dependingFilePaths.end()); - - dependingFilePaths = m_storage->getDependingFilePathsAndRemoveFileNodes(removedFilePaths); - updatedFilePaths.insert(dependingFilePaths.begin(), dependingFilePaths.end()); - - m_storage->clearFileData(updatedFilePaths); - m_storage->clearFileData(removedFilePaths); - - std::vector filesToParse; - filesToParse.insert(filesToParse.end(), addedFilePaths.begin(), addedFilePaths.end()); - filesToParse.insert(filesToParse.end(), updatedFilePaths.begin(), updatedFilePaths.end()); - - if (filesToParse.size() == 0) - { - MessageFinishedParsing(0, 0, m_storage->getErrorCount()).dispatch(); - } - else - { - // Add the SourcePaths as HeaderSearchPaths as well, so clang will also look here when searching include files. - std::vector headerSearchPaths = ProjectSettings::getInstance()->getHeaderSearchPaths(); - for (size_t i = 0; i < includePaths.size(); i++) - { - headerSearchPaths.push_back(includePaths[i]); - } - - // std::cout << "parse files" << std::endl; - // for (const FilePath& path : filesToParse) - // { - // std::cout << path.absoluteStr() << std::endl; - // } - // std::cout << std::endl; - - CxxParser parser(m_storage.get(), m_fileManager.get()); - clock_t time = clock(); - parser.parseFiles( - filesToParse, - ApplicationSettings::getInstance()->getHeaderSearchPaths(), - headerSearchPaths - ); - time = clock() - time; - - // m_storage->logGraph(); - // m_storage->logLocations(); - - double parseTime = (double)(time) / CLOCKS_PER_SEC; - LOG_INFO_STREAM(<< "parse time: " << parseTime); - - MessageFinishedParsing(filesToParse.size(), parseTime, m_storage->getErrorCount()).dispatch(); - } + return; } + + std::vector includePaths(sourcePaths); + + // TODO: move this creation to another place (after projectsettings have been loaded) + if (!m_fileManager) + { + std::vector sourceExtensions; + sourceExtensions.push_back(".cpp"); + sourceExtensions.push_back(".cc"); + + std::vector includeExtensions; + includeExtensions.push_back(".h"); + includeExtensions.push_back(".hpp"); + + m_fileManager = std::make_shared(sourcePaths, includePaths, sourceExtensions, includeExtensions); + } + + m_fileManager->fetchFilePaths(); + std::set addedFilePaths = m_fileManager->getAddedFilePaths(); + std::set updatedFilePaths = m_fileManager->getUpdatedFilePaths(); + std::set removedFilePaths = m_fileManager->getRemovedFilePaths(); + + utility::append(updatedFilePaths, m_storage->getDependingFilePathsAndRemoveFileNodes(updatedFilePaths)); + utility::append(updatedFilePaths, m_storage->getDependingFilePathsAndRemoveFileNodes(removedFilePaths)); + + m_storage->clearFileData(updatedFilePaths); + m_storage->clearFileData(removedFilePaths); + + std::vector filesToParse; + filesToParse.insert(filesToParse.end(), addedFilePaths.begin(), addedFilePaths.end()); + filesToParse.insert(filesToParse.end(), updatedFilePaths.begin(), updatedFilePaths.end()); + + if (filesToParse.size() == 0) + { + MessageFinishedParsing(0, 0, m_storage->getErrorCount()).dispatch(); + return; + } + + Parser::Arguments args; + + utility::append(args.compilerFlags, projSettings->getCompilerFlags()); + utility::append(args.compilerFlags, appSettings->getCompilerFlags()); + + // Add the include paths as HeaderSearchPaths as well, so clang will also look here when searching include files. + utility::append(args.systemHeaderSearchPaths, includePaths); + utility::append(args.systemHeaderSearchPaths, projSettings->getHeaderSearchPaths()); + utility::append(args.systemHeaderSearchPaths, appSettings->getHeaderSearchPaths()); + + utility::append(args.frameworkSearchPaths, projSettings->getFrameworkSearchPaths()); + utility::append(args.frameworkSearchPaths, appSettings->getFrameworkSearchPaths()); + + CxxParser parser(m_storage.get(), m_fileManager.get()); + + float duration = utility::duration( + [&]() + { + parser.parseFiles(filesToParse, args); + } + ); + + // m_storage->logGraph(); + // m_storage->logLocations(); + + MessageFinishedParsing(filesToParse.size(), duration, m_storage->getErrorCount()).dispatch(); } Project::Project(GraphAccessProxy* graphAccessProxy, LocationAccessProxy* locationAccessProxy) diff --git a/src/lib/Project.h b/src/lib/Project.h index 92c86d68..571bff9b 100644 --- a/src/lib/Project.h +++ b/src/lib/Project.h @@ -3,9 +3,9 @@ #include -#include "data/Storage.h" #include "utility/file/FileManager.h" -#include "ProjectSettings.h" + +#include "data/Storage.h" class GraphAccessProxy; class LocationAccessProxy; diff --git a/src/lib/ProjectSettings.cpp b/src/lib/ProjectSettings.cpp deleted file mode 100644 index 4f90715d..00000000 --- a/src/lib/ProjectSettings.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "ProjectSettings.h" - -std::shared_ptr ProjectSettings::s_instance; - -std::shared_ptr ProjectSettings::getInstance() -{ - if (!s_instance) - { - s_instance = std::shared_ptr(new ProjectSettings()); - } - - return s_instance; -} - -ProjectSettings::ProjectSettings() -{ -} - -ProjectSettings::~ProjectSettings() -{ -} - -std::string ProjectSettings::getSourcePath() const -{ - return getValue("source/SourcePath", ""); -} - -bool ProjectSettings::setSourcePath(const std::string& sourcePath) -{ - return setValue("source/SourcePath", sourcePath); -} - -std::vector ProjectSettings::getHeaderSearchPaths() const -{ - //TODO defaultvalues? - std::vector defaultValues; - return getValues("source/HeaderSearchPaths/HeaderSearchPath", defaultValues); -} diff --git a/src/lib/component/controller/StatusBarController.cpp b/src/lib/component/controller/StatusBarController.cpp index 847cef6f..8c8492f4 100644 --- a/src/lib/component/controller/StatusBarController.cpp +++ b/src/lib/component/controller/StatusBarController.cpp @@ -1,10 +1,12 @@ #include "component/controller/StatusBarController.h" -#include "component/view/StatusBarView.h" - #include #include +#include "utility/logging/logging.h" + +#include "component/view/StatusBarView.h" + StatusBarController::StatusBarController() : MessageListener(true) , MessageListener(true) @@ -29,7 +31,7 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message) std::stringstream ss; ss << "Parsing Finished: "; ss << message->fileCount << " files, "; - ss << std::setprecision(2) << message->parseTime << " seconds, "; + ss << std::setprecision(2) << std::fixed << message->parseTime << " seconds, "; ss << message->errorCount << " error(s)"; bool hasErrors = message->errorCount > 0; @@ -66,6 +68,8 @@ void StatusBarController::setStatus(const std::string& status, bool isError) { if (!status.empty()) { + LOG_INFO_STREAM(<< "STATUS " << status); + getView()->showMessage(status, isError); } } diff --git a/src/lib/data/graph/Edge.cpp b/src/lib/data/graph/Edge.cpp index cec35d4c..5c0b531d 100644 --- a/src/lib/data/graph/Edge.cpp +++ b/src/lib/data/graph/Edge.cpp @@ -97,7 +97,8 @@ void Edge::addComponentAccess(std::shared_ptr component) { if (getComponent()) { - LOG_ERROR("TokenComponentAccess has been set before!"); + // LOG_ERROR("TokenComponentAccess has been set before!"); + return; } else if (m_type != EDGE_MEMBER && m_type != EDGE_INHERITANCE) { @@ -182,7 +183,7 @@ std::ostream& operator<<(std::ostream& ostream, const Edge& edge) bool Edge::checkType() const { - Node::NodeTypeMask complexTypeMask = Node::NODE_UNDEFINED_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT; + Node::NodeTypeMask complexTypeMask = Node::NODE_UNDEFINED_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT | Node:: NODE_TEMPLATE_PARAMETER_TYPE; Node::NodeTypeMask typeMask = Node::NODE_UNDEFINED | Node::NODE_ENUM | Node::NODE_TYPEDEF | complexTypeMask; Node::NodeTypeMask variableMask = Node::NODE_UNDEFINED | Node::NODE_UNDEFINED_VARIABLE | Node::NODE_GLOBAL_VARIABLE | Node::NODE_FIELD; Node::NodeTypeMask functionMask = Node::NODE_UNDEFINED_FUNCTION | Node::NODE_FUNCTION | Node::NODE_METHOD; @@ -190,9 +191,10 @@ bool Edge::checkType() const switch (m_type) { case EDGE_MEMBER: - if (!m_from->isType(typeMask | Node::NODE_NAMESPACE) || + if (!m_from->isType(typeMask | Node::NODE_NAMESPACE | functionMask) || (!m_from->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE) && m_to->isType(Node::NODE_NAMESPACE)) || - (m_from->isType(Node::NODE_ENUM) && !m_to->isType(Node::NODE_ENUM_CONSTANT))) + (m_from->isType(Node::NODE_ENUM) && !m_to->isType(Node::NODE_ENUM_CONSTANT)) || + (m_from->isType(functionMask) && !m_to->isType(Node::NODE_TEMPLATE_PARAMETER_TYPE))) { break; } @@ -259,7 +261,7 @@ bool Edge::checkType() const case EDGE_TEMPLATE_ARGUMENT_OF: case EDGE_TEMPLATE_DEFAULT_ARGUMENT_OF: - if (!m_from->isType(typeMask) || !m_to->isType(typeMask)) + if (!m_from->isType(typeMask) || !m_to->isType(typeMask | functionMask)) { break; } diff --git a/src/lib/data/graph/Node.cpp b/src/lib/data/graph/Node.cpp index 82e9416a..048fb294 100644 --- a/src/lib/data/graph/Node.cpp +++ b/src/lib/data/graph/Node.cpp @@ -251,7 +251,8 @@ void Node::addComponentAbstraction(std::shared_ptr co { if (getComponent()) { - LOG_ERROR("TokenComponentAbstraction has been set before!"); + // LOG_ERROR("TokenComponentAbstraction has been set before!"); + return; } else if (!isType(NODE_METHOD)) { @@ -267,7 +268,8 @@ void Node::addComponentConst(std::shared_ptr component) { if (getComponent()) { - LOG_ERROR("TokenComponentConst has been set before!"); + // LOG_ERROR("TokenComponentConst has been set before!"); + return; } else if (!isType(NODE_METHOD)) { @@ -283,7 +285,8 @@ void Node::addComponentStatic(std::shared_ptr component) { if (getComponent()) { - LOG_ERROR("TokenComponentStatic has been set before!"); + // LOG_ERROR("TokenComponentStatic has been set before!"); + return; } else if (!isType(NODE_GLOBAL_VARIABLE | NODE_FIELD | NODE_FUNCTION | NODE_METHOD)) { @@ -315,11 +318,12 @@ void Node::addComponentFilePath(std::shared_ptr componen { if (getComponent()) { - LOG_ERROR("TokenComponentFilePath has been set before!"); + // LOG_ERROR("TokenComponentFilePath has been set before!"); + return; } else if (!isType(NODE_FILE)) { - LOG_ERROR("TokenComponentSignature can't be set on node of type: " + getTypeString()); + LOG_ERROR("TokenComponentFilePath can't be set on node of type: " + getTypeString()); } else { diff --git a/src/lib/data/graph/Node.h b/src/lib/data/graph/Node.h index 1bb7b640..64f2e63e 100644 --- a/src/lib/data/graph/Node.h +++ b/src/lib/data/graph/Node.h @@ -24,9 +24,9 @@ public: enum NodeType : NodeTypeMask { NODE_UNDEFINED = 0x1, - NODE_UNDEFINED_FUNCTION = 0x2, + NODE_UNDEFINED_TYPE = 0x2, NODE_UNDEFINED_VARIABLE = 0x4, - NODE_UNDEFINED_TYPE = 0x8, + NODE_UNDEFINED_FUNCTION = 0x8, NODE_STRUCT = 0x10, NODE_CLASS = 0x20, diff --git a/src/lib/data/parser/Parser.cpp b/src/lib/data/parser/Parser.cpp index d030de48..721ee5e6 100644 --- a/src/lib/data/parser/Parser.cpp +++ b/src/lib/data/parser/Parser.cpp @@ -1,5 +1,10 @@ #include "data/parser/Parser.h" +Parser::Arguments::Arguments() + : logErrors(true) +{ +} + Parser::Parser(ParserClient* client) : m_client(client) { diff --git a/src/lib/data/parser/Parser.h b/src/lib/data/parser/Parser.h index 94364eff..e87cc9ae 100644 --- a/src/lib/data/parser/Parser.h +++ b/src/lib/data/parser/Parser.h @@ -13,17 +13,22 @@ class TextAccess; class Parser { public: + struct Arguments + { + Arguments(); + + std::vector headerSearchPaths; + std::vector systemHeaderSearchPaths; + std::vector frameworkSearchPaths; + std::vector compilerFlags; + bool logErrors; + }; + Parser(ParserClient* client); virtual ~Parser(); - virtual void parseFiles( - const std::vector& filePaths, - const std::vector& systemHeaderSearchPaths, - const std::vector& headerSearchPaths) = 0; - virtual void parseFile( - std::shared_ptr textAccess, - const std::vector& systemHeaderSearchPaths, - bool logErrors) = 0; + virtual void parseFiles(const std::vector& filePaths, const Arguments& arguments) = 0; + virtual void parseFile(std::shared_ptr textAccess, const Arguments& arguments) = 0; protected: ParserClient* m_client; diff --git a/src/lib/data/parser/cxx/ASTVisitor.cpp b/src/lib/data/parser/cxx/ASTVisitor.cpp index 2f9d0f4f..d5c9a348 100644 --- a/src/lib/data/parser/cxx/ASTVisitor.cpp +++ b/src/lib/data/parser/cxx/ASTVisitor.cpp @@ -703,7 +703,7 @@ bool ASTVisitor::isLocatedInUnparsedProjectFile(const clang::Decl* declaration) return true; } - return m_fileRegister->includeFileIsParsing(m_context->getSourceManager().getFilename(location)); + return m_fileRegister->includeFileIsParsing(FilePath(m_context->getSourceManager().getFilename(location))); } bool ASTVisitor::isLocatedInProjectFile(const clang::Decl* declaration) const diff --git a/src/lib/data/parser/cxx/CxxParser.cpp b/src/lib/data/parser/cxx/CxxParser.cpp index 859c16d8..371d6596 100644 --- a/src/lib/data/parser/cxx/CxxParser.cpp +++ b/src/lib/data/parser/cxx/CxxParser.cpp @@ -58,12 +58,10 @@ CxxParser::~CxxParser() { } -void CxxParser::parseFiles( - const std::vector& filePaths, - const std::vector& systemHeaderSearchPaths, - const std::vector& headerSearchPaths -){ - std::vector args = getArgs(systemHeaderSearchPaths, headerSearchPaths); +void CxxParser::parseFiles(const std::vector& filePaths, const Arguments& arguments) +{ + // Commandline flags passed to the programm. Everything after '--' will be interpreted by the ClangTool. + std::vector args = getCommandlineArguments(arguments); args.insert(args.begin(), "app"); args.insert(args.begin() + 1, "--"); @@ -93,22 +91,34 @@ void CxxParser::parseFiles( } llvm::IntrusiveRefCntPtr options = new clang::DiagnosticOptions(); - CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client); + CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, arguments.logErrors); ASTActionFactory actionFactory(m_client, &fileRegister); clang::tooling::ClangTool tool(*compilationDatabase, sourcePaths); tool.setDiagnosticConsumer(&reporter); tool.run(&actionFactory); + + std::vector unparsedHeaders = fileRegister.getUnparsedIncludeFilePaths(); + for (const FilePath& path : unparsedHeaders) + { + if (!fileRegister.includeFileIsParsed(path)) + { + clang::tooling::ClangTool tool(*compilationDatabase, std::vector(1, path.str())); + tool.setDiagnosticConsumer(&reporter); + tool.run(&actionFactory); + } + } + + delete argv; } -void CxxParser::parseFile( - std::shared_ptr textAccess, const std::vector& systemHeaderSearchPaths, bool logErrors -){ - std::vector args = getArgs(systemHeaderSearchPaths, std::vector()); +void CxxParser::parseFile(std::shared_ptr textAccess, const Arguments& arguments) +{ + std::vector args = getCommandlineArguments(arguments); llvm::IntrusiveRefCntPtr options = new clang::DiagnosticOptions(); - CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, logErrors); + CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, arguments.logErrors); FileRegister fileRegister(m_fileManager, std::vector()); @@ -116,10 +126,8 @@ void CxxParser::parseFile( runToolOnCodeWithArgs(&reporter, actionFactory.create(), textAccess->getText(), args); } -std::vector CxxParser::getArgs( - const std::vector& systemHeaderSearchPaths, const std::vector& headerSearchPaths -) const { - // Commandline flags passed to the programm. Everything after '--' will be interpreted by the ClangTool. +std::vector CxxParser::getCommandlineArguments(const Arguments& arguments) const +{ std::vector args; // verbose @@ -138,15 +146,22 @@ std::vector CxxParser::getArgs( args.push_back("-std=c++11"); - for (const std::string& path : systemHeaderSearchPaths) - { - args.push_back("-isystem" + path); - } + args.insert(args.begin(), arguments.compilerFlags.begin(), arguments.compilerFlags.end()); - for (const std::string& path : headerSearchPaths) + for (const std::string& path : arguments.headerSearchPaths) { args.push_back("-I" + path); } + for (const std::string& path : arguments.systemHeaderSearchPaths) + { + args.push_back("-isystem" + path); + } + + for (const std::string& path : arguments.frameworkSearchPaths) + { + args.push_back("-iframework" + path); + } + return args; } diff --git a/src/lib/data/parser/cxx/CxxParser.h b/src/lib/data/parser/cxx/CxxParser.h index ee47439c..10e05886 100644 --- a/src/lib/data/parser/cxx/CxxParser.h +++ b/src/lib/data/parser/cxx/CxxParser.h @@ -10,19 +10,11 @@ public: CxxParser(ParserClient* client, const FileManager* fileManager); ~CxxParser(); - virtual void parseFiles( - const std::vector& filePaths, - const std::vector& systemHeaderSearchPaths, - const std::vector& headerSearchPaths); - virtual void parseFile( - std::shared_ptr textAccess, - const std::vector& systemHeaderSearchPaths, - bool logErrors); + virtual void parseFiles(const std::vector& filePaths, const Arguments& arguments); + virtual void parseFile(std::shared_ptr textAccess, const Arguments& arguments); private: - std::vector getArgs( - const std::vector& systemHeaderSearchPaths, - const std::vector& headerSearchPaths) const; + std::vector getCommandlineArguments(const Arguments& arguments) const; const FileManager* m_fileManager; }; diff --git a/src/lib/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp similarity index 91% rename from src/lib/ApplicationSettings.cpp rename to src/lib/settings/ApplicationSettings.cpp index c694b94f..9a6ac0b9 100644 --- a/src/lib/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -1,4 +1,4 @@ -#include "ApplicationSettings.h" +#include "settings/ApplicationSettings.h" std::shared_ptr ApplicationSettings::s_instance; @@ -16,13 +16,6 @@ ApplicationSettings::~ApplicationSettings() { } -std::vector ApplicationSettings::getHeaderSearchPaths() const -{ - //TODO: defaultValues? - std::vector defaultValues; - return getValues("source/HeaderSearchPaths/HeaderSearchPath", defaultValues); -} - int ApplicationSettings::getCodeTabWidth() const { return getValue("code/TabWidth", 4); diff --git a/src/lib/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h similarity index 91% rename from src/lib/ApplicationSettings.h rename to src/lib/settings/ApplicationSettings.h index 73a0cca0..5e13107c 100644 --- a/src/lib/ApplicationSettings.h +++ b/src/lib/settings/ApplicationSettings.h @@ -3,20 +3,19 @@ #include -#include "Settings.h" #include "utility/math/Color.h" + #include "data/graph/Node.h" #include "data/query/QueryNode.h" +#include "settings/CommonSettings.h" -class ApplicationSettings: public Settings +class ApplicationSettings + : public CommonSettings { public: static std::shared_ptr getInstance(); ~ApplicationSettings(); - // source - std::vector getHeaderSearchPaths() const; - // code int getCodeTabWidth() const; void setCodeTabWidth(int codeTabWidth); @@ -36,6 +35,7 @@ public: Colori getCodeActiveLinkColor() const; void setCodeActiveLinkColor(Colori color); + // colors std::string getNodeTypeColor(Node::NodeType type, const std::string& state = "normal") const; void setNodeTypeColor(Node::NodeType type, const std::string& color, const std::string& state = "normal"); diff --git a/src/lib/settings/CommonSettings.cpp b/src/lib/settings/CommonSettings.cpp new file mode 100644 index 00000000..141484fd --- /dev/null +++ b/src/lib/settings/CommonSettings.cpp @@ -0,0 +1,27 @@ +#include "settings/CommonSettings.h" + +CommonSettings::~CommonSettings() +{ +} + +std::vector CommonSettings::getHeaderSearchPaths() const +{ + std::vector defaultValues; + return getValues("source/HeaderSearchPaths/HeaderSearchPath", defaultValues); +} + +std::vector CommonSettings::getFrameworkSearchPaths() const +{ + std::vector defaultValues; + return getValues("source/FrameworkSearchPaths/FrameworkSearchPath", defaultValues); +} + +std::vector CommonSettings::getCompilerFlags() const +{ + std::vector defaultValues; + return getValues("source/CompilerFlags/CompilerFlag", defaultValues); +} + +CommonSettings::CommonSettings() +{ +} diff --git a/src/lib/settings/CommonSettings.h b/src/lib/settings/CommonSettings.h new file mode 100644 index 00000000..e57c8c3d --- /dev/null +++ b/src/lib/settings/CommonSettings.h @@ -0,0 +1,21 @@ +#ifndef COMMON_SETTINGS_H +#define COMMON_SETTINGS_H + +#include "settings/Settings.h" + +class CommonSettings + : public Settings +{ +public: + virtual ~CommonSettings(); + + // source + std::vector getHeaderSearchPaths() const; + std::vector getFrameworkSearchPaths() const; + std::vector getCompilerFlags() const; + +protected: + CommonSettings(); +}; + +#endif // COMMON_SETTINGS_H diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp new file mode 100644 index 00000000..3ecc51c1 --- /dev/null +++ b/src/lib/settings/ProjectSettings.cpp @@ -0,0 +1,32 @@ +#include "settings/ProjectSettings.h" + +std::shared_ptr ProjectSettings::s_instance; + +std::shared_ptr ProjectSettings::getInstance() +{ + if (!s_instance) + { + s_instance = std::shared_ptr(new ProjectSettings()); + } + + return s_instance; +} + +ProjectSettings::ProjectSettings() +{ +} + +ProjectSettings::~ProjectSettings() +{ +} + +std::vector ProjectSettings::getSourcePaths() const +{ + std::vector defaultValues; + return getValues("source/SourcePaths/SourcePath", defaultValues); +} + +bool ProjectSettings::setSourcePaths(const std::vector& sourcePaths) +{ + return setValues("source/SourcePaths/SourcePath", sourcePaths); +} diff --git a/src/lib/ProjectSettings.h b/src/lib/settings/ProjectSettings.h similarity index 65% rename from src/lib/ProjectSettings.h rename to src/lib/settings/ProjectSettings.h index 9f39f4e2..7820415f 100644 --- a/src/lib/ProjectSettings.h +++ b/src/lib/settings/ProjectSettings.h @@ -4,19 +4,18 @@ #include #include -#include "Settings.h" +#include "settings/CommonSettings.h" -class ProjectSettings: public Settings +class ProjectSettings + : public CommonSettings { public: static std::shared_ptr getInstance(); ~ProjectSettings(); // source - std::string getSourcePath() const; - bool setSourcePath(const std::string& sourcePath); - - std::vector getHeaderSearchPaths() const; + std::vector getSourcePaths() const; + bool setSourcePaths(const std::vector& sourcePaths); private: ProjectSettings(); diff --git a/src/lib/Settings.cpp b/src/lib/settings/Settings.cpp similarity index 96% rename from src/lib/Settings.cpp rename to src/lib/settings/Settings.cpp index d0b55519..0ac1aa0d 100644 --- a/src/lib/Settings.cpp +++ b/src/lib/settings/Settings.cpp @@ -1,15 +1,10 @@ -#include "Settings.h" +#include "settings/Settings.h" #include "utility/file/FileSystem.h" #include "utility/logging/logging.h" #include "utility/text/TextAccess.h" #include "utility/utilityString.h" -Settings::Settings() -{ - clear(); -} - Settings::~Settings() { } @@ -45,3 +40,8 @@ void Settings::clear() { m_config = ConfigManager::createEmpty(); } + +Settings::Settings() +{ + clear(); +} diff --git a/src/lib/Settings.h b/src/lib/settings/Settings.h similarity index 82% rename from src/lib/Settings.h rename to src/lib/settings/Settings.h index a0debe84..03e8f12e 100644 --- a/src/lib/Settings.h +++ b/src/lib/settings/Settings.h @@ -10,7 +10,6 @@ class Settings { public: - Settings(); virtual ~Settings(); bool load(const std::string& filePath); @@ -18,6 +17,8 @@ public: void clear(); protected: + Settings(); + template T getValue(const std::string& key, T defaultValue) const; @@ -27,6 +28,9 @@ protected: template bool setValue(const std::string& key, T value); + template + bool setValues(const std::string& key, std::vector values); + private: std::shared_ptr m_config; }; @@ -70,4 +74,15 @@ bool Settings::setValue(const std::string& key, T value) return false; } +template +bool Settings::setValues(const std::string& key, std::vector values) +{ + if (m_config) + { + m_config->setValues(key, values); + return true; + } + return false; +} + #endif // SETTINGS_H diff --git a/src/lib/utility/ConfigManager.cpp b/src/lib/utility/ConfigManager.cpp index b039811e..01e4d150 100644 --- a/src/lib/utility/ConfigManager.cpp +++ b/src/lib/utility/ConfigManager.cpp @@ -75,7 +75,7 @@ bool ConfigManager::getValues(const std::string& key, std::vector& if (ret.first != m_values.end()) { - std::multimap::const_iterator cit = ret.first; + std::multimap::const_iterator cit = ret.first; for(;cit!=ret.second;++cit) { values.push_back(cit->second); @@ -256,10 +256,10 @@ bool ConfigManager::createXmlDocument(bool saveAsFile, const std::string filepat { child = new TiXmlElement(tokens.front().c_str()); element->LinkEndChild(child); - } + } tokens.erase(tokens.begin()); element = child; - } + } child = new TiXmlElement(tokens.front().c_str()); element->LinkEndChild(child); diff --git a/src/lib/utility/file/FileRegister.cpp b/src/lib/utility/file/FileRegister.cpp index b759f1cb..f2d74f3d 100644 --- a/src/lib/utility/file/FileRegister.cpp +++ b/src/lib/utility/file/FileRegister.cpp @@ -29,9 +29,24 @@ const std::vector& FileRegister::getSourceFilePaths() const return m_sourceFilePaths; } -bool FileRegister::includeFileIsParsing(const std::string& filePath) const +std::vector FileRegister::getUnparsedIncludeFilePaths() const { - std::map::const_iterator it = m_includeFilePaths.find(FilePath(filePath)); + std::vector filePaths; + + for (std::pair&& p : m_includeFilePaths) + { + if (p.second == STATE_UNPARSED) + { + filePaths.push_back(p.first); + } + } + + return filePaths; +} + +bool FileRegister::includeFileIsParsing(const FilePath& filePath) const +{ + std::map::const_iterator it = m_includeFilePaths.find(filePath); if (it == m_includeFilePaths.end()) { return false; @@ -40,6 +55,17 @@ bool FileRegister::includeFileIsParsing(const std::string& filePath) const return it->second == STATE_PARSING; } +bool FileRegister::includeFileIsParsed(const FilePath& filePath) const +{ + std::map::const_iterator it = m_includeFilePaths.find(filePath); + if (it == m_includeFilePaths.end()) + { + return false; + } + + return it->second == STATE_PARSED; +} + void FileRegister::markIncludeFileParsing(const std::string& filePath) { std::map::iterator it = m_includeFilePaths.find(FilePath(filePath)); diff --git a/src/lib/utility/file/FileRegister.h b/src/lib/utility/file/FileRegister.h index 7429004f..b5aa4865 100644 --- a/src/lib/utility/file/FileRegister.h +++ b/src/lib/utility/file/FileRegister.h @@ -17,8 +17,10 @@ public: const FileManager* getFileManager() const; const std::vector& getSourceFilePaths() const; + std::vector getUnparsedIncludeFilePaths() const; - bool includeFileIsParsing(const std::string& filePath) const; + bool includeFileIsParsing(const FilePath& filePath) const; + bool includeFileIsParsed(const FilePath& filePath) const; void markIncludeFileParsing(const std::string& filePath); void markParsingIncludeFilesParsed(); diff --git a/src/lib/utility/file/FileSystem.cpp b/src/lib/utility/file/FileSystem.cpp index 4aa90e3e..3d190e8c 100644 --- a/src/lib/utility/file/FileSystem.cpp +++ b/src/lib/utility/file/FileSystem.cpp @@ -59,9 +59,10 @@ std::vector FileSystem::getFileInfosFromDirectoryPaths( std::vector files; for (const std::string& directoryPath: directoryPaths) { - if (boost::filesystem::is_directory(directoryPath)) + boost::filesystem::path path(directoryPath); + if (boost::filesystem::is_directory(path)) { - boost::filesystem::recursive_directory_iterator it(directoryPath); + boost::filesystem::recursive_directory_iterator it(path); boost::filesystem::recursive_directory_iterator endit; while (it != endit) { @@ -74,6 +75,12 @@ std::vector FileSystem::getFileInfosFromDirectoryPaths( ++it; } } + else if (boost::filesystem::exists(path) && hasExtension(path.string(), fileExtensions)) + { + std::time_t t = boost::filesystem::last_write_time(path); + boost::posix_time::ptime lastWriteTime = boost::posix_time::from_time_t(t); + files.push_back(FileInfo(path, lastWriteTime)); + } } return files; } diff --git a/src/lib/utility/utility.h b/src/lib/utility/utility.h new file mode 100644 index 00000000..8fb3d54c --- /dev/null +++ b/src/lib/utility/utility.h @@ -0,0 +1,41 @@ +#ifndef UTILITY_H +#define UTILITY_H + +#include + +namespace utility +{ + float duration(std::function func) + { + std::chrono::time_point start = std::chrono::system_clock::now(); + + func(); + + std::chrono::duration duration = + std::chrono::duration_cast(std::chrono::system_clock::now() - start); + return duration.count(); + } + + template + std::vector concat(const std::vector& a, const std::vector& b) + { + std::vector r(a.size() + b.size()); + append(r, a); + append(r, b); + return r; + } + + template + void append(std::vector& a, const std::vector& b) + { + a.insert(a.begin(), b.begin(), b.end()); + } + + template + void append(std::set& a, const std::set& b) + { + a.insert(b.begin(), b.end()); + } +} + +#endif // UTILITY_H diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index ccfe1fd4..71a819cd 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -1,14 +1,15 @@ #include "cxxtest/TestSuite.h" -#include "ApplicationSettings.h" +#include "utility/text/TextAccess.h" +#include "utility/utilityString.h" + #include "data/parser/cxx/CxxParser.h" #include "data/parser/ParseFunction.h" #include "data/parser/ParseLocation.h" #include "data/parser/ParserClient.h" #include "data/parser/ParseTypeUsage.h" #include "data/parser/ParseVariable.h" -#include "utility/text/TextAccess.h" -#include "utility/utilityString.h" +#include "settings/ApplicationSettings.h" #include "helper/TestFileManager.h" @@ -2247,7 +2248,7 @@ public: std::vector filePaths; filePaths.push_back(FilePath("data/CxxParserTestSuite/header.h")); filePaths.push_back(FilePath("data/CxxParserTestSuite/code.cpp")); - parser.parseFiles(filePaths, std::vector(), std::vector()); + parser.parseFiles(filePaths, Parser::Arguments()); TS_ASSERT_EQUALS(client.errors.size(), 0); @@ -2576,19 +2577,21 @@ private: std::shared_ptr parseCode(std::string code, bool logErrors = true) { - if (!m_systemHeaderSearchPaths.size()) + if (!m_args.headerSearchPaths.size()) { std::shared_ptr settings = ApplicationSettings::getInstance(); settings->load("data/TestSettings.xml"); - m_systemHeaderSearchPaths = settings->getHeaderSearchPaths(); + m_args.headerSearchPaths = settings->getHeaderSearchPaths(); } + m_args.logErrors = logErrors; + TestFileManager fm; std::shared_ptr client = std::make_shared(); CxxParser parser(client.get(), &fm); - parser.parseFile(TextAccess::createFromString(code), m_systemHeaderSearchPaths, logErrors); + parser.parseFile(TextAccess::createFromString(code), m_args); return client; } - std::vector m_systemHeaderSearchPaths; + Parser::Arguments m_args; }; diff --git a/src/test/DataTypeTestSuite.h b/src/test/DataTypeTestSuite.h index 953e6c34..8e2f38f8 100644 --- a/src/test/DataTypeTestSuite.h +++ b/src/test/DataTypeTestSuite.h @@ -1,5 +1,7 @@ #include "cxxtest/TestSuite.h" +#include "utility/utilityString.h" + #include "data/type/DataType.h" #include "data/type/modifier/DataTypeModifierArray.h" #include "data/type/modifier/DataTypeModifierPointer.h" diff --git a/src/test/GraphTestSuite.h b/src/test/GraphTestSuite.h index 9e964fe2..1873875f 100644 --- a/src/test/GraphTestSuite.h +++ b/src/test/GraphTestSuite.h @@ -1,5 +1,7 @@ #include "cxxtest/TestSuite.h" +#include "utility/utilityString.h" + #include "data/graph/Graph.h" #include "data/graph/token_component/TokenComponentName.h" diff --git a/src/test/MessageQueueTestSuite.h b/src/test/MessageQueueTestSuite.h index daa19b5d..a5d22d91 100644 --- a/src/test/MessageQueueTestSuite.h +++ b/src/test/MessageQueueTestSuite.h @@ -1,6 +1,7 @@ #include #include +#include #include "utility/messaging/Message.h" #include "utility/messaging/MessageListener.h" diff --git a/src/test/SearchIndexTestSuite.h b/src/test/SearchIndexTestSuite.h index 92fadc21..a98d1137 100644 --- a/src/test/SearchIndexTestSuite.h +++ b/src/test/SearchIndexTestSuite.h @@ -1,8 +1,10 @@ #include "cxxtest/TestSuite.h" -#include "data/search/SearchIndex.h" #include "utility/utilityString.h" +#include "data/search/SearchIndex.h" +#include "data/search/SearchMatch.h" + class SearchIndexTestSuite : public CxxTest::TestSuite { public: diff --git a/src/test/SettingsTestSuite.h b/src/test/SettingsTestSuite.h index 5a767820..031bc9ce 100644 --- a/src/test/SettingsTestSuite.h +++ b/src/test/SettingsTestSuite.h @@ -1,20 +1,20 @@ #include -#include "ProjectSettings.h" -#include "Settings.h" +#include "settings/ProjectSettings.h" +#include "settings/Settings.h" class SettingsTestSuite : public CxxTest::TestSuite { public: void test_settings_get_loaded_from_file() { - Settings settings; + TestSettings settings; TS_ASSERT(settings.load("data/SettingsTestSuite/settings.xml")); } void test_settings_get_not_loaded_from_file() { - Settings settings; + TestSettings settings; TS_ASSERT(!settings.load("data/SettingsTestSuite/wrong_settings.xml")); } @@ -114,7 +114,10 @@ public: void test_load_source_path_from_file() { ProjectSettings::getInstance()->load("data/SettingsTestSuite/settings.xml"); - TS_ASSERT_EQUALS(ProjectSettings::getInstance()->getSourcePath(), "data"); + std::vector paths = ProjectSettings::getInstance()->getSourcePaths(); + + TS_ASSERT_EQUALS(paths.size(), 1); + TS_ASSERT_EQUALS(paths[0], "data"); } void test_load_header_search_paths_from_file() diff --git a/src/test/StorageGraphTestSuite.h b/src/test/StorageGraphTestSuite.h index 9e872fc3..ed908586 100644 --- a/src/test/StorageGraphTestSuite.h +++ b/src/test/StorageGraphTestSuite.h @@ -1,7 +1,9 @@ #include "cxxtest/TestSuite.h" -#include "data/graph/token_component/TokenComponentAggregation.h" +#include "utility/utilityString.h" + #include "data/graph/StorageGraph.h" +#include "data/graph/token_component/TokenComponentAggregation.h" #include "data/search/SearchIndex.h" class StorageGraphTestSuite : public CxxTest::TestSuite diff --git a/src/test/StorageTestSuite.h b/src/test/StorageTestSuite.h index 17ca10c6..c0dca4a2 100644 --- a/src/test/StorageTestSuite.h +++ b/src/test/StorageTestSuite.h @@ -1,5 +1,7 @@ #include "cxxtest/TestSuite.h" +#include "utility/utilityString.h" + #include "data/graph/token_component/TokenComponentAbstraction.h" #include "data/graph/token_component/TokenComponentAccess.h" #include "data/graph/token_component/TokenComponentSignature.h" diff --git a/src/test/helper/TestStorage.cpp b/src/test/helper/TestStorage.cpp index 68fab477..3069d108 100644 --- a/src/test/helper/TestStorage.cpp +++ b/src/test/helper/TestStorage.cpp @@ -7,9 +7,10 @@ void TestStorage::parseCxxCode(std::string code) { clear(); + TestFileManager fm; CxxParser parser(this, &fm); - parser.parseFile(TextAccess::createFromString(code), std::vector(), true); + parser.parseFile(TextAccess::createFromString(code), Parser::Arguments()); } const Graph& TestStorage::getGraph() const