<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Closure folding in IntelliJ IDEA 9 (Maia)</title>
	<atom:link href="http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/</link>
	<description>tips &#38; tricks, news, how-to's</description>
	<pubDate>Mon, 22 Mar 2010 09:08:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
		<item>
		<title>By: Vadim Pesochinskiy</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-112607</link>
		<dc:creator>Vadim Pesochinskiy</dc:creator>
		<pubDate>Tue, 07 Jul 2009 21:00:27 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-112607</guid>
		<description>I have following code which have to retry something action. I downloaded Maia in anticipation of tada moment, but nothing happens.

new Retry(3,5000).run(new Retry.If(new Class[] {RemoteException.class} ) {
       public void exec() throws Exception {
                   ; // do something that throws RemoteException
       }
});

I was kinda hoping to see this:

new Retry(3,5000).run(new Retry.If(...) {
       ; // do something that throws RemoteException
});

So, where is the trick :-( ?  I am bitterly disappointed. Make me smile!</description>
		<content:encoded><![CDATA[<p>I have following code which have to retry something action. I downloaded Maia in anticipation of tada moment, but nothing happens.</p>
<p>new Retry(3,5000).run(new Retry.If(new Class[] {RemoteException.class} ) {<br />
       public void exec() throws Exception {<br />
                   ; // do something that throws RemoteException<br />
       }<br />
});</p>
<p>I was kinda hoping to see this:</p>
<p>new Retry(3,5000).run(new Retry.If(&#8230;) {<br />
       ; // do something that throws RemoteException<br />
});</p>
<p>So, where is the trick <img src='http://blogs.jetbrains.com/idea/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> ?  I am bitterly disappointed. Make me smile!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Piotr Gabryanczyk</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-111824</link>
		<dc:creator>Piotr Gabryanczyk</dc:creator>
		<pubDate>Fri, 26 Jun 2009 15:10:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-111824</guid>
		<description>Have a look at closures project.
http://code.google.com/p/closures/

It does simple closures in java and with IntelliJ "inject language" feature it works brilliantly!

Following things are now possible in java:
--------------------------------------------------

each(asList("a","b","c"), "print 'Element '+it+'\n'")
will print to the System.out:

Element a
Element b
Element c

find(asList("ab", "abc", "bc", "bcd"), "it =~ /.*a.*/; ");
=&#62; "ab"


findAll(asList(1,2,3,4,5,6,7), "it % 2 == 0")
=&#62; [2,4,6]

findAll(asList("ab", "abc", "bc", "bcd"), "it =~ /.*a.*/")
=&#62; ["ab", "abc"]

collect(asList(1,2,3), "it *it")
=&#62; [1,4,9]

any(asList("ab", "abc", "bc", "bcd"), "it =~ /bc/; ")
=&#62; true

any(asList("ab", "abc", "bc", "bcd"), "it =~ /bcde/; ")
=&#62;false

every(asList("ab", "abc", "bc", "bcd"), "it.length() &#62; 0")
=&#62; true

every(asList("ab", "abc", "bc", "bcd"), "it =~ /.*a.*/; ")
=&#62; false</description>
		<content:encoded><![CDATA[<p>Have a look at closures project.<br />
<a href="http://code.google.com/p/closures/" rel="nofollow">http://code.google.com/p/closures/</a></p>
<p>It does simple closures in java and with IntelliJ &#8220;inject language&#8221; feature it works brilliantly!</p>
<p>Following things are now possible in java:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>each(asList(&#8221;a&#8221;,&#8221;b&#8221;,&#8221;c&#8221;), &#8220;print &#8216;Element &#8216;+it+&#8217;\n&#8217;&#8221;)<br />
will print to the System.out:</p>
<p>Element a<br />
Element b<br />
Element c</p>
<p>find(asList(&#8221;ab&#8221;, &#8220;abc&#8221;, &#8220;bc&#8221;, &#8220;bcd&#8221;), &#8220;it =~ /.*a.*/; &#8220;);<br />
=&gt; &#8220;ab&#8221;</p>
<p>findAll(asList(1,2,3,4,5,6,7), &#8220;it % 2 == 0&#8243;)<br />
=&gt; [2,4,6]</p>
<p>findAll(asList(&#8221;ab&#8221;, &#8220;abc&#8221;, &#8220;bc&#8221;, &#8220;bcd&#8221;), &#8220;it =~ /.*a.*/&#8221;)<br />
=&gt; ["ab", "abc"]</p>
<p>collect(asList(1,2,3), &#8220;it *it&#8221;)<br />
=&gt; [1,4,9]</p>
<p>any(asList(&#8221;ab&#8221;, &#8220;abc&#8221;, &#8220;bc&#8221;, &#8220;bcd&#8221;), &#8220;it =~ /bc/; &#8220;)<br />
=&gt; true</p>
<p>any(asList(&#8221;ab&#8221;, &#8220;abc&#8221;, &#8220;bc&#8221;, &#8220;bcd&#8221;), &#8220;it =~ /bcde/; &#8220;)<br />
=&gt;false</p>
<p>every(asList(&#8221;ab&#8221;, &#8220;abc&#8221;, &#8220;bc&#8221;, &#8220;bcd&#8221;), &#8220;it.length() &gt; 0&#8243;)<br />
=&gt; true</p>
<p>every(asList(&#8221;ab&#8221;, &#8220;abc&#8221;, &#8220;bc&#8221;, &#8220;bcd&#8221;), &#8220;it =~ /.*a.*/; &#8220;)<br />
=&gt; false</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Knauf</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-111397</link>
		<dc:creator>Aaron Knauf</dc:creator>
		<pubDate>Fri, 19 Jun 2009 14:01:24 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-111397</guid>
		<description>This sounds like a fantastic feature.  Lots of good ideas in these comments.  Key things that I would like:  let me concentrate on the code - not the boilerplate.  Don't show me the "new EventListener(){ onClick(MouseEvent e){} }" bit, unless necessary to disambiguate.  Just show me the code that I need to write. e.g.

addListener(...{...(MouseEvent e){
    doStuff(e);
}});

I would avoid trying to fold anonymous classes into a closure syntax that resembles some other language, like ruby, or C#, or one of the proposals for java closures (which James Gosling reckons are off the cards now anyway).  There just isn't any one of those syntaxes that has a dominant support base.  Use the folding syntax that you already use throughout IDEA, which all of your users are already familiar with.</description>
		<content:encoded><![CDATA[<p>This sounds like a fantastic feature.  Lots of good ideas in these comments.  Key things that I would like:  let me concentrate on the code - not the boilerplate.  Don&#8217;t show me the &#8220;new EventListener(){ onClick(MouseEvent e){} }&#8221; bit, unless necessary to disambiguate.  Just show me the code that I need to write. e.g.</p>
<p>addListener(&#8230;{&#8230;(MouseEvent e){<br />
    doStuff(e);<br />
}});</p>
<p>I would avoid trying to fold anonymous classes into a closure syntax that resembles some other language, like ruby, or C#, or one of the proposals for java closures (which James Gosling reckons are off the cards now anyway).  There just isn&#8217;t any one of those syntaxes that has a dominant support base.  Use the folding syntax that you already use throughout IDEA, which all of your users are already familiar with.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Gromov</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-111204</link>
		<dc:creator>Peter Gromov</dc:creator>
		<pubDate>Mon, 15 Jun 2009 13:47:13 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-111204</guid>
		<description>Jim, the equals folding sounds reasonable, could you file a JIRA issue for it?

As for closures, I don't completely understand which glyphs you want to display. &#124; meaning 'as' also seems strange for a Java person.</description>
		<content:encoded><![CDATA[<p>Jim, the equals folding sounds reasonable, could you file a JIRA issue for it?</p>
<p>As for closures, I don&#8217;t completely understand which glyphs you want to display. | meaning &#8216;as&#8217; also seems strange for a Java person.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Popovich</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-111168</link>
		<dc:creator>Jim Popovich</dc:creator>
		<pubDate>Mon, 15 Jun 2009 01:56:25 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-111168</guid>
		<description>the first paragraph some how was garbled when submitted on the web site,

in long hand so it does not get garbled.

suggest that we can display different single glph chars for EQUAL vs DOUBLE EQUALS vs NOT EQUALS and you see the NOT EQUALS like a mathematical not-equal with a diagonal slash.  the single EQUAL is drawn as a LEFT ARROW  we use a RIGHT arrow in closure params separator and a graphic equals means equals = = .
you could have a really long graphical like 3 or 4 equals to swap in method .equals
so that you can see

mini = = = =  me

rather than mini.equals(me)</description>
		<content:encoded><![CDATA[<p>the first paragraph some how was garbled when submitted on the web site,</p>
<p>in long hand so it does not get garbled.</p>
<p>suggest that we can display different single glph chars for EQUAL vs DOUBLE EQUALS vs NOT EQUALS and you see the NOT EQUALS like a mathematical not-equal with a diagonal slash.  the single EQUAL is drawn as a LEFT ARROW  we use a RIGHT arrow in closure params separator and a graphic equals means equals = = .<br />
you could have a really long graphical like 3 or 4 equals to swap in method .equals<br />
so that you can see</p>
<p>mini = = = =  me</p>
<p>rather than mini.equals(me)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Popovich</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-111166</link>
		<dc:creator>Jim Popovich</dc:creator>
		<pubDate>Mon, 15 Jun 2009 01:51:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-111166</guid>
		<description>Expanding on this, you should add a config flag to "graphically" distinguish = form ==
using = means draw  (glpyh) onNodeChanged()}  &#124; (glyph) ActionListener );

the &#124; reads AS   meaning the {} closure created AS a new ActionListener

so that if you had many you could see


pretend that there are 2 of the ActionListener classes

    addActionListener( {ActionEvent e --&#62;(glpyh) onNodeChanged()}  &#124; (glyph) ActionListener );

   addActionListener( {ActionEvent e --&#62;(glpyh) onSuperNodeChanged()}  &#124; (glyph) ActionListenerSuper );


And you can use your "show me the Camel's" flag to just render the camels, which is very concise.

  addActionListener( {AE e --&#62;(glpyh) onNodeChanged()}  &#124; (glyph) AL );

  addActionListener( {AE e --&#62;(glpyh) onSuperNodeChanged()}  &#124; (glyph) ALS );</description>
		<content:encoded><![CDATA[<p>Expanding on this, you should add a config flag to &#8220;graphically&#8221; distinguish = form ==<br />
using = means draw  (glpyh) onNodeChanged()}  | (glyph) ActionListener );</p>
<p>the | reads AS   meaning the {} closure created AS a new ActionListener</p>
<p>so that if you had many you could see</p>
<p>pretend that there are 2 of the ActionListener classes</p>
<p>    addActionListener( {ActionEvent e &#8211;&gt;(glpyh) onNodeChanged()}  | (glyph) ActionListener );</p>
<p>   addActionListener( {ActionEvent e &#8211;&gt;(glpyh) onSuperNodeChanged()}  | (glyph) ActionListenerSuper );</p>
<p>And you can use your &#8220;show me the Camel&#8217;s&#8221; flag to just render the camels, which is very concise.</p>
<p>  addActionListener( {AE e &#8211;&gt;(glpyh) onNodeChanged()}  | (glyph) AL );</p>
<p>  addActionListener( {AE e &#8211;&gt;(glpyh) onSuperNodeChanged()}  | (glyph) ALS );</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray Cromwell</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-108744</link>
		<dc:creator>Ray Cromwell</dc:creator>
		<pubDate>Tue, 12 May 2009 17:56:08 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-108744</guid>
		<description>BTW, this mechanism seems incredibly powerful and could resolve a whole range of issues with Java. It would allow each programmer to visualize source in a way that makes them most productive while keeping the source in a neutral format (i.e. Java). It seems like a sort of Intentional Programming.

I hope you guys take this and run with it. No need to wait on Sun/Oracle/JCP. You can add support for Closures, Type Inferencing, Operator Overloading, etc now. The editor can be taught to visualize these in a succinct way (e.g. BigDecimal.add() = '+')  while preserving source code compatibility on disk.</description>
		<content:encoded><![CDATA[<p>BTW, this mechanism seems incredibly powerful and could resolve a whole range of issues with Java. It would allow each programmer to visualize source in a way that makes them most productive while keeping the source in a neutral format (i.e. Java). It seems like a sort of Intentional Programming.</p>
<p>I hope you guys take this and run with it. No need to wait on Sun/Oracle/JCP. You can add support for Closures, Type Inferencing, Operator Overloading, etc now. The editor can be taught to visualize these in a succinct way (e.g. BigDecimal.add() = &#8216;+&#8217;)  while preserving source code compatibility on disk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray Cromwell</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-108742</link>
		<dc:creator>Ray Cromwell</dc:creator>
		<pubDate>Tue, 12 May 2009 17:48:33 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-108742</guid>
		<description>Why not adopt Neal Gafter's BGGA closures syntax?

Then you'd write:

addActionListener({ActionEvent e =&#62; onNodeChanged()});

Better yet, since some people might prefer the CICE or FCM proposals, why not make it a preference or pluggable?</description>
		<content:encoded><![CDATA[<p>Why not adopt Neal Gafter&#8217;s BGGA closures syntax?</p>
<p>Then you&#8217;d write:</p>
<p>addActionListener({ActionEvent e =&gt; onNodeChanged()});</p>
<p>Better yet, since some people might prefer the CICE or FCM proposals, why not make it a preference or pluggable?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Gromov</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-100375</link>
		<dc:creator>Peter Gromov</dc:creator>
		<pubDate>Mon, 23 Mar 2009 12:25:13 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-100375</guid>
		<description>Igor,

Actually the user can type inside these folded closures, so not displaying the parameters probably won't be correct since they can be still referenced and completed inside the closure. As for generics, instead of hiding them I can shorten them to &lt;~&gt; (if the corresponding folding is enabled). As I've already said, I'm strictly against hiding base class name, but this can be made an option if there are many proponents (probably a JIRA issue?).</description>
		<content:encoded><![CDATA[<p>Igor,</p>
<p>Actually the user can type inside these folded closures, so not displaying the parameters probably won&#8217;t be correct since they can be still referenced and completed inside the closure. As for generics, instead of hiding them I can shorten them to < ~> (if the corresponding folding is enabled). As I&#8217;ve already said, I&#8217;m strictly against hiding base class name, but this can be made an option if there are many proponents (probably a JIRA issue?).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Sereda</title>
		<link>http://blogs.jetbrains.com/idea/2009/03/closure-folding-in-intellij-idea-9-maia/#comment-97657</link>
		<dc:creator>Igor Sereda</dc:creator>
		<pubDate>Mon, 16 Mar 2009 12:03:14 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=319#comment-97657</guid>
		<description>Peter, 

I think if you display "ActionEvent" instead of "ActionEvent&#60;T&#62;" in the placeholder, that would be misleading. But I see what you mean. I think it makes sense to display type when needed and parameters when needed.

For example:

1. "ActionEvent e" is used, so we need to display it:

myNodeBox.addActionListener(ActionListener(ActionEvent e) { onNodeChanged(e); });

2. ActionEvent is not used, listener type is inferred:

myNodeBox.addActionListener({ onNodeChanged(); });

or at least (without type inference)

myNodeBox.addActionListener(ActionListener(...) { onNodeChanged(); });

3. Type cannot be inferred:

Object r = Runnable { doWork(); };</description>
		<content:encoded><![CDATA[<p>Peter, </p>
<p>I think if you display &#8220;ActionEvent&#8221; instead of &#8220;ActionEvent&lt;T&gt;&#8221; in the placeholder, that would be misleading. But I see what you mean. I think it makes sense to display type when needed and parameters when needed.</p>
<p>For example:</p>
<p>1. &#8220;ActionEvent e&#8221; is used, so we need to display it:</p>
<p>myNodeBox.addActionListener(ActionListener(ActionEvent e) { onNodeChanged(e); });</p>
<p>2. ActionEvent is not used, listener type is inferred:</p>
<p>myNodeBox.addActionListener({ onNodeChanged(); });</p>
<p>or at least (without type inference)</p>
<p>myNodeBox.addActionListener(ActionListener(&#8230;) { onNodeChanged(); });</p>
<p>3. Type cannot be inferred:</p>
<p>Object r = Runnable { doWork(); };</p>
]]></content:encoded>
	</item>
</channel>
</rss>
