Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Include statements

Your solution contains some pitfalls. (1) never create an IASTTranslationUnit using the getAST() method since it will parse all the included headers as well (which will have a huge performance impact). Use the overload tu.getAST(index, flags) instead. (2) for what you want to do, you probably do not need to create an ast at all. have a look at what methods the index provides. it allows you to find either the includes present in one file (IIndexFile) or if you want to also all the files (that are transitively) included. The operations performed on the index will be very fast, whereas everything involving an AST is rather slow.


On 19.02.2014 09:35, Hadrien Bertrand wrote:
Thanks, it worked perfectly !

For the record, the code I used was :

String path = "/AppliToCheck/src/AppliToCheck.c";
IFile file =  ResourcesPlugin.getWorkspace().getRoot().getFile(new
ITranslationUnit tu = CoreModelUtil.findTranslationUnit(file);
try {
	IASTTranslationUnit iast = tu.getAST();
	IASTPreprocessorIncludeStatement[] tab = iast.getIncludeDirectives();
	//The header I am looking for is in tab
} catch (CoreException e1) {

View this message in context:
Sent from the Eclipse CDT - Development mailing list archive at
cdt-dev mailing list

Back to the top