groovy
  1. groovy
  2. GROOVY-6395

groovysh tab-complete properties of Map/Node instances

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.0-rc-1
    • Fix Version/s: 2.3.0-beta-1
    • Component/s: Groovysh
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Tab completion for groovysh currently does not provide candidates for map properties.
      To reproduce,: in groovysh

      groovy:000> x = ['someProperty': 42]
      ===> [someProperty:42]
      groovy:000> x.some

      pressing Tab does not yield results. However, x.someProperty is a valid notation to get the value.

      The same goes for Node instances, e.g.
      someBuilder = new NodeBuilder()
      ===> groovy.util.NodeBuilder@53b3da67
      groovy:000> node = someBuilder.foo(pop:3,pap:4){[bar(pop:2){}, baz()]}
      ===> foo[attributes=

      {pop=3, pap=4}

      ; value=[bar[attributes=

      {pop=2}

      ; value=[]], baz[attributes={}; value=[]]]]
      groovy:000> node.b

      Pressing tab will get nothing, but node.bar is a valid Groovy syntax.

      Both syntax usages for Map and Nodes are core to Groovy, and can significantly raise the benefits of using groovysh. E.g. Parsing an xml/config file in groovysh and then navigating the structure with tab completion to introspect and change would become a pleasure.

      Adding that Behavior would mean adding an instanceof check in ReflectionCompletor.complete, such that when an object is detected as Map instance, candidates are created from keySet(); simlar for groovy.util.Node(sadly not an interface ) and children(). So implementation would be a tiny change, but still might need discussion. Maybe some more important dot notation cases exist that I don't know of. Possibly at some point the completion for dot notation should also be expandable for better DSL REPL support.

      This JIRA issue is to be discussed, not sure whether to ask an dev@groovy or users@groovy would be best.

        Activity

        Hide
        Pascal Schumacher added a comment -

        When in doubt which mailing list to use to I just send the mail to both mailing lists.

        Show
        Pascal Schumacher added a comment - When in doubt which mailing list to use to I just send the mail to both mailing lists.
        Hide
        Thibault Kruse added a comment -

        Will do. Would comments and concerns still go here, or rather in the mailing list?

        I realize after learning more Groovy that for this to be really cool, this would require the categories used to adhere to some interface. E.g. for the DOMCategory, it would help if the NodeHolder and produced nodes adhered to a more general "Navigatable" interface or some other wrapper class offering get(String property) and getProperties().

        Show
        Thibault Kruse added a comment - Will do. Would comments and concerns still go here, or rather in the mailing list? I realize after learning more Groovy that for this to be really cool, this would require the categories used to adhere to some interface. E.g. for the DOMCategory, it would help if the NodeHolder and produced nodes adhered to a more general "Navigatable" interface or some other wrapper class offering get(String property) and getProperties().
        Hide
        Pascal Schumacher added a comment -

        Will do. Would comments and concerns still go here, or rather in the mailing list?

        There is not really a clean separation. Sometimes the discussion happens on the mailing list and is linked (via Nabble) from here. Sometimes the discussion happens here.

        Show
        Pascal Schumacher added a comment - Will do. Would comments and concerns still go here, or rather in the mailing list? There is not really a clean separation. Sometimes the discussion happens on the mailing list and is linked (via Nabble) from here. Sometimes the discussion happens here.
        Hide
        CÚdric Champeau added a comment -

        Merged, thank you!

        Show
        CÚdric Champeau added a comment - Merged, thank you!

          People

          • Assignee:
            CÚdric Champeau
            Reporter:
            Thibault Kruse
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: