X

Geertjan's Blog

  • August 20, 2007

Groovy Import Aliasing in the IDE

Geertjan Wielenga
Product Manager

Join the discussion

Comments ( 4 )
  • swaroop belur Monday, August 20, 2007

    Geertjan

    I did not get the use case of this feature.

    Do u mean to say that instead of using

    ItemLabelAnchor ila = ....

    I can use

    ILA ila = ...

    If so this does NOT make good reading/maintenance as well


  • Daniel Sheppard Tuesday, August 21, 2007

    Swaroop,

    My understanding is that import aliasing exists to allow otherwise identical class names to be disambiguated without having to provide a full class name and the chance to reduce particularly long class names to something more memorable.

    For example,

    import java.util.Label

    import com.company.acme.Label as AcmeLabel

    import org.jfree.chart.labels.StandardCategoryItemLabelGenerator as LabelGenerator


  • Geertjan Tuesday, August 21, 2007

    swaroop, what Daniel writes above is my understanding too. Plus, it's easier to write "BF" than "BorderFactory". But, I didn't invent this, so don't blame me if you don't like it. That's Groovy. Look up Groovy and write to those guys if you have problems with this. In terms of reading/maintenance, the screenshot above shows you quite clearly how the IDE can help you by providing syntax coloring so that at one glance you can see your import aliases.


  • Willem Wednesday, August 22, 2007

    Could I ask which plugin this is ? Is this the Coyote plugin you mentioned in some previous post or is this some other dedicated Groovy/Grails plugin ?


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha