Statically Typed Closure?


(Micah Zoltu) #1

When working in my build.gradle file, my IDE doesn’t give me any auto-complete and I don’t get any compile-time checking of my build.gradle file. I am willing to have a bit more code verbosity in exchange for auto-complete, but I’m not sure how to get it.

As a simple example, if I am working inside the dependencies closure, I would like my IDE to know that the context I am working in is DependencyHandler, so it can give me useful auto-complete hints and show me where I have made an error.

I really don’t even know where to start as far as figuring it out myself, maybe something like this?

((Closure<DependencyHandler>)dependencies) {
	...
}

(Mark Vieira) #3

You could try something like this:

(dependencies as DependencyHandler).with {
   ...
}