auto-complete for script bindings as arguments

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

auto-complete for script bindings as arguments

steve.ash
I am trying to build a dsld for a simple DSL that will be specified as a groovy script.  The DSL uses groovy's chained method with no parens style.  E.g:

when FIELDA matches "123"

We have a script base class with a "when" method that takes a single Foo argument and returns a WhenBuilder that has a "matches" method which takes a String argument.  Typical DSL use case.

In the above line FIELDA is of type Foo and is just a binding in the script.  I was thinking that I would need to contribute a property of type Foo with name FIELDA with a pointcut that would match an enclosingCall(hasArgument(type("com.package.Foo"))) but I see in the hasArguments documentation that it only works with named arguments. Is there any easy solution here?

I'm also having trouble getting proposals that for WhenBuilder to act correctly.

Does the current dsld support this kind of chaining like this?
Reply | Threaded
Open this post in threaded view
|

Re: auto-complete for script bindings as arguments

Andrew Eisenberg
Yes, this kind of DSL should be able to be supported. 

I don't see any need for the enclosingCall pointcut, unless I'm missing something.  Your contribution block could look something like this:

contribute(enclosingScript() && currentType(subType(Script))) {
  method name: when, params: [foo:'com.mydsl.Foo'], noParens:true, type: 'com.mydsl.WhenBuilder'
 
  property name: FIELDA, type: 'com.mydsl.Foo']
}
contribute( currentType('com.mydsl.WhenBuilder')) {
  // add your WhenBuilder methods here, all with 'noParens' set to true
}



On Mon, Sep 9, 2013 at 9:19 PM, Steve Ash <[hidden email]> wrote:
I am trying to build a dsld for a simple DSL that will be specified as a groovy script.  The DSL uses groovy's chained method with no parens style.  E.g:

when FIELDA matches "123"

We have a script base class with a "when" method that takes a single Foo argument and returns a WhenBuilder that has a "matches" method which takes a String argument.  Typical DSL use case.

In the above line FIELDA is of type Foo and is just a binding in the script.  I was thinking that I would need to contribute a property of type Foo with name FIELDA with a pointcut that would match an enclosingCall(hasArgument(type("com.package.Foo"))) but I see in the hasArguments documentation that it only works with named arguments. Is there any easy solution here?

I'm also having trouble getting proposals that for WhenBuilder to act correctly.

Does the current dsld support this kind of chaining like this?