Re: JSR 308 support for Groovy

2017-06-13 Thread Daniel Sun
Hi Paul,

   I'm reading an article on JSR308, which is really useful.
http://www.oracle.com/technetwork/articles/java/ma14-architect-annotations-2177655.html

   In addition, I've already created a branch
jsr308(https://github.com/danielsun1106/groovy-parser/tree/jsr308) to
experiment the grammar.  Before working on it, I want to confirm whether
Groovy will support JSR308 fully.

P.S. The following code is quite strange for me ;-)
Forecast @Readonly [] fiveDay = new Forecast @Readonly [5];

Cheers,
Daniel.Sun



--
View this message in context: 
http://groovy.329449.n5.nabble.com/JSR-308-support-for-Groovy-tp5741586p5741627.html
Sent from the Groovy Users mailing list archive at Nabble.com.


Re: JSR 308 support for Groovy

2017-06-12 Thread Paul King
Thanks Daniel,

I created this additional sub-task:

https://issues.apache.org/jira/browse/GROOVY-8228 JSR308 grammar changes

If any parts turn out to be controversial or need further discussion we can
create further issues.

Cheers, Paul.


On Tue, Jun 13, 2017 at 2:34 AM, Daniel Sun <realblue...@hotmail.com> wrote:

> Hi Paul,
>
> > The grammar isn't expecting an annotation on the parameterized type. It
> > fails for both the old and new parsers with slightly different error
> > messages.
>
>   I will set aside some time to complete the grammar and AST
> construction.
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/JSR-308-support-for-Groovy-tp5741586p5741591.html
> Sent from the Groovy Users mailing list archive at Nabble.com.
>


Re: JSR 308 support for Groovy

2017-06-12 Thread Daniel Sun
Hi Paul,

> The grammar isn't expecting an annotation on the parameterized type. It
> fails for both the old and new parsers with slightly different error
> messages.

  I will set aside some time to complete the grammar and AST
construction.

Cheers,
Daniel.Sun



--
View this message in context: 
http://groovy.329449.n5.nabble.com/JSR-308-support-for-Groovy-tp5741586p5741591.html
Sent from the Groovy Users mailing list archive at Nabble.com.


JSR 308 support for Groovy

2017-06-12 Thread Paul King
I have started examining what is required for JSR 308 support in Groovy. It
is one of those things which might make sense to ensure we support in the
new grammar from the get go.

Current issues:

https://issues.apache.org/jira/browse/GROOVY-8225
https://issues.apache.org/jira/browse/GROOVY-8226

With just a few tweaks (GROOVY-8226) we get some stuff for free since
we had some bits geared up already. We can now start using some of the
Java libraries which leverage the JSR, e.g.:

==>8==
@Grab('com.pholser:junit-quickcheck-generators:0.7')
@Grab('com.pholser:junit-quickcheck-core:0.7')
import com.pholser.junit.quickcheck.generator.InRange
import com.pholser.junit.quickcheck.runner.JUnitQuickcheck
import org.junit.runner.RunWith
import com.pholser.junit.quickcheck.Property

@RunWith(JUnitQuickcheck)
class IntegerRanges {
@Property
void shouldHold(@InRange(min = "0", max = "9") Integer item) {
item >= 0 && item <= 9
}
}
==>8==

Which uses a property-based testing framework to call our assertion 100
times. It works in fact even with the old grammar once the plumbing changes
are done.

What we can't do at the moment is something like this:

==>8==
@Property
void shouldAlsoHold(List<@InRange(min = "0", max = "9") Integer> items) {
assert items.every{ it >= 0 && it <= 9 }
}
==>8==

The grammar isn't expecting an annotation on the parameterized type. It
fails for both the old and new parsers with slightly different error
messages.

I'll be taking a look at what else is required to make this work but if
anyone has particular requirements or comments, or some part they would
like to work on, please let me know.

Cheers, Paul.