forked from qt-creator/qt-creator
		
	Merge remote-tracking branch 'origin/3.5'
Change-Id: Iebaabfc2f724cd493b7cab025406531cea5cd2dc
This commit is contained in:
		@@ -3235,6 +3235,120 @@ void CppToolsPlugin::test_completion_data()
 | 
			
		||||
            << QLatin1String("Foo")
 | 
			
		||||
            << QLatin1String("bar"));
 | 
			
		||||
 | 
			
		||||
    QTest::newRow("typedef for templates in namespace") << _(
 | 
			
		||||
             "namespace N {\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "struct Data { int x; };\n"
 | 
			
		||||
             "template <typename T> struct Foo { T member; };\n"
 | 
			
		||||
             "typedef Foo<Data> Bar;\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "} // N\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "void f()\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    N::Bar o;\n"
 | 
			
		||||
             "    @\n"
 | 
			
		||||
             "}\n"
 | 
			
		||||
    ) << _("o.member.") << (QStringList()
 | 
			
		||||
            << QLatin1String("Data")
 | 
			
		||||
            << QLatin1String("x"));
 | 
			
		||||
 | 
			
		||||
    QTest::newRow("std vector") << _(
 | 
			
		||||
             "namespace std\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "template<typename _Tp>\n"
 | 
			
		||||
             "struct allocator\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    typedef _Tp value_type;\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "    template<typename _Tp1>\n"
 | 
			
		||||
             "    struct rebind\n"
 | 
			
		||||
             "    { typedef allocator<_Tp1> other; };\n"
 | 
			
		||||
             "};\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "template<typename _Alloc, typename _Tp>\n"
 | 
			
		||||
             "struct __alloctr_rebind\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    typedef typename _Alloc::template rebind<_Tp>::other __type;\n"
 | 
			
		||||
             "};\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "template<typename _Alloc>\n"
 | 
			
		||||
             "struct allocator_traits\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    typedef typename _Alloc::value_type value_type;\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "    template<typename _Tp>\n"
 | 
			
		||||
             "    using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;\n"
 | 
			
		||||
             "};\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "template<typename _Iterator>\n"
 | 
			
		||||
             "struct iterator_traits { };\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "template<typename _Tp>\n"
 | 
			
		||||
             "struct iterator_traits<_Tp*>\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    typedef _Tp* pointer;\n"
 | 
			
		||||
             "};\n"
 | 
			
		||||
             "} // namespace std\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "namespace __gnu_cxx\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "template<typename _Alloc>\n"
 | 
			
		||||
             "struct __alloc_traits\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    typedef _Alloc allocator_type;\n"
 | 
			
		||||
             "    typedef std::allocator_traits<_Alloc> _Base_type;\n"
 | 
			
		||||
             "    typedef typename _Alloc::value_type value_type;\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "    static value_type *_S_pointer_helper(...);\n"
 | 
			
		||||
             "    typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer;\n"
 | 
			
		||||
             "    typedef __pointer pointer;\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "    template<typename _Tp>\n"
 | 
			
		||||
             "    struct rebind\n"
 | 
			
		||||
             "    { typedef typename _Base_type::template rebind_alloc<_Tp> other; };\n"
 | 
			
		||||
             "};\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "template<typename _Iterator, typename _Container>\n"
 | 
			
		||||
             "struct __normal_iterator\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    typedef std::iterator_traits<_Iterator> __traits_type;\n"
 | 
			
		||||
             "    typedef typename __traits_type::pointer pointer;\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "    pointer p;\n"
 | 
			
		||||
             "};\n"
 | 
			
		||||
             "} // namespace __gnu_cxx\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "namespace std {\n"
 | 
			
		||||
             "template<typename _Tp, typename _Alloc>\n"
 | 
			
		||||
             "struct _Vector_Base\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template\n"
 | 
			
		||||
             "    rebind<_Tp>::other _Tp_alloc_type;\n"
 | 
			
		||||
             "    typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer\n"
 | 
			
		||||
             "    pointer;\n"
 | 
			
		||||
             "};\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "template<typename _Tp, typename _Alloc = std::allocator<_Tp> >\n"
 | 
			
		||||
             "struct vector : protected _Vector_Base<_Tp, _Alloc>\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    typedef _Vector_Base<_Tp, _Alloc> _Base;\n"
 | 
			
		||||
             "    typedef typename _Base::pointer pointer;\n"
 | 
			
		||||
             "    typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;\n"
 | 
			
		||||
             "};\n"
 | 
			
		||||
             "} // namespace std\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "struct Foo { int bar; };\n"
 | 
			
		||||
             "\n"
 | 
			
		||||
             "void func()\n"
 | 
			
		||||
             "{\n"
 | 
			
		||||
             "    std::vector<Foo>::iterator it;\n"
 | 
			
		||||
             "    @;\n"
 | 
			
		||||
             "}\n"
 | 
			
		||||
    ) << _("it.p->") << (QStringList()
 | 
			
		||||
            << QLatin1String("Foo")
 | 
			
		||||
            << QLatin1String("bar"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_completion_member_access_operator()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user