NanoContainer
  1. NanoContainer
  2. NANO-156

Building parent and child from same script at different scopes gives groovy syntax error

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0-RC2
    • Fix Version/s: 1.0
    • Component/s: groovy
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Building parent AND child from same script at different scopes gives groovy compilation error.
      Building only one does not.

      nano = builder.container(parent:parent, scope:assemblyScope) {
      if ( assemblyScope instanceof ParentAssemblyScope )

      { component(A) }

      else if ( assemblyScope instanceof SomeAssemblyScope ){
      component(B)
      }
      }

      See GroovyNodeBuilderTestCase#testBuildContainerWithParentAndChildAssemblyScopes()

        Activity

        Hide
        Paul Hammant added a comment -

        That's because that is not how Groovy works (unless someone corrects me)

        nano = builder.container(parent:parent, scope:assemblyScope)

        { component(A) component(B) }

        is kosher.

        nano = builder.container(parent:parent, scope:assemblyScope) {
        }
        if ( assemblyScope instanceof ParentAssemblyScope )

        { nano.component(A) }

        else if ( assemblyScope instanceof SomeAssemblyScope )

        { nano.component(B) }

        is too I suspect.

        Show
        Paul Hammant added a comment - That's because that is not how Groovy works (unless someone corrects me) nano = builder.container(parent:parent, scope:assemblyScope) { component(A) component(B) } is kosher. nano = builder.container(parent:parent, scope:assemblyScope) { } if ( assemblyScope instanceof ParentAssemblyScope ) { nano.component(A) } else if ( assemblyScope instanceof SomeAssemblyScope ) { nano.component(B) } is too I suspect.
        Paul Hammant made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]
        Hide
        Michael Rimov added a comment -

        Ok, I know this is closed, and I even advocated that Mauro close it. But now I've been reading http://groovy.codehaus.org/GroovyMarkup and I'm starting to wonder if perhaps this is a legit issue?

        In particular, this is the example in the Groovy docs that caught my eye:
        ----------------------------------------------------------------------------------------
        What's more is this is native Groovy syntax; so you can mix and match this markup syntax with any other Groovy features (iteration, branching, method calls, variables, expressions etc). e.g.

        def widget = swing.frame(title:'My Frame', defaultCloseOperation:javax.swing.WindowConstants.EXIT_ON_CLOSE) {
        panel() {
        for (entry in someBean)

        { label(text:entry.key) textField(text:entry.value) }

        button(text:'OK', actionPerformed:{ println("I've been clicked with event $

        {it}

        ") })
        }
        }

        ----------------------------------------------------------------------------------------

        Is this something that should be reopened?

        Show
        Michael Rimov added a comment - Ok, I know this is closed, and I even advocated that Mauro close it. But now I've been reading http://groovy.codehaus.org/GroovyMarkup and I'm starting to wonder if perhaps this is a legit issue? In particular, this is the example in the Groovy docs that caught my eye: ---------------------------------------------------------------------------------------- What's more is this is native Groovy syntax; so you can mix and match this markup syntax with any other Groovy features (iteration, branching, method calls, variables, expressions etc). e.g. def widget = swing.frame(title:'My Frame', defaultCloseOperation:javax.swing.WindowConstants.EXIT_ON_CLOSE) { panel() { for (entry in someBean) { label(text:entry.key) textField(text:entry.value) } button(text:'OK', actionPerformed:{ println("I've been clicked with event $ {it} ") }) } } ---------------------------------------------------------------------------------------- Is this something that should be reopened?
        Hide
        Mauro Talevi added a comment -

        Not sure I see how the example is relevant in this case. Can you expand on it?
        I still have a feeling it is an issue - which we may or may not be able to solve.

        Show
        Mauro Talevi added a comment - Not sure I see how the example is relevant in this case. Can you expand on it? I still have a feeling it is an issue - which we may or may not be able to solve.
        Hide
        Paul Hammant added a comment -

        Ignore my previous advice - it was wrong. The issue is deep in Groovy. A Reader is not being reset before its second use. Proof is that script now works when new StringReader(..) makes test go green.

        Show
        Paul Hammant added a comment - Ignore my previous advice - it was wrong. The issue is deep in Groovy. A Reader is not being reset before its second use. Proof is that script now works when new StringReader(..) makes test go green.
        Paul Hammant made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Paul Hammant [ paul ]

          People

          • Assignee:
            Paul Hammant
            Reporter:
            Mauro Talevi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: