Skip to content

Commit

Permalink
Switch to Palantir's JavaPoet
Browse files Browse the repository at this point in the history
  • Loading branch information
squarejesse committed Oct 10, 2024
1 parent ea50a78 commit 53b4bc8
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dokka = "1.9.20"
grpc = "1.68.0"
gson = "2.11.0"
guava = "32.0.1-jre"
javapoet = "1.13.0"
javapoet = "0.5.0"
jimfs = "1.3.0"
jmh = "1.37"
jsr305 = "3.0.2"
Expand Down Expand Up @@ -43,7 +43,7 @@ grpc-protobuf = { module = "io.grpc:grpc-protobuf", version.ref = "grpc" }
grpc-stub = { module = "io.grpc:grpc-stub", version.ref = "grpc" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
javapoet = { module = "com.squareup:javapoet", version.ref = "javapoet" }
javapoet = { module = "com.palantir.javapoet:javapoet", version.ref = "javapoet" }
jimfs = { module = "com.google.jimfs:jimfs", version.ref = "jimfs" }
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
jmh-generator = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Ordering;
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.ArrayTypeName;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.NameAllocator;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import com.squareup.javapoet.WildcardTypeName;
import com.palantir.javapoet.AnnotationSpec;
import com.palantir.javapoet.ArrayTypeName;
import com.palantir.javapoet.ClassName;
import com.palantir.javapoet.CodeBlock;
import com.palantir.javapoet.FieldSpec;
import com.palantir.javapoet.MethodSpec;
import com.palantir.javapoet.NameAllocator;
import com.palantir.javapoet.ParameterSpec;
import com.palantir.javapoet.ParameterizedTypeName;
import com.palantir.javapoet.TypeName;
import com.palantir.javapoet.TypeSpec;
import com.palantir.javapoet.WildcardTypeName;
import com.squareup.wire.EnumAdapter;
import com.squareup.wire.FieldEncoding;
import com.squareup.wire.Message;
Expand Down Expand Up @@ -510,7 +510,7 @@ public TypeName typeName(ProtoType protoType) {
if (typeName instanceof ClassName) {
javaName = (ClassName) typeName;
} else if (typeName instanceof ParameterizedTypeName) {
javaName = ((ParameterizedTypeName) typeName).rawType;
javaName = ((ParameterizedTypeName) typeName).rawType();
} else {
throw new IllegalArgumentException("Unexpected typeName :" + typeName);
}
Expand Down Expand Up @@ -1641,7 +1641,7 @@ private String adapterString(ProtoType type) {
private String reflectionName(TypeName typeName) {
ClassName className;
if (typeName instanceof ParameterizedTypeName) {
className = ((ParameterizedTypeName) typeName).rawType;
className = ((ParameterizedTypeName) typeName).rawType();
} else {
className = (ClassName) typeName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.squareup.wire.java

import com.squareup.javapoet.JavaFile
import com.palantir.javapoet.JavaFile
import com.squareup.wire.schema.Extend
import com.squareup.wire.schema.Field
import com.squareup.wire.schema.Location
Expand Down Expand Up @@ -86,8 +86,8 @@ class JavaSchemaHandler(
}

private fun write(
javaTypeName: com.squareup.javapoet.ClassName,
typeSpec: com.squareup.javapoet.TypeSpec,
javaTypeName: com.palantir.javapoet.ClassName,
typeSpec: com.palantir.javapoet.TypeSpec,
source: Any,
location: Location,
context: Context,
Expand All @@ -98,12 +98,12 @@ class JavaSchemaHandler(
.addFileComment("\nSource: \$L in \$L", source, location.withPathOnly())
.build()
val filePath = outDirectory /
javaFile.packageName.replace(".", "/") /
javaFile.packageName().replace(".", "/") /
"${javaTypeName.simpleName()}.java"

context.logger.artifactHandled(
outDirectory,
"${javaFile.packageName}.${javaFile.typeSpec.name}",
"${javaFile.packageName()}.${javaFile.typeSpec().name()}",
"Java",
)
try {
Expand All @@ -113,7 +113,7 @@ class JavaSchemaHandler(
}
} catch (e: IOException) {
throw IOException(
"Error emitting ${javaFile.packageName}.${javaFile.typeSpec.name} to $outDirectory",
"Error emitting ${javaFile.packageName()}.${javaFile.typeSpec().name()} to $outDirectory",
e,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.squareup.wire.java

import com.squareup.javapoet.JavaFile
import com.palantir.javapoet.JavaFile
import com.squareup.wire.schema.Location
import com.squareup.wire.schema.Profile
import com.squareup.wire.schema.Schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import static com.squareup.wire.schema.SchemaHelpersJvmKt.addFromTest;
import static org.junit.Assert.fail;

import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.TypeSpec;
import com.palantir.javapoet.JavaFile;
import com.palantir.javapoet.TypeSpec;
import com.squareup.wire.SchemaBuilder;
import com.squareup.wire.schema.MessageType;
import com.squareup.wire.schema.PruningRules;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.squareup.wire.java

import com.squareup.javapoet.JavaFile
import com.palantir.javapoet.JavaFile
import com.squareup.wire.schema.Location
import com.squareup.wire.schema.Profile
import com.squareup.wire.schema.Schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.squareup.wire.schema

import com.squareup.javapoet.ClassName
import com.palantir.javapoet.ClassName
import com.squareup.kotlinpoet.ClassName as KClassName

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package com.squareup.wire.schema

import com.squareup.javapoet.ClassName
import com.squareup.javapoet.TypeName
import com.palantir.javapoet.ClassName
import com.palantir.javapoet.TypeName
import com.squareup.kotlinpoet.ClassName as KClassName
import com.squareup.kotlinpoet.TypeName as KTypeName
import com.squareup.wire.schema.internal.ProfileFileElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import assertk.assertThat
import assertk.assertions.hasMessage
import assertk.assertions.isEqualTo
import assertk.assertions.isNull
import com.squareup.javapoet.ClassName
import com.palantir.javapoet.ClassName
import com.squareup.wire.testing.add
import com.squareup.wire.testing.addZip
import java.io.IOException
Expand Down

0 comments on commit 53b4bc8

Please sign in to comment.