-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default values in multiple lines don't work #560
Comments
Can you add two images of the before and after? What works and what doesn’t? |
So in the images it’s the “g” parameter that breaks it or is it also “j”? |
I just formatted parameter Difference between |
That shouldn’t make a difference. I will check this when I get home. |
So, yeah I needed a little refresher, but we do not support default values declared in multiple lines. KSP does not support this "getting the default value" use case, so, for me to support it (which I really wanted) I have to parse these source code lines manually. And right now this parsing logic doesn't support multi lines. I will work on checking if I can add this support, or at least provide a better exception. |
I fixed this on 1.9.60. Please try it @UKMIITB and let me know :) Build is still cooking, but should be up in 30min or so. |
Thank you @raamcosta for fixing this. Just a side note, current version of kotlin is 1.21 & ksp is 1.0.15 Do you mind if I raise a PR with kotlin & ksp update. There are no core changes & only hotfix |
Sure be my guest! |
Btw can you just confirm to me that this indeed fixed your issue? |
breaking for this @raamcosta @UKMIITB @Destination
@Composable
fun MyScreen(
a: A,
navigator: DestinationsNavigator,
b: B = hiltViewModel(),
c: D.E = D.INSTANCE.E(),
d: F? = F()
) { trace:
|
Hi @ShivamGoyal1899 👋 Can you run ksp task with |
@raamcosta Just a suggestion based on generated file which is creating this issue. |
This fix causes an issue in our case:
However, we do not have multiline default values here:
Where
And
|
@raamcosta output of ksp task with --info
|
Build is up guys :) |
@raamcosta Unfortunately we now get a i: [ksp] validateClosedResultRecipients | checking param SearchScreen activateShoppingPassScreenResultRecipient
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix activateShoppingPassScreenResultRecipient =
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix ResultRecipient =
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix < =
i: [ksp] getFirstArgTypeSimpleName | result of removeSuffix > =
i: [ksp] getFirstArgTypeSimpleName | result of split =
i: [ksp] getFirstArgTypeSimpleName | Result of trim =
i: [ksp] validateClosedResultRecipients | checking param FilterScreen filterItemsRecipient
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix filterItemsRecipient =
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix ResultRecipient =
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix < =
i: [ksp] getFirstArgTypeSimpleName | result of removeSuffix > =
i: [ksp] getFirstArgTypeSimpleName | result of split =
i: [ksp] getFirstArgTypeSimpleName | Result of trim =
i: [ksp] validateClosedResultRecipients | checking param FilterScreen storeIdRecipient
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix storeIdRecipient =
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix ResultRecipient =
i: [ksp] getFirstArgTypeSimpleName | result of removePrefix < =
i: [ksp] getFirstArgTypeSimpleName | result of removeSuffix > =
i: [ksp] getFirstArgTypeSimpleName | result of split =
i: [ksp] getFirstArgTypeSimpleName | Result of trim =
i: [ksp] getDefaultValue | name = appliedFilters type = AppliedSearchFilters |
Thank you @harry248 I did find the issue thanks to the logs provided, one more use case I wasn't considering :P 1.9.62 is cooking 🧑🍳 |
Many thanks again for the quick fix! |
build is up @harry248 |
let me know how it goes @harry248 :D |
thanks @raamcosta. it worked for us! |
@raamcosta Works for us too! Thanks! |
thanks guys! |
[ksp] java.lang.IndexOutOfBoundsException: End index (-1) is less than start index (0).
at kotlin.text.StringsKt__StringsKt.removeRange(Strings.kt:550)
at com.ramcosta.composedestinations.ksp.commons.DefaultParameterValueReader.readDefaultValue(DefaultParameterValueReader.kt:43)
at com.ramcosta.composedestinations.ksp.commons.DefaultParameterValueReaderKt.getDefaultValue(DefaultParameterValueReader.kt:197)
at com.ramcosta.composedestinations.ksp.processors.KspToCodeGenDestinationsMapper$toParameter$2.invoke(KspToCodeGenDestinationsMapper.kt:506)
at com.ramcosta.composedestinations.ksp.processors.KspToCodeGenDestinationsMapper$toParameter$2.invoke(KspToCodeGenDestinationsMapper.kt:506)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.ramcosta.composedestinations.codegen.model.Parameter.getDefaultValue(Parameter.kt:10)
at com.ramcosta.composedestinations.codegen.writers.SingleDestinationWriter.defaultValueForInvokeFunction(SingleDestinationWriter.kt:436)
at com.ramcosta.composedestinations.codegen.writers.SingleDestinationWriter.innerNavArgsParametersCode(SingleDestinationWriter.kt:275)
at com.ramcosta.composedestinations.codegen.writers.SingleDestinationWriter.addNavArgsDataClass(SingleDestinationWriter.kt:166)
at com.ramcosta.composedestinations.codegen.writers.SingleDestinationWriter.write(SingleDestinationWriter.kt:96)
at com.ramcosta.composedestinations.codegen.writers.DestinationsWriter.write(DestinationsWriter.kt:30)
at com.ramcosta.composedestinations.codegen.CodeGenerator.generate(CodeGenerator.kt:44)
at com.ramcosta.composedestinations.ksp.processors.Processor.process(Processor.kt:61)
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:305)
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:303)
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:409)
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:303)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:77)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:256)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:247)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:247)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:87)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:43)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1523)
at jdk.internal.reflect.GeneratedMethodAccessor93.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
We were trying to apply ktfmt in our entire project. But when applying on UI files where destination is used, following error is occurring during build time.
The composable destination post formatting looked something like this. Can you please check if some build code assumption needs to be changed
@Destination @Composable fun ABC( xx: XXXActivity, xxViewModel: xxViewModel = hiltViewModel(), resultRecipient: ResultRecipient<xxScreenDestination, xxResult>, source: String = xx.YY, navigator: DestinationsNavigator, xx: String? = null, xx: XX.XX = XX.INSTANCE.XX(), finishAfterResult: Boolean = true, xx: XX = XX.DEFAULT )
The text was updated successfully, but these errors were encountered: