If I have an annotated class Foo<T>, and I u...
# ksp
c
If I have an annotated class Foo<T>, and I use the symbol information for the generic type T to create a file, should I tag the file spec with the originatingFile as T or Foo? What if multiple Ts make up a file, should all of them be tagged as the originating file? Any help is much appreciated
j
what do you mean by
tag the file spec with the originatingFile as T or Foo
?
c
I’m using this kotlin poet ksp function TypeSpec.Builder.addOriginatingKSFile(ksFile: KSFile) in an attempt to help incremental compilation determine if the file really needs to be recompiled
j
The part I don’t understand is
originatingFile as T or Foo
, originating file, as the name suggests, should be a file, not a type parameter or class. If you mean the file that contains the target type parameter
T
or target class
Foo
, aren’t they just the file that contains the annotated class? Or am I misunderstanding anything?
c
Well Foo and T (which could be anything the user chooses) are declared in different files, I only use symbol data from T in the creation of my code generated file, but Foo happens to be the class which is annotated . I’m trying to establish if T alone is sufficient or if changes to Foo (Like removing the annotation) would warrant it also being tagged as an originating file.
j
It’s actually up to your processor’s logic, it might be enough to not take
Foo
into incremental if you do not care about the annotated class but only cares about the type parameter ( to the extent that even
Foo
is unresolved reference it still won’t affect your code generation logic).
c
Thank you!