From 74a458bca09b5bd170b64e04bb68c8d958c61932 Mon Sep 17 00:00:00 2001 From: Leandro Melo Date: Wed, 22 Aug 2012 14:44:53 +0200 Subject: C++: Improve completion when forward declarations present This fixes one of the issues mentioned in the report below. THe other part will come in a separate patch. Task-number: QTCREATORBUG-7730 Change-Id: I9f56a9bcec8a881dab3ab60f40c5b71f296466da Reviewed-by: Roberto Raggi --- src/plugins/cpptools/cppcompletion_test.cpp | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/plugins/cpptools/cppcompletion_test.cpp') diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 7d9d9f3417..a6681bb398 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -121,6 +121,40 @@ static void setup(TestData *data) data->doc = data->editor->document(); } +void CppToolsPlugin::test_completion_forward_declarations_present() +{ + TestData data; + data.srcText = "\n" + "class Foo\n" + "{\n" + " struct Bar;\n" + " int i;\n" + "};\n" + "\n" + "struct Foo::Bar \n" + "{\n" + " Bar() {}\n" + "};\n" + "\n" + "@\n" + "// padding so we get the scope right\n"; + + setup(&data); + + Utils::ChangeSet change; + change.insert(data.pos, "Foo::Bar::"); + QTextCursor cursor(data.doc); + change.apply(&cursor); + data.pos += 10; + + QStringList expected; + expected.append("Bar"); + + QStringList completions = getCompletions(data); + + QCOMPARE(completions, expected); +} + void CppToolsPlugin::test_completion_basic_1() { TestData data; -- cgit v1.2.1