override fun nextToken()

in hot-reload-analysis/src/main/kotlin/org/jetbrains/compose/reload/analysis/InstructionToken.kt [396:431]


    override fun nextToken(context: TokenizerContext): Either<InstructionToken, Failure>? {
        val consumer = context.consumer()

        /* Search for key */
        val expectedKeyLoad = consumer.nextOrNull() ?: return null
        val key = expectedKeyLoad.intValueOrNull() ?: return null

        /* search for source information */
        val sourceInformation: String = consumer.find { next ->
            when (next) {
                is LabelNode -> null
                is LineNumberNode -> null
                is LdcInsnNode -> next.cst as? String ?: "N/A"
                else -> return null
            }
        } ?: return null

        /* search for sourceInformationMarkerStart call */
        consumer.find { next ->
            when (next) {
                is LabelNode -> null
                is LineNumberNode -> null
                is MethodInsnNode -> {
                    if (MethodId(next) == Ids.ComposerKt.sourceInformationMarkerStart) {
                        return InstructionToken.SourceInformationMarkerStart(
                            key = ComposeGroupKey(key),
                            sourceInformation = sourceInformation,
                            instructions = consumer.allConsumedInstructions()
                        ).toLeft()
                    }
                }
                else -> return null
            }
        }
        return null
    }