Golevka / emacs-clang-complete-async

An emacs plugin to complete C and C++ code using libclang
359 stars 71 forks source link

Fail to complete when using template parameters in the definitions of template classes or functions #77

Closed oracleyue closed 6 years ago

oracleyue commented 10 years ago

The issue I reported before was not precise, Sorry. Most times, the following issues I described before won't happen. (Now it works well. My problem happened before was ac-completion didn't work for containers using user-defined classes in any context. It works after I recompiled clang-complete-async and upgraded Clang.) However, it fails to complete when these containers or template classes use template parameters in the declarations or definitions of template classes or functions, as reported by psteinb on the second floor.

FYI, an example

class T;
template <class t>
class func{
       vector<T> vec1;
       void foo(){
            vec1.   <--- work, as expected
       }
       vector<t> vec2;
       void foo2(){
            vec2.   <--- not work!
       }
}

~~If the template parameter is a user-defined class (classes in the C++ standard library works well), it fails to complete. For instance, std::vector<double> var; when type var., it works well; However, std::vector<class_type> var, when typevar., it fails to prompt any completions. No candidates appear. It seems that a class as template parameters stops the complete function. Please help to check it. At least, update it to complete the original member functions of the container (like vector, map), by ingoring its template parameters. Thanks a lot!~~

psteinb commented 10 years ago

I can confirm this behavior, this also holds for any templated function/method. try:

template <typename T>
void foo(){

typename std::vector<T> temp;
temp.<TAB>

}

It would be nice to have this fixed, if I only knew how...