My favorites | Sign in
Logo
                
Search
for
Updated Jul 22, 2009 by e.lucash
Labels: Featured, Phase-Design
WhyMagicCommentAsMarker  
purpose of magic comment /* => */

since v0.3

There is alternative folding provider "Lambda4jdt JavaStyle closures" to collapse ALL single method anonymous inner classes without required comment marker (but also without fancy => syntax)

So why was magic comment was chosen as marker?

1. Do not collapse unexpectedly every anonymous inner class, an option

2. Projection infrastructure only allows to hide portions of master document (cannot add chunks, just hide). So traditional => syntax would be not possible (it must be mentioned in document to show up between arguments and closure body)

3. Annotation (even with source retention policy) - unnecessary compile time dependency and see 2.

Magic comment was not some random decision.

Suggestion welcome.

P.S. In version 0.2 and higher supported alternative single line comment.

Arrays.sort(array, new Comparator<Object>() {
  public int compare(Object o1, Object o2)// => /
  {
    return o1.hashCode() - o2.hashCode();
  }
});

Sign in to add a comment
Hosted by Google Code