diff --git a/bin/test/data/log/test_log.txt b/bin/test/data/log/test_log.txt index b7b91f98..60f96fc4 100644 --- a/bin/test/data/log/test_log.txt +++ b/bin/test/data/log/test_log.txt @@ -84,16 +84,12 @@ FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef +FileManager.cpp ERROR: No FileInfo found for file: input.cc +FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc @@ -113,14 +109,8 @@ FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc @@ -133,14 +123,8 @@ FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc @@ -153,14 +137,8 @@ FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc @@ -191,14 +169,8 @@ FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config -FileManager.cpp ERROR: No FileInfo found for file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/stddef.h -FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: /Users/ebsi/Documents/clang-llvm/llvm/tools/clang/lib/Headers/__stddef_max_align_t.h FileManager.cpp ERROR: No FileInfo found for file: input.cc FileManager.cpp ERROR: No FileInfo found for file: input.cc @@ -235,69 +207,95 @@ ConfigManager.cpp WARNING: value Float is not present in config. ConfigManager.cpp WARNING: value String is not present in config. ConfigManager.cpp WARNING: value NewBool is not present in config. Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: typedef: type -> int Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: class: Class Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: struct: Struct Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: global: Global Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: global: Global Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: field: m_field Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: field: Struct::m_field Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: function: isTrue Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: method: isMethod Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: method: Class::isMethod Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: namespace: utility Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: enum: Category Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: enum: Class::Category Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: enum constant: VALUE Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: class: ClassA Storage.cpp INFO: class: ClassB Storage.cpp INFO: inheritance: ClassB : ClassA Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: struct: StructA Storage.cpp INFO: struct: StructB Storage.cpp INFO: inheritance: StructB : StructA Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: method: A::isMethod Storage.cpp INFO: method: B::isMethod Storage.cpp INFO: override: A::isMethod -> B::isMethod Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: function: isTrue Storage.cpp INFO: function: func Storage.cpp INFO: call: isTrue -> func Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: global: global Storage.cpp INFO: function: isTrue Storage.cpp INFO: call: global -> isTrue Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: function: isTrue Storage.cpp INFO: field: Foo::m_field Storage.cpp INFO: field usage: isTrue -> Foo::m_field Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: function: isTrue Storage.cpp INFO: global: global Storage.cpp INFO: global usage: isTrue -> global Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: function: isTrue Storage.cpp INFO: struct: Struct Storage.cpp INFO: type usage: isTrue -> Struct Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: file: file.h < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.h Storage.cpp INFO: file: file.cpp < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.cpp Storage.cpp INFO: file: file.h < 0:0 0:0> +TextAccess.cpp ERROR: Could not open file file.h Storage.cpp INFO: file: file.cpp < 0:0 0:0> Storage.cpp INFO: include: file.h Storage.cpp INFO: file: file.cpp < 0:0 0:0> diff --git a/src/app/qt/element/QtCodeFile.cpp b/src/app/qt/element/QtCodeFile.cpp index ce54feed..ca7ad3ce 100644 --- a/src/app/qt/element/QtCodeFile.cpp +++ b/src/app/qt/element/QtCodeFile.cpp @@ -136,7 +136,7 @@ void QtCodeFile::addCodeSnippet( Id titleId, const std::string& code, std::shared_ptr locationFile, - uint refCount + int refCount ){ m_locationFile.reset(); @@ -153,7 +153,10 @@ void QtCodeFile::addCodeSnippet( m_fileSnippet = snippet; clickedMaximizeButton(); - updateRefCount(0); + if (refCount != -1) + { + updateRefCount(0); + } return; } @@ -169,7 +172,7 @@ QWidget* QtCodeFile::insertCodeSnippet( Id titleId, const std::string& code, std::shared_ptr locationFile, - uint refCount + int refCount ){ m_locationFile.reset(); @@ -271,7 +274,7 @@ void QtCodeFile::updateContent() } } -void QtCodeFile::setLocationFile(std::shared_ptr locationFile, uint refCount) +void QtCodeFile::setLocationFile(std::shared_ptr locationFile, int refCount) { m_locationFile = locationFile; clickedMinimizeButton(); @@ -395,7 +398,7 @@ void QtCodeFile::updateSnippets() clickedSnippetButton(); } -void QtCodeFile::updateRefCount(uint refCount) +void QtCodeFile::updateRefCount(int refCount) { if (refCount > 0) { diff --git a/src/app/qt/element/QtCodeFile.h b/src/app/qt/element/QtCodeFile.h index 94d0f662..7a938c65 100644 --- a/src/app/qt/element/QtCodeFile.h +++ b/src/app/qt/element/QtCodeFile.h @@ -38,7 +38,7 @@ public: Id titleId, const std::string& code, std::shared_ptr locationFile, - uint refCount + int refCount ); QWidget* insertCodeSnippet( @@ -47,7 +47,7 @@ public: Id titleId, const std::string& code, std::shared_ptr locationFile, - uint refCount + int refCount ); QWidget* findFirstActiveSnippet() const; @@ -55,7 +55,7 @@ public: void updateContent(); - void setLocationFile(std::shared_ptr locationFile, uint refCount); + void setLocationFile(std::shared_ptr locationFile, int refCount); public slots: void clickedSnippetButton(); @@ -68,7 +68,7 @@ private slots: private: void updateSnippets(); - void updateRefCount(uint refCount); + void updateRefCount(int refCount); QtCodeFileList* m_parent; diff --git a/src/app/qt/element/QtCodeFileList.cpp b/src/app/qt/element/QtCodeFileList.cpp index 6860d192..13c49fd2 100644 --- a/src/app/qt/element/QtCodeFileList.cpp +++ b/src/app/qt/element/QtCodeFileList.cpp @@ -46,7 +46,7 @@ void QtCodeFileList::addCodeSnippet( Id titleId, const std::string& code, std::shared_ptr locationFile, - uint refCount, + int refCount, bool insert ){ QtCodeFile* file = getFile(locationFile); @@ -62,7 +62,7 @@ void QtCodeFileList::addCodeSnippet( } } -void QtCodeFileList::addFile(std::shared_ptr locationFile, uint refCount) +void QtCodeFileList::addFile(std::shared_ptr locationFile, int refCount) { QtCodeFile* file = getFile(locationFile); file->setLocationFile(locationFile, refCount); diff --git a/src/app/qt/element/QtCodeFileList.h b/src/app/qt/element/QtCodeFileList.h index 586b80bc..8025c313 100644 --- a/src/app/qt/element/QtCodeFileList.h +++ b/src/app/qt/element/QtCodeFileList.h @@ -32,11 +32,11 @@ public: Id titleId, const std::string& code, std::shared_ptr locationFile, - uint refCount, + int refCount, bool insert = false ); - void addFile(std::shared_ptr locationFile, uint refCount); + void addFile(std::shared_ptr locationFile, int refCount); void clearCodeSnippets(); diff --git a/src/app/qt/view/QtCodeView.cpp b/src/app/qt/view/QtCodeView.cpp index 719b78c0..0cd87b97 100644 --- a/src/app/qt/view/QtCodeView.cpp +++ b/src/app/qt/view/QtCodeView.cpp @@ -134,7 +134,7 @@ void QtCodeView::doAddCodeSnippets(const std::vector& snippet void QtCodeView::doShowCodeFile(const CodeSnippetParams& params) { - m_widget->addCodeSnippet(1, params.title, 0, params.code, params.locationFile, params.refCount); + m_widget->addCodeSnippet(1, params.title, 0, params.code, params.locationFile, -1); } void QtCodeView::doShowFirstActiveSnippet() diff --git a/src/app/qt/view/QtMainView.cpp b/src/app/qt/view/QtMainView.cpp index c7f263d9..00bc9b14 100644 --- a/src/app/qt/view/QtMainView.cpp +++ b/src/app/qt/view/QtMainView.cpp @@ -5,6 +5,7 @@ #include "qt/window/QtMainWindow.h" QtMainView::QtMainView() + : m_setTitleFunctor(std::bind(&QtMainView::doSetTitle, this, std::placeholders::_1)) { m_window = std::make_shared(); m_window->show(); @@ -67,3 +68,13 @@ void QtMainView::showStartScreen() { m_window->showStartScreen(); } + +void QtMainView::setTitle(const std::string& title) +{ + m_setTitleFunctor(title); +} + +void QtMainView::doSetTitle(const std::string& title) +{ + m_window->setWindowTitle(QString::fromStdString(title)); +} diff --git a/src/app/qt/view/QtMainView.h b/src/app/qt/view/QtMainView.h index 27342997..93fac868 100644 --- a/src/app/qt/view/QtMainView.h +++ b/src/app/qt/view/QtMainView.h @@ -5,12 +5,15 @@ #include #include + #include "component/view/MainView.h" +#include "qt/utility/QtThreadedFunctor.h" class QtMainWindow; class View; -class QtMainView: public MainView +class QtMainView + : public MainView { public: QtMainView(); @@ -31,10 +34,15 @@ public: // MainView implementation virtual void showStartScreen(); + virtual void setTitle(const std::string& title); private: + void doSetTitle(const std::string& title); + std::shared_ptr m_window; std::vector m_views; + + QtThreadedFunctor m_setTitleFunctor; }; #endif // QT_MAIN_VIEW_H diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 945091c6..e8b2fbc0 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -24,6 +24,8 @@ std::shared_ptr Application::create(ViewFactory* viewFactory) ptr->m_componentManager = ComponentManager::create(viewFactory, ptr->m_storageCache.get()); ptr->m_mainView = viewFactory->createMainView(); + ptr->m_mainView->setTitle("Coati"); + ptr->m_componentManager->setup(ptr->m_mainView.get()); ptr->m_mainView->loadLayout(); @@ -71,6 +73,8 @@ void Application::loadProject(const FilePath& projectSettingsFilePath) updateRecentProjects(projectSettingsFilePath); + m_mainView->setTitle(projectSettingsFilePath.fileName()); + m_storageCache->clear(); m_componentManager->refreshViews(); @@ -109,20 +113,20 @@ void Application::handleMessage(MessageFinishedParsing* message) m_isInitialParse = false; - Id mainId = m_storageCache->getIdForNodeWithNameHierarchy(NameHierarchy("main")); + Id nodeId = m_storageCache->getIdForNodeWithNameHierarchy(NameHierarchy("main")); - if (!mainId) + if (!nodeId) { - mainId = 1; + nodeId = m_storageCache->getIdForFirstNode(); } - if (mainId) + if (nodeId) { MessageActivateNodes message; message.addNode( - mainId, - m_storageCache->getNodeTypeForNodeWithId(mainId), - m_storageCache->getNameHierarchyForNodeWithId(mainId) + nodeId, + m_storageCache->getNodeTypeForNodeWithId(nodeId), + m_storageCache->getNameHierarchyForNodeWithId(nodeId) ); message.isFromSystem = true; message.dispatch(); diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp index 6dfbed89..48adbe83 100644 --- a/src/lib/Project.cpp +++ b/src/lib/Project.cpp @@ -131,8 +131,6 @@ void Project::parseCode() void Project::logStats() const { - // m_storage->logGraph(); - // m_storage->logLocations(); m_storage->logStats(); } diff --git a/src/lib/component/view/CodeView.h b/src/lib/component/view/CodeView.h index aa104dee..17d0eb44 100644 --- a/src/lib/component/view/CodeView.h +++ b/src/lib/component/view/CodeView.h @@ -29,7 +29,7 @@ public: std::shared_ptr locationFile; - uint refCount; + int refCount; bool isActive; bool isDeclaration; diff --git a/src/lib/component/view/MainView.h b/src/lib/component/view/MainView.h index 84a4e69b..f47a6195 100644 --- a/src/lib/component/view/MainView.h +++ b/src/lib/component/view/MainView.h @@ -1,6 +1,8 @@ #ifndef MAIN_VIEW_H #define MAIN_VIEW_H +#include + #include "component/view/ViewLayout.h" class MainView: public ViewLayout @@ -10,6 +12,7 @@ public: virtual ~MainView(); virtual void showStartScreen() = 0; + virtual void setTitle(const std::string& title) = 0; }; #endif // MAIN_VIEW_H diff --git a/src/lib/data/SqliteStorage.cpp b/src/lib/data/SqliteStorage.cpp index 40c354a3..4c08cf90 100644 --- a/src/lib/data/SqliteStorage.cpp +++ b/src/lib/data/SqliteStorage.cpp @@ -188,6 +188,17 @@ void SqliteStorage::removeUnusedNameHierarchyElements() ); } +StorageNode SqliteStorage::getFirstNode() const +{ + std::vector nodes = getAllNodes("LIMIT 1"); + if (nodes.size()) + { + return nodes[0]; + } + + return StorageNode(0, 0, 0); +} + std::vector SqliteStorage::getAllNodes() const { std::vector nodes; @@ -680,17 +691,27 @@ Id SqliteStorage::getNodeIdBySignature(const std::string& signature) const int SqliteStorage::getNodeCount() const { - return m_database.execScalar("SELECT COUNT(*) from node;"); + return m_database.execScalar("SELECT COUNT(*) FROM node;"); } int SqliteStorage::getEdgeCount() const { - return m_database.execScalar("SELECT COUNT(*) from edge;"); + return m_database.execScalar("SELECT COUNT(*) FROM edge;"); +} + +int SqliteStorage::getFileCount() const +{ + return m_database.execScalar("SELECT COUNT(*) FROM file;"); } int SqliteStorage::getNameHierarchyElementCount() const { - return m_database.execScalar("SELECT COUNT(*) from name_hierarchy_element;"); + return m_database.execScalar("SELECT COUNT(*) FROM name_hierarchy_element;"); +} + +int SqliteStorage::getSourceLocationCount() const +{ + return m_database.execScalar("SELECT COUNT(*) FROM source_location;"); } void SqliteStorage::clearTables() diff --git a/src/lib/data/SqliteStorage.h b/src/lib/data/SqliteStorage.h index 2a180cec..5589cf2e 100644 --- a/src/lib/data/SqliteStorage.h +++ b/src/lib/data/SqliteStorage.h @@ -44,6 +44,7 @@ public: void removeFile(Id id); void removeUnusedNameHierarchyElements(); + StorageNode getFirstNode() const; std::vector getAllNodes() const; bool isEdge(Id elementId) const; @@ -97,7 +98,9 @@ public: int getNodeCount() const; int getEdgeCount() const; + int getFileCount() const; int getNameHierarchyElementCount() const; + int getSourceLocationCount() const; private: void clearTables(); diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index 22f0f76f..5fd07ff0 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -93,20 +93,51 @@ void Storage::removeUnusedNames() clearCaches(); } -void Storage::logGraph() const +std::vector Storage::getInfoOnAllFiles() const { + std::vector fileInfos; + + std::vector storageFiles = m_sqliteStorage.getAllFiles(); + for (size_t i = 0; i < storageFiles.size(); i++) + { + boost::posix_time::ptime modificationTime = boost::posix_time::not_a_date_time; + if (storageFiles[i].modificationTime != "not-a-date-time") + { + modificationTime = boost::posix_time::time_from_string(storageFiles[i].modificationTime); + } + fileInfos.push_back(FileInfo( + FilePath(storageFiles[i].filePath), + modificationTime + )); + } + + return fileInfos; } -void Storage::logLocations() const -{ -} - -void Storage::logIndex() const +const SearchIndex& Storage::getSearchIndex() const { + return m_tokenIndex; } void Storage::logStats() const { + std::stringstream ss; + + ss << "\nGraph:\n"; + ss << "\t" << m_sqliteStorage.getNodeCount() << " Nodes\n"; + ss << "\t" << m_sqliteStorage.getEdgeCount() << " Edges\n"; + + ss << "\nSearch:\n"; + ss << "\t" << m_tokenIndex.getCharCount() << " Characters\n"; + ss << "\t" << m_tokenIndex.getWordCount() << " Words\n"; + ss << "\t" << m_tokenIndex.getNodeCount() << " SearchNodes\n"; + ss << "\t" << m_sqliteStorage.getNameHierarchyElementCount() << " NameHierarchyElements\n"; + + ss << "\nCode:\n"; + ss << "\t" << m_sqliteStorage.getFileCount() << " Files\n"; + ss << "\t" << m_sqliteStorage.getSourceLocationCount() << " Source Locations\n"; + + LOG_WARNING(ss.str()); } void Storage::startParsing() @@ -704,25 +735,9 @@ Id Storage::getIdForEdge( return m_sqliteStorage.getEdgeBySourceTargetType(sourceId, targetId, type).id; } -std::vector Storage::getInfoOnAllFiles() const +Id Storage::getIdForFirstNode() const { - std::vector fileInfos; - - std::vector storageFiles = m_sqliteStorage.getAllFiles(); - for (size_t i = 0; i < storageFiles.size(); i++) - { - boost::posix_time::ptime modificationTime = boost::posix_time::not_a_date_time; - if (storageFiles[i].modificationTime != "not-a-date-time") - { - modificationTime = boost::posix_time::time_from_string(storageFiles[i].modificationTime); - } - fileInfos.push_back(FileInfo( - FilePath(storageFiles[i].filePath), - modificationTime - )); - } - - return fileInfos; + return m_sqliteStorage.getFirstNode().id; } NameHierarchy Storage::getNameHierarchyForNodeWithId(Id nodeId) const @@ -796,7 +811,7 @@ std::shared_ptr Storage::getGraphForActiveTokenIds(const std::vector& addAggregationEdgesToGraph(elementId, graph); } - else + else if (m_sqliteStorage.isEdge(elementId)) { addEdgeAndAllChildrenToGraph(elementId, graph); } @@ -1129,11 +1144,6 @@ std::shared_ptr Storage::getFileContent(const FilePath& filePath) co return m_sqliteStorage.getFileContentByPath(filePath.str()); } -const SearchIndex& Storage::getSearchIndex() const -{ - return m_tokenIndex; -} - Id Storage::addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, bool distinct) { addNameHierarchyElements(nameHierarchy); diff --git a/src/lib/data/Storage.h b/src/lib/data/Storage.h index e830911f..a4c28f68 100644 --- a/src/lib/data/Storage.h +++ b/src/lib/data/Storage.h @@ -32,9 +32,9 @@ public: void clearFileElement(const FilePath& filePath); void removeUnusedNames(); - void logGraph() const; - void logLocations() const; - void logIndex() const; + std::vector getInfoOnAllFiles() const; + const SearchIndex& getSearchIndex() const; + void logStats() const; // ParserClient implementation @@ -126,7 +126,7 @@ public: virtual Id getIdForEdge( Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const; - virtual std::vector getInfoOnAllFiles() const; + virtual Id getIdForFirstNode() const; virtual NameHierarchy getNameHierarchyForNodeWithId(Id nodeId) const; virtual Node::NodeType getNodeTypeForNodeWithId(Id nodeId) const; @@ -156,8 +156,6 @@ public: virtual std::shared_ptr getFileContent(const FilePath& filePath) const; - const SearchIndex& getSearchIndex() const; - private: Id addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, bool distinct = false); Id addNodeHierarchyWithDistinctSignature(Node::NodeType type, const ParseFunction& function); diff --git a/src/lib/data/access/StorageAccess.h b/src/lib/data/access/StorageAccess.h index 5b3cf200..6a4823a9 100644 --- a/src/lib/data/access/StorageAccess.h +++ b/src/lib/data/access/StorageAccess.h @@ -27,7 +27,7 @@ public: virtual Id getIdForEdge( Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const = 0; - virtual std::vector getInfoOnAllFiles() const = 0; + virtual Id getIdForFirstNode() const = 0; virtual NameHierarchy getNameHierarchyForNodeWithId(Id id) const = 0; virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const = 0; diff --git a/src/lib/data/access/StorageAccessProxy.cpp b/src/lib/data/access/StorageAccessProxy.cpp index 9226836a..0a599933 100644 --- a/src/lib/data/access/StorageAccessProxy.cpp +++ b/src/lib/data/access/StorageAccessProxy.cpp @@ -53,19 +53,19 @@ Id StorageAccessProxy::getIdForEdge( return 0; } -std::vector StorageAccessProxy::getInfoOnAllFiles() const +Id StorageAccessProxy::getIdForFirstNode() const { - std::vector fileInfos; if (hasSubject()) { - fileInfos = m_subject->getInfoOnAllFiles(); + return m_subject->getIdForFirstNode(); } - return fileInfos; + + return 0; } Node::NodeType StorageAccessProxy::getNodeTypeForNodeWithId(Id id) const { - if(hasSubject()) + if (hasSubject()) { return m_subject->getNodeTypeForNodeWithId(id); } diff --git a/src/lib/data/access/StorageAccessProxy.h b/src/lib/data/access/StorageAccessProxy.h index 2b8409c3..3e6feb13 100644 --- a/src/lib/data/access/StorageAccessProxy.h +++ b/src/lib/data/access/StorageAccessProxy.h @@ -17,7 +17,7 @@ public: virtual Id getIdForEdge( Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const; - virtual std::vector getInfoOnAllFiles() const; + virtual Id getIdForFirstNode() const; virtual NameHierarchy getNameHierarchyForNodeWithId(Id id) const; virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const; diff --git a/src/lib/data/parser/Parser.h b/src/lib/data/parser/Parser.h index 5de9de89..0b845e6d 100644 --- a/src/lib/data/parser/Parser.h +++ b/src/lib/data/parser/Parser.h @@ -28,7 +28,7 @@ public: virtual ~Parser(); virtual void parseFiles(const std::vector& filePaths, const Arguments& arguments) = 0; - virtual void parseFile(std::shared_ptr textAccess, const Arguments& arguments) = 0; + virtual void parseFile(const FilePath& filePath, std::shared_ptr textAccess, const Arguments& arguments) = 0; protected: ParserClient* m_client; diff --git a/src/lib/data/parser/cxx/CxxParser.cpp b/src/lib/data/parser/cxx/CxxParser.cpp index 134c93b2..a67e71f9 100644 --- a/src/lib/data/parser/cxx/CxxParser.cpp +++ b/src/lib/data/parser/cxx/CxxParser.cpp @@ -83,8 +83,10 @@ void CxxParser::parseFiles(const std::vector& filePaths, const Argumen } } -void CxxParser::parseFile(std::shared_ptr textAccess, const Arguments& arguments) +void CxxParser::parseFile(const FilePath& filePath, std::shared_ptr textAccess, const Arguments& arguments) { + setupParsing(std::vector(1, filePath), arguments); + std::vector args = getCommandlineArguments(arguments); std::shared_ptr diagnostics = getDiagnostics(arguments); diff --git a/src/lib/data/parser/cxx/CxxParser.h b/src/lib/data/parser/cxx/CxxParser.h index cc393952..da789bf2 100644 --- a/src/lib/data/parser/cxx/CxxParser.h +++ b/src/lib/data/parser/cxx/CxxParser.h @@ -24,7 +24,7 @@ public: // ParserClient implementation virtual void parseFiles(const std::vector& filePaths, const Arguments& arguments); - virtual void parseFile(std::shared_ptr textAccess, const Arguments& arguments); + virtual void parseFile(const FilePath& filePath, std::shared_ptr textAccess, const Arguments& arguments); private: std::vector getCommandlineArguments(const Arguments& arguments) const; diff --git a/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp b/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp index bcc2b668..7ed3ce75 100644 --- a/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp +++ b/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp @@ -57,7 +57,7 @@ void PreprocessorCallbacks::InclusionDirective( const FileManager* fileManager = m_fileRegister->getFileManager(); if (fileManager->hasFilePath(baseFilePath) && fileManager->hasFilePath(includedFilePath) && - !m_fileRegister->includeFileIsParsed(baseFilePath)) + !m_fileRegister->fileIsParsed(baseFilePath)) { m_client->onFileIncludeParsed( getParseLocation(fileNameRange.getAsRange()), @@ -77,7 +77,7 @@ void PreprocessorCallbacks::MacroDefined(const clang::Token& macroNameToken, con } FilePath filePath = FilePath(fileStr); - if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->includeFileIsParsed(filePath)) + if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath)) { // ignore builtin macros if (m_sourceManager.getSpellingLoc(macroNameToken.getLocation()).printToString(m_sourceManager)[0] == '<') @@ -103,7 +103,7 @@ void PreprocessorCallbacks::MacroExpands( } FilePath filePath = FilePath(fileStr); - if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->includeFileIsParsed(filePath)) + if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath)) { NameHierarchy nameHierarchy; nameHierarchy.push(std::make_shared(macroNameToken.getIdentifierInfo()->getName().str())); diff --git a/src/lib/utility/file/FileRegister.cpp b/src/lib/utility/file/FileRegister.cpp index 1a321004..6b6944e6 100644 --- a/src/lib/utility/file/FileRegister.cpp +++ b/src/lib/utility/file/FileRegister.cpp @@ -18,8 +18,10 @@ void FileRegister::setFilePaths(const std::vector& filePaths) m_sourceFilePaths.clear(); m_includeFilePaths.clear(); - for (const FilePath& path : filePaths) + for (const FilePath& p : filePaths) { + FilePath path = p.exists() ? p.absolute() : p; + if (m_fileManager->hasSourceExtension(path)) { m_sourceFilePaths.emplace(path, STATE_UNPARSED); @@ -41,6 +43,23 @@ std::vector FileRegister::getUnparsedIncludeFilePaths() const return getUnparsedFilePaths(m_includeFilePaths); } +bool FileRegister::fileIsParsed(const FilePath& filePath) const +{ + std::map::const_iterator it = m_includeFilePaths.find(filePath); + if (it != m_includeFilePaths.end()) + { + return it->second == STATE_PARSED; + } + + it = m_sourceFilePaths.find(filePath); + if (it != m_sourceFilePaths.end()) + { + return it->second == STATE_PARSED; + } + + return true; +} + bool FileRegister::includeFileIsParsing(const FilePath& filePath) const { std::map::const_iterator it = m_includeFilePaths.find(filePath); diff --git a/src/lib/utility/file/FileRegister.h b/src/lib/utility/file/FileRegister.h index 01038b1c..d6d81dad 100644 --- a/src/lib/utility/file/FileRegister.h +++ b/src/lib/utility/file/FileRegister.h @@ -21,6 +21,8 @@ public: std::vector getUnparsedSourceFilePaths() const; std::vector getUnparsedIncludeFilePaths() const; + bool fileIsParsed(const FilePath& filePath) const; + bool includeFileIsParsing(const FilePath& filePath) const; bool includeFileIsParsed(const FilePath& filePath) const; diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index 1da324d7..4bcb8254 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -1,5 +1,6 @@ #include "cxxtest/TestSuite.h" +#include "utility/file/FileRegister.h" #include "utility/text/TextAccess.h" #include "utility/utilityString.h" @@ -2641,13 +2642,6 @@ private: return 0; } - virtual Id onFieldUsageParsed( - const ParseLocation& location, const ParseVariable& user, const NameHierarchy& usedNameHierarchy) - { - usages.push_back(addLocationSuffix(variableStr(user) + " -> " + usedNameHierarchy.getFullName(), location)); - return 0; - } - virtual Id onGlobalVariableUsageParsed( const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy) { @@ -2835,7 +2829,7 @@ private: TestFileManager fm; std::shared_ptr client = std::make_shared(); CxxParser parser(client.get(), &fm); - parser.parseFile(TextAccess::createFromString(code), m_args); + parser.parseFile("input.cc", TextAccess::createFromString(code), m_args); return client; } diff --git a/src/test/StorageTestSuite.h b/src/test/StorageTestSuite.h index eece01bb..5b17120a 100644 --- a/src/test/StorageTestSuite.h +++ b/src/test/StorageTestSuite.h @@ -27,10 +27,10 @@ public: TestStorage storage; Id id = storage.onTypedefParsed(validLocation(1), createNameHierarchy("type"), typeUsage("int"), ParserClient::ACCESS_NONE); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "type"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "type"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_TYPEDEF); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPEDEF_OF) + ":type->int") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPEDEF_OF, "type", "int") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -41,7 +41,7 @@ public: TestStorage storage; Id id = storage.onClassParsed(validLocation(1), createNameHierarchy("Class"), ParserClient::ACCESS_NONE, validLocation(2)); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Class"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Class"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_CLASS); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); @@ -54,7 +54,7 @@ public: TestStorage storage; Id id = storage.onStructParsed(validLocation(1), createNameHierarchy("Struct"), ParserClient::ACCESS_NONE, validLocation(2)); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Struct"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Struct"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_STRUCT); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); @@ -67,12 +67,12 @@ public: TestStorage storage; Id id = storage.onGlobalVariableParsed(validLocation(42), ParseVariable(typeUsage("char"), createNameHierarchy("Global"), false)); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Global"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Global"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_GLOBAL_VARIABLE); //TS_ASSERT(!node->getComponent()); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_OF) + ":Global->char") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_OF, "Global", "char") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -83,7 +83,7 @@ public: TestStorage storage; Id id = storage.onGlobalVariableParsed(validLocation(7), ParseVariable(typeUsage("char"), createNameHierarchy("Global"), true)); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Global"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Global"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_GLOBAL_VARIABLE); //TS_ASSERT(node->getComponent()); @@ -99,10 +99,10 @@ public: validLocation(3), ParseVariable(typeUsage("bool"), createNameHierarchy("m_field"), false), ParserClient::ACCESS_NONE ); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "m_field"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "m_field"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FIELD); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_OF) + ":m_field->bool") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_OF, "m_field", "bool") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -115,17 +115,17 @@ public: validLocation(11), ParseVariable(typeUsage("bool"), createNameHierarchy("Struct::m_field"), false), ParserClient::ACCESS_PUBLIC ); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Struct::m_field"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Struct::m_field"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FIELD); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_MEMBER) + ":Struct->Struct::m_field") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_MEMBER, "Struct", "Struct::m_field") != 0); //TS_ASSERT(memberEdge->getComponent()); //TS_ASSERT_EQUALS( // memberEdge->getComponent()->getAccess(), TokenComponentAccess::ACCESS_PUBLIC //); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_OF) + ":Struct::m_field->bool") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_OF, "Struct::m_field", "bool") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -138,13 +138,13 @@ public: validLocation(14), ParseFunction(typeUsage("bool"), createNameHierarchy("isTrue"), parameters("char")), validLocation(41) ); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "isTrue"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "isTrue"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FUNCTION); - // TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_RETURN_TYPE_OF) + ":isTrue->bool") != 0); - // TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_PARAMETER_TYPE_OF) + ":isTrue->char") != 0); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isTrue->bool") != 0); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isTrue->char") != 0); + // TS_ASSERT(storage.getEdgeId(Edge::EDGE_RETURN_TYPE_OF, "isTrue", "bool") != 0); + // TS_ASSERT(storage.getEdgeId(Edge::EDGE_PARAMETER_TYPE_OF, "isTrue", "char") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isTrue", "bool") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isTrue", "char") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 2); @@ -161,13 +161,13 @@ public: validLocation(4) ); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "isMethod"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "isMethod"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_METHOD); - // TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_RETURN_TYPE_OF) + ":isMethod->void") != 0); - // TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_PARAMETER_TYPE_OF) + ":isMethod->bool") != 0); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isMethod->void") != 0); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isMethod->bool") != 0); + // TS_ASSERT(storage.getEdgeId(Edge::EDGE_RETURN_TYPE_OF, "isMethod", "void") != 0); + // TS_ASSERT(storage.getEdgeId(Edge::EDGE_PARAMETER_TYPE_OF, "isMethod", "bool") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isMethod", "void") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isMethod", "bool") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 2); @@ -208,7 +208,7 @@ public: // TokenComponentAbstraction::ABSTRACTION_VIRTUAL //); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_MEMBER) + ":Class->Class::isMethod") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_MEMBER, "Class", "Class::isMethod") != 0); //TS_ASSERT(memberEdge->getComponent()); //TS_ASSERT_EQUALS( // memberEdge->getComponent()->getAccess(), TokenComponentAccess::ACCESS_PROTECTED @@ -220,7 +220,7 @@ public: TestStorage storage; Id id = storage.onNamespaceParsed(validLocation(1), createNameHierarchy("utility"), validLocation(2)); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "utility"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "utility"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_NAMESPACE); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); @@ -233,7 +233,7 @@ public: TestStorage storage; Id id = storage.onEnumParsed(validLocation(17), createNameHierarchy("Category"), ParserClient::ACCESS_NONE, validLocation(23)); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Category"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Category"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_ENUM); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); @@ -249,7 +249,7 @@ public: ParserClient::ACCESS_PRIVATE, validLocation(2) ); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_MEMBER) + ":Class->Class::Category") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_MEMBER, "Class", "Class::Category") != 0); //TS_ASSERT(memberEdge->getComponent()); //TS_ASSERT_EQUALS( @@ -262,7 +262,7 @@ public: TestStorage storage; Id id = storage.onEnumConstantParsed(validLocation(1), createNameHierarchy("VALUE")); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "VALUE"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "VALUE"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_ENUM_CONSTANT); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); @@ -279,7 +279,7 @@ public: createNameHierarchy("ClassA"), ParserClient::ACCESS_PUBLIC ); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_INHERITANCE) + ":ClassB->ClassA") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_INHERITANCE, "ClassB", "ClassA") != 0); //TS_ASSERT(edge->getComponent()); //TS_ASSERT_EQUALS(edge->getComponent()->getAccess(), TokenComponentAccess::ACCESS_PUBLIC); @@ -297,7 +297,7 @@ public: createNameHierarchy("StructA"), ParserClient::ACCESS_PUBLIC ); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_INHERITANCE) + ":StructB->StructA") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_INHERITANCE, "StructB", "StructA") != 0); //TS_ASSERT(edge->getComponent()); //TS_ASSERT_EQUALS(edge->getComponent()->getAccess(), TokenComponentAccess::ACCESS_PUBLIC); @@ -318,7 +318,7 @@ public: storage.onMethodOverrideParsed(validLocation(4), a, b); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_OVERRIDE) + ":B::isMethod->A::isMethod") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_OVERRIDE, "B::isMethod", "A::isMethod") != 0); } void test_storage_saves_call() @@ -336,7 +336,7 @@ public: ParseFunction(typeUsage("void"), createNameHierarchy("func"), parameters("bool")) ); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_CALL) + ":isTrue->func") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_CALL, "isTrue", "func") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -356,7 +356,7 @@ public: ParseFunction(typeUsage("bool"), createNameHierarchy("isTrue"), parameters("char")) ); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_CALL) + ":global->isTrue") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_CALL, "global", "isTrue") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -378,7 +378,7 @@ public: createNameHierarchy("Foo::m_field") ); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_USAGE) + ":isTrue->Foo::m_field") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_USAGE, "isTrue", "Foo::m_field") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -398,7 +398,7 @@ public: createNameHierarchy("global") ); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_USAGE) + ":isTrue->global") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_USAGE, "isTrue", "global") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -419,7 +419,7 @@ public: ParseFunction(typeUsage("bool"), createNameHierarchy("isTrue"), parameters("char")) ); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isTrue->Struct") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isTrue", "Struct") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -548,7 +548,7 @@ public: Id id = storage.onFileParsed(FileInfo("file.h")); - TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "file.h"); + TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "file.h"); TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FILE); } @@ -560,7 +560,7 @@ public: storage.onFileParsed(FileInfo("file.cpp")); Id id = storage.onFileIncludeParsed(validLocation(7), FileInfo("file.cpp"), FileInfo("file.h")); - TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_INCLUDE) + ":file.cpp->file.h") != 0); + TS_ASSERT(storage.getEdgeId(Edge::EDGE_INCLUDE, "file.cpp", "file.h") != 0); std::shared_ptr tlc = storage.getLocationCollectionForTokenId(id); TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1); @@ -631,6 +631,24 @@ private: { return getSearchIndex(); } + + NameHierarchy nameHierarchyFromString(const std::string& str) const + { + NameHierarchy result; + std::vector names = utility::splitToVector(str, "::"); + for (const std::string& name : names) + { + result.push(std::make_shared(name)); + } + return result; + } + + Id getEdgeId(Edge::EdgeType type, const std::string& fromName, const std::string& toName) const + { + NameHierarchy from; + + return getIdForEdge(type, nameHierarchyFromString(fromName), nameHierarchyFromString(toName)); + } }; ParseLocation validLocation(Id locationId = 0) const // id is not used as id ..... who programs this? ebsi? :P diff --git a/src/test/helper/TestStorage.cpp b/src/test/helper/TestStorage.cpp index cf62324d..be61d4ff 100644 --- a/src/test/helper/TestStorage.cpp +++ b/src/test/helper/TestStorage.cpp @@ -15,5 +15,5 @@ void TestStorage::parseCxxCode(std::string code) TestFileManager fm; CxxParser parser(this, &fm); - parser.parseFile(TextAccess::createFromString(code), Parser::Arguments()); + parser.parseFile("input.cc", TextAccess::createFromString(code), Parser::Arguments()); }