Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] Applying Multiple Changes with Refactoring

Emanuel I don't see why one should not be allowed to insert an existing
ast-node to another place in the AST (which should create a copy). The 
ASTRewrite is built in a way that even allows you to separately modify
the
inserted ast-node independently of the ast-node in its original
location. 
This is because the insert operation returns a new ASTRewrite object
that 
operates on the inserted sub-tree, only.

Above that the change generator should make exact copies of the source
code
in such situations, which than nicely handles stuff that is not modelled
in 
the AST in every detail (e.g. __attribute__, asm-decls, concatenated
string
literals, ...)

Why does the change generator depend on getParent().
Markus. 

> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx 
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Emanuel Graf
> Sent: Tuesday, May 27, 2008 8:37 AM
> To: CDT General developers list.
> Subject: Re: [cdt-dev] Applying Multiple Changes with Refactoring
> Importance: Low
> 
> On Saturday 24 May 2008, student08 wrote:
> > Thanks it turned out the cause of my problem was trying to 
> re-use the 
> > declarators from the declaration to create a new function 
> prototype. 
> > Guess ASTRewrite didn't like that.
> 
> A re-used node is accessible by to parent nodes, but 
> getParent() returns only one node and this the cause for the 
> problem in the in the change generator.
> 
> > Just wondering if there's a simple way of copying all the 
> contents of 
> > the declarator from a declaration, or would I have to 
> iterate through 
> > all the declarator's contents one by one and create them anew?
> >
> No there isch no easy way to copy or clone a node. But you 
> can use an empty placeholder node to build your new node. And 
> replace the placeholder node with the existing node using a 
> replace modification. 
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
> 


Back to the top