compose-destinations: Default values in multiple lines don't work
[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 )
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Reactions: 1
- Comments: 25 (14 by maintainers)
Commits related to this issue
- Fixes regression caused by #560 fix — committed to raamcosta/compose-destinations by raamcosta 5 months ago
- fixes #560 — committed to petrstetka/compose-destinations by raamcosta 6 months ago
Alright guys, sorry about all this, I believe this time it will be working fine in all cases 🙏
Do test 1.9.61 and let me know all of you @harry248 @ShivamGoyal1899 @UKMIITB
(build is still cooking, but should be up in like 30min or so, I’ll update you guys here when it is)
@raamcosta Works for us too! Thanks!
thanks @raamcosta. it worked for us!
Thank you @harry248
I did find the issue thanks to the logs provided, one more use case I wasn’t considering 😛 I’m adding all of these to actual automated test cases so they shouldn’t pop up again on next iterations.
1.9.62 is cooking 🧑🍳
@raamcosta It seems it is picking main content as well for parameters. For finding the last point, when first
(
is found insert it in stack & keep adding(
in stack & pop when)
is found. And when stack is empty it means whole of params for destination part is extracted.Just a suggestion based on generated file which is creating this issue. Not sure what the exact implementation is
Hi @ShivamGoyal1899 👋
Can you run ksp task with
--info
and paste output here please? Thanks 🙏