[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Problem getting CFunctions when other headers are included

I tried things like:
transUnit.getAST(null,ITranslationUnit.AST_SKIP_INDEXED_HEADERS |
                    ITranslationUnit.AST_SKIP_NONINDEXED_HEADERS);

But then i cannot resolve types defined in other headers....

"patrick.schmitt@xxxxxxx" <patrick.schmitt@xxxxxxx> hat am 5. Oktober 2009 um 16:20 geschrieben:

> 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