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

Fix JavaPoet formating #4583

Merged
merged 1 commit into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.apollographql.apollo3.compiler.codegen.java.JavaContext
import com.apollographql.apollo3.compiler.codegen.java.L
import com.apollographql.apollo3.compiler.codegen.java.helpers.BuilderBuilder
import com.apollographql.apollo3.compiler.codegen.java.helpers.makeDataClassFromParameters
import com.apollographql.apollo3.compiler.codegen.java.helpers.maybeAddDescription
import com.apollographql.apollo3.compiler.codegen.java.helpers.toNamedType
import com.apollographql.apollo3.compiler.codegen.java.helpers.toParameterSpec
import com.apollographql.apollo3.compiler.ir.IrInputObject
Expand Down Expand Up @@ -40,7 +41,7 @@ internal class InputObjectBuilder(
TypeSpec
.classBuilder(simpleName)
.addModifiers(Modifier.PUBLIC)
.applyIf(description?.isNotBlank() == true) { addJavadoc("$L\n", description!!) }
.maybeAddDescription(description)
.makeDataClassFromParameters(fields.map {
it.toNamedType().toParameterSpec(context)
})
Expand All @@ -54,9 +55,7 @@ internal class InputObjectBuilder(
} else {
val builderFields = inputObject.fields.map {
FieldSpec.builder(context.resolver.resolveIrType(it.type).withoutAnnotations(), context.layout.propertyName(it.name))
.applyIf(!it.description.isNullOrBlank()) {
addJavadoc(it.description)
}
.maybeAddDescription(it.description)
.build()
}
return addMethod(BuilderBuilder.builderFactoryMethod())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal class SchemaBuilder(

private fun typeSpec(): TypeSpec {
return TypeSpec.classBuilder(generatedSchemaName)
.addJavadoc("A Schema object containing all the composite types and a possibleTypes helper function")
.addJavadoc(L, "A Schema object containing all the composite types and a possibleTypes helper function")
.addModifiers(Modifier.PUBLIC)
.addField(customScalarAdaptersFieldSpec())
.addField(typesFieldSpec())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ internal class BuilderBuilder(
}
.build()
)
.addJavadoc(field.javadoc)
.applyIf(!field.javadoc.isEmpty) {
addJavadoc(L, field.javadoc)
}
.returns(JavaClassNames.Builder)
.addStatement("this.$L = $L", field.name, context.wrapValueInOptional(value = CodeBlock.of(L, field.name), fieldType = field.type))
.addStatement("return this")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion libraries/apollo-compiler/src/test/graphql/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ interface Character {

"""The input object sent when passing in a color"""
input colorInput {
"""Red color"""
"""
A description with a dollar sign: $10
"""
red: Int! = 1

"""Green color"""
Expand Down
6 changes: 3 additions & 3 deletions tests/compiler-hooks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class PrefixNamesJavaHooks(private val prefix: String) : DefaultApolloCompilerJa
return when (kind) {
com.squareup.javapoet.TypeSpec.Kind.CLASS -> {
com.squareup.javapoet.TypeSpec.classBuilder(name)
.addJavadoc(javadoc)
.addJavadoc("\$L", javadoc)
.addAnnotations(annotations)
.addModifiers(*modifiers.toTypedArray())
.addTypeVariables(typeVariables)
Expand All @@ -267,7 +267,7 @@ class PrefixNamesJavaHooks(private val prefix: String) : DefaultApolloCompilerJa

com.squareup.javapoet.TypeSpec.Kind.ENUM -> {
com.squareup.javapoet.TypeSpec.enumBuilder(name)
.addJavadoc(javadoc)
.addJavadoc("\$L", javadoc)
.addAnnotations(annotations)
.addModifiers(*modifiers.toTypedArray())
.addTypeVariables(typeVariables)
Expand All @@ -284,7 +284,7 @@ class PrefixNamesJavaHooks(private val prefix: String) : DefaultApolloCompilerJa

com.squareup.javapoet.TypeSpec.Kind.INTERFACE -> {
com.squareup.javapoet.TypeSpec.interfaceBuilder(name)
.addJavadoc(javadoc)
.addJavadoc("\$L", javadoc)
.addAnnotations(annotations)
.addModifiers(*modifiers.toTypedArray())
.addTypeVariables(typeVariables)
Expand Down