[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [ptp-dev] Eclipse CDT - Get the definition of a C++ method when I have the declaration
|
I suggest you post this to the cdt-dev mailing list.
...Beth
Beth Tibbitts
Eclipse Parallel Tools Platform http://eclipse.org/ptp
IBM STG Communications Protocols and Tools
Mailing Address: IBM Corp., Coldstream Research Campus, 745 West New Circle Road, Lexington, KY 40511
HAIDUC SONIA ---11/09/2010 12:15:22 PM---Hi, I am trying to extract the source code of all C++ classes from a C++ program,
![]()
| ![]()
HAIDUC SONIA <haiduc_sonia@xxxxxxxxx> |
![]()
| ![]()
ptp-dev@xxxxxxxxxxx |
![]()
| ![]()
11/09/2010 12:15 PM |
![]()
| ![]()
[ptp-dev] Eclipse CDT - Get the definition of a C++ method when I have the declaration |
![]()
| ![]()
ptp-dev-bounces@xxxxxxxxxxx |
Hi,
I am trying to extract the source code of all C++ classes from a C++ program, and I need to get, for each class, its whole source code, i.e., with both the definition of the class and the declaration of its methods from a header file and the definition of its methods from a source file. I am able to get the definition of the class, including the declaration of its methods, by using the following code:
HashSet<ITranslationUnit> transUnits = new HashSet<ITranslationUnit>();
ISourceRoot roots[] = project.getSourceRoots();
for (ISourceRoot root:roots){
transUnits.addAll(Arrays.asList(root.getTranslationUnits()));
}
for (ITranslationUnit translationUnit:transUnits){
if (translationUnit.isCXXLanguage()){
ICElement elems[] = TypeUtil.getTypes(translationUnit);
for (int i=0;i<elems.length;i++)
if (TypeUtil.isClass(elems[i])){
String classDeclarationCode = ((IStructure)elem).getSource();
}
}
}
This gets me the definitions of classes from header files, including the declarations of their methods. However, I still need to get the definition of the class' methods, which are not in the header file. I have been going around this for several days now, and I could not find a solution to this.
I managed to get the method declarations from the header file, by using the following code:
List<ICElement> methodDeclarationsClass = new ArrayList<ICElement>();
methodDeclarationsClass.addAll(((IStructure)elem).getChildrenOfType(ICElement.C_METHOD_DECLARATION));
String methodDeclarationCode;
for (int i = 0; i<methodDeclarationsClass.size(); i++) {
methodDeclarationCode = ((IMethodDeclaration)methodDeclarationsClass.get(i)).getSource();
}
, but I can't get form this to the method definitions... I would really appreciate some help on this, as I am kinda stuck...
Thanks a lot!
Sonia
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev

