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

groovysh tab-complete properties of Map/Node instances

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.2.0-rc-1
    • 2.3.0-beta-1
    • Groovysh
    • None

    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.

      Attachments

        Activity

          People

            melix Cédric Champeau
            tkruse Thibault Kruse
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: