Skip to content

Commit

Permalink
[J2KT] Fix KDoc comments in TypeDescriptorRenderer to match the guide…
Browse files Browse the repository at this point in the history
…lines.

PiperOrigin-RevId: 585673064
  • Loading branch information
Googler authored and copybara-github committed Nov 27, 2023
1 parent 4aa0264 commit cff83e5
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ import com.google.j2cl.transpiler.backend.kotlin.source.Source.Companion.source
import com.google.j2cl.transpiler.backend.kotlin.source.Source.Companion.spaceSeparated
import com.google.j2cl.transpiler.backend.kotlin.source.orEmpty

/**
* Returns source for the given type descriptor.
*
* @param typeDescriptor the type descriptor to get the source for
* @param asSuperType whether to use bridge name for the super-type
* @param projectRawToWildcards whether to project raw types to use wildcards
*/
internal fun Renderer.typeDescriptorSource(
typeDescriptor: TypeDescriptor,
asSuperType: Boolean = false,
Expand All @@ -51,9 +58,16 @@ internal fun Renderer.typeDescriptorSource(
)
.source(typeDescriptor.withImplicitNullability)

/** Returns source for the given list of type arguments. */
internal fun Renderer.typeArgumentsSource(typeArguments: List<TypeArgument>): Source =
TypeDescriptorRenderer(this).argumentsSource(typeArguments)

/**
* Returns source containing qualified name for the given type descriptor.
*
* @param typeDescriptor the type descriptor to get the source for
* @param asSuperType whether to use bridge name for the super-type
*/
internal fun Renderer.qualifiedNameSource(
typeDescriptor: TypeDescriptor,
asSuperType: Boolean = false
Expand Down Expand Up @@ -86,19 +100,19 @@ internal fun Renderer.qualifiedNameSource(
topLevelQualifiedNameSource(typeDescriptor.ktQualifiedName())
}

/** Type descriptor renderer. */
/**
* Type descriptor renderer, contains options for rendering type descriptor sources.
*
* @property renderer the underlying renderer
* @property seenTypeVariables a set of seen type variables used to detect recursion
* @property asSuperType whether to render a super-type, using bridge name if present
* @property projectRawToWildcards whether to project raw types to wildcards, or bounds
*/
private data class TypeDescriptorRenderer(
/** The underlying renderer. */
val renderer: Renderer,

/** Set of seen type variables used to detect recursion. */
val seenTypeVariables: Set<TypeVariable> = setOf(),

// TODO(b/246842682): Remove when bridge types are materialized as TypeDescriptors
/** Whether to render a super-type, using bridge name if present. */
val asSuperType: Boolean = false,

/** Whether to project RAW types to wildcards, or bounds. */
val projectRawToWildcards: Boolean = false
) {
/** Renderer for child type descriptors, including: arguments, bounds, intersections, etc... */
Expand Down

0 comments on commit cff83e5

Please sign in to comment.