CDT API Forum and ASTVisitor

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

CDT API Forum and ASTVisitor

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
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT API Forum and ASTVisitor

Jonah Graham
Hi Ming,

I hope you are getting clarity on what needs asking where. Different projects have different requirements. The Forum you mention is for end users and the cdt-dev list is for discussing CDT development and using its APIs.

Sorry that I don't have an answer to your technical question though.

Jonah

~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com


On Fri, 8 May 2020 at 04:18, Ming Cheng <[hidden email]> wrote:
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
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT API Forum and ASTVisitor

Jan Baeyens
In reply to this post by Ming Cheng

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
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT API Forum and ASTVisitor

Corbat Thomas

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!


Von: [hidden email] <[hidden email]> im Auftrag von Jan Baeyens <[hidden email]>
Gesendet: Freitag, 8. Mai 2020 15:04:30
An: [hidden email]
Betreff: Re: [cdt-dev] CDT API Forum and ASTVisitor
 

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
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT API Forum and ASTVisitor

Ming Cheng
Hi Corbat,
Thanks for your tips and help. AST_SKIP_ALL_HEADERS is what I need.


From: [hidden email] <[hidden email]> on behalf of Corbat Thomas <[hidden email]>
Sent: Friday, May 8, 2020 3:00 PM
To: CDT General developers list. <[hidden email]>
Subject: Re: [cdt-dev] CDT API Forum and ASTVisitor
 

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!


Von: [hidden email] <[hidden email]> im Auftrag von Jan Baeyens <[hidden email]>
Gesendet: Freitag, 8. Mai 2020 15:04:30
An: [hidden email]
Betreff: Re: [cdt-dev] CDT API Forum and ASTVisitor
 

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
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
[hidden email]
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev