Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9266

Extension method metaClass lacks closure metadata for IDE/STC

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.17, 2.5.8, 3.0.0-beta-3
    • 2.5.9, 3.0.0-rc-1
    • None
    • None

    Description

      The two "metaClass" methods of DefaultGroovyMethods accept a Closure but do not indicate delegate or parameter metadata.

      public static MetaClass metaClass(Class self, Closure closure) ...
      public static MetaClass metaClass(Object self, Closure closure) ...
      

      Both methods pass the closure to ExpandoMetaClass.define which also lacks metadata. Here is the proposed change to that method, which could be propagated to the DGMs:

          public ExpandoMetaClass define(@ClosureParams(value=SimpleType.class, options="java.lang.Object")
                  @DelegatesTo(value=DefiningClosure.class, strategy=Closure.DELEGATE_ONLY) Closure closure) {
              final DefiningClosure definer = new DefiningClosure();
              Object delegate = closure.getDelegate();
              closure.setDelegate(definer);
              closure.setResolveStrategy(Closure.DELEGATE_ONLY);
              closure.call((Object)null);
              closure.setDelegate(delegate);
              closure.setResolveStrategy(Closure.DELEGATE_FIRST);
              definer.definition = false;
              return this;
          }
      

      Note: Not sure exactly how to indicate that the parameter is "null" or if that's important.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h