[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] Problem getting CFunctions when other headers are included
|
Hello guys,
I have a problem with my CDT AST Parser Plugin.
I wanted to get all CFUnctions of a single header file. But when including other headers in that file,
e.g. windows.h, i get thousands of functions declarations, even i just want the declaration of that single header file. I think I am doing something wrong basicly....
Here is my code:
// object when right click on header file
IStructuredSelection sel = (IStructuredSelection) _select;
// get the translation unit
if (sel.getFirstElement() instanceof ITranslationUnit)
{
// create transUnit
tUnit = (ITranslationUnit) sel.getFirstElement();
// get AST of the ITranslationUnit
_astUnit = tUnit .getAST();
decs = _astUnit.getDeclarations();
for (IASTDeclaration dec : decs)
{
// if its a simple declaration
if (dec instanceof IASTSimpleDeclaration)
{
// cast to simple declaration
simplDec = (IASTSimpleDeclaration)dec;
// cast the declarator
declas = simplDec.getDeclarators();
// only if its a functionDeclarator
if (declas.length > 0
&& declas[0] instanceof IASTFunctionDeclarator)
{
// cast to function declarator
IASTFunctionDeclarator funcDecl = (IASTFunctionDeclarator)declas[0];
// HERE WE GO WITH THE FUNCTION
// .....
}
}
}
Maybe anybody has an idea ?
Sincerly
Patrick