Groovy
  1. Groovy
  2. GROOVY-6043

Precompiled typechecking extension scripts

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2.0-beta-1
    • Component/s: Static Type Checker
    • Labels:
      None

      Description

      It would be rather desirable to allow pre-compiled typechecking scripts, if reasonably possible.

      Not only the repeated compilation of the script considerably increases the build time (and with hundreds of sources the difference is not negligible); besides, if one uses AST transforms, they get each time applied to the script, too.

      Most transforms are probably not written to do that – myself, I had to check explicitly for sourceUnit.name=='Script1.groovy' and skip the transform in this case, but that's an extremely ugly and highly fragile solution.

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        1d 22h 36m 1 Cédric Champeau 13/Mar/13 13:11
        Resolved Resolved Closed Closed
        118d 15h 30m 1 Paul King 10/Jul/13 04:42
        Mark Thomas made changes -
        Workflow jira [ 12972412 ] Default workflow, editable Closed status [ 12980242 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12734956 ] Default workflow, editable Closed status [ 12746639 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Cédric Champeau made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Assignee Cedric Champeau [ melix ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.2.0-beta-1 [ 19074 ]
        Hide
        Cédric Champeau added a comment -

        Support has been pushed to master. Technically, you have to use:

        @TypeChecked(extensions='fully.qualified.class.Name')
        void foo() { ... }
        

        The extension can be pre-compiled using:

        groovyc -b org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingDSL MyExtension.groovy
        

        Or you can use a class wrapping the script, like the unit test does:

        package groovy.transform.stc
        
        import org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport
        
        class PrecompiledExtension extends GroovyTypeCheckingExtensionSupport.TypeCheckingDSL {
        
            Object run() {
                // body of the script
                setup {
                    addStaticTypeError('Error thrown from extension', context.enclosingClassNode)
                }
            }
        }
        
        Show
        Cédric Champeau added a comment - Support has been pushed to master . Technically, you have to use: @TypeChecked(extensions='fully.qualified.class.Name') void foo() { ... } The extension can be pre-compiled using: groovyc -b org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingDSL MyExtension.groovy Or you can use a class wrapping the script, like the unit test does: package groovy.transform.stc import org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport class PrecompiledExtension extends GroovyTypeCheckingExtensionSupport.TypeCheckingDSL { Object run() { // body of the script setup { addStaticTypeError('Error thrown from extension', context.enclosingClassNode) } } }
        OC created issue -

          People

          • Assignee:
            Cédric Champeau
            Reporter:
            OC
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development