INodeFactory and ICPPNodeFactory

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

INodeFactory and ICPPNodeFactory

Ming Cheng
Hi,


IASTTranslationUnit ast = CurrentGui.getInstance().getGui().getAST(file);
ASTRewrite r = ASTRewrite.create( ast );
addIncludeDirectives(ast, r, className + ".h");

 INodeFactory factory = ast.getASTNodeFactory();

I have ast, is there a way to get ICPPNodeFactory? I want to "new" a class declaration as simple and natural as possible. For example I don't want ASTRewrite's createLiteralNode to get a IASTNode.  Then to add some class's elements. I prefer to get a IASTSimpleDeclaration with ICPPASTCompositeTypeSpecifier.k_class .

Rgds.
Ming Cheng

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

Re: INodeFactory and ICPPNodeFactory

Ming Cheng

I know everyone is very busy.

Hope any expert can give some guide.

 

Thank you very much!

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: Wednesday, February 26, 2020 4:52 PM
To: [hidden email]
Subject: [cdt-dev] INodeFactory and ICPPNodeFactory

 

Hi,

 

 

IASTTranslationUnit ast = CurrentGui.getInstance().getGui().getAST(file);

ASTRewrite r = ASTRewrite.create( ast );

addIncludeDirectives(ast, r, className + ".h");

 

 INodeFactory factory = ast.getASTNodeFactory();

 

I have ast, is there a way to get ICPPNodeFactory? I want to "new" a class declaration as simple and natural as possible. For example I don't want ASTRewrite's createLiteralNode to get a IASTNode.  Then to add some class's elements. I prefer to get a IASTSimpleDeclaration with ICPPASTCompositeTypeSpecifier.k_class .

 

Rgds.

Ming Cheng

 


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

Re: INodeFactory and ICPPNodeFactory

Nathan Ridge
A C++ translation unit will have a C++ node factory. So, code like the following is reasonable:

if (ast instanceof ICPPASTTranslationUnit) {
  ICPPNodeFactory cppNodeFactory = (ICPPNodeFactory) ast.getASTNodeFactory();
  // use cppNodeFactory
} else {
  // not a C++ translation unit
}

Hope that helps,
Nate

________________________________________
From: [hidden email] <[hidden email]> on behalf of Ming Cheng <[hidden email]>
Sent: February 27, 2020 2:16 AM
To: CDT General developers list.
Subject: Re: [cdt-dev] INodeFactory and ICPPNodeFactory

I know everyone is very busy.
Hope any expert can give some guide.

Thank you very much!

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: Ming Cheng<mailto:[hidden email]>
Sent: Wednesday, February 26, 2020 4:52 PM
To: [hidden email]<mailto:[hidden email]>
Subject: [cdt-dev] INodeFactory and ICPPNodeFactory

Hi,


IASTTranslationUnit ast = CurrentGui.getInstance().getGui().getAST(file);
ASTRewrite r = ASTRewrite.create( ast );
addIncludeDirectives(ast, r, className + ".h");

 INodeFactory factory = ast.getASTNodeFactory();

I have ast, is there a way to get ICPPNodeFactory? I want to "new" a class declaration as simple and natural as possible. For example I don't want ASTRewrite's createLiteralNode to get a IASTNode.  Then to add some class's elements. I prefer to get a IASTSimpleDeclaration with ICPPASTCompositeTypeSpecifier.k_class .

Rgds.
Ming Cheng

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

Re: INodeFactory and ICPPNodeFactory

Ming Cheng

Hi Nate,

 

IASTTranslationUnit ast = CurrentGui.getInstance().getGui().getAST(file);  // file is an empty file with .cpp extention.

Will if (ast instanceof ICPPASTTranslationUnit) succeed?

 

Thanks.

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: Thursday, February 27, 2020 10:37 AM
To: [hidden email]; [hidden email]
Subject: Re: INodeFactory and ICPPNodeFactory

 

A C++ translation unit will have a C++ node factory. So, code like the following is reasonable:

if (ast instanceof ICPPASTTranslationUnit) {
  ICPPNodeFactory cppNodeFactory = (ICPPNodeFactory) ast.getASTNodeFactory();
  // use cppNodeFactory
} else {
  // not a C++ translation unit
}

Hope that helps,
Nate

________________________________________
From: [hidden email] <[hidden email]> on behalf of Ming Cheng <[hidden email]>
Sent: February 27, 2020 2:16 AM
To: CDT General developers list.
Subject: Re: [cdt-dev] INodeFactory and ICPPNodeFactory

I know everyone is very busy.
Hope any expert can give some guide.

Thank you very much!

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: Ming Cheng<[hidden email]>
Sent: Wednesday, February 26, 2020 4:52 PM
To: [hidden email]<[hidden email]>
Subject: [cdt-dev] INodeFactory and ICPPNodeFactory

Hi,


IASTTranslationUnit ast = CurrentGui.getInstance().getGui().getAST(file);
ASTRewrite r = ASTRewrite.create( ast );
addIncludeDirectives(ast, r, className + ".h");

 INodeFactory factory = ast.getASTNodeFactory();

I have ast, is there a way to get ICPPNodeFactory? I want to "new" a class declaration as simple and natural as possible. For example I don't want ASTRewrite's createLiteralNode to get a IASTNode.  Then to add some class's elements. I prefer to get a IASTSimpleDeclaration with ICPPASTCompositeTypeSpecifier.k_class .

Rgds.
Ming Cheng

 


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

Re: INodeFactory and ICPPNodeFactory

Nathan Ridge
> IASTTranslationUnit ast = CurrentGui.getInstance().getGui().getAST(file);  // file is an empty > file with .cpp extention.
> Will if (ast instanceof ICPPASTTranslationUnit) succeed?

It should, yes.
_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: INodeFactory and ICPPNodeFactory

Ming Cheng

Hi Nathan,

 

It works and thanks.

 

Sent from Mail for Windows 10

 


From: Nathan Ridge <[hidden email]>
Sent: Thursday, February 27, 2020 10:51:06 AM
To: Ming Cheng <[hidden email]>; CDT General developers list. <[hidden email]>
Subject: Re: INodeFactory and ICPPNodeFactory
 
> IASTTranslationUnit ast = CurrentGui.getInstance().getGui().getAST(file);  // file is an empty > file with .cpp extention.
> Will if (ast instanceof ICPPASTTranslationUnit) succeed?

It should, yes.

_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev