Skip to content

Commit

Permalink
Remove dead code, start to add some ktdoc (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pranjalvachaspati-toast authored Oct 13, 2021
1 parent e237a23 commit 36ca69e
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 408 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import com.toasttab.protokt.codegen.protoc.Service
import com.toasttab.protokt.codegen.protoc.TopLevelType
import com.toasttab.protokt.codegen.protoc.TypeDesc

/**
* Annotates an unannotated AST. This effectively converts the protobuf AST to a Kotlin AST.
*/
object Annotator {
const val rootGoogleProto = "google.protobuf"
const val googleProto = ".google.protobuf"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object HeaderAccumulator {
is Import.PackageMethod -> addImport(it.pkg.toString(), it.name)
}
}
}
}.indent(" ")

private fun `package`(protocol: Protocol) =
kotlinPackage(protocol).let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,7 @@ private constructor(
} else {
val properties = annotateProperties(msg, ctx)
val messageInfo = messageInfo()
MessageTemplate.render(
message = messageInfo(),
properties = annotateProperties(msg, ctx),
oneofs = listOf(), // annotateOneofs(msg, ctx),
sizeof = listOf(), // annotateMessageSizeOld(msg, ctx),
serialize = listOf(), // annotateSerializer(msg, ctx),
deserialize = listOf(), // annotateDeserializerNew(msg, ctx),
nested = listOf(), // nestedTypes(),
options = options()
)

TypeSpec.classBuilder(msg.name)
.handleAnnotations(messageInfo)
.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import com.toasttab.protokt.codegen.template.Renderers.DefaultValue
import com.toasttab.protokt.codegen.template.Renderers.Standard
import com.toasttab.protokt.codegen.template.Oneof as OneofTemplate

/**
*
*/
internal class PropertyAnnotator
private constructor(
private val msg: Message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import com.toasttab.protokt.codegen.model.FieldType
import com.toasttab.protokt.codegen.model.PClass
import com.toasttab.protokt.ext.Protokt

/**
* Converts a message in the format used by protoc to the unannotated AST used by protokt.
*/
fun toProtocol(ctx: ProtocolContext) =
Protocol(
FileDesc(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,11 @@ import com.toasttab.protokt.codegen.impl.Deprecation
import com.toasttab.protokt.codegen.model.PClass

object Message {
object Message : StTemplate(StGroup.Message) {
fun render(
message: MessageInfo,
serialize: List<SerializerInfo>,
deserialize: List<DeserializerInfo>,
sizeof: List<SizeofInfo>,
properties: List<PropertyInfo>,
oneofs: List<String>,
nested: List<String>,
options: Options
) =
renderArgs(
message,
serialize,
deserialize,
sizeof,
properties,
oneofs,
nested,
options
)
object Message {

/**
* Contains metadata about the message. Does not contain information about the contents of the message.
*/
class MessageInfo(
val name: String,
val doesImplement: Boolean,
Expand All @@ -55,6 +38,9 @@ object Message {
val name: String
}

/**
* Contains type information about a protobuf field (or oneof) that is relevant to the Kotlin interface
*/
class PropertyInfo(
override val name: String,
val propertyType: String,
Expand All @@ -74,6 +60,9 @@ object Message {
val deprecation: Deprecation.RenderOptions? = null
) : FieldInfo

/**
* Information relevant to reading and writing a message (and other stuff outside the standard access interface?)
*/
interface FieldWriteInfo : FieldInfo {
val fieldName: String
val conditionals: List<ConditionalParams>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,13 @@

package com.toasttab.protokt.codegen.template

import com.toasttab.protokt.codegen.protoc.Method

abstract class ServicesTemplate : StTemplate(StGroup.Services)

object Services {
object Service : ServicesTemplate() {
fun render(
generateService: Boolean,
generateDescriptor: Boolean,
name: String,
qualifiedName: String,
grpcDescriptor: String,
methods: List<MethodInfo>,
reflectInfo: ReflectInfo
) =
renderArgs(
generateService,
generateDescriptor,
name,
qualifiedName,
grpcDescriptor,
methods,
reflectInfo
)

class MethodInfo(
val name: String,
val lowerName: String,
val body: String,
val `in`: String,
val `out`: String
)

class ReflectInfo(
val index: Int,
val fileDescriptorObjectName: String
)
}

object Descriptor : ServicesTemplate() {
fun render(methods: List<String>) =
renderArgs(methods)
}

object Method : ServicesTemplate() {
fun render(
name: String,
type: String,
`in`: String,
out: String,
options: MethodOptions
) =
renderArgs(name, type, `in`, out, options)

class MethodOptions(
val requestMarshaller: String?,
val responseMarshaller: String?
)
}

object MethodType : ServicesTemplate() {
fun render(method: com.toasttab.protokt.codegen.protoc.Method) =
fun render(method: Method) =
renderArgs(method)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ package com.toasttab.protokt.codegen.template

sealed class StGroup {
val fileName
get() = "${this::class.java.simpleName.decapitalize()}.stg"
get() = "${this::class.java.simpleName.decapitalize(java.util.Locale.ROOT)}.stg"

object Descriptor : StGroup()
object Header : StGroup()
object Message : StGroup()
object Oneof : StGroup()
object Options : StGroup()
object Renderers : StGroup()
Expand Down
24 changes: 0 additions & 24 deletions protokt-codegen/src/main/resources/header.stg

This file was deleted.

Loading

0 comments on commit 36ca69e

Please sign in to comment.