forked from qt-creator/qt-creator
		
	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 <roberto.raggi@nokia.com>
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -90,6 +90,7 @@ private slots:
 | 
			
		||||
    void test_codegen_definition_last_member();
 | 
			
		||||
    void test_codegen_definition_middle_member();
 | 
			
		||||
 | 
			
		||||
    void test_completion_forward_declarations_present();
 | 
			
		||||
    void test_completion_basic_1();
 | 
			
		||||
    void test_completion_template_1();
 | 
			
		||||
    void test_completion_template_as_base();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user