source Declaration
Represents the source declaration associated with this type.
The sourceDeclaration property provides access to the declaration of the type within the Kotlin codebase. It allows retrieving additional information about the declaration, such as its properties, functions, annotations, and other relevant metadata.
It points to an instance of KoSourceDeclaration, which serves as the base interface for various types:
KoClassDeclarationrepresents classKoInterfaceDeclarationrepresents interfaceKoObjectDeclarationrepresents objectKoTypeAliasDeclarationrepresents type aliasKoImportAliasDeclarationrepresents import aliasKoKotlinTypeDeclarationrepresents Kotlin basic types and collectionsKoFunctionDeclarationrepresents function typeKoExternalDeclarationrepresents declaration which is not defined in the project
For import statements, sourceDeclaration refers to the declaration being imported. Similarly, for an import alias, sourceDeclaration also refers to the declaration being imported, allowing direct access to the original declaration.
Example usage:
scope
.properties()
.types
.assertTrue { it.isInterface }