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.

Lukas


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
Path(path));
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: http://eclipse.1072660.n5.nabble.com/Include-statements-tp165635p165661.html
Sent from the Eclipse CDT - Development mailing list archive at Nabble.com.
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top