Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Getting methods/fields from CPPClassTemplate

I need to get the field and methods objects in the AST from a template. However, org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplate that extends CPPClassType explicitly returns null from the following methods: getDeclaredFields, getMethods, getAllDeclaredMethods & getDeclaredMethods. I was able to find a workaround for getting the fields by doing something like the code below. However, I still have not figured out how to get the methods. Can anybody point out the reasons why the methods were overridden to return null and what would be the best way to get the fields & methods?

                        org.eclipse.cdt.core.dom.ast.IField[] astFields = null;
                        ICppClassType type = getTemplateType();
                        ICElement elem = getICElement(type);
                        if (elem instanceof IStructureTemplate)  {
                                IStructureTemplate template = (IStructureTemplate) elem;
                                org.eclipse.cdt.core.model.IField[] fields = template.getFields();
                                astFields = new IField[fields.length];
                                for (int i = 0; i < fields.length; i++)  {
                                        astFields[i] = type.findField(fields[i].getElementName());


Back to the top