aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2021-05-31 15:57:44 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2021-06-18 11:11:17 +0000
commit41dafc8132ead035b4c02e6f7332ed35fc8dcbc7 (patch)
tree4be977d002165bd3debadde4866baa5c4f1337a9 /src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
parentde6c7696d2ce8f3424146ebe0b6cf172361b9b87 (diff)
ClangCodeModel: Implement declaration/definition switch via clangd
Change-Id: I522a415d76fbc5332e5cc1fdfd2d7ab19cb9ed64 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp')
-rw-r--r--src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp132
1 files changed, 126 insertions, 6 deletions
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
index 401a7eb39f..5eefae1e02 100644
--- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
+++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
@@ -297,14 +297,12 @@ F2TestCase::F2TestCase(CppEditorAction action,
QSKIP("fuzzy matching is not supposed to work with clangd"); // TODO: Implement fallback as we do with libclang
if (tag == "baseClassFunctionIntroducedByUsingDeclaration")
QSKIP("clangd points to the using declaration");
- if (tag == "classDestructor")
+ if (tag == "classDestructor" || tag == "fromDestructorDefinitionSymbol"
+ || tag == "fromDestructorBody") {
QSKIP("clangd wants the cursor before the ~ character");
+ }
if (curTestName == "test_FollowSymbolUnderCursor_classOperator_inOp")
QSKIP("clangd goes to operator name first");
- if (tag == "fromFunctionBody" || tag == "fromReturnType"
- || tag == "conversionOperatorDecl2Def") {
- QSKIP("TODO: explicit decl/def switch not yet supported with clangd");
- }
}
// Write files to disk
@@ -415,7 +413,9 @@ F2TestCase::F2TestCase(CppEditorAction action,
break;
}
case SwitchBetweenMethodDeclarationDefinitionAction:
- if (CppTools::codeModelSettings()->useClangd())
+ // Some test cases were erroneously added as decl/def, but they are really
+ // follow symbol functionality (in commit a0764603d0).
+ if (useClangd && tag.endsWith("Var"))
initialTestFile->m_editorWidget->openLinkUnderCursor();
else
CppEditorPlugin::instance()->switchDeclarationDefinition();
@@ -623,6 +623,126 @@ void CppEditorPlugin::test_SwitchMethodDeclarationDefinition_data()
"}\n" // Line 10
);
+ QTest::newRow("fromConstructorDeclarationSymbol") << _(
+ "class C\n"
+ "{\n"
+ "public:\n"
+ " C();\n"
+ " int @function();\n" // Line 5
+ "};\n"
+ ) << _(
+ "#include \"file.h\"\n"
+ "\n"
+ "C::C()\n"
+ "{\n"
+ "}\n" // Line 5
+ "\n"
+ "int C::$function()\n"
+ "{\n"
+ " return 1 + 1;\n"
+ "}\n" // Line 10
+ );
+
+ QTest::newRow("fromConstructorDefinitionSymbol") << _(
+ "class C\n"
+ "{\n"
+ "public:\n"
+ " $C();\n"
+ " int function();\n"
+ "};\n"
+ ) << _(
+ "#include \"file.h\"\n"
+ "\n"
+ "C::@C()\n"
+ "{\n"
+ "}\n"
+ "\n"
+ "int C::function()\n"
+ "{\n"
+ " return 1 + 1;\n"
+ "}\n"
+ );
+
+ QTest::newRow("fromConstructorBody") << _(
+ "class C\n"
+ "{\n"
+ "public:\n"
+ " $C();\n"
+ " int function();\n"
+ "};\n"
+ ) << _(
+ "#include \"file.h\"\n"
+ "\n"
+ "C::C()\n"
+ "{@\n"
+ "}\n" // Line 5
+ "\n"
+ "int C::function()\n"
+ "{\n"
+ " return 1 + 1;\n"
+ "}\n" // Line 10
+ );
+
+ QTest::newRow("fromDestructorDeclarationSymbol") << _(
+ "class C\n"
+ "{\n"
+ "public:\n"
+ " @C();\n"
+ " int function();\n" // Line 5
+ "};\n"
+ ) << _(
+ "#include \"file.h\"\n"
+ "\n"
+ "C::$C()\n"
+ "{\n"
+ "}\n" // Line 5
+ "\n"
+ "int C::function()\n"
+ "{\n"
+ " return 1 + 1;\n"
+ "}\n" // Line 10
+ );
+
+ QTest::newRow("fromDestructorDefinitionSymbol") << _(
+ "class C\n"
+ "{\n"
+ "public:\n"
+ " ~$C();\n"
+ " int function();\n"
+ "};\n"
+ ) << _(
+ "#include \"file.h\"\n"
+ "\n"
+ "C::@~C()\n"
+ "{\n"
+ "}\n"
+ "\n"
+ "int C::function()\n"
+ "{\n"
+ " return 1 + 1;\n"
+ "}\n"
+ );
+
+ QTest::newRow("fromDestructorBody") << _(
+ "class C\n"
+ "{\n"
+ "public:\n"
+ " ~$C();\n"
+ " int function();\n"
+ "};\n"
+ ) << _(
+ "#include \"file.h\"\n"
+ "\n"
+ "C::~C()\n"
+ "{@\n"
+ "}\n" // Line 5
+ "\n"
+ "int C::function()\n"
+ "{\n"
+ " return 1 + 1;\n"
+ "}\n" // Line 10
+ );
+
QTest::newRow("fromReturnType") << _(
"class C\n"
"{\n"