Simple explicitly typed method call

20 views
Skip to first unread message

Andrea Peruffo

unread,
Jun 12, 2015, 12:23:27 PM6/12/15
to treehugg...@googlegroups.com
Hi there,
first of all really thanks for the work that save me a lot of time in generating code ;-)

I'm trying to obtain something like:

Class.method(x: Int)

Unfortunately the only two way to construct the desired syntax I found close to my problem doesn't fit:

REF("Class") DOT("method") APPLY(PARAM("x", IntClass))

Class.method(val x: Int)

and
REF("Class") DOT("method") APPLY(REF("x") withType(IntClass))

Class.method((x: Int))

Any way to get the job done?

Thanks in advance.

Andrea

eugene yokota

unread,
Jun 12, 2015, 12:32:44 PM6/12/15
to treehugg...@googlegroups.com
Glad you like treehugger!

What's wrong with Class.method((x: Int))?
You want to eliminate the extra paren or does it actually cause semantic difference?

-eugene


--
You received this message because you are subscribed to the Google Groups "treehugger-scala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to treehugger-sca...@googlegroups.com.
To post to this group, send email to treehugg...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/treehugger-scala/a37aca88-3dd0-48d1-9e4b-e94282daa462%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrea Peruffo

unread,
Jun 12, 2015, 12:36:04 PM6/12/15
to treehugg...@googlegroups.com
exactly, and, in some cases to have a default param...

--
You received this message because you are subscribed to a topic in the Google Groups "treehugger-scala" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/treehugger-scala/Yo8acK6wTV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to treehugger-sca...@googlegroups.com.

To post to this group, send email to treehugg...@googlegroups.com.

eugene yokota

unread,
Jun 12, 2015, 12:40:18 PM6/12/15
to treehugg...@googlegroups.com
ok. but don't they mean the same thing in this case though?


Andrea Peruffo

unread,
Jun 12, 2015, 12:43:13 PM6/12/15
to treehugg...@googlegroups.com
err... ok, I'm working on generating a play "routes" file, 
also I will like to have a very clean syntax.

eugene yokota

unread,
Jun 12, 2015, 12:52:11 PM6/12/15
to treehugg...@googlegroups.com
Eliminating parens is easy, but I have to make sure that any other trees that use this won't break.
For instance someone could be generating something like:

    (x: Int) + _

Now it might turn into 

    x: Int + _

From pretty printer's point of view Typed is just Typed right now.

I'm up for making special cases to make things look prettier, but some compromises need to be made since we are generating Tree first.


Andrea Peruffo

unread,
Jun 12, 2015, 1:53:40 PM6/12/15
to treehugg...@googlegroups.com
Is it possible to provide a modified pretty printer ad hoc to ```treeToString``` method(implicit parameter i.e.)?

b.t.w. 
really prompt answers, thanks a lot!

Andrea Peruffo

unread,
Jun 16, 2015, 11:38:34 AM6/16/15
to treehugg...@googlegroups.com
I realised that the custom injectable TreePrinter will solve all of my problems.

I have made a demo of what needed here:

This is completely retro-compatible, if you agree I can PR it...

Thanks in advance.

Andrea
Reply all
Reply to author
Forward
0 new messages