Are there ways to modify existing code? Specifical...
# compiler
Are there ways to modify existing code? Specifically, I’m trying to remove an annotation from a class or to modify it:
Copy code
// Original:
@MyAnnotation(values = ["a", "b"]
class MyClass

// Expected:
@MyAnnotation(values = ["a", "b", "c"]
class MyClass
I couldn’t find a hook to do this. I only found ways add a new annotation. Any pointers?
Modification is the hardest I think You can check arrow-meta
or just do it on backend, depending on where you need those values.
Found it. So basically they leverage the
, but I’m afraid to use that, because they rely on implementation details and this could easily break in the future. For the analysis you get access to the list of files
files: Collection<KtFile>
and they cast this to an ArrayList and then replace some of files for changing the source code. That’s scary in my opinion.