Package-level declarations

Properties

Link copied to clipboard
val KClass<*>.fqName: FqName

Returns the computed FqName representation of this KClass.

Link copied to clipboard
val TypeName.unwrappedTypes: List<TypeName>

For Map<String, Int> this will return `String`, `Int`. For star projections like List<*> the result will be mapped to Any.

Functions

Link copied to clipboard
fun KotlinType.argumentType(): KotlinType
fun ConstantValue<*>.argumentType(module: ModuleDescriptor): KotlinType
Link copied to clipboard
fun ClassDescriptor.asClassName(): ClassName
fun ClassId.asClassName(): ClassName
fun FqName.asClassName(module: ModuleDescriptor): ClassName
Link copied to clipboard
fun FileSpec.Companion.buildFile(packageName: String, fileName: String, generatorComment: String = "Generated by Anvil.", block: FileSpec.Builder.() -> Unit): String
Link copied to clipboard
Link copied to clipboard
fun KotlinType.classDescriptor(): ClassDescriptor
Link copied to clipboard
fun KotlinType.classDescriptorOrNull(): ClassDescriptor?
Link copied to clipboard
fun FqName.classIdBestGuess(): ClassId
Link copied to clipboard
fun PsiElement.containingFileAsJavaFile(): File
Link copied to clipboard
fun FileSpec.Companion.createAnvilSpec(packageName: String, fileName: String, generatorComment: String = "Generated by Anvil.", block: FileSpec.Builder.() -> Unit): FileSpec
Link copied to clipboard
Link copied to clipboard
fun FqName.descendant(segments: String): FqName
Link copied to clipboard
fun TypeName.findRawType(): ClassName?

Returns the raw type for this TypeName or null if one can't be resolved.

Link copied to clipboard
fun PsiElement.fqNameOrNull(module: ModuleDescriptor): FqName?
Link copied to clipboard
fun FqName.getContributedPropertyOrNull(module: ModuleDescriptor): PropertyDescriptor?

Assumes that the FqName is a top-level property, e.g. com.squareup.CONSTANT.

Link copied to clipboard
fun PsiElement.ktFile(): KtFile
Link copied to clipboard
fun FqName.parents(): Sequence<FqName>

Generates a sequence of FqName starting from the current FqName and including its parents up to the root. The sequence will not include the current FqName.

Link copied to clipboard
fun FqName.parentsWithSelf(): Sequence<FqName>

Generates a sequence of FqName starting from the current FqName and including its parents up to the root. The sequence will include the current FqName as well.

Link copied to clipboard
fun KtNamedDeclaration.requireFqName(): FqName
fun PsiElement.requireFqName(module: ModuleDescriptor): FqName
Link copied to clipboard
fun TypeName.requireRawType(): ClassName

Returns the result of findRawType or throws.

Link copied to clipboard
fun FqName.safePackageString(dotPrefix: Boolean = false, dotSuffix: Boolean = true): String

fun String.safePackageString(isRoot: Boolean = isEmpty(), dotPrefix: Boolean = false, dotSuffix: Boolean = true): String

This function should only be used for package names. If the FqName is the root (no package at all), then this function returns an empty string whereas toString() would return "". For a more convenient string concatenation the returned result can be prefixed and suffixed with an additional dot. The root package never will use a prefix or suffix.

Link copied to clipboard
fun TypeName.withJvmSuppressWildcardsIfNeeded(annotatedReference: AnnotatedReference, typeReference: TypeReference): TypeName