Skip to content

Support string interpolation in code generator #1546

Closed
@EgorkaKulikov

Description

@EgorkaKulikov

Description

Sometimes we need to render some expression with string interpolation. There is no support for it now.

It will be useful. for example, to assert failures with informative messages. Something like this

fail("Informative message with variables from generated code")

Expected behavior

In Kotlin it should be rendered like this

"An overflow error occurred in ${method.name} call with arguments ${first.name} ${first.value},  ${second.name} ${second.value}"

In Java it is a little bit complicated

String.format("An overflow error occured in %s call with arguments %s %s,  %s %s", method.name, first.name, first.value, second.name, second.value)

Here we need to think about the modifiers for complex types

Potential alternatives

This examples are just a proposal, we may introduce another approach.

Context

There are not specific Cg items for this. We need to introduce them.

Metadata

Metadata

Labels

comp-codegenIssue is related to code generatorctg-enhancementNew feature, improvement or change request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions