You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2019/10/31 11:51:00 UTC
[jira] [Commented] (GROOVY-9296) [GEP] Import `TypeChecked`,
`CompileStatic` and `CompileDynamic` by default
[ https://issues.apache.org/jira/browse/GROOVY-9296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16963912#comment-16963912 ]
Eric Milles commented on GROOVY-9296:
-------------------------------------
Adding default imports does not remove the burden of annotating classes and methods. There is also GROOVY-8663 proposed that would add keyword that would alias {{@CompileStatic}}, much like {{trait}} is now used in place of {{@Trait}}.
I'm still in favor of keeping things as is. Any user that wants these default imports can use compiler config script. If the desire is to remove the burden of annotating classes, compiler config script can do that too.
{code:groovy}
configuration.optimizationOptions.indy = true
configuration.parameters = true
withConfig(configuration) {
ast(groovy.transform.CompileStatic)
imports {
star 'groovy.transform'
normal 'java.util.regex.Matcher'
normal 'java.util.regex.Pattern'
}
source(unitValidator: { unit -> !!(unit.name =~ /.src.test./) }) {
imports {
normal 'org.junit.Test'
normal 'org.junit.After'
normal 'org.junit.Before'
normal 'org.mockito.Mock'
normal 'org.mockito.InjectMocks'
staticStar 'org.mockito.Mockito'
}
}
}
{code}
> [GEP] Import `TypeChecked`, `CompileStatic` and `CompileDynamic` by default
> ---------------------------------------------------------------------------
>
> Key: GROOVY-9296
> URL: https://issues.apache.org/jira/browse/GROOVY-9296
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 4.x
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> (http://groovy.329449.n5.nabble.com/GEP-Import-TypeChecked-CompileStatic-and-CompileDynamic-by-default-tt5761771.html)
> As static groovy is widely used, importing
> {{groovy.transform.TypeChecked}}, {{groovy.transform.CompileStatic}} and
> {{groovy.transform.CompileDynamic}} again and again makes user experience not
> very good. So I propose to import the classes by default. For example,
> After GEP accepted:
> {code:java}
> @CompileStatic
> def hello {
> println 'hello'
> }
> {code}
> Before GEP accepted:
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic
> def hello {
> println 'hello'
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)