[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Is extern parsed is ast or the indexer?
|
Nate
Thank you very much. This is exactly what I needed.
Best regards
Jantje
PS I haven't forgotten about the CDT issues. Please be patient.
Op 2/01/2017 om 23:57 schreef Nathan Ridge:
Hi Jantje,
I don't think extern "C" blocks get an ICElement, but you can discover information about them using the AST:
- Use ITranslationUnit.getAST() to get an IASTTranslationUnit
- Use IASTTranslationUnit.getDeclarations() to get a list of the top-level
declarations in the AST
- Loop through them and look for one that implements ICPPASTLinkageSpecification
- ICPPASTLinkageSpecification.getLiteral() will tell you the type of linkage, e.g. "C"
(I'm not actually sure whether there are other types besides "C"?)
- To discover start and end line numbers, use IASTNode.getFileLocation()
(on the ICPPASTLinkageSpecification).
- IASTFileLocation has methods getStartingLineNumber() and
getEndingLineNumber().
Hope that helps!
Regards,
Nate
________________________________________
From: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Jan Baeyens <jan@xxxxxxxxxx>
Sent: January 2, 2017 8:13:50 PM
To: CDT General developers list.
Subject: [cdt-dev] Is extern parsed is ast or the indexer?
Hi
For my delayed V4 release I'm trying to fix a known limitation in
Sloeber and to do so I'd like to find the ICElement of the extern bloks.
I have the ITranslationUnit tu of the file.
When I try tu.getElement("extern"); I get a null back.
I tried some alternatives but I always get null.
I'm sure I have the correct tu as the following code works
String fileContent = new String(tu.getContents());
if (fileContent.contains("extern \"C\"")) {
I looked for a type that could match but IMHO nothing seems to match.
I'd like to find out where the extern "C" { XXXXX} blok starts and stops.
Line level is ok.
I can do it with string parsing but it would be far more convenient if I
could use getSourceRange.
So my question is: is extern parsed by the indexer and if so what type
is it.
I could find out myself is there is a way to dump the index/ast in a
readable format.
Thanks and best wishes for 2017
Jantje
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev