https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
ksp
  • g

    galex

    08/20/2021, 3:20 AM
    Hello, where can I find the logs created by using
    environment.logger
    ?
    t
    • 2
    • 2
  • u

    Udi Cohen

    08/20/2021, 7:53 PM
    Hi, I was wondering how can I generate the
    symbol-processing-cmdline
    artifact locally? I see it's only created to be published in Maven (https://github.com/google/ksp/pull/541), but I don't see a way to generate it myself in case I want to test the 1.5.30 branch for example. It's also unclear to me what is the difference between that and the regular
    symbol-processing
    artifact. I know the cmdline variant is necessary for Kotlin Native and command line, but why is that?
    t
    • 2
    • 4
  • u

    Udi Cohen

    08/23/2021, 8:31 PM
    Hi, I'm trying to use KSP from command line and while I do get the generated classes in the kotlinOutputDir, the
    kotlinc
    command doesn't compile the project's classes and places them in the output folder. As a repro example using the playground project, after running the following command I don't see anything in the
    build2/classes
    folder. I do however see the generated
    AClassBuilder
    class inside
    build2/generated/ksp/main/kotlin
    .
    kotlinc \
    -d /Users/udinic/projects/ksp-playground4/workload/build2/classes \
    -verbose \
    -cp /Users/udinic/projects/ksp-playground4/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar \
    -Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar \
    -Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-cmdline-1.5.21-1.0.0-beta07.jar \
    -P plugin:com.google.devtools.ksp.symbol-processing:apclasspath=/Users/udinic/projects/ksp-playground4/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar \
    -P plugin:com.google.devtools.ksp.symbol-processing:projectBaseDir=/Users/udinic/projects/ksp-playground4/workload/src/main/java \
    -P plugin:com.google.devtools.ksp.symbol-processing:classOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/classes/kotlin/main \
    -P plugin:com.google.devtools.ksp.symbol-processing:kotlinOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/kotlin \
    -P plugin:com.google.devtools.ksp.symbol-processing:javaOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/java \
    -P plugin:com.google.devtools.ksp.symbol-processing:resourceOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/resources \
    -P plugin:com.google.devtools.ksp.symbol-processing:cachesDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/cache \
    -P plugin:com.google.devtools.ksp.symbol-processing:kspOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/ksp \
    /Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/kotlin/ /Users/udinic/projects/ksp-playground4/workload/src/main/java
    If I disable KSP, by removing the
    -Xplugin
    params, I will see the compiled classes in the classes folder, but without any new generated classes of course. Is there something missing in my command?
    t
    • 2
    • 9
  • r

    Rafael Costa

    08/24/2021, 12:25 PM
    Hi guys, is it possible with KSP to get the default value of a function parameter which function is annotated? I am able to check if there is a default value for that parameter (using
    KSValueParameter.hasDefault
    ), but not what that value is..
    e
    z
    • 3
    • 6
  • e

    edrd

    08/24/2021, 9:44 PM
    Hey folks. I'm writing a KSP processor for a multiplatform project where I want to scan annotated JVM code and generate both JVM + JS code, however the current
    CodeGeneration
    API does not seem to support writing to a different source set rather than the one being processed. My workaround is to pass
    fileName = "../../(a lot more "../")/jsMain/OutputFileName"
    . Is there any other way to achieve this?
    t
    • 2
    • 4
  • e

    elihart

    08/25/2021, 5:14 PM
    I am running into an issue where an annotation argument is missing during processing (KSP beta8, kotlin 1.5.30) - I’m not sure if it’s a KSP or Kotlin bug. I know there have been several bugs with values in annotations not working correctly in some edge cases, but this one seems different. I am seeing this when using an Android resource value (Int) as an annotation argument
    @Attr(R2.layout.my_layout)
    class MyClass
    Where the resource is defined in a class like this
    public final class R2 {
        public static final class layout {
            public static final int my_layout = 1616;
        }
    }
    We borrowed this pattern from Butterknife, and the R2 class comes from the Butterknife gradle plugin to make the resource values final. When a resource value is used as the annotation argument like this, KSP and the kotlin compiler don’t seem to recognize it. I’ve done some debugging and the whole argument is just absent in the compiler representation of the arguments list. However, if I use a constant Int directly the argument is available. Does anyone know why KSP/Kotlin can’t recognize a value defined this way?
    j
    t
    • 3
    • 23
  • y

    yigit

    08/25/2021, 5:15 PM
    seems like the evaluation is not handling it properly
    e
    • 2
    • 1
  • a

    Alex Beggs

    08/26/2021, 4:24 PM
    @Ting-Yuan Huang You brought up non-JVM support for the PR I submitted. I thought it might be useful to discuss ideas about the non-JVM support for https://github.com/google/ksp/pull/508 which adds the getAnnotationsByType and isAnnotationPresent experimental methods. I saw that the latest version of Kotlin 1.5.30 provides the ability to instantiate. I am not sure if this provides a better integration into just utilizing Kotlin reflection and isolating away from using JVM specific calls. This KEEP discusses “3. Better multiplatform support”. What are your thoughts, as I am just scratching the surface of the JVM vs Multiplatform understanding here.
    t
    • 2
    • 12
  • n

    natario1

    08/29/2021, 2:14 PM
    Has anyone encountered this issue with native targets?
    > Task :an-sample:kspTestKotlinAndroidNativeArm64 FAILED
    e: Could not find "/Users/natario/Projects/ccc/ppp/an-sample/build/generated/ksp/androidNativeArm64Main/classes" in [/Users/natario/Projects/ccc/ppp, /Users/natario/.konan/klib, /Users/natario/.konan/kotlin-native-prebuilt-macos-x86_64-1.5.30/klib/common, /Users/natario/.konan/kotlin-native-prebuilt-macos-x86_64-1.5.30/klib/platform/android_arm64]
    Trying to run processor on the
    test
    compilation, gives the error above about missing class file in the
    main
    compilation path. Indeed that "generated/ksp/classes" directory is empty, not sure what it's expecting to find there. The error wording also seems suspicious, in
    Could not find "XXX" in [list of paths]
    I'd expect XXX to be a filename, not a resolved path.
    t
    a
    • 3
    • 11
  • e

    elihart

    08/30/2021, 7:49 PM
    I noticed that kotlin sources generated in android debug unit tests don’t seem to be visible to the java compiler, which causes the java compilation to fail.
    z
    t
    • 3
    • 6
  • n

    natario1

    08/30/2021, 9:31 PM
    I'd like to tackle https://github.com/google/ksp/issues/277 if team is not working on it. I have it working actually, but I need to take some decisions which I'd like to discuss: 1. Right now I'm creating a configuration per
    KotlinTarget
    , named
    ksp<TargetName>
    . For single-platform projects though, it might make sense to skip this step - when kotlin-jvm plugin is used for example, there's no point in having to write
    kspJvm
    as it would be identical to root
    ksp
    . What do you think? 2. Within each target, I create a configuration per
    KotlinCompilation
    , named
    ksp<TargetName><CompilationName>
    , extending the target configuration. As above, target name is omitted in single-platform. We could avoid creating this configuration for the main compilation, but after playing with it I think it's very nice to have fine grained control over main vs. test vs. both. 3. Within each compilation, I create a configuration per
    KotlinSourceSet
    , named
    ksp<SourceSetName>
    , but only if the source set is not the default one for that compilation. Basically this will be skipped 99% of the times? 4. Intermediate source sets do not have their own configuration. May be introduced in a future PR/version? 5. Android needs special handling. The KotlinSourceSet names are very confusing:
    compilation=debug sourceSets=[androidDebug, androidMain]
    compilation=debugAndroidTest sourceSets=[androidDebugAndroidTest, androidAndroidTest, androidAndroidTestDebug]
    compilation=debugUnitTest sourceSets=[androidDebugUnitTest, androidTest, androidTestDebug]
    compilation=release sourceSets=[androidRelease, androidMain]
    compilation=releaseUnitTest sourceSets=[androidReleaseUnitTest, androidTest, androidTestRelease]
    Looks to me that compilations == AGP variants, so one option is to create one config per variant named
    ksp<TargetName><VariantName>
    . Another option is to read the `AndroidSourceSet`s from AGP (main, debug, release, test, testDebug, testRelease, androidTest, androidTestDebug, androidTestRelease). This gives more fine grained control, but it's harder to do (testDebug should extend both debug and test... Also not clear how to retrieve the correct configurations later in
    applyToCompilation()
    ).
    t
    g
    • 3
    • 14
  • e

    elihart

    09/01/2021, 7:38 PM
    I was surprised to see the
    KSDeclaration.getVisibility()
    returns the visibility of the original declaration by looking up the overridee if the declaration is an override. I was expecting, and hoping, to get the visibility of an overridden function and was pretty confused by this behavior. Why was this approach chosen? It seems like a strange default. I suppose we can check modifiers directly to get visibility of a overridden declaration but it’s not ideal imo
    y
    j
    • 3
    • 9
  • z

    Zac Sweers

    09/04/2021, 8:58 PM
    I think a missing API that we can get from Metadata today but not in KSP is the target language information.
    jvmTarget
    ,
    languageVersion
    , and
    apiVersion
    in particular. Worth filing an issue?
    j
    • 2
    • 2
  • a

    andylamax

    09/06/2021, 2:46 PM
    Hello there, Whenever I add the JS target to my multiplatform build, I get the error below. Removing JS target causes code to be generated on all other platforms but commonMain.
    > Failed to calculate the value of task ':compileTestDevelopmentExecutableKotlinJs' property 'entryModule$kotlin_gradle_plugin'.
       > Collection has more than one element.
    Asking here to know if it is an unknown bug, or I don't know how to configure this yet. N.B: I am new to ksp
    e
    • 2
    • 1
  • a

    atsushieno

    09/07/2021, 8:14 AM
    I have been trying to build a native project that depends on a library that makes use of ksp. Apart from the issue regarding test builds (context: https://kotlinlang.slack.com/archives/C013BA8EQSE/p1630246449011600), now the library looks like it builds. However when I'm building the app part, it results in
    undefined reference to (my type)
    . Any idea why this happens?
    j
    • 2
    • 3
  • j

    jameskleeh

    09/07/2021, 5:53 PM
    How can I create a KType from a string (the fully qualified name of a class) ?
    j
    • 2
    • 5
  • t

    Ting-Yuan Huang

    09/07/2021, 9:31 PM
    Hello everyone, here is the KSP 1.0.0 stable release! We want to thank you for being KSP's early adopters and giving us so many invaluable feedback / contributions. With all your help we finally are able to make the first stable release of KSP. The next steps of KSP will be supporting new Kotlin compiler, better multiplatform support, performance and bug fixing. We'd also like to spend more time working with you to bring KSP to everyone. Of course, please feel free to let us know if you have any ideas on what can be done next. Again, please give it a try and let us know what you think! P.S. The version convention is unchanged; The exact version number is 1.5.30-1.0.0 to match the compiler version.
    :kotlin-intensifies: 22
    🎉 40
    e
    j
    m
    • 4
    • 4
  • e

    escodro

    09/08/2021, 4:48 PM
    Hello, everyone! 👋 I’m trying to update Room from KAPT to KSP in my project but I’m facing
    Plugin with id 'com.google.devtools.ksp' not found.
    . I followed this article where it states that only by adding
    apply plugin: 'com.google.devtools.ksp'
    and replacing
    kapt
    with
    ksp
    in the dependency it is good to go. Am I missing something? Thanks a lot! ❤️
    u
    t
    • 3
    • 7
  • e

    evant

    09/08/2021, 5:08 PM
    I don't think it's on the gradle plugin portal? Try adding
    pluginManagement {
        repositories {
            gradlePluginPortal()
            mavenCentral()
        }
    }
    To your settings.gradle
    👍 1
    e
    e
    j
    • 4
    • 5
  • r

    russhwolf

    09/09/2021, 2:59 PM
    What's the compatibility story for KSP now that it's 1.0? Since there's still a Kotlin version in the version number, does that mean consumers are still tied to using that same version for the foreseeable future while we wait for compiler plugins to stabilize?
    e
    e
    t
    • 4
    • 6
  • z

    Zac Sweers

    09/10/2021, 5:52 AM
    I'm working on upstreaming the KSP implementation of moshi codegen here but running into what looks like a bug with processing. When I breakpoint it in the
    JsonClassSymbolProcessorTest#disableProguardGeneration()
    test, it runs successfully the first time and then is called a second time, upon which it throws an exception internally (in thread) that appears to originate from parsing the file generated by the first pass. I think it's a bug, but I don't really know what exactly to file as I'm not sure where it's going wrong. Doing a second round makes sense to me, but I don't understand why it fails in this particular test case (and two others, but the rest are fine). The test runs fine in the moshix repo with no changes, but falls over in this repo and suggests something is up with the build. Let me know if there's somewhere specific I should dig!
    j
    u
    • 3
    • 6
  • u

    uli

    09/11/2021, 5:07 PM
    In the announcement blog post it says
    We have also updated a number of Android specific libraries which are ready for you to try today and offer significant performance improvements.
    Is there any hint to a list or something?
    👍 1
    z
    • 2
    • 2
  • z

    Zac Sweers

    09/12/2021, 9:10 PM
    Working on a KSP interop artifact for KotlinPoet, if KSP folks have some time I'd love extra eyes on this! https://github.com/square/kotlinpoet/pull/1146
    👍 4
    👍🏻 1
    🙏 5
    ❤️ 1
    🙏🏻 1
    j
    i
    • 3
    • 7
  • u

    Udi Cohen

    09/13/2021, 5:33 AM
    Hi, after upgrading from beta08 to the stable version my processor got broken due to a change in KSTypeImpl, and I'm no sure why is that. In 1.0.0 stable, there's an additional check when resolving a KSType, where the constractor's declaration is compared to NotFoundClasses.MockClassDescriptor (See commit https://github.com/google/ksp/commit/4ac387a98c8acfcefb5e46a795a5ffcd2dbf1af9). One of my annotations is found to be this way, which means its KSType is resolved to "<Error>". I'm not sure why is that and I was hoping for some clarification on this check, and what does it mean if the constractor is of type NotFoundClasses.MockClassDescriptor. For reference, my annotation is a meta-annotation, in Java, that's declared something like this: @Retention(RetentionPolicy.CLASS) @Target(ElementType.ANNOTATION_TYPE) public @interface UdinicMetaAnnotation { String GENERATOR = "generator"; String generator() default ""; Target[] targets(); Class<?>[] nestedAnnotations() default {}; // .... } BTW in beta08, before this change, I didn't notice any issues related to this annotation's problematic constractor type.
    j
    • 2
    • 2
  • j

    jameskleeh

    09/14/2021, 4:03 PM
    This is for determining if the method for example is accessible if it has the internal modifier
    e
    j
    • 3
    • 4
  • j

    jameskleeh

    09/15/2021, 3:07 PM
    KSType has
    arguments
    but I don’t see a way to know what the source type is
    j
    • 2
    • 1
  • a

    Anton Popov

    09/15/2021, 4:11 PM
    Is it possible to get start and end line number of the KSFunctionDeclaration's source code? There is FileLocation.lineNumber, but, as I understand, is indicates only first line of the function's source code
    j
    • 2
    • 1
  • u

    Udi Cohen

    09/16/2021, 2:55 AM
    Does KSP supports loading resource files from the classpath? In a Java annotation processor, I could use the Filer's method getResource() (see https://javadoc.io/static/org.jvnet.sorcerer/sorcerer-javac/0.8/index.html?com/sun/tools/javac/processing/JavacFiler.html), which supports loading resources from CLASS_OUTPUT, CLASS_PATH and ANNOTATION_PROCESSOR_PATH. For context, I have a KSP processor that loads a template for the sources it generates, which is located in one of the jars in its classpath.
    t
    m
    • 3
    • 4
  • e

    elihart

    09/16/2021, 7:13 PM
    I’m having an issue with incremental compilation. I’ve read the docs and used
    ksp.incremental.log=true
    (very helpful, btw!) so I think I understand what is going on. My generated file (aggregating) relies on both a symbol in sources acquired with
    getSymbolsWithAnnotation
    and a set of classes on the classpath (via
    getDeclarationsFromPackage
    ). The file’s originating elements reflect this, as do the ksp incremental logs, so the dependencies seem correctly understood by KSP. My problem is that when there are classpath changes and the processor incrementally runs, KSP sees that only the classpath files changed and does not consider my source file as dirty, so my call to
    getSymbolsWithAnnotation
    does not return anything. This is problematic because I need both the symbol in source as well as the classpath files to generate my output file, and this fails when I cannot get the source symbol with
    getSymbolsWithAnnotation
    . I understand why KSP does this, and it is optimal for some cases, but it makes generating a file that depends on both sources and classpath difficult - I think I would have to work around this by manually getting all files and parsing them. Would it be reasonable instead for KSP to look at the set of inputs to a generated file, and if any one of those input is a classpath change then consider the rest of the inputs as dirty as well? according to the docs this is already done with sources, but maybe not for classpath changes?
    Propagation by input-output correspondence: If a source file is changed or affected, all other source files having some output in common with that file are affected.
    t
    y
    • 3
    • 18
  • j

    jameskleeh

    09/20/2021, 3:59 PM
    How can I create a KSTypeReference from a class?
    y
    j
    • 3
    • 11
Powered by Linen
Title
j

jameskleeh

09/20/2021, 3:59 PM
How can I create a KSTypeReference from a class?
y

yigit

09/20/2021, 4:45 PM
https://github.com/google/ksp/blob/main/api/src/main/kotlin/com/google/devtools/ksp/processing/Resolver.kt#L101
👍 1
j

Jiaxiang

09/20/2021, 4:54 PM
and you can call
asStarProjectedType
or
asType()
to get a
KSType
from
KSClassDeclaration
j

jameskleeh

09/20/2021, 5:34 PM
So I have a KClass
This is in regards to trying to understand the generics api
I have an object that is known to implement X<Y,Z> and I want to get the values of Y and Z
I’m trying to get it by resolver.getTypeArgument and passing in the variance from the declaration.typeArguments, but the method on the resolver takes in a KSType and I just have a KClass of the known type
y

yigit

09/20/2021, 5:44 PM
Are you interested in the bounds of Y/Z ? because, otherwise, they don't mean anything until you have a type referencing it
this might help if you want bounds: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:room/roo[…]/java/androidx/room/compiler/processing/ksp/KSTypeExt.kt;l=76
j

Jiaxiang

09/20/2021, 5:48 PM
if you already have the
KClass
, then you can get the
KSClassDeclaration
by
resolver.getClassDeclarationByName(KClass.qualifiedName)
🙌 1
j

jameskleeh

09/20/2021, 5:53 PM
@yigit Yes the bounds. I have the object that has the specified values for Y and Z
I’ll give those extensions a look - thanks
View count: 74