use of org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance in project linuxtools by eclipse.
the class LibHover method getClassName.
// Get the class name for a type, including any instance template parameters
// e.g. std::basic_string<char>
private String getClassName(ICPPClassType c) {
String className = null;
try {
String[] qualified = c.getQualifiedName();
className = qualified[0];
for (int k = 1; k < qualified.length; ++k) {
// $NON-NLS-1$
className += "::" + qualified[k];
}
// Check if we have an instance of a template class.
if (c instanceof ICPPTemplateInstance) {
ICPPTemplateInstance ti = (ICPPTemplateInstance) c;
// Get a map which tells us the values of the template
// arguments (e.g. _CharT maps to char in the instance).
ICPPTemplateParameterMap tiMap = ti.getTemplateParameterMap();
ICPPTemplateDefinition td = ti.getTemplateDefinition();
ICPPTemplateParameter[] templateArgs = td.getTemplateParameters();
// $NON-NLS-1$
className += "<";
// $NON-NLS-1$
String separator = "";
for (int x = 0; x < templateArgs.length; ++x) {
ICPPTemplateParameter tp = templateArgs[x];
ICPPTemplateArgument ta = tiMap.getArgument(tp);
IType type = null;
// that when we do a lookup.
if (ta.isTypeValue()) {
type = ta.getTypeValue();
} else {
type = ta.getTypeOfNonTypeValue();
}
if (tp.getTemplateNestingLevel() == 0) {
// get its class name including template parameters
if (type instanceof ICPPClassType) {
className += separator + getClassName((ICPPClassType) type);
} else {
className += separator + type.toString();
}
// $NON-NLS-1$
separator = ",";
}
}
// $NON-NLS-1$
className += ">";
}
} catch (DOMException e) {
return null;
}
return className;
}
Aggregations