Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Visiting IASTNodes inside preprocessor blocks

Em 13-05-2011 02:57, Schorn, Markus escreveu:
Hi,
In general, there is not AST for inactive code branches. There is limited support for creating AST for  declarations in inactive code branches, see ITranslationUnit. AST_PARSE_INACTIVE_CODE.
Markus.

Thanks, that information was very useful. I have studied these classes and now I understand a little bit more about the parsers and scanners. But I still have a doubt. When I use the AST_PARSE_INACTIVE_CODE the scanner in AbstractCLikeLanguage contains the tokens for code inside inactive blocks. But I couldn't find a way to get this scanner and use in my plugin. Is it possible to get this scanner or at least the raw string from code inside an inactive code? In the moment I am creating a Scanner and parsing tokens again, but I think that this is not a good idea. And eclipse is complaining because I'm using classes that are not in the API. It would help me a lot if I can get the IScanner object.

Thanks in advance,
Otavio Pontes


-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Otávio Pontes
Sent: Donnerstag, 12. Mai 2011 20:44
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] Visiting IASTNodes inside preprocessor blocks
Importance: Low

Hi folks,
I'm writting a plugin based in cdt/codan and i need to visit all IASTNodes in a C code. To do that I'm using the IASTTranslationUnit.accept method and it is working fine. But I also need to visit nodes inside a block excluded by the preprocessor (#ifdef,
#ifndef) and the IASTTranslationUnit.accept is not doing this. In the example bellow bar() is visited, but foo() is not.

void main() {
      #ifdef VAR
          foo();
      #endif
      bar();
}

Is there a way to get the nodes from code inside this block? It seems to me that codan checkers do not work inside this block too, so looking at the code won't help me. I realize that I can get the preprocessor statements using IASTTranslationUnit.getAllPreprocessorStatements, but I cannot get the content.

Thanks,
Otavio Pontes
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top