AST: Adding RBComment to a node

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

AST: Adding RBComment to a node

Mehrdad
Hello,

How can I make a comment on a node dynamically?

- Here is a code i've tried:

b:= RBParser parseMethod: 'foo self x: 2. x:=0. y:=8.'.
node := b body statements at: 1.
node comments: { RBComment with: 'comment' at: node stop + 1 }.
b formattedCode.

- The result:

foo
    self x: 2.    . x:=0. y
    x := 0.
    y := 8

- I expect:

foo
    self x: 2.    "comment"
    x := 0.
    y := 8


Reply | Threaded
Open this post in threaded view
|

Re: AST: Adding RBComment to a node

Marcus Denker-4
Hello,

I checked it in both Pharo8 and Pharo9: The good news is that it works fine in Pharo 9!

But I did not check how much work it would be to back port the fix...

> On 23 Apr 2020, at 11:13, Mehrdad Abdi <[hidden email]> wrote:
>
> Hello,
>
> How can I make a comment on a node dynamically?
>
> - Here is a code i've tried:
>
> b:= RBParser parseMethod: 'foo self x: 2. x:=0. y:=8.'.
> node := b body statements at: 1.
> node comments: { RBComment with: 'comment' at: node stop + 1 }.
> b formattedCode.
>
> - The result:
>
> foo
>    self x: 2.    . x:=0. y
>    x := 0.
>    y := 8
>
> - I expect:
>
> foo
>    self x: 2.    "comment"
>    x := 0.
>    y := 8
>