This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Code templates for IDEA

8 replies
edmondo1984
Joined: 2011-09-14,
User offline. Last seen 28 weeks 3 days ago.
Dear all,has someone created or knows how to create live templates for most common scala collection methods, such as foreach, map, collect, and so on?
Best Regards
Edmondo
H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.
Re: Code templates for IDEA

Am 28.12.2011 16:22, schrieb Edmondo Porcu:
> Dear all,
> has someone created or knows how to create live templates for most
> common scala collection methods, such as foreach, map, collect, and so on?
>
> Best Regards
>
> Edmondo
what exactly is the boilerplate you are trying to template away?
anyway, you can take a look at the existing templates for for loops

Donald McLean
Joined: 2009-11-11,
User offline. Last seen 2 years 48 weeks ago.
Re: Code templates for IDEA

The existing templates are of the form:

for (a <- bob) { doStuff(a) }

I think the OP is looking for stuff more like:

bob.foreach((a) => doStuff(a))

On Wed, Dec 28, 2011 at 1:26 PM, HamsterofDeath wrote:
> Am 28.12.2011 16:22, schrieb Edmondo Porcu:
>> Dear all,
>> has someone created or knows how to create live templates for most
>> common scala collection methods, such as foreach, map, collect, and so on?
>>
>> Best Regards
>>
>> Edmondo
> what exactly is the boilerplate you are trying to template away?
> anyway, you can take a look at the existing templates for for loops

H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.
Re: Code templates for IDEA

but you can easily modify them

Am 28.12.2011 20:27, schrieb Donald McLean:
> The existing templates are of the form:
>
> for (a <- bob) { doStuff(a) }
>
> I think the OP is looking for stuff more like:
>
> bob.foreach((a) => doStuff(a))
>
> On Wed, Dec 28, 2011 at 1:26 PM, HamsterofDeath wrote:
>> Am 28.12.2011 16:22, schrieb Edmondo Porcu:
>>> Dear all,
>>> has someone created or knows how to create live templates for most
>>> common scala collection methods, such as foreach, map, collect, and so on?
>>>
>>> Best Regards
>>>
>>> Edmondo
>> what exactly is the boilerplate you are trying to template away?
>> anyway, you can take a look at the existing templates for for loops

Geir Hedemark
Joined: 2011-11-01,
User offline. Last seen 42 years 45 weeks ago.
Re: Code templates for IDEA

On 2011, Dec 28, at 7:26 PM, HamsterofDeath wrote:
>> has someone created or knows how to create live templates for most
>> common scala collection methods, such as foreach, map, collect, and so on?
> what exactly is the boilerplate you are trying to template away?
> anyway, you can take a look at the existing templates for for loops

I don't know if cmd/ctrl-p (for show parameters) will help, but I find that helps a lot, personally.

yours
Geir

edmondo1984
Joined: 2011-09-14,
User offline. Last seen 28 weeks 3 days ago.
Re: Code templates for IDEA
I did it but and I created a template for foreach,
but it doesn't work as expected because:
- It doesn't guess or propose the transversable name- It doesn't propose the name of the temporary variable to store the current element
bEst Regards

2011/12/29 Geir Hedemark <geir.hedemark@gmail.com>
On 2011, Dec 28, at 7:26 PM, HamsterofDeath wrote:
>> has someone created or knows how to create live templates for most
>> common scala collection methods, such as foreach, map, collect, and so on?
> what exactly is the boilerplate you are trying to template away?
> anyway, you can take a look at the existing templates for for loops

I don't know if cmd/ctrl-p (for show parameters) will help, but I find that helps a lot, personally.

yours
Geir


H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.
Re: Code templates for IDEA
Am 29.12.2011 09:22, schrieb Edmondo Porcu:
zBHkFfWsxrL0_saiBVG2uTQ [at] mail [dot] gmail [dot] com" type="cite">I did it but and I created a template for foreach,
but it doesn't work as expected because:
- It doesn't guess or propose the transversable name - It doesn't propose the name of the temporary variable to store the current element
bEst Regards

2011/12/29 Geir Hedemark <geir [dot] hedemark [at] gmail [dot] com" rel="nofollow">geir.hedemark@gmail.com>
On 2011, Dec 28, at 7:26 PM, HamsterofDeath wrote:
>> has someone created or knows how to create live templates for most
>> common scala collection methods, such as foreach, map, collect, and so on?
> what exactly is the boilerplate you are trying to template away?
> anyway, you can take a look at the existing templates for for loops

I don't know if cmd/ctrl-p (for show parameters) will help, but I find that helps a lot, personally.

yours
Geir


open original working template
press "edit variables" and take a look at the important parts you are probably missing



edmondo1984
Joined: 2011-09-14,
User offline. Last seen 28 weeks 3 days ago.
Re: Code templates for IDEA
Dear All,
I actually discovered there are some Expressions for scala which you don't find in the list. I have found them investigating existing scala template.

Namely they are

scalaVariableOfType

suggestScalaVariableName

Do you have an idea of where one can find more details?

Best Regards

2011/12/29 HamsterofDeath <h-star@gmx.de>
Am 29.12.2011 09:22, schrieb Edmondo Porcu:
I did it but and I created a template for foreach,
but it doesn't work as expected because:
- It doesn't guess or propose the transversable name - It doesn't propose the name of the temporary variable to store the current element
bEst Regards

2011/12/29 Geir Hedemark <geir.hedemark@gmail.com>
On 2011, Dec 28, at 7:26 PM, HamsterofDeath wrote:
>> has someone created or knows how to create live templates for most
>> common scala collection methods, such as foreach, map, collect, and so on?
> what exactly is the boilerplate you are trying to template away?
> anyway, you can take a look at the existing templates for for loops

I don't know if cmd/ctrl-p (for show parameters) will help, but I find that helps a lot, personally.

yours
Geir


open original working template
press "edit variables" and take a look at the important parts you are probably missing




H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.
Re: Code templates for IDEA

-------- Original-Nachricht --------
> Datum: Wed, 11 Jan 2012 12:10:28 +0100
> Von: Edmondo Porcu
> An: scala-user
> Betreff: Re: [scala-user] Code templates for IDEA

> Dear All,
> I actually discovered there are some Expressions for scala which you don't
> find in the list. I have found them investigating existing scala template.
>
> Namely they are
>
> scalaVariableOfType
>
> suggestScalaVariableName
>
> Do you have an idea of where one can find more details?
>
> Best Regards
>
> 2011/12/29 HamsterofDeath
>
> > Am 29.12.2011 09:22, schrieb Edmondo Porcu:
> >
> > I did it but and I created a template for foreach,
> >
> > but it doesn't work as expected because:
> >
> > - It doesn't guess or propose the transversable name
> > - It doesn't propose the name of the temporary variable to store the
> > current element
> >
> > bEst Regards
> >
> > 2011/12/29 Geir Hedemark
> >
> >> On 2011, Dec 28, at 7:26 PM, HamsterofDeath wrote:
> >> >> has someone created or knows how to create live templates for most
> >> >> common scala collection methods, such as foreach, map, collect, and
> so
> >> on?
> >> > what exactly is the boilerplate you are trying to template away?
> >> > anyway, you can take a look at the existing templates for for loops
> >>
> >> I don't know if cmd/ctrl-p (for show parameters) will help, but I find
> >> that helps a lot, personally.
> >>
> >> yours
> >> Geir
> >>
> >>
> > open original working template
> > press "edit variables" and take a look at the important parts you are
> > probably missing
> >
> >
> >
> >

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland