You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks, I'm new to arrow and arrow-meta, not sure this is the right place to ask questions :-p
I'm trying to generate some kotlin code based on annotations and came across arrow-meta. After reading this article: https://medium.com/@heyitsmohit/writing-kotlin-compiler-plugin-with-arrow-meta-cf7b3689aa3e, I decided to give it a try but I found examples are very limited, apart from above example, the only thing I could find is the arror-meta-examples project, but example there is just generating a new source, which is a bit simple for me. Here's my use case.
Let's say I have an annotation called @node for functions. For each annotated function in a class, I want to rename this function and generate another wrapper function. For example
before:
class Foo {
}
after:
class Foo {
fun foo(x:Int):Double = withContext(...) { foo_node(x) }
fun foo_node(x:Int):Double { ... }
}
Playing with arrorw-meta, I'm able to locate the annotated function within 'classBody' deractive, but it seems there's only 'replace', 'newSource' and 'remove' in Transform. What's the best way to do what I described above for renaming and adding new functions?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi folks, I'm new to arrow and arrow-meta, not sure this is the right place to ask questions :-p
I'm trying to generate some kotlin code based on annotations and came across arrow-meta. After reading this article: https://medium.com/@heyitsmohit/writing-kotlin-compiler-plugin-with-arrow-meta-cf7b3689aa3e, I decided to give it a try but I found examples are very limited, apart from above example, the only thing I could find is the arror-meta-examples project, but example there is just generating a new source, which is a bit simple for me. Here's my use case.
Let's say I have an annotation called @node for functions. For each annotated function in a class, I want to rename this function and generate another wrapper function. For example
before:
class Foo {
@node fun foo(x:Int):Double { ... }
}
after:
class Foo {
fun foo(x:Int):Double = withContext(...) { foo_node(x) }
fun foo_node(x:Int):Double { ... }
}
Playing with arrorw-meta, I'm able to locate the annotated function within 'classBody' deractive, but it seems there's only 'replace', 'newSource' and 'remove' in Transform. What's the best way to do what I described above for renaming and adding new functions?
Beta Was this translation helpful? Give feedback.
All reactions