Skip to content
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

Differentiate escaping of Java or Kotlin keywords #3630

Merged
merged 7 commits into from
Dec 1, 2021

Conversation

BoD
Copy link
Contributor

@BoD BoD commented Nov 30, 2021

No description provided.

@@ -37,7 +37,7 @@ public class TestQuery() : Query<TestQuery.Data> {
public override fun selections(): List<CompiledSelection> = TestQuerySelections.root

public data class Data(
public val enum_: Enum?
public val `enum`: Enum?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must admit I don't understand this one. Is this KotlinPoet automatically escaping it? If yes why is it not done in other places?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relevant PR from kotlinpoet: square/kotlinpoet#994

Feels weird escaping in both Apollo + KotlinPoet but I'm not sure we can rely 100% on KotlinPoet because we might use identifiers in places where KotlinPoet doesn't know enough context to escape?

Things like:

CodeBlock.of("%L.value", layout.fieldName(responseName))

Might be worth trying to remove all escaping from Apollo and give KotlinPoet the proper hints?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in bc1aa75 and e3aeb45.

I added an integration test with keywords in different situations, and it looks like it's working. I hope some other cases of %T needing to be %N aren't missing!

@BoD BoD force-pushed the escape-java-or-kotlin-keywords branch from c6f7975 to fdffe2d Compare December 1, 2021 12:21
@BoD BoD merged commit 7f244a5 into dev-3.x Dec 1, 2021
@BoD BoD deleted the escape-java-or-kotlin-keywords branch December 1, 2021 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants