forked from qt-creator/qt-creator
		
	C++: fix cloning of templates
Fix instantiation of templates(by cloning original symbols). Assigning of scope for cloned symbol is taken from the symbol which is used to instantiate. Task-number: QTCREATORBUG-9098 Change-Id: I066cc8b5f69333fabdaf2d4466b205baf08bd3f1 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
		
				
					committed by
					
						
						Nikolai Kosjar
					
				
			
			
				
	
			
			
			
						parent
						
							b55961d225
						
					
				
				
					commit
					17cd161a9d
				
			@@ -1843,3 +1843,42 @@ void CppToolsPlugin::test_completion_namespace_alias_with_many_namespace_declara
 | 
			
		||||
    QVERIFY(completions.contains(QLatin1String("Foo1")));
 | 
			
		||||
    QVERIFY(completions.contains(QLatin1String("Foo2")));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_QTCREATORBUG9098()
 | 
			
		||||
{
 | 
			
		||||
    TestData data;
 | 
			
		||||
    data.srcText =
 | 
			
		||||
            "template <typename T>\n"
 | 
			
		||||
            "class B\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "public:\n"
 | 
			
		||||
            "    C<T> c;\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
            "template <typename T>\n"
 | 
			
		||||
            "class A\n"
 | 
			
		||||
            "{\n"
 | 
			
		||||
            "public:\n"
 | 
			
		||||
            "    B<T> b;\n"
 | 
			
		||||
            "    void fun()\n"
 | 
			
		||||
            "    {\n"
 | 
			
		||||
            "       @\n"
 | 
			
		||||
            "       // padding so we get the scope right\n"
 | 
			
		||||
            "    }\n"
 | 
			
		||||
            "};\n"
 | 
			
		||||
 | 
			
		||||
            ;
 | 
			
		||||
    setup(&data);
 | 
			
		||||
 | 
			
		||||
    Utils::ChangeSet change;
 | 
			
		||||
    QString txt = QLatin1String("b.");
 | 
			
		||||
    change.insert(data.pos, txt);
 | 
			
		||||
    QTextCursor cursor(data.doc);
 | 
			
		||||
    change.apply(&cursor);
 | 
			
		||||
    data.pos += txt.length();
 | 
			
		||||
 | 
			
		||||
    QStringList completions = getCompletions(data);
 | 
			
		||||
 | 
			
		||||
    QCOMPARE(completions.size(), 2);
 | 
			
		||||
    QVERIFY(completions.contains(QLatin1String("c")));
 | 
			
		||||
    QVERIFY(completions.contains(QLatin1String("B")));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -123,6 +123,7 @@ private slots:
 | 
			
		||||
    void test_completion_typedef_using_templates1();
 | 
			
		||||
    void test_completion_typedef_using_templates2();
 | 
			
		||||
    void test_completion_namespace_alias_with_many_namespace_declarations();
 | 
			
		||||
    void test_completion_QTCREATORBUG9098();
 | 
			
		||||
 | 
			
		||||
    void test_format_pointerdeclaration_in_simpledeclarations();
 | 
			
		||||
    void test_format_pointerdeclaration_in_simpledeclarations_data();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user