Hello
Together with Lukas Felber I'm working on the Includator plug-in, for managing include directives in CDT. Currently, I'm trying to resolve dependencies to (partial) template specializations.
The starting point is a simple template definition:
template <typename T, unsigned length>
class FixedVector {
public:
FixedVector() { std::cout << "constr of FixedVector" << std::endl; }
};
This template has three specializations:
template <unsigned length>
class FixedVector<bool, length> {
public:
FixedVector() { std::cout << "constr of FixedVector<bool, length>" << std::endl; }
};
template <unsigned length>
class FixedVector<int, length> {
public:
FixedVector() { std::cout << "constr of FixedVector<int, length>" << std::endl; }
};
template<>
class FixedVector<int, 5> {
public:
FixedVector() { std::cout << "constr of FixedVector<int, 5>" << std::endl; }
};
In the main-function three FixedVector templates are instantiated:
int main() {
FixedVector<double,8> fDouble;
FixedVector<int,5> fInt;
FixedVector<bool,8> fBool;
return 0;
}
From these statements I'm expecting to get the following dependencies.
- From FixedVector<double,8> to the template FixedVector<T, length>
- From FixedVector<int,5> to the template specialization FixedVector<int,5>
- From FixedVector<bool,8> to the partially specialized template FixedVector<bool,length>
My question is, whether I can get such information from the indexer. Currently, I'm able to resolve the following dependencies:
- For each type specifier I get a binding of type PDOMCPPClassInstance
- If I query the indexer for the names of corresponding declarations and definitions I get the following result (index.findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS)):
- FixedVector<double,8>: Nothing; no corresponding name
- FixedVector<bool,8>: Nothing; no corresponding name
- FixedVector<int,5>: The name of the corresponding specialization
Via the completion context for FixedVector<double,8> and FixedVector<bool,8> I can get all names of the base template and all not-fully specified template definitions. This is actually too much, but I could use this result for further investigation.
Is there a nifty way to get the effectively used partial specializations for FixedVector<double,8> and FixedVector<bool,8>?
Thanks a lot.
Thomas
PS: I'm working on the "cdt_7_0_1 (Branch)" tag.