diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-04-26 17:35:55 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-05-07 11:43:00 +0200 |
commit | ed4b202774ee6c690764674641972fc83a789011 (patch) | |
tree | 944fc44c1332e800582f04b153005752466a6d1b /src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp | |
parent | 49e27b35fca8e2a4723f0d2b8a114e026a4aa22a (diff) | |
download | qt-creator-ed4b202774ee6c690764674641972fc83a789011.tar.gz |
CppEditor: Fix "Switch Method Decl/Def" for cursor on return type
If the cursor is on the return type, Document::lastVisibleSymbol()
returns the function defined before the current function definition,
which is unfavorable for "Switch Method Decl/Def".
Fixed by using ASTPath instead of Document::lastVisibleSymbol().
Task-Number: QTCREATORBUG-9206
Change-Id: I94aba2fdbb437c6007f328f31deee7ae363364e2
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp')
-rw-r--r-- | src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index c2b3af4b1e..428b6e2079 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -420,6 +420,38 @@ void CppEditorPlugin::test_SwitchMethodDeclarationDefinition_fromFunctionBody() test.run(); } +void CppEditorPlugin::test_SwitchMethodDeclarationDefinition_fromReturnType() +{ + QList<TestDocumentPtr> testFiles; + + const QByteArray headerContents = + "class C\n" + "{\n" + "public:\n" + " C();\n" + " int $function();\n" + "};\n" + ; + testFiles << TestDocument::create(headerContents, QLatin1String("file.h")); + + const QByteArray sourceContents = + "#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 + ; + testFiles << TestDocument::create(sourceContents, QLatin1String("file.cpp")); + + TestCase test(TestCase::SwitchBetweenMethodDeclarationDefinition, testFiles); + test.run(); +} + /// Check ... void CppEditorPlugin::test_FollowSymbolUnderCursor_globalVarFromFunction() { |