diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2021-02-02 14:01:15 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2021-02-22 11:16:49 +0000 |
commit | b066b3029efb3e518e62439c2be8e5de8fe906ac (patch) | |
tree | f645ec4657e6b341f1fd74e1efd709ddabd394f7 /src/plugins/cppeditor/cppquickfix_test.cpp | |
parent | f47c7b2e90fedd9e3a4ea4affdd4ab715b58c9a5 (diff) | |
download | qt-creator-b066b3029efb3e518e62439c2be8e5de8fe906ac.tar.gz |
CPlusPlus: Improve type name minimization
... for function parameters. These are located in the scope of the
surrounding class or namespace.
This uncovered a bug in the "Insert Virtual Functions of Base Classes"
quickfix, which we also fix here.
Fixes: QTCREATORBUG-8030
Change-Id: I7f11659dc8e252e3819df8178734e8958fa1b496
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppquickfix_test.cpp')
-rw-r--r-- | src/plugins/cppeditor/cppquickfix_test.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index ac408b154d..37ca090f7e 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -4593,6 +4593,68 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeredForFriendFunc( QuickFixOperationTest(singleDocument(contents, ""), &factory); } +void CppEditorPlugin::test_quickfix_InsertDefFromDecl_minimalFunctionParameterType() +{ + QList<QuickFixTestDocument::Ptr> testDocuments; + + QByteArray original; + QByteArray expected; + + // Header File + original = R"( +class C { + typedef int A; + A @foo(A); +}; +)"; + expected = original; + testDocuments << QuickFixTestDocument::create("file.h", original, expected); + + // Source File + original = R"( +#include "file.h" +)"; + expected = R"( +#include "file.h" + +C::A C::foo(A) +{ + +} +)"; + testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); + + InsertDefFromDecl factory; + QuickFixOperationTest(testDocuments, &factory); + + testDocuments.clear(); + // Header File + original = R"( +namespace N { + struct S; + S @foo(const S &s); +}; +)"; + expected = original; + testDocuments << QuickFixTestDocument::create("file.h", original, expected); + + // Source File + original = R"( +#include "file.h" +)"; + expected = R"( +#include "file.h" + +N::S N::foo(const S &s) +{ + +} +)"; + testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); + + QuickFixOperationTest(testDocuments, &factory); +} + void CppEditorPlugin::test_quickfix_InsertDefsFromDecls_data() { QTest::addColumn<QByteArrayList>("headers"); |