I am currently writing a custom lint for a library I made and I've implemented most of the stuff.
The thing which is bugging me is how to create quickDataFix
to add a method in a UClass
.
So for eg: I have the following code where the LintFix
will be applied.
class TestClass {
}
After applying the fix, it should become
class TestClass {
fun method1() { }
}
So far, I've been trying this rule.
val fix = LintFix.create()
.replace()
.name("Add method")
.pattern("TestClass(.*)")
.with("TestClass {\nfun method1() { }\n")
.shortenNames()
.range(context.getLocation(clazz.scope)) // 'context' is JavaContext & 'clazz' is UClass
.build()
But nothing seems to work, I tried googling & finding projects that have lint checks so that I can read the source code & try to solve my problem but no luck.
Any help would be really appreciated.