Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] INodeFactory and ICPPNodeFactory
  • From: Ming Cheng <chengm349@xxxxxxxxxxx>
  • Date: Thu, 27 Feb 2020 02:39:40 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Of3Jb0sUTfzYAiwAwe2hj+4fKj3j9Cf8GSQ4R1CP62E=; b=meN6LJ3VkyHVdgdARCNedXd2BB2fGE/QFErdYVnQEyMLpnsKYMprV9BBdQEMuDtMyD2ioXBkm2NDPhVXOTQe4y8TloLYVIac/6zLrLHzKOPQsLxNnL1naxtblvz2Ym0CadHbMtSnjjxXnQUprHuZgeEFMoGqWbbCVGDL29hc8SOEVDVTijMSGFLnH7/9OokJN9S2Oup5QH53T6nqHJL+A+SPQeHGVucWS3AptdZFa6UIAGuixk5VjjZ4y90xz2xvotZFEoshVO7kSEW8GUiyRMD+wKOgwDtpEmdxLXpanpXc4UgdYwStmwA9EYRxUFu02yqtwf5SjK3HRnsO9/4WWg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W7YRRbwgzYMZg59gYQ7qpAp8aFx8vmNkdBvrF0Abv/Ow3gU+TQjRc9JvUvn3ZqheJdp3LYJGSEZSxvqg1EDx6i+Z6rxu0ZUzevzVZFXIiTnZlttM6Iai8OhJ08df6/0gtfzrXmlTRvZRibj8U9ol2BNtGo0xgHB3jD7OiH/M3MH783iTgMZzp+j3dlo6d7tbgAoea7E7sOvdE3D8FRN73KZ+LWsO3FaSakg7AnvvCGtrwUMLzzFwvRrrb54JCne2jHhRUxjrlRJknQQyLpoWjIsUxd0X7kqJ8URWyDRTOStD8SbtlCsmtZN1HMwZfGpnomn1D4frxWRTQA1lUetOrA==
  • Delivered-to: cdt-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/cdt-dev>
  • List-help: <mailto:cdt-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/cdt-dev>, <mailto:cdt-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/cdt-dev>, <mailto:cdt-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHV7IBhDeL+/QVjdk+8ga2MEGuBRaguTpSagAAFeYiAAAD4AA==
  • Thread-topic: INodeFactory and ICPPNodeFactory

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: Nathan Ridge
Sent: Thursday, February 27, 2020 10:37 AM
To: Ming Cheng; CDT General developers list.
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: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Ming Cheng <chengm349@xxxxxxxxxxx>
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:chengm349@xxxxxxxxxxx>
Sent: Wednesday, February 26, 2020 4:52 PM
To: cdt-dev@xxxxxxxxxxx<mailto:cdt-dev@xxxxxxxxxxx>
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

 


Back to the top