Re: Compatibility with Java syntax

2024-02-20 Thread Saravanan Palanichamy
Hello Groovy users I am trying to compile Java code using the Groovy compiler. 99% of it works which is awesome. There are however some constructs that dont play nice Annotation collections needs a [ ... ] instead of { ... } that is used in Java. @MyCollectionOfAnnotations({

Compatibility with Java syntax

2024-02-20 Thread Saravanan Palanichamy
Hello Groovy users I am trying to compile Java code using the Groovy compiler. 99% of it works which is awesome. There are however some constructs that dont play nice - Annotation collections needs a [ ... ] instead of { ... } that is used in Java @MyCollectionOfAnnotations({ >@

Re: Generics question

2023-08-27 Thread Saravanan Palanichamy
Hello Jochen Maybe its good for me to state the original problem separately from the solution I am pursuing to see if there are other ways to do it. Apologies if the email is too long. I tried to stick to a lot of example rather than text The problem. Entities in the DSL are either mutable or imm

Re: Generics question

2023-08-27 Thread Saravanan Palanichamy
able() > > List myThings = [] > myThings << new Immutable() > // myThings << new Mutable() forbidden > > List myMutables = [] > // myMutables << new Immutable() forbiddden > myMutables << new Mutable() > > On 27.08.23 14:59, Saravanan Palanicham

Generics question

2023-08-27 Thread Saravanan Palanichamy
Hello folks I am building an AST transformation that will allow me to define a concept of mutable and immutable objects. Java lets me hold mutable objects in immutable object lists (as per the code below). But my DSL also wants to allow immutable objects to be held in mutable lists. The meaning it

Restricting list extensions

2023-08-02 Thread Saravanan Palanichamy
Hello Groovy users/devs I have a derived class from List (lets call this MyImmutableList) and I want to only allow the use of certain extension functions. For example, collect is ok, but left shift is not myImmutableList << 100 // I want to prevent this because its an immutable list) myImmutableL

Duplicate visits to expressions defined in RHS of a setter

2023-04-02 Thread Saravanan Palanichamy
Hello Groovy Devs - I have a class defined MyTestClass in java/kotlin (does not matter) - I have a groovy class defined MyClassDefinedInGroovy - I have code in a groovy function that is creating these classes and setting a variable in the object. I compile this with static compilation

Closure params hint

2023-03-19 Thread Saravanan Palanichamy
Hello Everyone I am trying to define a method that will take a closure whose parameters are a generic type based on generic parameters on the function. The closure returns void class Result { > public Map pairs; > } > > class MyOtherClass { > // This closure takes an input of Result >

Re: Compiling several groovy files together

2022-03-10 Thread Saravanan Palanichamy
from a jar or class path. This only fails if I use the same class loader that compiled someMethod regards Saravanan On Fri, Mar 4, 2022 at 5:44 PM Jochen Theodorou wrote: > On 15.02.22 05:20, Saravanan Palanichamy wrote: > > Hello Groovy users > > > > I am using Groovy 3.0

Compiling several groovy files together

2022-02-14 Thread Saravanan Palanichamy
Hello Groovy users I am using Groovy 3.0.5 - I have a file A.groovy and B.groovy. B depends on A - I have ast transformations that add annotations to methods in A (specifically an annotation with a list expression that contains other annotations) - I compile A.groovy using the load

Re: Extracting groovy comments and source code

2021-09-29 Thread Saravanan Palanichamy
; trying to do. > > Cheers, Paul. > > On Wed, Sep 29, 2021 at 4:26 PM Saravanan Palanichamy > wrote: > > > Hello all, > > > > I am trying to do two things > > > > 1) Extract comments from inside a function code (not the function's groovy > >

Re: Extracting groovy comments and source code

2021-09-29 Thread Saravanan Palanichamy
gt; I don't know about Groovy specifically, but most parsers discard comments > >> (and whitespace, line endings, etc.) before building an AST. However, you > >> can reconstruct the missing text if you have the position information of > >> each AST node and the origina

Extracting groovy comments and source code

2021-09-28 Thread Saravanan Palanichamy
Hello all, I am trying to do two things 1) Extract comments from inside a function code (not the function's groovy doc, but comments embedded inside the function code itself) 2) Extract the source code of the function itself For example /* Comments about myFunction *./ void myFunction() {

Re: AST to add a new class

2021-04-12 Thread Saravanan Palanichamy
are compiling your other > classes at the same time, I'd just get the module node from one of those > classes and add your new class to it. > > Cheers, Paul. > > > On Mon, Apr 12, 2021 at 9:34 PM Saravanan Palanichamy > wrote: > >> Hello paul >> >> Thank y

Re: AST to add a new class

2021-04-12 Thread Saravanan Palanichamy
, 12 Apr, 2021, 16:52 Paul King, wrote: > The Builders and Sortable AST do something similar and use: > > https://github.com/apache/groovy/blob/master/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java#L129 > > > On Mon, Apr 12, 2021 at 8:36 PM Saravanan Palanichamy &

AST to add a new class

2021-04-12 Thread Saravanan Palanichamy
Hello What is the right way to add a new class through an AST during the Groovy compilation phase? What I am trying to do is this * Compile N different classes * During the compile process, create a new class for each of these N classes that denotes how it should be serialized (for example) * A

Default values for parameters in interface methods

2021-01-04 Thread Saravanan Palanichamy
Hello Are there plans to support default parameters in interface methods interface MyClass { def myFunction(String parameter1 = "1234") } the error I get is Cannot specify default value for method parameter inside an interface regards Saravanan

Re: IDE support for multi assignment statements

2020-12-11 Thread Saravanan Palanichamy
heers, > mg > > *I would also recommend closely following the ticket guidelines, i.e. > describe current (erronous) state, and the expected behavior - in short you > want to make it easy for them to work on this. > > > On 11/12/2020 15:40, Saravanan Palanichamy wrote: > >

IDE support for multi assignment statements

2020-12-10 Thread Saravanan Palanichamy
Hello I am using Groovy 3.0.5 and it supports multiple assignment statements from tuples when using static compile def(var1, var2) = Tuple.tuple("a", 1) but it looks like the Intellij IDE still calls this out as a compile error. Also it defaults to identifying var1 and var2 as objects. Thi

Closures in annotations over interface methods

2020-07-17 Thread Saravanan Palanichamy
Hello, I am using a closure inside an annotation over an interface method. I then decompile the class in intellij (open the .class file essentially) and I see that the closure class was created, but I dont see the class definition anywhere. I am however able to access it in code. Is this a limi

Re: Loading groovy files from a remote repository

2020-05-25 Thread Saravanan Palanichamy
better approach. > > All the best, > OC > > > On 24 May 2020, at 7:35, Saravanan Palanichamy wrote: > > > > Hello > > > > I have a requirement where I load all my groovy files into a remote > > database. I then have to pull them down to compile a

Loading groovy files from a remote repository

2020-05-23 Thread Saravanan Palanichamy
Hello I have a requirement where I load all my groovy files into a remote database. I then have to pull them down to compile and I am wondering what is the best way to do this. Right now I do this * I pull down the names of all files (not the actual file) * I then use a GroovyClassLoader to load