From f6e8a2125d34c0345d5c3fbcf59f13e417c6ee71 Mon Sep 17 00:00:00 2001 From: Malte Langkabel Date: Mon, 30 Mar 2020 21:24:23 +0200 Subject: [PATCH] logic: respect class qualifyer in method call for python post processing (#951) If the class of a called method is explicitly specified ("Base.__init__()"), only record an ambiguous edge to that method. --- .../indexer/TaskExecuteCustomCommands.cpp | 321 +++++----- .../data/indexer/TaskExecuteCustomCommands.h | 4 +- src/test/CMakeLists.txt | 3 +- src/test/CxxParserTestSuite.cpp | 586 +++++++++--------- src/test/JavaIndexSampleProjectsTestSuite.cpp | 10 +- src/test/JavaParserTestSuite.cpp | 201 +++--- src/test/PythonIndexerTestSuite.cpp | 122 ++++ ...estIntermediateStorage.h => TestStorage.h} | 86 +-- 8 files changed, 748 insertions(+), 585 deletions(-) create mode 100644 src/test/PythonIndexerTestSuite.cpp rename src/test/helper/{TestIntermediateStorage.h => TestStorage.h} (83%) diff --git a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp index 83a6b2b5..13a583fd 100644 --- a/src/lib/data/indexer/TaskExecuteCustomCommands.cpp +++ b/src/lib/data/indexer/TaskExecuteCustomCommands.cpp @@ -19,6 +19,182 @@ #include "utilityFile.h" #include "utilityString.h" +void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& storage) +{ + std::vector unsolvedLocationIds; + for (const StorageSourceLocation location: storage.getStorageSourceLocations()) + { + if (intToLocationType(location.type) == + LOCATION_UNSOLVED) // FIXME: this doesn't catch unsolved qualifiers -> convert + // Qualifier location type to qualifier edge + { + unsolvedLocationIds.push_back(location.id); + } + } + + std::shared_ptr locationCollection = + storage.getSourceLocationsForLocationIds(unsolvedLocationIds); + + std::map> nodeNameToStorageNodes; + if (locationCollection->getSourceLocationCount() > 0) + { + for (const StorageNode& node: storage.getStorageNodes()) + { + nodeNameToStorageNodes[NameHierarchy::deserialize(node.serializedName).back().getName()] + .push_back(node); + } + } + + struct DataToInsert + { + StorageEdgeData edgeData; + Id sourceLocationId; + }; + + storage.setMode(SqliteIndexStorage::STORAGE_MODE_READ); + + std::vector dataToInsert; + std::vector occurrencesToDelete; + locationCollection->forEachSourceLocationFile( + [&nodeNameToStorageNodes, &storage, &dataToInsert, &occurrencesToDelete]( + std::shared_ptr locationFile) { + const FilePath filePath = locationFile->getFilePath(); + if (filePath.empty()) + { + return; + } + if (!filePath.exists()) + { + LOG_WARNING(L"Skipping post processing for non-existing file: " + filePath.wstr()); + return; + } + + std::shared_ptr textAccess = TextAccess::createFromFile(filePath); + if (textAccess) + { + locationFile->forEachStartSourceLocation([textAccess, + &nodeNameToStorageNodes, + &storage, + &dataToInsert, + &occurrencesToDelete]( + const SourceLocation* startLoc) { + if (!startLoc) + { + return; + } + const SourceLocation* endLoc = startLoc->getOtherLocation(); + if (!endLoc) + { + return; + } + + const std::string tokenLine = textAccess->getLine( + static_cast(startLoc->getLineNumber())); + const std::wstring token = utility::decodeFromUtf8(tokenLine.substr( + startLoc->getColumnNumber() - 1, + endLoc->getColumnNumber() - startLoc->getColumnNumber() + 1)); + + + std::string prefixString = tokenLine.substr(0, startLoc->getColumnNumber() - 1); + std::wstring definitionContextName = L""; + { + std::regex regex("\\s([^\\.()\\s]+)\\.$"); + std::smatch matches; + std::regex_search(prefixString, matches, regex); + if (!matches.empty()) + { + definitionContextName = utility::decodeFromUtf8(matches.str(1)); + } + } + { + std::vector targetNodes; + if (!definitionContextName.empty()) + { + for (const StorageNode& node: nodeNameToStorageNodes[token]) + { + NameHierarchy nameHierarchy = NameHierarchy::deserialize( + node.serializedName); + if (nameHierarchy.size() > 1 && + nameHierarchy.getRange(0, nameHierarchy.size() - 1).back().getName() == + definitionContextName) + { + targetNodes.push_back(node); + } + } + } + if (targetNodes.empty()) + { + targetNodes = nodeNameToStorageNodes[token]; + } + + for (const StorageNode& targetNode: targetNodes) + { + for (const Id elementId: startLoc->getTokenIds()) + { + const StorageEdge edge = storage.getEdgeById(elementId); + if (edge.id != 0) // for node elements this condition will fail + { + if (Edge::intToType(edge.type) == Edge::EDGE_INHERITANCE && + intToNodeKind(targetNode.type) != NODE_CLASS) + { + continue; + } + + dataToInsert.push_back( + {StorageEdgeData(edge.type, edge.sourceNodeId, targetNode.id), + startLoc->getLocationId()}); + occurrencesToDelete.push_back( + StorageOccurrence(edge.id, startLoc->getLocationId())); + } + } + } + } + }); + } + }); + + storage.setMode(SqliteIndexStorage::STORAGE_MODE_WRITE); + + storage.startInjection(); + + std::vector edgesToInsert; + for (const DataToInsert& data: dataToInsert) + { + edgesToInsert.push_back(StorageEdge(0, data.edgeData)); + } + const std::vector ambiguousEdgeIds = storage.addEdges(edgesToInsert); + + if (ambiguousEdgeIds.size() == dataToInsert.size()) + { + for (size_t i = 0; i < ambiguousEdgeIds.size(); i++) + { + storage.addElementComponent(StorageElementComponent( + ambiguousEdgeIds[i], + elementComponentKindToInt(ElementComponentKind::IS_AMBIGUOUS), + L"")); + storage.addOccurrence( + StorageOccurrence(ambiguousEdgeIds[i], dataToInsert[i].sourceLocationId)); + } + storage.setMode(SqliteIndexStorage::STORAGE_MODE_CLEAR); + + storage.removeOccurrences(occurrencesToDelete); + std::set edgeIds; + for (const StorageOccurrence& occurrence: occurrencesToDelete) + { + edgeIds.insert(occurrence.elementId); + } + storage.removeElementsWithoutOccurrences(utility::toVector(edgeIds)); + + storage.finishInjection(); + LOG_INFO("Finished Python post processing."); + } + else + { + LOG_ERROR("Error occurred while running Python post processing. Rolling back all changes."); + storage.rollbackInjection(); + } +} + TaskExecuteCustomCommands::TaskExecuteCustomCommands( std::unique_ptr indexerCommandProvider, std::shared_ptr storage, @@ -129,6 +305,10 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr if (m_hasPythonCommands && ApplicationSettings::getInstance()->getPythonPostProcessingEnabled()) { + LOG_INFO("Starting Python post processing."); + m_dialogView->showUnknownProgressDialog( + L"Finish Indexing", L"Run Python Post Processing"); + targetStorage.clearCaches(); targetStorage.buildCaches(); runPythonPostProcessing(targetStorage); @@ -268,144 +448,3 @@ void TaskExecuteCustomCommands::runIndexerCommand( blackboard->update("indexed_source_file_count", [=](int count) { return count + 1; }); } } - -void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& storage) -{ - LOG_INFO("Starting Python post processing."); - m_dialogView->showUnknownProgressDialog(L"Finish Indexing", L"Run Python Post Processing"); - - std::vector unsolvedLocationIds; - for (const StorageSourceLocation location: storage.getStorageSourceLocations()) - { - if (intToLocationType(location.type) == - LOCATION_UNSOLVED) // FIXME: this doesn't catch unsolved qualifiers -> convert - // Qualifier location type to qualifier edge - { - unsolvedLocationIds.push_back(location.id); - } - } - - std::shared_ptr locationCollection = - storage.getSourceLocationsForLocationIds(unsolvedLocationIds); - - std::map> nodeNameToStorageNodes; - if (locationCollection->getSourceLocationCount() > 0) - { - for (const StorageNode& node: storage.getStorageNodes()) - { - nodeNameToStorageNodes[NameHierarchy::deserialize(node.serializedName).back().getName()] - .push_back(node); - } - } - - struct DataToInsert - { - StorageEdgeData edgeData; - Id sourceLocationId; - }; - - storage.setMode(SqliteIndexStorage::STORAGE_MODE_READ); - - std::vector dataToInsert; - std::vector occurrencesToDelete; - locationCollection->forEachSourceLocationFile( - [&nodeNameToStorageNodes, &storage, &dataToInsert, &occurrencesToDelete]( - std::shared_ptr locationFile) { - const FilePath filePath = locationFile->getFilePath(); - if (filePath.empty()) - { - return; - } - if (!filePath.exists()) - { - LOG_WARNING(L"Skipping post processing for non-existing file: " + filePath.wstr()); - return; - } - - std::shared_ptr textAccess = TextAccess::createFromFile(filePath); - if (textAccess) - { - locationFile->forEachStartSourceLocation( - [textAccess, &nodeNameToStorageNodes, &storage, &dataToInsert, &occurrencesToDelete]( - const SourceLocation* startLoc) { - if (!startLoc) - { - return; - } - const SourceLocation* endLoc = startLoc->getOtherLocation(); - if (!endLoc) - { - return; - } - - const std::wstring token = utility::decodeFromUtf8( - textAccess->getLine(static_cast(startLoc->getLineNumber())) - .substr( - startLoc->getColumnNumber() - 1, - endLoc->getColumnNumber() - startLoc->getColumnNumber() + 1)); - - for (const Id elementId: startLoc->getTokenIds()) - { - const StorageEdge edge = storage.getEdgeById(elementId); - if (edge.id != 0) - { - for (const StorageNode& targetNode: nodeNameToStorageNodes[token]) - { - if (Edge::intToType(edge.type) == Edge::EDGE_INHERITANCE && - intToNodeKind(targetNode.type) != NODE_CLASS) - { - continue; - } - dataToInsert.push_back( - {StorageEdgeData(edge.type, edge.sourceNodeId, targetNode.id), - startLoc->getLocationId()}); - occurrencesToDelete.push_back( - StorageOccurrence(edge.id, startLoc->getLocationId())); - } - } - } - }); - } - }); - - storage.setMode(SqliteIndexStorage::STORAGE_MODE_WRITE); - - storage.startInjection(); - - std::vector edgesToInsert; - for (const DataToInsert& data: dataToInsert) - { - edgesToInsert.push_back(StorageEdge(0, data.edgeData)); - } - const std::vector ambiguousEdgeIds = storage.addEdges(edgesToInsert); - - if (ambiguousEdgeIds.size() == dataToInsert.size()) - { - for (size_t i = 0; i < ambiguousEdgeIds.size(); i++) - { - storage.addElementComponent(StorageElementComponent( - ambiguousEdgeIds[i], - elementComponentKindToInt(ElementComponentKind::IS_AMBIGUOUS), - L"")); - storage.addOccurrence( - StorageOccurrence(ambiguousEdgeIds[i], dataToInsert[i].sourceLocationId)); - } - storage.setMode(SqliteIndexStorage::STORAGE_MODE_CLEAR); - - storage.removeOccurrences(occurrencesToDelete); - std::set edgeIds; - for (const StorageOccurrence& occurrence: occurrencesToDelete) - { - edgeIds.insert(occurrence.elementId); - } - storage.removeElementsWithoutOccurrences(utility::toVector(edgeIds)); - - storage.finishInjection(); - LOG_INFO("Finished Python post processing."); - } - else - { - LOG_ERROR("Error occurred while running Python post processing. Rolling back all changes."); - storage.rollbackInjection(); - } -} diff --git a/src/lib/data/indexer/TaskExecuteCustomCommands.h b/src/lib/data/indexer/TaskExecuteCustomCommands.h index 03888571..1357300b 100644 --- a/src/lib/data/indexer/TaskExecuteCustomCommands.h +++ b/src/lib/data/indexer/TaskExecuteCustomCommands.h @@ -20,6 +20,8 @@ class TaskExecuteCustomCommands , public MessageListener { public: + static void runPythonPostProcessing(PersistentStorage& storage); + TaskExecuteCustomCommands( std::unique_ptr indexerCommandProvider, std::shared_ptr storage, @@ -38,9 +40,7 @@ private: void executeParallelIndexerCommands(int threadId, std::shared_ptr blackboard); void runIndexerCommand( std::shared_ptr indexerCommand, std::shared_ptr blackboard); - void runPythonPostProcessing(PersistentStorage& storage); -private: std::unique_ptr m_indexerCommandProvider; std::shared_ptr m_storage; std::shared_ptr m_dialogView; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index d2b42f9b..20fa3a8f 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -3,7 +3,7 @@ add_files( helper/TestFileRegister.cpp helper/TestFileRegister.h - helper/TestIntermediateStorage.h + helper/TestStorage.h test_main.cpp @@ -25,6 +25,7 @@ add_files( MatrixDynamicBaseTestSuite.cpp MessageQueueTestSuite.cpp NetworkProtocolHelperTestSuite.cpp + PythonIndexerTestSuite.cpp RefreshInfoGeneratorTestSuite.cpp SearchIndexTestSuite.cpp SettingsMigratorTestSuite.cpp diff --git a/src/test/CxxParserTestSuite.cpp b/src/test/CxxParserTestSuite.cpp index b824733b..b60ae568 100644 --- a/src/test/CxxParserTestSuite.cpp +++ b/src/test/CxxParserTestSuite.cpp @@ -14,14 +14,13 @@ # include "ParserClientImpl.h" # include "TestFileRegister.h" -# include "TestIntermediateStorage.h" +# include "TestStorage.h" namespace { -std::shared_ptr parseCode( - std::string code, std::vector compilerFlags = {}) +std::shared_ptr parseCode(std::string code, std::vector compilerFlags = {}) { - std::shared_ptr storage = std::make_shared(); + std::shared_ptr storage = std::make_shared(); CxxParser parser( std::make_shared(storage.get()), std::make_shared(), @@ -30,21 +29,21 @@ std::shared_ptr parseCode( L"input.cc", TextAccess::createFromString(code), utility::concat(compilerFlags, std::vector(1, L"-std=c++1z"))); - storage->generateStringLists(); - return storage; + + return TestStorage::create(storage); } } // namespace TEST_CASE("cxx parser finds global variable declaration") { - std::shared_ptr client = parseCode("int x;\n"); + std::shared_ptr client = parseCode("int x;\n"); REQUIRE(utility::containsElement(client->globalVariables, L"int x <1:5 1:5>")); } TEST_CASE("cxx parser finds static global variable declaration") { - std::shared_ptr client = parseCode("static int x;\n"); + std::shared_ptr client = parseCode("static int x;\n"); REQUIRE(utility::containsElement( client->globalVariables, L"int x (input.cc) <1:12 1:12>")); @@ -52,7 +51,7 @@ TEST_CASE("cxx parser finds static global variable declaration") TEST_CASE("cxx parser finds static const global variable declaration") { - std::shared_ptr client = parseCode("static const int x;\n"); + std::shared_ptr client = parseCode("static const int x;\n"); REQUIRE(utility::containsElement( client->globalVariables, L"const int x (input.cc) <1:18 1:18>")); @@ -60,7 +59,7 @@ TEST_CASE("cxx parser finds static const global variable declaration") TEST_CASE("cxx parser finds global class definition") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" "};\n"); @@ -70,14 +69,14 @@ TEST_CASE("cxx parser finds global class definition") TEST_CASE("cxx parser finds global class declaration") { - std::shared_ptr client = parseCode("class A;\n"); + std::shared_ptr client = parseCode("class A;\n"); REQUIRE(utility::containsElement(client->classes, L"A <1:7 1:7>")); } TEST_CASE("cxx parser finds global struct definition") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "struct A\n" "{\n" "};\n"); @@ -87,21 +86,21 @@ TEST_CASE("cxx parser finds global struct definition") TEST_CASE("cxx parser finds global struct declaration") { - std::shared_ptr client = parseCode("struct A;\n"); + std::shared_ptr client = parseCode("struct A;\n"); REQUIRE(utility::containsElement(client->structs, L"A <1:8 1:8>")); } TEST_CASE("cxx parser finds variable definitions in global scope") { - std::shared_ptr client = parseCode("int x;\n"); + std::shared_ptr client = parseCode("int x;\n"); REQUIRE(utility::containsElement(client->globalVariables, L"int x <1:5 1:5>")); } TEST_CASE("cxx parser finds fields in class with access type") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" " int a;\n" @@ -124,7 +123,7 @@ TEST_CASE("cxx parser finds fields in class with access type") TEST_CASE("cxx parser finds function declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int ceil(float a)\n" "{\n" " return 1;\n" @@ -136,7 +135,7 @@ TEST_CASE("cxx parser finds function declaration") TEST_CASE("cxx parser finds static function declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "static int ceil(float a)\n" "{\n" " return static_cast(a) + 1;\n" @@ -148,7 +147,7 @@ TEST_CASE("cxx parser finds static function declaration") TEST_CASE("cxx parser finds method declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class B\n" "{\n" "public:\n" @@ -161,7 +160,7 @@ TEST_CASE("cxx parser finds method declaration") TEST_CASE("cxx parser finds overloaded operator declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class B\n" "{\n" "public:\n" @@ -174,7 +173,7 @@ TEST_CASE("cxx parser finds overloaded operator declaration") TEST_CASE("cxx parser finds method declaration and definition") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class B\n" "{\n" "public:\n" @@ -190,7 +189,7 @@ TEST_CASE("cxx parser finds method declaration and definition") TEST_CASE("cxx parser finds virtual method declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class B\n" "{\n" "public:\n" @@ -203,7 +202,7 @@ TEST_CASE("cxx parser finds virtual method declaration") TEST_CASE("cxx parser finds pure virtual method declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class B\n" "{\n" "protected:\n" @@ -216,7 +215,7 @@ TEST_CASE("cxx parser finds pure virtual method declaration") TEST_CASE("cxx parser finds named namespace declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace A\n" "{\n" "}\n"); @@ -226,7 +225,7 @@ TEST_CASE("cxx parser finds named namespace declaration") TEST_CASE("cxx parser finds anonymous namespace declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace\n" "{\n" "}\n"); @@ -237,7 +236,7 @@ TEST_CASE("cxx parser finds anonymous namespace declaration") TEST_CASE("cxx parser finds multiple anonymous namespace declarations as same symbol") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace\n" "{\n" "}\n" @@ -254,7 +253,7 @@ TEST_CASE("cxx parser finds multiple anonymous namespace declarations as same sy TEST_CASE("cxx parser finds multiple nested anonymous namespace declarations as different symbol") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace\n" "{\n" " namespace\n" @@ -275,7 +274,7 @@ TEST_CASE( "cxx parser finds anonymous namespace declarations nested inside namespaces with different " "name as different symbol") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace a\n" "{\n" " namespace\n" @@ -304,7 +303,7 @@ TEST_CASE( "cxx parser finds anonymous namespace declarations nested inside namespaces with same name as " "same symbol") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace a\n" "{\n" " namespace\n" @@ -331,7 +330,7 @@ TEST_CASE( TEST_CASE("cxx parser finds anonymous struct declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "typedef struct\n" "{\n" " int x;\n" @@ -343,7 +342,7 @@ TEST_CASE("cxx parser finds anonymous struct declaration") TEST_CASE("cxx parser finds multiple anonymous struct declarations as distinct elements") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "typedef struct\n" "{\n" " int x;\n" @@ -362,7 +361,7 @@ TEST_CASE("cxx parser finds multiple anonymous struct declarations as distinct e TEST_CASE("cxx parser finds anonymous union declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "typedef union\n" "{\n" " int i;\n" @@ -375,7 +374,7 @@ TEST_CASE("cxx parser finds anonymous union declaration") TEST_CASE("cxx parser finds name of anonymous struct declared inside typedef") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "typedef struct\n" "{\n" " int x;\n" @@ -387,7 +386,7 @@ TEST_CASE("cxx parser finds name of anonymous struct declared inside typedef") TEST_CASE("cxx parser finds name of anonymous class declared inside typedef") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "typedef class\n" "{\n" " int x;\n" @@ -399,7 +398,7 @@ TEST_CASE("cxx parser finds name of anonymous class declared inside typedef") TEST_CASE("cxx parser finds name of anonymous enum declared inside typedef") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "typedef enum\n" "{\n" " CONSTANT_1;\n" @@ -411,7 +410,7 @@ TEST_CASE("cxx parser finds name of anonymous enum declared inside typedef") TEST_CASE("cxx parser finds name of anonymous union declared inside typedef") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "typedef union\n" "{\n" " int x;\n" @@ -424,7 +423,7 @@ TEST_CASE("cxx parser finds name of anonymous union declared inside typedef") TEST_CASE("cxx parser finds name of anonymous struct declared inside type alias") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "using Foo = struct\n" "{\n" " int x;\n" @@ -436,7 +435,7 @@ TEST_CASE("cxx parser finds name of anonymous struct declared inside type alias" TEST_CASE("cxx parser finds name of anonymous class declared inside type alias") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "using Foo = class\n" "{\n" " int x;\n" @@ -448,7 +447,7 @@ TEST_CASE("cxx parser finds name of anonymous class declared inside type alias") TEST_CASE("cxx parser finds name of anonymous enum declared inside type alias") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "using Foo = enum\n" "{\n" " CONSTANT_1;\n" @@ -460,7 +459,7 @@ TEST_CASE("cxx parser finds name of anonymous enum declared inside type alias") TEST_CASE("cxx parser finds name of anonymous union declared inside type alias") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "using Foo = union\n" "{\n" " int x;\n" @@ -473,7 +472,7 @@ TEST_CASE("cxx parser finds name of anonymous union declared inside type alias") TEST_CASE("cxx parser finds enum defined in global namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "enum E\n" "{\n" "};\n"); @@ -483,7 +482,7 @@ TEST_CASE("cxx parser finds enum defined in global namespace") TEST_CASE("cxx parser finds enum constant in global enum") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "enum E\n" "{\n" " P\n" @@ -494,14 +493,14 @@ TEST_CASE("cxx parser finds enum constant in global enum") TEST_CASE("cxx parser finds typedef in global namespace") { - std::shared_ptr client = parseCode("typedef unsigned int uint;\n"); + std::shared_ptr client = parseCode("typedef unsigned int uint;\n"); REQUIRE(utility::containsElement(client->typedefs, L"uint <1:22 1:25>")); } TEST_CASE("cxx parser finds typedef in named namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace test\n" "{\n" " typedef unsigned int uint;\n" @@ -512,7 +511,7 @@ TEST_CASE("cxx parser finds typedef in named namespace") TEST_CASE("cxx parser finds typedef in anonymous namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace\n" "{\n" " typedef unsigned int uint;\n" @@ -524,7 +523,7 @@ TEST_CASE("cxx parser finds typedef in anonymous namespace") TEST_CASE("cxx parser finds type alias in class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Foo\n" "{\n" " using Bar = Foo;\n" @@ -536,7 +535,7 @@ TEST_CASE("cxx parser finds type alias in class") TEST_CASE("cxx parser finds macro define") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define PI\n" "void test()\n" "{\n" @@ -547,7 +546,7 @@ TEST_CASE("cxx parser finds macro define") TEST_CASE("cxx parser finds macro undefine") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#undef PI\n" "void test()\n" "{\n" @@ -558,7 +557,7 @@ TEST_CASE("cxx parser finds macro undefine") TEST_CASE("cxx parser finds macro in ifdef") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define PI\n" "#ifdef PI\n" "void test()\n" @@ -571,7 +570,7 @@ TEST_CASE("cxx parser finds macro in ifdef") TEST_CASE("cxx parser finds macro in ifndef") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define PI\n" "#ifndef PI\n" "void test()\n" @@ -584,7 +583,7 @@ TEST_CASE("cxx parser finds macro in ifndef") TEST_CASE("cxx parser finds macro in ifdefined") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define PI\n" "#if defined(PI)\n" "void test()\n" @@ -598,7 +597,7 @@ TEST_CASE("cxx parser finds macro in ifdefined") TEST_CASE("cxx parser finds macro expand") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define PI 3.14159265359\n" "void test()\n" "{\n" @@ -611,7 +610,7 @@ TEST_CASE("cxx parser finds macro expand") TEST_CASE("cxx parser finds macro expand within macro") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define PI 3.14159265359\n" "#define TAU (2 * PI)\n" "void test()\n" @@ -625,7 +624,7 @@ TEST_CASE("cxx parser finds macro expand within macro") TEST_CASE("cxx parser finds macro define scope") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define MAX(a,b) \\\n" " ((a)>(b)?(a):(b))"); @@ -634,7 +633,7 @@ TEST_CASE("cxx parser finds macro define scope") TEST_CASE("cxx parser finds type template parameter definition of template type alias") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template\n" "using MyType = int;\n"); @@ -644,7 +643,7 @@ TEST_CASE("cxx parser finds type template parameter definition of template type TEST_CASE("cxx parser finds type template parameter definition of class template") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -658,7 +657,7 @@ TEST_CASE( "cxx parser finds type template parameter definition of explicit partial class template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -677,7 +676,7 @@ TEST_CASE( TEST_CASE("cxx parser finds type template parameter definition of variable template") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T v;\n"); @@ -689,7 +688,7 @@ TEST_CASE( "cxx parser finds type template parameter definition of explicit partial variable template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T t = Q(5);\n" "\n" @@ -705,7 +704,7 @@ TEST_CASE( TEST_CASE("cxx parser finds type template parameter defined with class keyword") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -717,7 +716,7 @@ TEST_CASE("cxx parser finds type template parameter defined with class keyword") TEST_CASE("cxx parser finds non type int template parameter definition of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -729,7 +728,7 @@ TEST_CASE("cxx parser finds non type int template parameter definition of templa TEST_CASE("cxx parser finds non type bool template parameter definition of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -742,7 +741,7 @@ TEST_CASE("cxx parser finds non type bool template parameter definition of templ TEST_CASE( "cxx parser finds non type custom pointer template parameter definition of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -756,7 +755,7 @@ TEST_CASE( TEST_CASE( "cxx parser finds non type custom reference template parameter definition of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -771,7 +770,7 @@ TEST_CASE( "cxx parser finds non type template parameter definition that depends on type template " "parameter of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n"); @@ -788,7 +787,7 @@ TEST_CASE( "cxx parser finds non type template parameter definition that depends on template template " "parameter of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template class T1, T1& T2>\n" "class A\n" "{};\n"); @@ -804,7 +803,7 @@ TEST_CASE( "cxx parser finds non type template parameter definition that depends on type template " "parameter of template template parameter") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template typename S>\n" "class A\n" "{\n" @@ -819,7 +818,7 @@ TEST_CASE( TEST_CASE("cxx parser finds template argument of dependent non type template parameter") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template class T1, T1& T2>\n" "class A\n" "{};\n"); @@ -830,7 +829,7 @@ TEST_CASE("cxx parser finds template argument of dependent non type template par // void _test_foofoo() //{ -// std::shared_ptr client = parseCode( +// std::shared_ptr client = parseCode( // "template \n" // "class vector { };\n" // "\n" @@ -851,7 +850,7 @@ TEST_CASE("cxx parser finds template argument of dependent non type template par TEST_CASE("cxx parser finds template template parameter of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -869,7 +868,7 @@ TEST_CASE("cxx parser finds template template parameter of template class") TEST_CASE("cxx parser finds type template parameter pack type of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -881,7 +880,7 @@ TEST_CASE("cxx parser finds type template parameter pack type of template class" TEST_CASE("cxx parser finds non type int template parameter pack type of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -893,7 +892,7 @@ TEST_CASE("cxx parser finds non type int template parameter pack type of templat TEST_CASE("cxx parser finds template template parameter pack type of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template typename... T>\n" "class A\n" "{\n" @@ -905,7 +904,7 @@ TEST_CASE("cxx parser finds template template parameter pack type of template cl TEST_CASE("cxx parser finds type template parameters of template class with multiple parameters") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -919,7 +918,7 @@ TEST_CASE("cxx parser finds type template parameters of template class with mult TEST_CASE("cxx parser skips creating node for template parameter without a name") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" // local symbol for brace @@ -934,7 +933,7 @@ TEST_CASE("cxx parser skips creating node for template parameter without a name" TEST_CASE( "cxx parser finds type template parameter of template method definition outside template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -952,7 +951,7 @@ TEST_CASE( TEST_CASE("cxx parser finds explicit class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -967,7 +966,7 @@ TEST_CASE("cxx parser finds explicit class template specialization") TEST_CASE("cxx parser finds explicit variable template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T t = T(5);\n" "\n" @@ -980,7 +979,7 @@ TEST_CASE("cxx parser finds explicit variable template specialization") TEST_CASE("cxx parser finds explicit partial class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -996,7 +995,7 @@ TEST_CASE("cxx parser finds explicit partial class template specialization") TEST_CASE("cxx parser finds explicit partial variable template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T t = Q(5);\n" "\n" @@ -1009,7 +1008,7 @@ TEST_CASE("cxx parser finds explicit partial variable template specialization") TEST_CASE("cxx parser finds correct field member name of template class in declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -1022,7 +1021,7 @@ TEST_CASE("cxx parser finds correct field member name of template class in decla TEST_CASE("cxx parser finds correct type of field member of template class in declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -1044,7 +1043,7 @@ TEST_CASE("cxx parser finds correct type of field member of template class in de TEST_CASE("cxx parser finds correct method member name of template class in declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -1057,7 +1056,7 @@ TEST_CASE("cxx parser finds correct method member name of template class in decl TEST_CASE("cxx parser finds type template parameter definition of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T test(T a)\n" "{\n" @@ -1070,7 +1069,7 @@ TEST_CASE("cxx parser finds type template parameter definition of template funct TEST_CASE("cxx parser finds non type int template parameter definition of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "int test(int a)\n" "{\n" @@ -1083,7 +1082,7 @@ TEST_CASE("cxx parser finds non type int template parameter definition of templa TEST_CASE("cxx parser finds non type bool template parameter definition of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "int test(int a)\n" "{\n" @@ -1097,7 +1096,7 @@ TEST_CASE("cxx parser finds non type bool template parameter definition of templ TEST_CASE( "cxx parser finds non type custom pointer template parameter definition of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -1113,7 +1112,7 @@ TEST_CASE( TEST_CASE( "cxx parser finds non type custom reference template parameter definition of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -1128,7 +1127,7 @@ TEST_CASE( TEST_CASE("cxx parser finds template template parameter definition of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -1144,7 +1143,7 @@ TEST_CASE("cxx parser finds template template parameter definition of template f TEST_CASE("cxx parser finds function for implicit instantiation of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T test(T a)\n" "{\n" @@ -1163,7 +1162,7 @@ TEST_CASE("cxx parser finds function for implicit instantiation of template func TEST_CASE( "cxx parser skips implicit template method definition of implicit template class instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -1187,7 +1186,7 @@ TEST_CASE( TEST_CASE("cxx parser finds lambda definition and call in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void lambdaCaller()\n" "{\n" " [](){}();\n" @@ -1204,7 +1203,7 @@ TEST_CASE("cxx parser finds lambda definition and call in function") TEST_CASE("cxx parser finds mutable lambda definition") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void lambdaWrapper()\n" "{\n" " [](int foo) mutable { return foo; };\n" @@ -1218,7 +1217,7 @@ TEST_CASE("cxx parser finds mutable lambda definition") TEST_CASE("cxx parser finds local variable declared in lambda capture") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void lambdaWrapper()\n" "{\n" " [x(42)]() { return x; };\n" @@ -1232,7 +1231,7 @@ TEST_CASE("cxx parser finds local variable declared in lambda capture") TEST_CASE("cxx parser finds definition of local symbol in function parameter list") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void test(int a)\n" "{\n" "}\n"); @@ -1243,7 +1242,7 @@ TEST_CASE("cxx parser finds definition of local symbol in function parameter lis TEST_CASE("cxx parser finds definition of local symbol in function scope") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void test()\n" "{\n" " int a;\n" @@ -1258,7 +1257,7 @@ TEST_CASE("cxx parser finds definition of local symbol in function scope") TEST_CASE("cxx parser finds class definition in class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" "public:\n" @@ -1270,7 +1269,7 @@ TEST_CASE("cxx parser finds class definition in class") TEST_CASE("cxx parser finds class definition in namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace a\n" "{\n" " class B;\n" @@ -1281,7 +1280,7 @@ TEST_CASE("cxx parser finds class definition in namespace") TEST_CASE("cxx parser finds struct definition in class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" " struct B\n" @@ -1295,7 +1294,7 @@ TEST_CASE("cxx parser finds struct definition in class") TEST_CASE("cxx parser finds struct definition in namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace A\n" "{\n" " struct B\n" @@ -1308,7 +1307,7 @@ TEST_CASE("cxx parser finds struct definition in namespace") TEST_CASE("cxx parser finds struct definition in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void foo(int)\n" "{\n" " struct B\n" @@ -1328,7 +1327,7 @@ TEST_CASE("cxx parser finds struct definition in function") TEST_CASE("cxx parser finds variable definitions in namespace scope") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace n" "{\n" " int x;\n" @@ -1339,7 +1338,7 @@ TEST_CASE("cxx parser finds variable definitions in namespace scope") TEST_CASE("cxx parser finds field in nested class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class B\n" "{\n" "public:\n" @@ -1356,7 +1355,7 @@ TEST_CASE("cxx parser finds field in nested class") TEST_CASE("cxx parser finds function in anonymous namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace\n" "{\n" " int sum(int a, int b);\n" @@ -1369,7 +1368,7 @@ TEST_CASE("cxx parser finds function in anonymous namespace") TEST_CASE("cxx parser finds method declared in nested class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class B\n" "{\n" " class C\n" @@ -1384,7 +1383,7 @@ TEST_CASE("cxx parser finds method declared in nested class") TEST_CASE("cxx parser finds nested named namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace A\n" "{\n" " namespace B\n" @@ -1398,7 +1397,7 @@ TEST_CASE("cxx parser finds nested named namespace") TEST_CASE("cxx parser finds enum defined in class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class B\n" "{\n" "public:\n" @@ -1413,7 +1412,7 @@ TEST_CASE("cxx parser finds enum defined in class") TEST_CASE("cxx parser finds enum defined in namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace n\n" "{\n" " enum Z\n" @@ -1426,7 +1425,7 @@ TEST_CASE("cxx parser finds enum defined in namespace") TEST_CASE("cxx parser finds enum definition in template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -1443,7 +1442,7 @@ TEST_CASE("cxx parser finds enum definition in template class") TEST_CASE("cxx parser finds enum constants in template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -1463,7 +1462,7 @@ TEST_CASE("cxx parser finds enum constants in template class") TEST_CASE("cxx parser finds qualifier of access to global variable defined in namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace foo {\n" " namespace bar {\n" " int x;\n" @@ -1479,7 +1478,7 @@ TEST_CASE("cxx parser finds qualifier of access to global variable defined in na TEST_CASE("cxx parser finds qualifier of access to static field") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Foo {\n" "public:\n" " struct Bar {\n" @@ -1497,7 +1496,7 @@ TEST_CASE("cxx parser finds qualifier of access to static field") TEST_CASE("cxx parser finds qualifier of access to enum constant") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "enum Foo {\n" " FOO_V\n" "};\n" @@ -1510,7 +1509,7 @@ TEST_CASE("cxx parser finds qualifier of access to enum constant") TEST_CASE("cxx parser finds qualifier of reference to method") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Foo {\n" "public:\n" " static void my_int_func(int x) {\n" @@ -1527,7 +1526,7 @@ TEST_CASE("cxx parser finds qualifier of reference to method") TEST_CASE("cxx parser finds qualifier of constructor call") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Foo {\n" "public:\n" " Foo(int i) {}\n" @@ -1546,7 +1545,7 @@ TEST_CASE("cxx parser finds qualifier of constructor call") TEST_CASE("cxx parser finds builtin types") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void t1(int v) {}\n" "void t2(float v) {}\n" "void t3(double v) {}\n" @@ -1561,7 +1560,7 @@ TEST_CASE("cxx parser finds builtin types") TEST_CASE("cxx parser finds implicit copy constructor") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class TestClass {}\n" "void foo()\n" "{\n" @@ -1583,7 +1582,7 @@ TEST_CASE("cxx parser finds implicit copy constructor") TEST_CASE("cxx parser finds enum usage in template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -1602,7 +1601,7 @@ TEST_CASE("cxx parser finds enum usage in template class") TEST_CASE("cxx parser finds correct field member type of nested template class in declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -1630,14 +1629,14 @@ TEST_CASE("cxx parser finds correct field member type of nested template class i TEST_CASE("cxx parser finds type usage of global variable") { - std::shared_ptr client = parseCode("int x;\n"); + std::shared_ptr client = parseCode("int x;\n"); REQUIRE(utility::containsElement(client->typeUses, L"int x -> int <1:1 1:3>")); } TEST_CASE("cxx parser finds typedefs type use") { - std::shared_ptr client = parseCode("typedef unsigned int uint;\n"); + std::shared_ptr client = parseCode("typedef unsigned int uint;\n"); REQUIRE(utility::containsElement( client->typeUses, L"uint -> unsigned int <1:9 1:16>")); @@ -1645,7 +1644,7 @@ TEST_CASE("cxx parser finds typedefs type use") TEST_CASE("cxx parser finds typedef that uses type defined in named namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace test\n" "{\n" " struct TestStruct{};\n" @@ -1658,7 +1657,7 @@ TEST_CASE("cxx parser finds typedef that uses type defined in named namespace") TEST_CASE("cxx parser finds type use of typedef") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "typedef unsigned int uint;\n" "uint number;\n"); @@ -1668,7 +1667,7 @@ TEST_CASE("cxx parser finds type use of typedef") TEST_CASE("cxx parser finds class default private inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {};\n" "class B : A {};\n"); @@ -1677,7 +1676,7 @@ TEST_CASE("cxx parser finds class default private inheritance") TEST_CASE("cxx parser finds class public inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {};\n" "class B : public A {};\n"); @@ -1686,7 +1685,7 @@ TEST_CASE("cxx parser finds class public inheritance") TEST_CASE("cxx parser finds class protected inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {};\n" "class B : protected A {};\n"); @@ -1695,7 +1694,7 @@ TEST_CASE("cxx parser finds class protected inheritance") TEST_CASE("cxx parser finds class private inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {};\n" "class B : private A {};\n"); @@ -1704,7 +1703,7 @@ TEST_CASE("cxx parser finds class private inheritance") TEST_CASE("cxx parser finds class multiple inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {};\n" "class B {};\n" "class C\n" @@ -1718,7 +1717,7 @@ TEST_CASE("cxx parser finds class multiple inheritance") TEST_CASE("cxx parser finds struct default public inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "struct A {};\n" "struct B : A {};\n"); @@ -1727,7 +1726,7 @@ TEST_CASE("cxx parser finds struct default public inheritance") TEST_CASE("cxx parser finds struct public inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "struct A {};\n" "struct B : public A {};\n"); @@ -1736,7 +1735,7 @@ TEST_CASE("cxx parser finds struct public inheritance") TEST_CASE("cxx parser finds struct protected inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "struct A {};\n" "struct B : protected A {};\n"); @@ -1745,7 +1744,7 @@ TEST_CASE("cxx parser finds struct protected inheritance") TEST_CASE("cxx parser finds struct private inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "struct A {};\n" "struct B : private A {};\n"); @@ -1754,7 +1753,7 @@ TEST_CASE("cxx parser finds struct private inheritance") TEST_CASE("cxx parser finds struct multiple inheritance") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "struct A {};\n" "struct B {};\n" "struct C\n" @@ -1768,7 +1767,7 @@ TEST_CASE("cxx parser finds struct multiple inheritance") TEST_CASE("cxx parser finds method override when virtual") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {\n" " virtual void foo();\n" "};\n" @@ -1782,7 +1781,7 @@ TEST_CASE("cxx parser finds method override when virtual") TEST_CASE("cxx parser finds multi layer method overrides") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {\n" " virtual void foo();\n" "};\n" @@ -1801,7 +1800,7 @@ TEST_CASE("cxx parser finds multi layer method overrides") TEST_CASE("cxx parser finds method overrides on different return types") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {\n" " virtual void foo();\n" "};\n" @@ -1816,7 +1815,7 @@ TEST_CASE("cxx parser finds method overrides on different return types") TEST_CASE("cxx parser finds no method override when not virtual") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {\n" " void foo();\n" "};\n" @@ -1829,7 +1828,7 @@ TEST_CASE("cxx parser finds no method override when not virtual") TEST_CASE("cxx parser finds no method overrides on different signatures") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {\n" " virtual void foo(int a);\n" "};\n" @@ -1842,7 +1841,7 @@ TEST_CASE("cxx parser finds no method overrides on different signatures") TEST_CASE("cxx parser finds using directive decl in function context") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void foo()\n" "{\n" " using namespace std;\n" @@ -1854,14 +1853,14 @@ TEST_CASE("cxx parser finds using directive decl in function context") TEST_CASE("cxx parser finds using directive decl in file context") { - std::shared_ptr client = parseCode("using namespace std;\n"); + std::shared_ptr client = parseCode("using namespace std;\n"); REQUIRE(utility::containsElement(client->usages, L"input.cc -> std <1:17 1:19>")); } TEST_CASE("cxx parser finds using decl in function context") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace foo\n" "{\n" " int a;\n" @@ -1877,7 +1876,7 @@ TEST_CASE("cxx parser finds using decl in function context") TEST_CASE("cxx parser finds using decl in file context") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace foo\n" "{\n" " int a;\n" @@ -1890,7 +1889,7 @@ TEST_CASE("cxx parser finds using decl in file context") TEST_CASE("cxx parser finds call in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int sum(int a, int b)\n" "{\n" " return a + b;\n" @@ -1906,7 +1905,7 @@ TEST_CASE("cxx parser finds call in function") TEST_CASE("cxx parser finds call in function with correct signature") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int sum(int a, int b)\n" "{\n" " return a + b;\n" @@ -1925,7 +1924,7 @@ TEST_CASE("cxx parser finds call in function with correct signature") TEST_CASE("cxx parser finds call to function with right signature") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int sum(int a, int b)\n" "{\n" " return a + b;\n" @@ -1948,7 +1947,7 @@ TEST_CASE("cxx parser finds call to function with right signature") TEST_CASE("cxx parser finds function call in function parameter list") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int sum(int a, int b)\n" "{\n" " return a + b;\n" @@ -1964,7 +1963,7 @@ TEST_CASE("cxx parser finds function call in function parameter list") TEST_CASE("cxx parser finds function call in method") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int sum(int a, int b)\n" "{\n" " return a + b;\n" @@ -1983,7 +1982,7 @@ TEST_CASE("cxx parser finds function call in method") TEST_CASE("cxx parser finds implicit constructor without definition call") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" "};\n" @@ -1998,7 +1997,7 @@ TEST_CASE("cxx parser finds implicit constructor without definition call") TEST_CASE("cxx parser finds explicit constructor call") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" "public:\n" @@ -2015,7 +2014,7 @@ TEST_CASE("cxx parser finds explicit constructor call") TEST_CASE("cxx parser finds call of explicitly defined destructor at delete keyword") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Foo\n" "{\n" "public:\n" @@ -2035,7 +2034,7 @@ TEST_CASE("cxx parser finds call of explicitly defined destructor at delete keyw TEST_CASE("cxx parser finds call of implicitly defined destructor at delete keyword") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Foo\n" "{\n" "}; \n" @@ -2052,7 +2051,7 @@ TEST_CASE("cxx parser finds call of implicitly defined destructor at delete keyw TEST_CASE("cxx parser finds explicit constructor call of field") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Item\n" "{\n" "};\n" @@ -2069,7 +2068,7 @@ TEST_CASE("cxx parser finds explicit constructor call of field") TEST_CASE("cxx parser finds function call in member initialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int one() { return 1; }\n" "class Item\n" "{\n" @@ -2090,7 +2089,7 @@ TEST_CASE("cxx parser finds function call in member initialization") TEST_CASE("cxx parser finds copy constructor call") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" "public:\n" @@ -2109,7 +2108,7 @@ TEST_CASE("cxx parser finds copy constructor call") TEST_CASE("cxx parser finds global variable constructor call") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" "public:\n" @@ -2123,7 +2122,7 @@ TEST_CASE("cxx parser finds global variable constructor call") TEST_CASE("cxx parser finds global variable function call") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int one() { return 1; }\n" "int a = one();\n"); @@ -2132,7 +2131,7 @@ TEST_CASE("cxx parser finds global variable function call") TEST_CASE("cxx parser finds operator call") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" "public:\n" @@ -2152,7 +2151,7 @@ TEST_CASE("cxx parser finds operator call") TEST_CASE("cxx parser finds usage of function pointer") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void my_int_func(int x)\n" "{\n" "}\n" @@ -2169,7 +2168,7 @@ TEST_CASE("cxx parser finds usage of function pointer") TEST_CASE("cxx parser finds usage of global variable in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int bar;\n" "\n" "int main()\n" @@ -2183,7 +2182,7 @@ TEST_CASE("cxx parser finds usage of global variable in function") TEST_CASE("cxx parser finds usage of global variable in global variable initialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int a = 0;\n" "int b[] = {a};\n"); @@ -2193,7 +2192,7 @@ TEST_CASE("cxx parser finds usage of global variable in global variable initiali TEST_CASE("cxx parser finds usage of global variable in method") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int bar;\n" "\n" "class App\n" @@ -2210,7 +2209,7 @@ TEST_CASE("cxx parser finds usage of global variable in method") TEST_CASE("cxx parser finds usage of field in method") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" " void foo()\n" @@ -2229,7 +2228,7 @@ TEST_CASE("cxx parser finds usage of field in method") TEST_CASE("cxx parser finds usage of field in function call arguments") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" "public:\n" @@ -2246,7 +2245,7 @@ TEST_CASE("cxx parser finds usage of field in function call arguments") TEST_CASE("cxx parser finds usage of field in function call context") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" "public:\n" @@ -2263,7 +2262,7 @@ TEST_CASE("cxx parser finds usage of field in function call context") TEST_CASE("cxx parser finds usage of field in initialization list") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" " App()\n" @@ -2278,7 +2277,7 @@ TEST_CASE("cxx parser finds usage of field in initialization list") TEST_CASE("cxx parser finds usage of member in call expression to unresolved member expression") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A {\n" " template \n" " T run() { return 5; }\n" @@ -2297,7 +2296,7 @@ TEST_CASE("cxx parser finds usage of member in call expression to unresolved mem TEST_CASE("cxx parser finds usage of member in temporary object expression") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Foo\n" "{\n" "public:\n" @@ -2324,7 +2323,7 @@ TEST_CASE("cxx parser finds usage of member in temporary object expression") TEST_CASE("cxx parser finds usage of member in dependent scope member expression") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2342,7 +2341,7 @@ TEST_CASE("cxx parser finds usage of member in dependent scope member expression TEST_CASE("cxx parser finds return type use in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "double PI()\n" "{\n" " return 3.14159265359;\n" @@ -2354,7 +2353,7 @@ TEST_CASE("cxx parser finds return type use in function") TEST_CASE("cxx parser finds parameter type uses in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void ceil(float a)\n" "{\n" "}\n"); @@ -2365,7 +2364,7 @@ TEST_CASE("cxx parser finds parameter type uses in function") TEST_CASE("cxx parser finds use of decayed parameter type in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template\n" "class VectorBase\n" "{\n" @@ -2381,7 +2380,7 @@ TEST_CASE("cxx parser finds use of decayed parameter type in function") TEST_CASE("cxx parser usage of injected type in method declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class Foo\n" "{\n" @@ -2400,7 +2399,7 @@ TEST_CASE("cxx parser usage of injected type in method declaration") TEST_CASE("cxx parser finds use of qualified type in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void test(const int t)\n" "{\n" "}\n"); @@ -2411,7 +2410,7 @@ TEST_CASE("cxx parser finds use of qualified type in function") TEST_CASE("cxx parser finds parameter type uses in constructor") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" " A(int a);\n" @@ -2423,7 +2422,7 @@ TEST_CASE("cxx parser finds parameter type uses in constructor") TEST_CASE("cxx parser finds type uses in function body") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int main()\n" "{\n" " int a = 42;\n" @@ -2435,7 +2434,7 @@ TEST_CASE("cxx parser finds type uses in function body") TEST_CASE("cxx parser finds type uses in method body") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" " int main()\n" @@ -2451,7 +2450,7 @@ TEST_CASE("cxx parser finds type uses in method body") TEST_CASE("cxx parser finds type uses in loops and conditions") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int main()\n" "{\n" " if (true)\n" @@ -2474,7 +2473,7 @@ TEST_CASE("cxx parser finds type uses in loops and conditions") TEST_CASE("cxx parser finds type uses of base class in derived constructor") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" "public:\n" @@ -2491,7 +2490,7 @@ TEST_CASE("cxx parser finds type uses of base class in derived constructor") TEST_CASE("cxx parser finds enum uses in global space") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "enum A\n" "{\n" " B,\n" @@ -2508,7 +2507,7 @@ TEST_CASE("cxx parser finds enum uses in global space") TEST_CASE("cxx parser finds enum uses in function body") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "enum A\n" "{\n" " B,\n" @@ -2529,7 +2528,7 @@ TEST_CASE("cxx parser finds enum uses in function body") TEST_CASE("cxx parser finds usage of template parameter of template member variable declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "struct IsBaseType {\n" " static const bool value = true;\n" @@ -2547,7 +2546,7 @@ TEST_CASE("cxx parser finds usage of template parameter of template member varia TEST_CASE("cxx parser finds usage of template parameters with different depth of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2569,7 +2568,7 @@ TEST_CASE( "cxx parser finds usage of template parameters with different depth of partial class template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2596,7 +2595,7 @@ TEST_CASE( "cxx parser finds usage of template template parameter of template class explicitly " "instantiated with concrete type argument") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -2615,7 +2614,7 @@ TEST_CASE( "cxx parser finds usage of template template parameter of template class explicitly " "instantiated with template type") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -2633,7 +2632,7 @@ TEST_CASE( TEST_CASE("cxx parser finds typedef in other class that depends on own template parameter") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2660,7 +2659,7 @@ TEST_CASE("cxx parser finds typedef in other class that depends on own template TEST_CASE("cxx parser finds usage of template parameter in qualifier of other symbol") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "struct find_if_impl;\n" "\n" @@ -2677,7 +2676,7 @@ TEST_CASE("cxx parser finds usage of template parameter in qualifier of other sy TEST_CASE("cxx parser finds use of dependent template specialization type") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2703,7 +2702,7 @@ TEST_CASE( "cxx parser creates single node for all possible parameter pack expansions of template " "function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template\n" "T adder(T v) { return v; }\n" "\n" @@ -2721,7 +2720,7 @@ TEST_CASE( TEST_CASE("cxx parser finds type template argument of explicit template instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2741,7 +2740,7 @@ TEST_CASE( "cxx parser finds type template argument of explicit template instantiated with function " "prototype") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2761,7 +2760,7 @@ TEST_CASE( TEST_CASE( "cxx parser finds type template argument for parameter pack of explicit template instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2788,7 +2787,7 @@ TEST_CASE( "cxx parser finds type template argument in non default constructor of explicit template " "instaitiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2811,7 +2810,7 @@ TEST_CASE( "cxx parser finds type template argument in default constructor of explicit template " "instaitiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2833,7 +2832,7 @@ TEST_CASE( TEST_CASE( "cxx parser finds type template argument in new expression of explicit template instaitiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2856,7 +2855,7 @@ TEST_CASE( "cxx parser finds no template argument for builtin non type int template parameter of explicit " "template instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" // use of "int" "class A\n" "{\n" @@ -2874,7 +2873,7 @@ TEST_CASE( "cxx parser finds no template argument for builtin non type bool template parameter of " "explicit template instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" // use of "bool" "class A\n" "{\n" @@ -2891,7 +2890,7 @@ TEST_CASE( TEST_CASE( "cxx parser finds non type custom pointer template argument of implicit template instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -2910,7 +2909,7 @@ TEST_CASE( "cxx parser finds non type custom reference template argument of implicit template " "instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -2929,7 +2928,7 @@ TEST_CASE( "cxx parser finds no template argument for builtin non type int template parameter pack of " "explicit template instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" // use of "int" "class A\n" "{\n" @@ -2944,7 +2943,7 @@ TEST_CASE( TEST_CASE("cxx parser finds template template argument of explicit template instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -2966,7 +2965,7 @@ TEST_CASE( "cxx parser finds template template argument for parameter pack of explicit template " "instantiation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -2993,7 +2992,7 @@ TEST_CASE( TEST_CASE( "cxx parser finds template argument for implicit specialization of global template variable") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T v;\n" "void test()\n" @@ -3011,7 +3010,7 @@ TEST_CASE( "cxx parser finds template member specialization for method of implicit template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3031,7 +3030,7 @@ TEST_CASE( "cxx parser finds template member specialization for static variable of implicit template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3051,7 +3050,7 @@ TEST_CASE( TEST_CASE( "cxx parser finds template member specialization for field of implicit template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3071,7 +3070,7 @@ TEST_CASE( "cxx parser finds template member specialization for field of member class of implicit " "template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3095,7 +3094,7 @@ TEST_CASE( "cxx parser finds template member specialization for member class of implicit template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3113,7 +3112,7 @@ TEST_CASE( TEST_CASE("cxx parser finds type template argument of explicit template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3130,7 +3129,7 @@ TEST_CASE( "cxx parser finds no template argument for builtin non type int template parameter of explicit " "template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" // use of "int" "class A\n" "{\n" @@ -3147,7 +3146,7 @@ TEST_CASE( "cxx parser finds no template argument for builtin non type bool template parameter of " "explicit template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" // use of "bool" "class A\n" "{\n" @@ -3164,7 +3163,7 @@ TEST_CASE( "cxx parser finds non type custom pointer template argument of explicit template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -3184,7 +3183,7 @@ TEST_CASE( "cxx parser finds non type custom reference template argument of explicit template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -3202,7 +3201,7 @@ TEST_CASE( TEST_CASE("cxx parser finds template template argument of explicit template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -3221,7 +3220,7 @@ TEST_CASE("cxx parser finds template template argument of explicit template spec TEST_CASE( "cxx parser finds type template arguments of explicit partial class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3241,7 +3240,7 @@ TEST_CASE( "cxx parser finds no template argument for builtin non type int template parameter of explicit " "partial class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3259,7 +3258,7 @@ TEST_CASE( "cxx parser finds no template argument for builtin non type bool template parameter of " "explicit partial class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3277,7 +3276,7 @@ TEST_CASE( "cxx parser finds template argument for non type custom pointer template parameter of explicit " "partial class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -3301,7 +3300,7 @@ TEST_CASE( "cxx parser finds template argument for non type custom reference template parameter of " "explicit partial class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class P\n" "{};\n" "template \n" @@ -3323,7 +3322,7 @@ TEST_CASE( "cxx parser finds template argument for template template parameter of explicit partial class " "template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -3345,7 +3344,7 @@ TEST_CASE( "cxx parser finds non type template argument that depends on type template parameter of " "explicit partial class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3363,7 +3362,7 @@ TEST_CASE( "cxx parser finds non type template argument that depends on template template parameter of " "explicit partial class template specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template class T2, T2 T3>\n" "class A\n" "{\n" @@ -3381,7 +3380,7 @@ TEST_CASE( TEST_CASE("cxx parser finds implicit template class specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3396,7 +3395,7 @@ TEST_CASE("cxx parser finds implicit template class specialization") TEST_CASE("cxx parser finds class inheritance from implicit template class specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3413,7 +3412,7 @@ TEST_CASE("cxx parser finds class inheritance from implicit template class speci TEST_CASE("record base class of implicit template class specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template\n" "class VectorBase {}; \n" "\n" @@ -3430,7 +3429,7 @@ TEST_CASE("record base class of implicit template class specialization") TEST_CASE("cxx parser finds template class specialization with template argument") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3453,7 +3452,7 @@ TEST_CASE( "cxx parser finds correct order of template arguments for explicit class template " "specialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class vector { };\n" "template\n" @@ -3467,7 +3466,7 @@ TEST_CASE( "cxx parser replaces dependent template arguments of explicit template specialization with " "name of base template") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A {};\n" "template \n" @@ -3483,7 +3482,7 @@ TEST_CASE( "cxx parser replaces unknown template arguments of explicit template specialization with depth " "and position index") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class foo {\n" " template \n" @@ -3498,7 +3497,7 @@ TEST_CASE( TEST_CASE("cxx parser finds template class constructor usage of field") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3512,7 +3511,7 @@ TEST_CASE("cxx parser finds template class constructor usage of field") TEST_CASE("cxx parser finds correct method return type of template class in declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3528,7 +3527,7 @@ TEST_CASE("cxx parser finds correct method return type of template class in decl TEST_CASE("cxx parser finds type template default argument type of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3542,7 +3541,7 @@ TEST_CASE( "cxx parser finds no default argument type for non type bool template parameter of template " "class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{\n" @@ -3554,7 +3553,7 @@ TEST_CASE( TEST_CASE("cxx parser finds template template default argument type of template class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -3568,7 +3567,7 @@ TEST_CASE("cxx parser finds template template default argument type of template TEST_CASE("cxx parser finds implicit instantiation of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T test(T a)\n" "{\n" @@ -3586,7 +3585,7 @@ TEST_CASE("cxx parser finds implicit instantiation of template function") TEST_CASE("cxx parser finds explicit specialization of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T test(T a)\n" "{\n" @@ -3607,7 +3606,7 @@ TEST_CASE( "cxx parser finds explicit type template argument of explicit instantiation of template " "function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "void test()\n" "{\n" @@ -3624,7 +3623,7 @@ TEST_CASE( TEST_CASE("cxx parser finds explicit type template argument of function call in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "void test(){}\n" "\n" @@ -3641,7 +3640,7 @@ TEST_CASE("cxx parser finds explicit type template argument of function call in TEST_CASE( "cxx parser finds no explicit non type int template argument of function call in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" // use of "int" "void test(){}\n" // 2x use of "void" "\n" @@ -3656,7 +3655,7 @@ TEST_CASE( TEST_CASE("cxx parser finds explicit template template argument of function call in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A {};\n" "template class T>\n" @@ -3673,7 +3672,7 @@ TEST_CASE("cxx parser finds explicit template template argument of function call TEST_CASE("cxx parser finds no implicit type template argument of function call in function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "void test(T data){}\n" // 2x use of "void" + 1x use of "int" "\n" @@ -3688,7 +3687,7 @@ TEST_CASE("cxx parser finds no implicit type template argument of function call TEST_CASE("cxx parser finds explicit type template argument of function call in var decl") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T test(){ return 1; }\n" "\n" @@ -3703,7 +3702,7 @@ TEST_CASE("cxx parser finds explicit type template argument of function call in TEST_CASE("cxx parser finds no implicit type template argument of function call in var decl") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "T test(T i){ return i; }\n" // 2x use of "int" "\n" @@ -3717,7 +3716,7 @@ TEST_CASE("cxx parser finds no implicit type template argument of function call TEST_CASE("cxx parser finds type template default argument type of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "void test()\n" "{\n" @@ -3737,7 +3736,7 @@ TEST_CASE( "cxx parser does not find default argument type for non type bool template parameter of " "template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "void test()\n" "{\n" @@ -3749,7 +3748,7 @@ TEST_CASE( TEST_CASE("cxx parser finds template template default argument type of template function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class A\n" "{};\n" @@ -3765,7 +3764,7 @@ TEST_CASE("cxx parser finds template template default argument type of template TEST_CASE("cxx parser finds lambda calling a function") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void func() {}\n" "void lambdaCaller()\n" "{\n" @@ -3781,7 +3780,7 @@ TEST_CASE("cxx parser finds lambda calling a function") TEST_CASE("cxx parser finds local variable in lambda capture") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void lambdaWrapper()\n" "{\n" " int x = 2;\n" @@ -3794,7 +3793,7 @@ TEST_CASE("cxx parser finds local variable in lambda capture") TEST_CASE("cxx parser finds usage of local variable in microsoft inline assembly statement") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void foo()\n" "{\n" " int x = 2;\n" @@ -3815,7 +3814,7 @@ TEST_CASE("cxx parser finds usage of local variable in microsoft inline assembly TEST_CASE("cxx parser finds template argument of unresolved lookup expression") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "void a()\n" "{\n" @@ -3836,7 +3835,7 @@ TEST_CASE("cxx parser finds template argument of unresolved lookup expression") TEST_CASE("cxx parser finds correct location of explicit constructor defined in namespace") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace n\n" "{\n" " class App\n" @@ -3858,7 +3857,7 @@ TEST_CASE( "cxx parser finds macro argument location for field definition with name passed as argument to " "macro") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define DEF_INT_FIELD(name) int name;\n" "class A {\n" " DEF_INT_FIELD(m_value)\n" @@ -3872,7 +3871,7 @@ TEST_CASE( "cxx parser finds macro usage location for field definition with name partially passed as " "argument to macro") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define DEF_INT_FIELD(name) int m_##name;\n" "class A {\n" " DEF_INT_FIELD(value)\n" @@ -3887,7 +3886,7 @@ TEST_CASE( "cxx parser finds macro argument location for function call in code passed as argument to " "macro") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define DEF_INT_FIELD(name, init) int name = init;\n" "int foo() { return 5; }\n" "class A {\n" @@ -3901,7 +3900,7 @@ TEST_CASE( TEST_CASE("cxx parser finds macro usage location for function call in code of macro body") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int foo() { return 5; }\n" "#define DEF_INT_FIELD(name) int name = foo();\n" "class A {\n" @@ -3915,7 +3914,7 @@ TEST_CASE("cxx parser finds macro usage location for function call in code of ma TEST_CASE("cxx parser finds type template argument of static cast expression") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int main()\n" "{\n" " return static_cast(4.0f);" @@ -3927,7 +3926,7 @@ TEST_CASE("cxx parser finds type template argument of static cast expression") TEST_CASE("cxx parser finds implicit constructor call in initialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" "};\n" @@ -3958,42 +3957,42 @@ TEST_CASE("cxx parser parses multiple files") std::vector { L"--target=x86_64-pc-windows-msvc", L"-std=c++1z", sourceFilePath.wstr()}); - TestIntermediateStorage storage; + std::shared_ptr storage = std::make_shared(); CxxParser parser( - std::make_shared(&storage), + std::make_shared(storage.get()), std::make_shared(), std::make_shared()); parser.buildIndex(indexerCommand); - storage.generateStringLists(); + std::shared_ptr testStorage = TestStorage::create(storage); - REQUIRE(storage.errors.size() == 0); + REQUIRE(testStorage->errors.size() == 0); - REQUIRE(storage.typedefs.size() == 1); - REQUIRE(storage.classes.size() == 4); - REQUIRE(storage.enums.size() == 1); - REQUIRE(storage.enumConstants.size() == 2); - REQUIRE(storage.functions.size() == 2); - REQUIRE(storage.fields.size() == 4); - REQUIRE(storage.globalVariables.size() == 2); - REQUIRE(storage.methods.size() == 15); - REQUIRE(storage.namespaces.size() == 2); - REQUIRE(storage.structs.size() == 1); + REQUIRE(testStorage->typedefs.size() == 1); + REQUIRE(testStorage->classes.size() == 4); + REQUIRE(testStorage->enums.size() == 1); + REQUIRE(testStorage->enumConstants.size() == 2); + REQUIRE(testStorage->functions.size() == 2); + REQUIRE(testStorage->fields.size() == 4); + REQUIRE(testStorage->globalVariables.size() == 2); + REQUIRE(testStorage->methods.size() == 15); + REQUIRE(testStorage->namespaces.size() == 2); + REQUIRE(testStorage->structs.size() == 1); - REQUIRE(storage.inheritances.size() == 1); - REQUIRE(storage.calls.size() == 3); - REQUIRE(storage.usages.size() == 3); - REQUIRE(storage.typeUses.size() == 16); + REQUIRE(testStorage->inheritances.size() == 1); + REQUIRE(testStorage->calls.size() == 3); + REQUIRE(testStorage->usages.size() == 3); + REQUIRE(testStorage->typeUses.size() == 16); - REQUIRE(storage.files.size() == 2); - REQUIRE(storage.includes.size() == 1); + REQUIRE(testStorage->files.size() == 2); + REQUIRE(testStorage->includes.size() == 1); } TEST_CASE("cxx parser finds braces of class decl") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" "};\n"); @@ -4006,7 +4005,7 @@ TEST_CASE("cxx parser finds braces of class decl") TEST_CASE("cxx parser finds braces of namespace decl") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "namespace n\n" "{\n" "}\n"); @@ -4019,7 +4018,7 @@ TEST_CASE("cxx parser finds braces of namespace decl") TEST_CASE("cxx parser finds braces of function decl") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int main()\n" "{\n" "}\n"); @@ -4032,7 +4031,7 @@ TEST_CASE("cxx parser finds braces of function decl") TEST_CASE("cxx parser finds braces of method decl") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class App\n" "{\n" "public:\n" @@ -4047,7 +4046,7 @@ TEST_CASE("cxx parser finds braces of method decl") TEST_CASE("cxx parser finds braces of init list") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "int a = 0;\n" "int b[] = {a};\n"); @@ -4059,7 +4058,7 @@ TEST_CASE("cxx parser finds braces of init list") TEST_CASE("cxx parser finds braces of lambda") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void lambdaCaller()\n" "{\n" " [](){}();\n" @@ -4073,7 +4072,7 @@ TEST_CASE("cxx parser finds braces of lambda") TEST_CASE("cxx parser finds braces of asm stmt") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "void foo()\n" "{\n" " __asm\n" @@ -4091,7 +4090,7 @@ TEST_CASE("cxx parser finds braces of asm stmt") TEST_CASE("cxx parser finds no duplicate braces of template class and method decl") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template \n" "class App\n" "{\n" @@ -4110,7 +4109,7 @@ TEST_CASE("cxx parser finds no duplicate braces of template class and method dec TEST_CASE("cxx parser finds braces with closing bracket in macro") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "\n" "namespace constants\n" "{\n" @@ -4151,7 +4150,7 @@ TEST_CASE("cxx parser finds braces with closing bracket in macro") TEST_CASE("cxx parser finds correct signature location of constructor with initializer list") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class A\n" "{\n" " A(const int& foo) : m_foo(foo)\n" @@ -4167,7 +4166,7 @@ TEST_CASE("cxx parser finds correct signature location of constructor with initi TEST_CASE("cxx parser catches error") { - std::shared_ptr client = parseCode("int a = b;\n"); + std::shared_ptr client = parseCode("int a = b;\n"); REQUIRE(utility::containsElement( client->errors, L"use of undeclared identifier \'b\' <1:9 1:9>")); @@ -4175,8 +4174,7 @@ TEST_CASE("cxx parser catches error") TEST_CASE("cxx parser catches error in force include") { - std::shared_ptr client = parseCode( - "void foo() {} \n", {L"-include nothing"}); + std::shared_ptr client = parseCode("void foo() {} \n", {L"-include nothing"}); REQUIRE(utility::containsElement( client->errors, L"' nothing' file not found <1:1 1:1>")); @@ -4184,7 +4182,7 @@ TEST_CASE("cxx parser catches error in force include") TEST_CASE("cxx parser finds correct error location after line directive") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#line 55 \"foo.hpp\"\n" "void foo()\n"); @@ -4194,7 +4192,7 @@ TEST_CASE("cxx parser finds correct error location after line directive") TEST_CASE("cxx parser catches error in macro expansion") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "#define MACRO_WITH_NONEXISTING_PATH \"this_path_does_not_exist.txt\"\n" "#include MACRO_WITH_NONEXISTING_PATH\n"); @@ -4204,14 +4202,14 @@ TEST_CASE("cxx parser catches error in macro expansion") TEST_CASE("cxx parser finds location of line comment") { - std::shared_ptr client = parseCode("// this is a line comment\n"); + std::shared_ptr client = parseCode("// this is a line comment\n"); REQUIRE(utility::containsElement(client->comments, L"comment <1:1 1:26>")); } TEST_CASE("cxx parser finds location of block comment") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "/* this is a\n" "block comment */\n"); @@ -4220,7 +4218,7 @@ TEST_CASE("cxx parser finds location of block comment") void _test_TEST() { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "template class> class T>\n" "class A {\n" "T<>\n" diff --git a/src/test/JavaIndexSampleProjectsTestSuite.cpp b/src/test/JavaIndexSampleProjectsTestSuite.cpp index 5b9e0aaa..d03e40b3 100644 --- a/src/test/JavaIndexSampleProjectsTestSuite.cpp +++ b/src/test/JavaIndexSampleProjectsTestSuite.cpp @@ -13,7 +13,7 @@ # include "JavaEnvironmentFactory.h" # include "JavaParser.h" # include "ParserClientImpl.h" -# include "TestIntermediateStorage.h" +# include "TestStorage.h" # include "TextAccess.h" # include "TimeStamp.h" # include "utility.h" @@ -66,9 +66,9 @@ std::shared_ptr parseCode( const FilePath& projectDataSrcRoot, const std::vector& classpath) { - TestIntermediateStorage storage; + std::shared_ptr storage = std::make_shared(); JavaParser parser( - std::make_shared(&storage), std::make_shared()); + std::make_shared(storage.get()), std::make_shared()); std::shared_ptr command = std::make_shared( sourceFilePath, L"12", classpath); @@ -76,9 +76,7 @@ std::shared_ptr parseCode( parser.buildIndex(command); duration += TimeStamp::now().deltaMS(startTime); - storage.generateStringLists(); - - return TextAccess::createFromLines(storage.m_lines); + return TextAccess::createFromLines(TestStorage::create(storage)->m_lines); } void processSourceFile( diff --git a/src/test/JavaParserTestSuite.cpp b/src/test/JavaParserTestSuite.cpp index 3346ed8c..39b1a16a 100644 --- a/src/test/JavaParserTestSuite.cpp +++ b/src/test/JavaParserTestSuite.cpp @@ -13,9 +13,9 @@ # include "utilityJava.h" # include "utilityPathDetection.h" -# include "TestIntermediateStorage.h" +# include "TestStorage.h" -# define REQUIRE_MESSAGE(msg, cond) \ +# define REQUIRE_MESSAGE(msg, cond) \ do \ { \ INFO(msg); \ @@ -55,18 +55,16 @@ std::string setupJavaEnvironmentFactory() return ""; } -std::shared_ptr parseCode(std::string code, bool logErrors = true) +std::shared_ptr parseCode(std::string code, bool logErrors = true) { setupJavaEnvironmentFactory(); - std::shared_ptr storage = std::make_shared(); + std::shared_ptr storage = std::make_shared(); JavaParser parser( std::make_shared(storage.get()), std::make_shared()); parser.buildIndex(FilePath(L"input.java"), TextAccess::createFromString(code)); - storage->generateStringLists(); - - return storage; + return TestStorage::create(storage); } } // namespace @@ -100,14 +98,14 @@ TEST_CASE("java parser can setup environment factory") TEST_CASE("java parser finds package declaration") { - std::shared_ptr client = parseCode("package foo;\n"); + std::shared_ptr client = parseCode("package foo;\n"); REQUIRE(utility::containsElement(client->packages, L"foo <1:9 1:11>")); } TEST_CASE("java parser finds anotation declaration in defaut package") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public @interface SampleAnnotation\n" "{\n" "}\n"); @@ -118,7 +116,7 @@ TEST_CASE("java parser finds anotation declaration in defaut package") TEST_CASE("java parser finds anotation member declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public @interface SampleAnnotation\n" "{\n" " public int value() default 0;\n" @@ -130,7 +128,7 @@ TEST_CASE("java parser finds anotation member declaration") TEST_CASE("java parser finds class declaration in defaut package") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" "}\n"); @@ -141,7 +139,7 @@ TEST_CASE("java parser finds class declaration in defaut package") TEST_CASE("java parser finds interface declaration in defaut package") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public interface A\n" "{\n" "}\n"); @@ -152,7 +150,7 @@ TEST_CASE("java parser finds interface declaration in defaut package") TEST_CASE("java parser finds class declaration in named package") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -164,7 +162,7 @@ TEST_CASE("java parser finds class declaration in named package") TEST_CASE("java parser finds class declaration in nested named package") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo.bar;\n" "public class A\n" "{\n" @@ -176,7 +174,7 @@ TEST_CASE("java parser finds class declaration in nested named package") TEST_CASE("java parser finds enum declaration in named package") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public enum A\n" "{\n" @@ -188,7 +186,7 @@ TEST_CASE("java parser finds enum declaration in named package") TEST_CASE("java parser finds enum constant declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public enum A\n" "{\n" @@ -201,7 +199,7 @@ TEST_CASE("java parser finds enum constant declaration") TEST_CASE("java parser finds constructor declaration without parameters") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -216,7 +214,7 @@ TEST_CASE("java parser finds constructor declaration without parameters") TEST_CASE("java parser finds method declaration with custom type in signature") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -231,7 +229,7 @@ TEST_CASE("java parser finds method declaration with custom type in signature") TEST_CASE("java parser finds anonymous class declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -248,7 +246,7 @@ TEST_CASE("java parser finds anonymous class declaration") TEST_CASE("java parser finds method declaration in anonymous class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -272,7 +270,7 @@ TEST_CASE("java parser finds method declaration in anonymous class") TEST_CASE("java parser finds method declaration with static keyword in signature") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -287,7 +285,7 @@ TEST_CASE("java parser finds method declaration with static keyword in signature TEST_CASE("java parser finds field declaration with initial assignment") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -300,7 +298,7 @@ TEST_CASE("java parser finds field declaration with initial assignment") TEST_CASE("java parser finds public access specifier in field declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -313,7 +311,7 @@ TEST_CASE("java parser finds public access specifier in field declaration") TEST_CASE("java parser finds protected access specifier in field declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -326,7 +324,7 @@ TEST_CASE("java parser finds protected access specifier in field declaration") TEST_CASE("java parser finds private access specifier in field declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -339,7 +337,7 @@ TEST_CASE("java parser finds private access specifier in field declaration") TEST_CASE("java parser finds static keyword in field declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -352,7 +350,7 @@ TEST_CASE("java parser finds static keyword in field declaration") TEST_CASE("java parser finds declaration of method parameter") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -367,7 +365,7 @@ TEST_CASE("java parser finds declaration of method parameter") TEST_CASE("java parser finds declaration of local variable") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -382,7 +380,7 @@ TEST_CASE("java parser finds declaration of local variable") TEST_CASE("java parser finds declaration of type parameter of class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A \n" "{\n" "}\n"); @@ -392,7 +390,7 @@ TEST_CASE("java parser finds declaration of type parameter of class") TEST_CASE("java parser finds declaration of type parameter of method") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public void foo()\n" @@ -406,7 +404,7 @@ TEST_CASE("java parser finds declaration of type parameter of method") TEST_CASE("java parser finds field of interface to be implicitly static") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public interface A\n" "{\n" " int b = 5;\n" @@ -418,7 +416,7 @@ TEST_CASE("java parser finds field of interface to be implicitly static") TEST_CASE("java parser finds line comment") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "// this is a line comment\n" "package foo;\n"); @@ -427,7 +425,7 @@ TEST_CASE("java parser finds line comment") TEST_CASE("java parser finds block comment") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "/* this is a line comment*/\n" "package foo;\n"); @@ -436,7 +434,7 @@ TEST_CASE("java parser finds block comment") TEST_CASE("java parser finds missing semicolon as parse error") { - std::shared_ptr client = parseCode("package foo\n"); + std::shared_ptr client = parseCode("package foo\n"); REQUIRE(utility::containsElement( client->errors, L"Syntax error on token \"foo\", ; expected after this token <1:9 1:9>")); @@ -444,7 +442,7 @@ TEST_CASE("java parser finds missing semicolon as parse error") TEST_CASE("java parser finds missing import as error") { - std::shared_ptr client = parseCode("import foo;\n"); + std::shared_ptr client = parseCode("import foo;\n"); REQUIRE(utility::containsElement( client->errors, L"The import foo cannot be resolved <1:8 1:8>")); @@ -456,7 +454,7 @@ TEST_CASE("java parser finds missing import as error") TEST_CASE("java parser finds class declaration nested in class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo.bar;\n" "public class A\n" "{\n" @@ -471,7 +469,7 @@ TEST_CASE("java parser finds class declaration nested in class") TEST_CASE("java parser finds class declaration nested in method") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo.bar;\n" "public class A\n" "{\n" @@ -493,7 +491,7 @@ TEST_CASE("java parser finds class declaration nested in method") TEST_CASE("java parser finds no qualifier location of standalone this expression") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -508,14 +506,14 @@ TEST_CASE("java parser finds no qualifier location of standalone this expression TEST_CASE("java parser finds qualifier location of import declaration") { - std::shared_ptr client = parseCode("import foo.bar;\n"); + std::shared_ptr client = parseCode("import foo.bar;\n"); REQUIRE(utility::containsElement(client->qualifiers, L"foo <1:8 1:10>")); } TEST_CASE("java parser finds qualifier location of simple type") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo.bar;\n" "public class A\n" "{\n" @@ -531,7 +529,7 @@ TEST_CASE("java parser finds qualifier location of simple type") TEST_CASE("java parser finds qualifier location of field access") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -548,7 +546,7 @@ TEST_CASE("java parser finds qualifier location of field access") TEST_CASE("java parser finds qualifier location of super field access") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "class A\n" "{\n" @@ -570,7 +568,7 @@ TEST_CASE("java parser finds qualifier location of super field access") TEST_CASE("java parser finds qualifier location of this expression") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "class A\n" "{\n" @@ -587,7 +585,7 @@ TEST_CASE("java parser finds qualifier location of this expression") TEST_CASE("java parser finds qualifier location of method invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -604,7 +602,7 @@ TEST_CASE("java parser finds qualifier location of method invocation") TEST_CASE("java parser finds qualifier location of method invocation on this") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -619,7 +617,7 @@ TEST_CASE("java parser finds qualifier location of method invocation on this") TEST_CASE("java parser finds qualifier location of super method invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -650,7 +648,7 @@ TEST_CASE("java parser finds qualifier location of super method invocation") TEST_CASE("java parser finds qualifier location of creation reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public interface Functor\n" @@ -675,7 +673,7 @@ TEST_CASE("java parser finds qualifier location of creation reference") TEST_CASE("java parser finds qualifier location of expression method reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public interface Functor\n" @@ -701,7 +699,7 @@ TEST_CASE("java parser finds qualifier location of expression method reference") TEST_CASE("java parser finds qualifier location of super method reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A {\n" " public interface Functor {\n" " public void doSomething();\n" @@ -724,7 +722,7 @@ TEST_CASE("java parser finds qualifier location of super method reference") TEST_CASE("java parser finds qualifier location of class instance creation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A {\n" " public interface Functor {\n" " public void doSomething();\n" @@ -746,7 +744,7 @@ TEST_CASE("java parser finds qualifier location of class instance creation") TEST_CASE("java parser finds usage of marker annotation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public @interface SampleAnnotation\n" "{\n" "}\n" @@ -762,7 +760,7 @@ TEST_CASE("java parser finds usage of marker annotation") TEST_CASE("java parser finds usage of single member annotation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public @interface SampleAnnotation\n" "{\n" " public int value() default 0;\n" @@ -779,7 +777,7 @@ TEST_CASE("java parser finds usage of single member annotation") TEST_CASE("java parser finds usage of normal annotation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public @interface SampleAnnotation\n" "{\n" " public int a() default 0;\n" @@ -797,7 +795,7 @@ TEST_CASE("java parser finds usage of normal annotation") TEST_CASE("java parser finds usage of normal annotation member in initialization") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public @interface SampleAnnotation\n" "{\n" " public int a() default 0;\n" @@ -815,7 +813,7 @@ TEST_CASE("java parser finds usage of normal annotation member in initialization TEST_CASE("java parser finds inheritance using extends keyword") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -831,7 +829,7 @@ TEST_CASE("java parser finds inheritance using extends keyword") TEST_CASE("java parser finds inheritance using implements keyword") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -847,7 +845,7 @@ TEST_CASE("java parser finds inheritance using implements keyword") TEST_CASE("java parser finds inheritance of anonymous class declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public interface Base\n" @@ -868,7 +866,7 @@ TEST_CASE("java parser finds inheritance of anonymous class declaration") TEST_CASE("java parser finds usage of string for var type") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public void foo(){\n" @@ -882,7 +880,7 @@ TEST_CASE("java parser finds usage of string for var type") TEST_CASE("java parser finds type parameter in signature of method") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A \n" "{\n" " public A foo(A a){\n" @@ -898,7 +896,7 @@ TEST_CASE("java parser finds type parameter in signature of method") TEST_CASE("parser finds usage of type defined in base class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class Foo {\n" " public class Base {\n" " public class X {\n" @@ -915,7 +913,7 @@ TEST_CASE("parser finds usage of type defined in base class") TEST_CASE("java parser finds correct location of qualified type usage") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public class B\n" @@ -933,7 +931,7 @@ TEST_CASE("java parser finds correct location of qualified type usage") TEST_CASE("java parser finds type argument of parameterized type") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A {\n" " T t;\n" "}\n" @@ -952,7 +950,7 @@ TEST_CASE("java parser finds type argument of parameterized type") TEST_CASE("java parser finds type argument of method invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -973,7 +971,7 @@ TEST_CASE("java parser finds type argument of method invocation") TEST_CASE("java parser finds type argument of super method invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -1002,7 +1000,7 @@ TEST_CASE("java parser finds type argument of super method invocation") TEST_CASE("java parser finds type argument of constructor invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class Bar\n" "{\n" @@ -1025,7 +1023,7 @@ TEST_CASE("java parser finds type argument of constructor invocation") TEST_CASE("java parser finds type argument of super constructor invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public class Base\n" @@ -1050,7 +1048,7 @@ TEST_CASE("java parser finds type argument of super constructor invocation") TEST_CASE("java parser finds type argument of creation reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public interface Functor\n" @@ -1077,7 +1075,7 @@ TEST_CASE("java parser finds type argument of creation reference") TEST_CASE("java parser finds type argument of expression method reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public interface Functor\n" @@ -1104,7 +1102,7 @@ TEST_CASE("java parser finds type argument of expression method reference") TEST_CASE("java parser finds type argument of super method reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A {\n" " public interface Functor {\n" " public void doSomething();\n" @@ -1131,7 +1129,7 @@ TEST_CASE("java parser finds type argument of super method reference") TEST_CASE("java parser finds type argument of type method reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A {\n" " \n" " void foo() {\n" @@ -1147,7 +1145,7 @@ TEST_CASE("java parser finds type argument of type method reference") TEST_CASE("java parser finds type argument of class instance creation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A {\n" " public interface Functor {\n" " public void doSomething();\n" @@ -1171,7 +1169,7 @@ TEST_CASE("java parser finds type argument of class instance creation") TEST_CASE("java parser finds super method invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -1197,7 +1195,7 @@ TEST_CASE("java parser finds super method invocation") TEST_CASE("java parser finds constructor invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class Bar\n" "{\n" @@ -1217,7 +1215,7 @@ TEST_CASE("java parser finds constructor invocation") TEST_CASE("java parser finds super constructor invocation") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public class Base\n" @@ -1239,7 +1237,7 @@ TEST_CASE("java parser finds super constructor invocation") TEST_CASE("java parser finds invocation of method of anonymous class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Main {\n" " public interface Interfaze {\n" " public void foo();\n" @@ -1263,7 +1261,7 @@ TEST_CASE("java parser finds invocation of method of anonymous class") TEST_CASE("java parser finds overridden method with same signature") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Main {\n" " public interface Interfaze {\n" " public void foo(int t);\n" @@ -1281,7 +1279,7 @@ TEST_CASE("java parser finds overridden method with same signature") TEST_CASE("java parser finds overridden method with generic signature") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "class Main {\n" " public interface Interfaze {\n" " public void foo(T t);\n" @@ -1301,7 +1299,7 @@ TEST_CASE("java parser finds overridden method with generic signature") TEST_CASE("java parser finds method usage for creation reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public interface Functor\n" @@ -1325,7 +1323,7 @@ TEST_CASE("java parser finds method usage for creation reference") TEST_CASE("java parser finds method usage for expression method reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public interface Functor\n" @@ -1352,7 +1350,7 @@ TEST_CASE("java parser finds method usage for expression method reference") TEST_CASE("java parser finds method usage for super method reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A {\n" " public interface Functor {\n" " public void doSomething();\n" @@ -1376,7 +1374,7 @@ TEST_CASE("java parser finds method usage for super method reference") TEST_CASE("java parser finds no method usage for type method reference") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A {\n" " void foo() {\n" " Functor method = int []::clone;\n" @@ -1389,7 +1387,7 @@ TEST_CASE("java parser finds no method usage for type method reference") TEST_CASE("java parser finds no usage of field within that fields declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -1401,7 +1399,7 @@ TEST_CASE("java parser finds no usage of field within that fields declaration") TEST_CASE("java parser finds no usage of enum constant within that enum constants declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public enum X\n" "{\n" @@ -1413,7 +1411,7 @@ TEST_CASE("java parser finds no usage of enum constant within that enum constant TEST_CASE("java parser finds usage of field with same name as method parameter") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -1430,7 +1428,7 @@ TEST_CASE("java parser finds usage of field with same name as method parameter") TEST_CASE("java parser does not confuse method name with field name") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class X\n" "{\n" @@ -1447,7 +1445,7 @@ TEST_CASE("java parser does not confuse method name with field name") TEST_CASE("java parser finds assignment of method parameter") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -1462,7 +1460,7 @@ TEST_CASE("java parser finds assignment of method parameter") TEST_CASE("java parser finds assignment of local variable") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "public class A\n" "{\n" @@ -1478,7 +1476,7 @@ TEST_CASE("java parser finds assignment of local variable") TEST_CASE("java parser finds scope of class declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" "}\n"); @@ -1491,7 +1489,7 @@ TEST_CASE("java parser finds scope of class declaration") TEST_CASE("java parser finds scope of enum declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public enum A\n" "{\n" "}\n"); @@ -1504,7 +1502,7 @@ TEST_CASE("java parser finds scope of enum declaration") TEST_CASE("java parser finds scope of constructor declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public A()\n" @@ -1520,7 +1518,7 @@ TEST_CASE("java parser finds scope of constructor declaration") TEST_CASE("java parser finds scope of method declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public void a()\n" @@ -1536,7 +1534,7 @@ TEST_CASE("java parser finds scope of method declaration") TEST_CASE("java parser finds scope of switch statement") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public void a()\n" @@ -1557,7 +1555,7 @@ TEST_CASE("java parser finds scope of switch statement") TEST_CASE("java parser finds scope of block statement") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public void a()\n" @@ -1575,7 +1573,7 @@ TEST_CASE("java parser finds scope of block statement") TEST_CASE("java parser finds scope of array initialization list") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " private int[] array = {1, 2};\n" @@ -1589,7 +1587,7 @@ TEST_CASE("java parser finds scope of array initialization list") TEST_CASE("java parser finds scope of anonymous class declaration") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public interface Base\n" @@ -1612,7 +1610,7 @@ TEST_CASE("java parser finds scope of anonymous class declaration") TEST_CASE("java parser finds usage of type parameter of class") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A \n" "{\n" " T t;\n" @@ -1624,7 +1622,7 @@ TEST_CASE("java parser finds usage of type parameter of class") TEST_CASE("java parser finds usage of type parameter of method") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A\n" "{\n" " public void foo(T t){};\n" @@ -1636,7 +1634,7 @@ TEST_CASE("java parser finds usage of type parameter of method") TEST_CASE("java parser finds correct location of generic type usage") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A \n" "{\n" " A t;\n" @@ -1648,7 +1646,7 @@ TEST_CASE("java parser finds correct location of generic type usage") TEST_CASE("java parser finds bound type of type parameter") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "public class A \n" "{\n" "}\n"); @@ -1659,7 +1657,7 @@ TEST_CASE("java parser finds bound type of type parameter") TEST_CASE("java parsersupports java 12 switch expression") { - std::shared_ptr client = parseCode( + std::shared_ptr client = parseCode( "package foo;\n" "\n" "public class Foo {\n" @@ -1677,7 +1675,8 @@ TEST_CASE("java parsersupports java 12 switch expression") " }\n" "}\n"); - REQUIRE(utility::containsElement(client->usages, L"void foo.Foo.foo() -> foo.Foo.FruitType.PEAR <12:9 12:12>")); + REQUIRE(utility::containsElement( + client->usages, L"void foo.Foo.foo() -> foo.Foo.FruitType.PEAR <12:9 12:12>")); } diff --git a/src/test/PythonIndexerTestSuite.cpp b/src/test/PythonIndexerTestSuite.cpp new file mode 100644 index 00000000..65cd1fe0 --- /dev/null +++ b/src/test/PythonIndexerTestSuite.cpp @@ -0,0 +1,122 @@ +#include "catch.hpp" + +#include "language_packages.h" + +#if BUILD_PYTHON_LANGUAGE_PACKAGE + +# include +# include + +# include "FileSystem.h" +# include "IndexerCommandCustom.h" +# include "PersistentStorage.h" +# include "ResourcePaths.h" +# include "SqliteIndexStorage.h" +# include "TaskExecuteCustomCommands.h" +# include "TestStorage.h" +# include "utilityApp.h" + +namespace +{ +void deleteAllContents(const FilePath& tempPath) +{ + if (tempPath.recheckExists()) + { + for (const FilePath& path: FileSystem::getFilePathsFromDirectory(tempPath)) + { + FileSystem::remove(path); + } + } +} + +std::shared_ptr parseCode(std::string code) +{ + const FilePath rootPath = FilePath(L"data/PythonIndexerTestSuite/temp/").makeAbsolute(); + + if (!rootPath.exists()) + { + FileSystem::createDirectory(rootPath); + } + + deleteAllContents(rootPath); + + const FilePath sourceFilePath = rootPath.getConcatenated(L"test.py"); + const FilePath tempDbPath = rootPath.getConcatenated(L"temp.srctrldb"); + + { + std::ofstream codeFile; + codeFile.open(sourceFilePath.str()); + codeFile << code; + codeFile.close(); + } + + { + const std::set indexedPaths = {rootPath}; + const std::set excludeFilters; + const std::set includeFilters; + const FilePath workingDirectory(L"."); + + std::wstring args = L""; + args += L" --source-file-path=%{SOURCE_FILE_PATH}"; + args += L" --database-file-path=%{DATABASE_FILE_PATH}"; + args += L" --shallow"; + + std::shared_ptr indexerCommand = std::make_shared( + INDEXER_COMMAND_PYTHON, + L"\"" + + FilePath("../app").getConcatenated(ResourcePaths::getPythonPath()).makeAbsolute().wstr() + + L"SourcetrailPythonIndexer\" index" + args, + rootPath, + tempDbPath, + std::to_wstring(SqliteIndexStorage::getStorageVersion()), + sourceFilePath, + true); + + std::wstring errorMessage; + const int result = utility::executeProcessAndGetExitCode( + indexerCommand->getCustomCommand(), {}, rootPath, -1, true, &errorMessage); + + REQUIRE(result == 0); + REQUIRE(errorMessage.empty()); + } + + std::shared_ptr testStorage; + { + std::shared_ptr persistentStorage = std::make_shared( + tempDbPath, FilePath()); + persistentStorage->setup(); + persistentStorage->buildCaches(); + TaskExecuteCustomCommands::runPythonPostProcessing(*(persistentStorage.get())); + + testStorage = TestStorage::create(persistentStorage); + } + + deleteAllContents(rootPath); + return testStorage; +} +} // namespace + +TEST_CASE("python post processing regards class name in call context when adding ambiguous edges") +{ + std::shared_ptr storage = parseCode( + "class A:\n" + " def init(self):\n" + " pass\n" + "\n" + "class A1(A):\n" + " def init(self):\n" + " A.init()\n" + "\n" + "class B:\n" + " def init(self):\n" + " pass\n"); + + REQUIRE(storage->calls.size() == 1); + REQUIRE(utility::containsElement(storage->calls, L"test.A1.init -> test.A.init")); + + REQUIRE( + !utility::containsElement(storage->calls, L"test.A1.init -> test.A1.init")); + REQUIRE(!utility::containsElement(storage->calls, L"test.A1.init -> test.B.init")); +} + +#endif // BUILD_PYTHON_LANGUAGE_PACKAGE diff --git a/src/test/helper/TestIntermediateStorage.h b/src/test/helper/TestStorage.h similarity index 83% rename from src/test/helper/TestIntermediateStorage.h rename to src/test/helper/TestStorage.h index 518c364d..edcbaa27 100644 --- a/src/test/helper/TestIntermediateStorage.h +++ b/src/test/helper/TestStorage.h @@ -1,41 +1,43 @@ -#ifndef TEST_INTERMEDIATE_STORAGE_H -#define TEST_INTERMEDIATE_STORAGE_H +#ifndef TEST_STORAGE_H +#define TEST_STORAGE_H #include #include "AccessKind.h" #include "Edge.h" #include "FilePath.h" -#include "IntermediateStorage.h" #include "LocationType.h" #include "NameHierarchy.h" #include "NodeType.h" +#include "Storage.h" #include "utilityString.h" -class TestIntermediateStorage: public IntermediateStorage +class TestStorage { public: - void generateStringLists() + static std::shared_ptr create(std::shared_ptr storage) { + std::shared_ptr testStorage = std::make_shared(); + std::map filePathMap; - for (const StorageFile& file: getStorageFiles()) + for (const StorageFile& file: storage->getStorageFiles()) { filePathMap.emplace(file.id, FilePath(file.filePath)); - files.emplace(file.filePath); + testStorage->files.emplace(file.filePath); - addLine( + testStorage->addLine( L"FILE: " + FilePath(file.filePath).fileName() + (file.indexed ? L"" : L" non-indexed")); } std::map accessMap; - for (const StorageComponentAccess& access: getComponentAccesses()) + for (const StorageComponentAccess& access: storage->getComponentAccesses()) { accessMap.emplace(access.nodeId, access); } std::multimap occurrenceMap; - for (const StorageOccurrence& occurence: getStorageOccurrences()) + for (const StorageOccurrence& occurence: storage->getStorageOccurrences()) { occurrenceMap.emplace(occurence.sourceLocationId, occurence.elementId); } @@ -47,7 +49,7 @@ public: std::multimap qualifierLocationMap; std::multimap errorLocationMap; std::vector commentLocations; - for (const StorageSourceLocation& location: getStorageSourceLocations()) + for (const StorageSourceLocation& location: storage->getStorageSourceLocations()) { std::vector elementIds; for (auto it = occurrenceMap.find(location.id); @@ -113,7 +115,7 @@ public: std::map nodesMap; std::set fileIdMap; - for (const StorageNode& node: getStorageNodes()) + for (const StorageNode& node: storage->getStorageNodes()) { nodesMap.emplace(node.id, node); @@ -131,13 +133,13 @@ public: qualifierLocationIt++) { std::wstring locStr = addLocationStr(L"", qualifierLocationIt->second); - qualifiers.emplace_back(nameStr + locStr); - addLine( + testStorage->qualifiers.emplace_back(nameStr + locStr); + testStorage->addLine( L"QUALIFIER: " + nameStr + addFileName(locStr, filePathMap[qualifierLocationIt->second.fileNodeId])); } - std::vector* bin = getBinForNodeType(node.type); + std::vector* bin = testStorage->getBinForNodeType(node.type); if (bin != nullptr) { auto accessIt = accessMap.find(node.id); @@ -176,7 +178,7 @@ public: std::wstring locStr = addLocationStr( locationStr, scopeLocationIt->second); bin->emplace_back(nameStr + locStr); - addLine( + testStorage->addLine( nodeTypeToString(node.type) + L": " + nameStr + addFileName(locStr, filePathMap[tokenLocationIt->second.fileNodeId])); added = true; @@ -186,7 +188,7 @@ public: if (!added) { bin->emplace_back(nameStr + locationStr); - addLine( + testStorage->addLine( nodeTypeToString(node.type) + L": " + nameStr + addFileName(locationStr, filePathMap[tokenLocationIt->second.fileNodeId])); added = true; @@ -196,12 +198,12 @@ public: if (!added) { bin->emplace_back(nameStr); - addLine(nodeTypeToString(node.type) + L": " + nameStr); + testStorage->addLine(nodeTypeToString(node.type) + L": " + nameStr); } } } - for (const StorageEdge& edge: getStorageEdges()) + for (const StorageEdge& edge: storage->getStorageEdges()) { auto targetIt = nodesMap.find(edge.targetNodeId); if (targetIt == nodesMap.end()) @@ -218,19 +220,21 @@ public: const StorageNode& target = targetIt->second; const StorageNode& source = sourceIt->second; - std::vector* bin = getBinForEdgeType(edge.type); + std::vector* bin = testStorage->getBinForEdgeType(edge.type); if (bin != nullptr) { std::wstring sourceName = NameHierarchy::deserialize(source.serializedName).getQualifiedNameWithSignature(); - if (fileIdMap.find(edge.sourceNodeId) != fileIdMap.end() && FilePath(sourceName).exists()) + if (fileIdMap.find(edge.sourceNodeId) != fileIdMap.end() && + FilePath(sourceName).exists()) { sourceName = FilePath(sourceName).fileName(); } std::wstring targetName = NameHierarchy::deserialize(target.serializedName).getQualifiedNameWithSignature(); - if (fileIdMap.find(edge.targetNodeId) != fileIdMap.end() && FilePath(targetName).exists()) + if (fileIdMap.find(edge.targetNodeId) != fileIdMap.end() && + FilePath(targetName).exists()) { targetName = FilePath(targetName).fileName(); } @@ -244,7 +248,7 @@ public: { std::wstring locStr = addLocationStr(L"", tokenLocationIt->second); bin->emplace_back(nameStr + locStr); - addLine( + testStorage->addLine( edgeTypeToString(edge.type) + L": " + nameStr + addFileName(locStr, filePathMap[tokenLocationIt->second.fileNodeId])); added = true; @@ -253,12 +257,12 @@ public: if (!added) { bin->emplace_back(nameStr); - addLine(edgeTypeToString(edge.type) + L": " + nameStr); + testStorage->addLine(edgeTypeToString(edge.type) + L": " + nameStr); } } } - for (const StorageLocalSymbol& localSymbol: getStorageLocalSymbols()) + for (const StorageLocalSymbol& localSymbol: storage->getStorageLocalSymbols()) { bool added = false; for (auto localSymbolLocationIt = localSymbolLocationMap.find(localSymbol.id); @@ -267,8 +271,8 @@ public: localSymbolLocationIt++) { std::wstring locStr = addLocationStr(L"", localSymbolLocationIt->second); - localSymbols.emplace_back(localSymbol.name + locStr); - addLine( + testStorage->localSymbols.emplace_back(localSymbol.name + locStr); + testStorage->addLine( L"LOCAL_SYMBOL: " + localSymbol.name + addFileName(locStr, filePathMap[localSymbolLocationIt->second.fileNodeId])); added = true; @@ -276,31 +280,33 @@ public: if (!added) { - localSymbols.emplace_back(localSymbol.name); - addLine(L"LOCAL_SYMBOL: " + localSymbol.name); + testStorage->localSymbols.emplace_back(localSymbol.name); + testStorage->addLine(L"LOCAL_SYMBOL: " + localSymbol.name); } } for (const StorageSourceLocation& location: commentLocations) { std::wstring locStr = addLocationStr(L"", location); - comments.emplace_back(L"comment" + locStr); - addLine(L"COMMENT: comment" + addFileName(locStr, filePathMap[location.fileNodeId])); + testStorage->comments.emplace_back(L"comment" + locStr); + testStorage->addLine( + L"COMMENT: comment" + addFileName(locStr, filePathMap[location.fileNodeId])); } - for (const StorageError& error: getErrors()) + for (const StorageError& error: storage->getErrors()) { for (auto errorLocationIt = errorLocationMap.find(error.id); errorLocationIt != errorLocationMap.end() && errorLocationIt->first == error.id; errorLocationIt++) { std::wstring locStr = addLocationStr(L"", errorLocationIt->second); - errors.emplace_back(error.message + locStr); - addLine( + testStorage->errors.emplace_back(error.message + locStr); + testStorage->addLine( L"ERROR: " + error.message + addFileName(locStr, filePathMap[errorLocationIt->second.fileNodeId])); } } + return testStorage; } std::vector errors; @@ -343,7 +349,7 @@ public: std::vector m_lines; private: - std::wstring nodeTypeToString(int nodeType) const + static std::wstring nodeTypeToString(int nodeType) { switch (intToNodeKind(nodeType)) { @@ -387,7 +393,7 @@ private: return L"SYMBOL_NON_INDEXED"; } - std::wstring edgeTypeToString(int edgeType) const + static std::wstring edgeTypeToString(int edgeType) { switch (Edge::intToType(edgeType)) { @@ -497,19 +503,19 @@ private: return nullptr; } - std::wstring addLocationStr(const std::wstring& locationStr, const StorageSourceLocation& loc) const + static std::wstring addLocationStr(const std::wstring& locationStr, const StorageSourceLocation& loc) { return L" <" + std::to_wstring(loc.startLine) + L':' + std::to_wstring(loc.startCol) + locationStr + L' ' + std::to_wstring(loc.endLine) + L':' + std::to_wstring(loc.endCol) + L'>'; } - std::wstring addFileName(const std::wstring& locationStr, const FilePath& filePath) const + static std::wstring addFileName(const std::wstring& locationStr, const FilePath& filePath) { return L" [" + filePath.fileName() + locationStr + L']'; } - bool containsLocation(const StorageSourceLocation& out, const StorageSourceLocation& in) const + static bool containsLocation(const StorageSourceLocation& out, const StorageSourceLocation& in) { if (out.startLine > in.startLine) { @@ -540,4 +546,4 @@ private: } }; -#endif // TEST_INTERMEDIATE_STORAGE_H +#endif // TEST_STORAGE_H