Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Constructing Compond statement without brackets

> But are there ways to actually force a change into a text file, read the change source file into an ast. That would also work . But all these need to be performed within one refactoring click. 

 

Well, that's what a refactoring does at the end - except for the creation of a new AST. But afaik there is no infrastructure in CDT refactorings to perform such a thing as intermediate step.

 

> I observed that IASTNode has only getChildren. Even if there is a way to set Children, that would solve the problem. I can have an IASTNode which I use for my intermediate modifications and then insert it at the end.

 

Modifications to the AST in general (or specifically the AST you get from the refactoring) are not supported, as they might be frozen. Therefore, such operations are not available through the public interfaces. If you have a copy of a specific node and you know its type, you should be able to modify it through the methods of the concrete class.

 

Regards

Thomas

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Krishna Narasimhan
Sent: Mittwoch, 22. Oktober 2014 15:36
To: CDT General developers list.
Subject: Re: [cdt-dev] Constructing Compond statement without brackets

 

I observed that IASTNode has only getChildren. Even if there is a way to set Children, that would solve the problem. I can have an IASTNode which I use for my intermediate modifications and then insert it at the end. 

 

On Wed, Oct 22, 2014 at 2:46 PM, Krishna Narasimhan <krishna.nm86@xxxxxxxxx> wrote:

Hi thanks for the response.

 

But are there ways to actually force a change into a text file, read the change source file into an ast. That would also work . But all these need to be performed within one refactoring click. 

 

And are there ways to insert / delete child nodes into an IASTNode. actually even this exists, that would suffice.

 

On Wed, Oct 22, 2014 at 2:33 PM, Corbat Thomas <tcorbat@xxxxxx> wrote:

Hi Krishna

 

Unfortunately, there is no such operation for getting an intermediate AST yet. While the AST could be created in such a way, there might be inconsistencies regarding location information (positions not corresponding to actual source code). That's one problem, but a much more severe issue would be to provide a complete resolution of the bindings for the intermediate AST. That goes far beyond of the capabilities of the ASTRewrite.

 

Regards

Thomas

 

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Krishna Narasimhan
Sent: Mittwoch, 22. Oktober 2014 14:27
To: CDT General developers list.
Subject: Re: [cdt-dev] Constructing Compond statement without brackets

 

I wanted to do that. But, I am currently using a very lame and crude approach of performing all my modifications on a IASTNode (which only supports replace and only when the node being modified is a AMbigiousNode).

 

This is because I was facing an issue with the ASTRewrite.

 

I have a question : 

 

1) How do I get the AST after every modification and continue to work on that AST . Basically how do I save and retreive the state of an AST after every rewrite operation and how do I use a Saved AST ... 

 

 

something like 

 

ASTRewrite rewriter = collector.getRewriterforast(ast);

rewriter.insertbefore(...)

astsaved = rewriter.getAST(ast)

 

 

Something like that... 

 

On Wed, Oct 22, 2014 at 8:14 AM, Corbat Thomas <tcorbat@xxxxxx> wrote:

Hi Krishna

 

A compound statement is always surrounded by curly braces. Can't you just insert the "bunch of other statements" before the statement which should be at the end?

 

Regards

Thomas

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Krishna Narasimhan
Sent: Montag, 20. Oktober 2014 12:04
To: CDT General developers list.
Subject: [cdt-dev] Constructing Compond statement without brackets

 

Dear all,

           I am trying to construct a replace a statement with a bunch of other statements and itself at the end. The problem I have here is that when I use a compound statement, it places a bracket . Anyway to remove this?

 


 

 

Regards
       Krishna


_______________________________________________
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



 

--
-----------------------------------------------------
I dare do all that may become a man; Who dares do more, is none - Macbeth, twelfh night!
Regards
       Krishna


_______________________________________________
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



 

--
-----------------------------------------------------
I dare do all that may become a man; Who dares do more, is none - Macbeth, twelfh night!
Regards
       Krishna



 

--
-----------------------------------------------------
I dare do all that may become a man; Who dares do more, is none - Macbeth, twelfh night!
Regards
       Krishna


Back to the top