It depends on how the translation unit is parsed. If you parse the complete unit, the includes are resolved and you receive a full AST. You can configure how the AST is created by supplying parse options to the getAST() method (the overload taking an index
and the option flags). You probably want the option AST_SKIP_ALL_HEADERS.
I hope this helps!
Though I'm not qualified to make any statements/remarks I feel very strongly to throw in my "2 cent architectural view"
Though it is not clear from the code I think you are querying the indexer "about the file
XYZ.h".
>From that point of view it is expected that the indexer also parses the included files (like ABC.h) and returns results from included files.
in short: IMHO XYZ.h is a entry point (known by XYZ.h) and not a filter (is in XYZ.h).
Best regards
Jantje
Op 8/05/2020 om 10:18 schreef Ming Cheng:
Hi All,
Seems there is no CDT API Forum. Please kindly let me know if there is one.
Home » Language
IDEs » C
/ C++ IDE (CDT) seems for IDE user.
Assume I have a header file XYZ.h and its content is:
#include "ABC.h"
class XYZ
{
....
}
My java processing code to this effect:
ITranslationUnit tu= (ITranslationUnit) CoreModel.getDefault().create(file); // file here is XYZ.h
IASTTranslationUnit ast= tu.getAST();
ast.accept(new ASTVisitor());
It seems to me that the visitor also visit ABC.h file content which is out of my expectation.
Thanks.
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev