How to print parsed tree nicely?

12 views
Skip to the first unread message

Andrey Ilinykh

unread,
24 Oct 2015, 22:46:1124/10/2015
to Scala IDE Dev
Hello everybody!
I want to print a parsed tree. if I just call toString method I get something like Function1[Int,Int]. It is correct, but I want to have Int => Int. What is the best way to do it? I Looked into declaration printer, it heavily relies on Symbols (which are not available in parsed tree) and has to run on compiler thread. Is it possible to use declaration printer on any thread?

Thank you,
  Andrey

Simon Schäfer

unread,
25 Oct 2015, 06:30:4725/10/2015
to scala-...@googlegroups.com


On 10/25/2015 03:46 AM, Andrey Ilinykh wrote:
> I want to print a parsed tree. if I just call toString method I get
> something like Function1[Int,Int]. It is correct, but I want to have
> Int => Int. What is the best way to do it?
This is indeed a problem, which makes DeclarationPrinter useless. It
looks like you have to bite the bullet and reimplement parts of
DeclarationPrinter based only on the syntactical information.
> I Looked into declaration printer, it heavily relies on Symbols (which
> are not available in parsed tree) and has to run on compiler thread.
> Is it possible to use declaration printer on any thread?
No, that is not possible. It needs to run on the PC thread.

iulian dragos

unread,
26 Oct 2015, 06:19:5426/10/2015
to scala-ide-dev
On Sun, Oct 25, 2015 at 3:46 AM, Andrey Ilinykh <aili...@gmail.com> wrote:
Hello everybody!
I want to print a parsed tree. if I just call toString method I get something like Function1[Int,Int]. It is correct, but I want to have Int => Int. What is the best way to do it? I Looked into declaration printer, it heavily relies on Symbols (which are not available in parsed tree) and has to run on compiler thread. Is it possible to use declaration printer on any thread?

Indeed, the declaration printer is using Symbols so you won't be able to use it for parse trees. However, I think it does provide a good start for what cases need to be treated in a special way. Probably only a handful of cases FunctionN, TupleN come to mind.

iulian
 

Thank you,
  Andrey

--
You received this message because you are subscribed to the Google Groups "Scala IDE Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-dev/c1bd4c10-088a-4b1e-9c72-11894a0dd4e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais
Reply all
Reply to author
Forward
0 new messages