forked from qt-creator/qt-creator
		
	Merge remote-tracking branch 'origin/2.6'
Conflicts: dist/gdb/Makefile.osx src/libs/qmldebug/qmldebug.qbs src/plugins/android/androidsettingswidget.cpp Change-Id: I85627130b575f7d08f416dea52031fa72019b217
This commit is contained in:
		@@ -231,7 +231,7 @@ void CppToolsPlugin::test_completion_template_1()
 | 
			
		||||
    QVERIFY(!completions.contains("func"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_template_as_base()
 | 
			
		||||
void CppToolsPlugin::test_completion()
 | 
			
		||||
{
 | 
			
		||||
    QFETCH(QByteArray, code);
 | 
			
		||||
    QFETCH(QStringList, expectedCompletions);
 | 
			
		||||
@@ -253,6 +253,11 @@ void CppToolsPlugin::test_completion_template_as_base()
 | 
			
		||||
    QCOMPARE(actualCompletions, expectedCompletions);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_template_as_base()
 | 
			
		||||
{
 | 
			
		||||
    test_completion();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_template_as_base_data()
 | 
			
		||||
{
 | 
			
		||||
    QTest::addColumn<QByteArray>("code");
 | 
			
		||||
@@ -399,3 +404,391 @@ void CppToolsPlugin::test_completion_template_as_base_data()
 | 
			
		||||
    completions.append("otherMember");
 | 
			
		||||
    QTest::newRow("case: base as template name in non-template") << code << completions;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_use_global_identifier_as_base_class()
 | 
			
		||||
{
 | 
			
		||||
    test_completion();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_use_global_identifier_as_base_class_data()
 | 
			
		||||
{
 | 
			
		||||
    QTest::addColumn<QByteArray>("code");
 | 
			
		||||
    QTest::addColumn<QStringList>("expectedCompletions");
 | 
			
		||||
 | 
			
		||||
    QByteArray code;
 | 
			
		||||
    QStringList completions;
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "struct Global\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "    int int_global;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "struct Final : ::Global\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_final;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "Final c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_global");
 | 
			
		||||
    completions.append("int_final");
 | 
			
		||||
    completions.append("Final");
 | 
			
		||||
    completions.append("Global");
 | 
			
		||||
    QTest::newRow("case: derived as global and base as global") << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "struct Global\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "    int int_global;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "namespace NS\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct Final : ::Global\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_final;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "}\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "NS::Final c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_global");
 | 
			
		||||
    completions.append("int_final");
 | 
			
		||||
    completions.append("Final");
 | 
			
		||||
    completions.append("Global");
 | 
			
		||||
    QTest::newRow("case: derived is inside namespace, base as global")
 | 
			
		||||
            << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
    //this test does not work due to the bug QTCREATORBUG-7912
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//    code = "\n"
 | 
			
		||||
//            "struct Global\n"
 | 
			
		||||
//            "{\n"
 | 
			
		||||
//            "    int int_global;\n"
 | 
			
		||||
//            "};\n"
 | 
			
		||||
//            "\n"
 | 
			
		||||
//            "template <typename T>\n"
 | 
			
		||||
//            "struct Enclosing\n"
 | 
			
		||||
//            "{\n"
 | 
			
		||||
//            "struct Final : ::Global\n"
 | 
			
		||||
//            "{\n"
 | 
			
		||||
//            "   int int_final;\n"
 | 
			
		||||
//            "};\n"
 | 
			
		||||
//            "}\n"
 | 
			
		||||
//            "\n"
 | 
			
		||||
//            "Enclosing<int>::Final c;\n"
 | 
			
		||||
//            "@\n"
 | 
			
		||||
//            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
//    completions.append("int_global");
 | 
			
		||||
//    completions.append("int_final");
 | 
			
		||||
//    completions.append("Final");
 | 
			
		||||
//    completions.append("Global");
 | 
			
		||||
//    QTest::newRow("case: derived is enclosed by template, base as global")
 | 
			
		||||
//    << code << completions;
 | 
			
		||||
 | 
			
		||||
//    completions.clear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived()
 | 
			
		||||
{
 | 
			
		||||
    test_completion();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_data()
 | 
			
		||||
{
 | 
			
		||||
    QTest::addColumn<QByteArray>("code");
 | 
			
		||||
    QTest::addColumn<QStringList>("expectedCompletions");
 | 
			
		||||
 | 
			
		||||
    QByteArray code;
 | 
			
		||||
    QStringList completions;
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "struct A : A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_a");
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    QTest::newRow("case: base class is derived class") << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "namespace NS\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct A : A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "}\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "NS::A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_a");
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    QTest::newRow("case: base class is derived class. class is in namespace")
 | 
			
		||||
            << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "namespace NS\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct A : NS::A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "}\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "NS::A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_a");
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    QTest::newRow("case: base class is derived class. class is in namespace. "
 | 
			
		||||
                  "use scope operator for base class") << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "namespace NS1\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_ns1_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "}\n"
 | 
			
		||||
            "namespace NS2\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct A : NS1::A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_ns2_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "}\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "NS2::A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_ns1_a");
 | 
			
		||||
    completions.append("int_ns2_a");
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    QTest::newRow("case: base class has the same name as derived but in different namespace")
 | 
			
		||||
            << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "struct Enclosing\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_enclosing_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "namespace NS2\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct A : Enclosing::A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_ns2_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "}\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "NS2::A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_enclosing_a");
 | 
			
		||||
    completions.append("int_ns2_a");
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    QTest::newRow("case: base class has the same name as derived(in namespace) "
 | 
			
		||||
                  "but is nested by different class") << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "struct EnclosingBase\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_enclosing_base_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "struct EnclosingDerived\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "struct A : EnclosingBase::A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_enclosing_derived_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "EnclosingDerived::A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_enclosing_base_a");
 | 
			
		||||
    completions.append("int_enclosing_derived_a");
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    QTest::newRow("case: base class has the same name as derived(nested) "
 | 
			
		||||
                  "but is nested by different class") << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "template <typename T>\n"
 | 
			
		||||
            "struct A : A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   int int_a;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "A<int> c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            "// padding so we get the scope right\n";
 | 
			
		||||
 | 
			
		||||
    completions.append("int_a");
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    QTest::newRow("case: base class is derived class. class is a template")
 | 
			
		||||
            << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_cyclic_inheritance()
 | 
			
		||||
{
 | 
			
		||||
    test_completion();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_cyclic_inheritance_data()
 | 
			
		||||
{
 | 
			
		||||
    QTest::addColumn<QByteArray>("code");
 | 
			
		||||
    QTest::addColumn<QStringList>("expectedCompletions");
 | 
			
		||||
 | 
			
		||||
    QByteArray code;
 | 
			
		||||
    QStringList completions;
 | 
			
		||||
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "struct B;\n"
 | 
			
		||||
            "struct A : B { int _a; };\n"
 | 
			
		||||
            "struct B : A { int _b; };\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            ;
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    completions.append("_a");
 | 
			
		||||
    completions.append("B");
 | 
			
		||||
    completions.append("_b");
 | 
			
		||||
    QTest::newRow("case: direct cyclic inheritance") << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "struct C;\n"
 | 
			
		||||
            "struct A : C { int _a; };\n"
 | 
			
		||||
            "struct B : A { int _b; };\n"
 | 
			
		||||
            "struct C : B { int _c; };\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            ;
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    completions.append("_a");
 | 
			
		||||
    completions.append("B");
 | 
			
		||||
    completions.append("_b");
 | 
			
		||||
    completions.append("C");
 | 
			
		||||
    completions.append("_c");
 | 
			
		||||
    QTest::newRow("case: indirect cyclic inheritance") << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "struct B;\n"
 | 
			
		||||
            "struct A : B { int _a; };\n"
 | 
			
		||||
            "struct C { int _c; };\n"
 | 
			
		||||
            "struct B : C, A { int _b; };\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "A c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            ;
 | 
			
		||||
    completions.append("A");
 | 
			
		||||
    completions.append("_a");
 | 
			
		||||
    completions.append("B");
 | 
			
		||||
    completions.append("_b");
 | 
			
		||||
    completions.append("C");
 | 
			
		||||
    completions.append("_c");
 | 
			
		||||
    QTest::newRow("case: indirect cyclic inheritance") << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "template< typename T > struct C;\n"
 | 
			
		||||
            "template< typename T, typename S > struct D : C< S >\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   T _d_t;\n"
 | 
			
		||||
            "   S _d_s;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "template< typename T > struct C : D< T, int >\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   T _c_t;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "D<int, float> c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            ;
 | 
			
		||||
    completions.append("D");
 | 
			
		||||
    completions.append("_d_t");
 | 
			
		||||
    completions.append("_d_s");
 | 
			
		||||
    completions.append("C");
 | 
			
		||||
    completions.append("_c_t");
 | 
			
		||||
    QTest::newRow("case: direct cyclic inheritance with templates")
 | 
			
		||||
            << code << completions;
 | 
			
		||||
 | 
			
		||||
    completions.clear();
 | 
			
		||||
    code = "\n"
 | 
			
		||||
            "template< typename T > struct C;\n"
 | 
			
		||||
            "template< typename T, typename S > struct D : C< S >\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   T _d_t;\n"
 | 
			
		||||
            "   S _d_s;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "template< typename T > struct B : D< T, int >\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   T _b_t;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "template< typename T > struct C : B<T>\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "   T _c_t;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "\n"
 | 
			
		||||
            "D<int, float> c;\n"
 | 
			
		||||
            "@\n"
 | 
			
		||||
            ;
 | 
			
		||||
    completions.append("D");
 | 
			
		||||
    completions.append("_d_t");
 | 
			
		||||
    completions.append("_d_s");
 | 
			
		||||
    completions.append("C");
 | 
			
		||||
    completions.append("_c_t");
 | 
			
		||||
    completions.append("B");
 | 
			
		||||
    completions.append("_b_t");
 | 
			
		||||
    QTest::newRow("case: indirect cyclic inheritance with templates")
 | 
			
		||||
            << code << completions;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -77,6 +77,7 @@ private slots:
 | 
			
		||||
    void switchHeaderSource();
 | 
			
		||||
 | 
			
		||||
#ifdef WITH_TESTS
 | 
			
		||||
 | 
			
		||||
    // codegen tests
 | 
			
		||||
    void test_codegen_public_in_empty_class();
 | 
			
		||||
    void test_codegen_public_in_nonempty_class();
 | 
			
		||||
@@ -95,6 +96,15 @@ private slots:
 | 
			
		||||
    void test_completion_template_1();
 | 
			
		||||
    void test_completion_template_as_base();
 | 
			
		||||
    void test_completion_template_as_base_data();
 | 
			
		||||
    void test_completion_use_global_identifier_as_base_class();
 | 
			
		||||
    void test_completion_use_global_identifier_as_base_class_data();
 | 
			
		||||
    void test_completion_base_class_has_name_the_same_as_derived();
 | 
			
		||||
    void test_completion_base_class_has_name_the_same_as_derived_data();
 | 
			
		||||
    void test_completion_cyclic_inheritance();
 | 
			
		||||
    void test_completion_cyclic_inheritance_data();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void test_completion();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user