### Run Hello World Example (Gradle) Source: https://github.com/rnett/inspekt/blob/context7/examples/README.md This command executes the 'hello-world' example using the Gradle wrapper. It demonstrates a simple Inspekt project runnable on multiple platforms. ```bash ./gradlew :hello-world:run ``` -------------------------------- ### Run Multiplatform Example (Gradle) Source: https://github.com/rnett/inspekt/blob/context7/examples/README.md This command runs the multiplatform example using the Gradle wrapper, specifically targeting the JVM execution. It showcases Inspekt's capabilities in a multiplatform environment. ```bash ./gradlew :multiplatform:jvmRun ``` -------------------------------- ### ClassName Constructor and Example Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model.name/-class-name/index.md Demonstrates the construction of a ClassName object using its package and class segments. This example illustrates how a nested class 'B' within 'com.example' would be represented. ```kotlin package com.example class A { class B {} } // Example usage: val className = ClassName(PackageName("com", "example"), listOf("A", "B")) ``` -------------------------------- ### Get Start Offset of Parameter Kind in Argument List (Kotlin) Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-parameters/index.md Retrieves the starting offset within the parameter list for a specified 'Parameter.Kind'. This function returns an integer representing the offset. A returned value does not guarantee the presence of parameters of the specified kind. ```kotlin fun startOffset(kind: Parameter.Kind): Int ``` -------------------------------- ### Get All Context Parameters Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-parameters/context.md Retrieves the entire list of context parameters without allocating a new list. ```APIDOC ## GET /rnett/inspekt/dev/rnett/inspekt/model/Parameters/context ### Description Retrieves the entire list of context parameters without allocating a new list. ### Method GET ### Endpoint /rnett/inspekt/dev/rnett/inspekt/model/Parameters/context ### Response #### Success Response (200) - **context** (List) - A list of all available context parameters. #### Response Example ```json [ { "name": "param1", "value": "value1" }, { "name": "param2", "value": "value2" } ] ``` ``` -------------------------------- ### Parameter startOffset Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-parameters/start-offset.md Retrieves the starting index (offset) for parameters of a specified kind within a parameter list. ```APIDOC ## startOffset ### Description Get the start offset in the parameter list of the given kind. Returning a value does not guarantee that parameters of type kind are present. ### Method GET ### Endpoint /rnett/inspekt/dev.rnett.inspekt.model.Parameters/startOffset ### Parameters #### Query Parameters - **kind** (Parameter.Kind) - Required - The kind of parameter to find the start offset for. ### Request Example ```json { "kind": "some_parameter_kind" } ``` ### Response #### Success Response (200) - **offset** (Int) - The starting offset of the parameters of the specified kind. #### Response Example ```json { "offset": 5 } ``` ``` -------------------------------- ### PropertyGet.args Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.proxy/-super-call/-property-get/args.md Retrieves the arguments that the function is being called with during a property get operation. ```APIDOC ## GET /rnett/inspekt/dev.rnett.inspekt.proxy.SuperCall.PropertyGet/args ### Description Retrieves the arguments the function is being called with. ### Method GET ### Endpoint /rnett/inspekt/dev.rnett.inspekt.proxy.SuperCall.PropertyGet/args ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **args** (ArgumentList) - The arguments the function is being called with. #### Response Example ```json { "args": { "argument1": "value1", "argument2": 123 } } ``` ``` -------------------------------- ### Retrieve Parameter by Name or Kind/Index (Kotlin) Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-parameters/index.md The `get` function provides multiple ways to retrieve a `Parameter`. You can get a parameter by its `String` name (though not recommended for 'this'), or by its `Parameter.Kind` and index within that kind. It also supports retrieval by a general `Int` index. ```kotlin operator fun get(name: String): Parameter? operator fun get(kind: Parameter.Kind, indexInKind: Int): Parameter open operator override fun get(index: Int): Parameter ``` -------------------------------- ### Reuse Inspection Objects in Kotlin Source: https://github.com/rnett/inspekt/blob/context7/docs/binary-size.md Demonstrates how to reuse Inspekt objects to minimize binary size. Storing the 'Inspektion' object in a property or singleton reduces the number of call sites, thereby reducing the binary footprint. The 'Good' examples show effective reuse, while the 'Bad' example illustrates how multiple call sites increase binary size. ```kotlin // Good: Call once and reuse object MyReflection { val fooInspektion = inspekt(Foo::class) } // Also good: Multiple calls, but a single call site. Binary implementation is added once, inspektion object is re-created each call fun fooInspektion() = inspekt(Foo::class) // Bad: Each call site adds to the binary val foo1 = inspekt(Foo::class) val foo2 = inspekt(Foo::class) ``` -------------------------------- ### Access and Modify Properties with get() and set() in Kotlin Source: https://context7.com/rnett/inspekt/llms.txt Illustrates how to get and set property values of an object using the Inspekt library. It covers accessing properties via class inspection and direct property inspection, including handling mutable properties. ```kotlin import dev.rnett.inspekt.inspekt import dev.rnett.inspekt.model.MutableProperty class Person(var name: String, var age: Int) fun main() { val person = Person("Alice", 30) val personClass = inspekt(Person::class) // Get property value via Inspektion val nameValue = personClass.getProperty(person, "name") println("Name: $nameValue") // Name: Alice // Set property value via Inspektion personClass.setProperty(person, "age", 31) println("New age: ${person.age}") // New age: 31 // Direct property inspection and access val ageProp = inspekt(Person::age) val currentAge = ageProp.get { dispatchReceiver = person } println("Age via property: $currentAge") // Age via property: 31 // Set via property (must cast to MutableProperty for setter) if (ageProp is MutableProperty) { ageProp.set { dispatchReceiver = person value(32) } } println("Updated age: ${person.age}") // Updated age: 32 } ``` -------------------------------- ### Property Access Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-mutable-property/index.md Functions for getting and setting property values. ```APIDOC ## GET /property/get ### Description Retrieves the value of a property by invoking its getter. This can be done using a pre-built `ArgumentList` or an `ArgumentsBuilder`. ### Method GET ### Endpoint /property/get ### Parameters #### Query Parameters - **arguments** (ArgumentList | ArgumentsBuilder) - Required - The arguments to pass to the getter. ### Response #### Success Response (200) - **value** (Any) - The retrieved property value. #### Response Example ```json { "value": "propertyValue" } ``` ## POST /property/set ### Description Sets the value of a property by invoking its setter. This can be done using a pre-built `ArgumentList` or an `ArgumentsBuilder`. ### Method POST ### Endpoint /property/set ### Parameters #### Request Body - **arguments** (ArgumentList | ArgumentsBuilder) - Required - The arguments to pass to the setter. ### Request Example ```json { "arguments": { "args": { "newValue": "someValue" } } } ``` ### Response #### Success Response (200) - **result** (Any) - The result of the setter operation (often the set value or null). #### Response Example ```json { "result": "someValue" } ``` ``` -------------------------------- ### Get Kotlin Property Reference Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-property/kotlin.md This section details how to access the `kotlin` property, which provides a reference to the Kotlin declaration represented by the Inspekt object. ```APIDOC ## GET /rnett/inspekt/dev.rnett.inspekt.model.Property/kotlin ### Description Retrieves a reference to the Kotlin declaration that this Inspekt property represents. ### Method GET ### Endpoint /rnett/inspekt/dev.rnett.inspekt.model.Property/kotlin ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **kotlin** (KProperty1<*, *>) - A reference to the Kotlin declaration this represents. #### Response Example ```json { "kotlin": "" } ``` ``` -------------------------------- ### Get List Iterator for Argument List (Kotlin) Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-parameters/index.md Provides a list iterator for the argument list. Overloads allow obtaining an iterator for the entire list or starting from a specific index. The iterator works with 'Parameter' objects. ```kotlin open override fun listIterator(): ListIterator open override fun listIterator(index: Int): ListIterator ``` -------------------------------- ### PackageName Constructors Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model.name/-package-name/-package-name.md Provides information on how to instantiate the PackageName class using either a list of strings or a variable number of string arguments. ```APIDOC ## PackageName Constructors ### Description This section details the constructors available for the `PackageName` class, allowing for initialization with a collection of package names. ### Method Constructors ### Endpoint N/A (Class Constructors) ### Parameters #### Constructor 1: List - **packageNames** (List) - Required - A list of strings representing package names. #### Constructor 2: vararg String - **packageNames** (String) - Required - A variable number of strings representing package names. ### Request Example ```kotlin // Using List constructor val packageNamesList = listOf("com.example.app", "com.example.utils") val packageNameObj1 = PackageName(packageNamesList) // Using vararg constructor val packageNameObj2 = PackageName("com.example.app", "com.example.utils", "com.example.core") ``` ### Response #### Success Response N/A (Constructors do not return values in the typical API sense, they create objects). #### Response Example N/A ``` -------------------------------- ### Create Instances with Constructor Invocation in Kotlin Source: https://context7.com/rnett/inspekt/llms.txt Explains how to invoke constructors reflectively to create new instances of classes. This includes calling the primary constructor with all arguments, using the invoke operator as a shorthand, and accessing constructor details. ```kotlin import dev.rnett.inspekt.inspekt data class Product(val name: String, val price: Double, val quantity: Int = 1) fun main() { val productClass = inspekt(Product::class) // Invoke primary constructor with all arguments val product1 = productClass.callPrimaryConstructor { value("Laptop", 999.99, 2) } as Product println(product1) // Product(name=Laptop, price=999.99, quantity=2) // Using invoke operator (shorthand for callPrimaryConstructor) val product2 = productClass { value("Mouse", 29.99) // quantity uses default value 1 } as Product println(product2) // Product(name=Mouse, price=29.99, quantity=1) // Access specific constructor val ctor = productClass.primaryConstructor!! println("Is primary: ${ctor.isPrimary}") // Is primary: true println("Parameters: ${ctor.parameters.size}") // Parameters: 3 } ``` -------------------------------- ### Handle Suspend Functions in Kotlin Proxies Source: https://context7.com/rnett/inspekt/llms.txt Shows how to handle suspend functions within proxies using `handleSuspend` in a `ProxyHandler`. This allows asynchronous operations to be managed correctly within the proxy mechanism. The example uses `runBlocking` to execute the suspend functions. ```kotlin import dev.rnett.inspekt.proxy.proxy import dev.rnett.inspekt.proxy.ProxyHandler import kotlinx.coroutines.runBlocking import kotlinx.coroutines.delay interface AsyncApi { suspend fun fetchData(key: String): String fun syncCall(): Int } fun main() = runBlocking { val handler = object : ProxyHandler { override fun SuperCall.handle(): Any? { return when (functionName) { "syncCall" -> 42 else -> throw IllegalStateException("Non-suspend call to $functionName") } } override suspend fun SuperCall.handleSuspend(): Any? { return when (functionName) { "fetchData" -> { delay(100) "Async result for ${args.value(0)}" } else -> handle() } } } val api = proxy(AsyncApi::class, handler = handler) println(api.syncCall()) // 42 println(api.fetchData("config")) // Async result for config } ``` -------------------------------- ### Get Declared Annotations (Kotlin) Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-inspektion/declared-annotations.md Accesses the declaredAnnotations property to get a list of annotations directly present on a class. This property is part of the Inspektion interface in the Inspekt library. No specific dependencies are required beyond the Inspekt library itself. ```kotlin import dev.rnett.inspekt.model.Inspektion // Assuming 'inspektion' is an instance of Inspektion val annotations: List = inspektion.declaredAnnotations ``` -------------------------------- ### Constructor toString Method Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-constructor/to-string.md This method provides a string representation of the constructor, with an option to include the full name. ```APIDOC ## Constructor toString Method ### Description Provides a string representation of the constructor. You can choose to include the full name of the constructor in the output. ### Method `toString(includeFullName: Boolean)` ### Endpoint N/A (This is a method within a class, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin // Example of calling the method (not a direct API request) val constructor = ... // Obtain a constructor object val representation = constructor.toString(true) // Include full name val shortRepresentation = constructor.toString(false) // Exclude full name ``` ### Response #### Success Response (200) - **String** (String) - The string representation of the constructor. ``` -------------------------------- ### Inspekt Proxy Factory (Kotlin) Source: https://context7.com/rnett/inspekt/llms.txt Illustrates the use of Inspekt's proxy factory for creating multiple proxies of the same interface efficiently. This is recommended when generating numerous proxies. ```kotlin import inspek.proxyFactory interface MyService { fun doSomething(): String } val proxyFactory = MyService::proxyFactory // Create multiple proxies using the factory val proxy1 = proxyFactory { /* implementation for proxy1 */ } val proxy2 = proxyFactory { /* implementation for proxy2 */ } ``` -------------------------------- ### Creating Interface Proxies with Inspekt Source: https://context7.com/rnett/inspekt/llms.txt Demonstrates how to create runtime implementations of interfaces using the `proxy` function from `dev.rnett.inspekt.proxy`. It involves defining a `ProxyHandler` to intercept and handle method calls on the generated proxy object. ```kotlin import dev.rnett.inspekt.proxy.proxy import dev.rnett.inspekt.proxy.ProxyHandler interface Logger { fun log(message: String) fun warn(message: String): Boolean } fun main() { // Create a proxy that intercepts all method calls val loggingProxy = proxy(Logger::class) { println("Method called: $functionName with args: ${args.toList()}") when (functionName) { "log" -> { println("[LOG] ${args.value(0)}") Unit } "warn" -> { println("[WARN] ${args.value(0)}") true } else -> null } } loggingProxy.log("Application started") // Output: Method called: log with args: [loggingProxy instance, Application started] // Output: [LOG] Application started val result = loggingProxy.warn("Low memory") // Output: Method called: warn with args: [loggingProxy instance, Low memory] // Output: [WARN] Low memory println("Warn returned: $result") // Warn returned: true } ``` -------------------------------- ### Get Inspektion Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.proxy/-proxyable-inspektion/inspektion.md Retrieves the underlying Inspektion object from a ProxyableInspektion. ```APIDOC ## GET /rnett/inspekt/dev.rnett.inspekt.proxy/ProxyableInspektion/inspektion ### Description Retrieves the underlying `Inspektion` object that the `ProxyableInspektion` is wrapping. This allows direct access to the methods and properties of the original `Inspektion`. ### Method GET ### Endpoint /rnett/inspekt/dev.rnett.inspekt.proxy/ProxyableInspektion/inspektion ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **inspektion** (Inspektion) - The underlying Inspektion object. #### Response Example ```json { "inspektion": { ... } } ``` ``` -------------------------------- ### Manage Proxy Calls with Helper Functions in Kotlin Source: https://github.com/rnett/inspekt/blob/context7/docs/binary-size.md Explains how to manage binary size increases from proxy calls. Similar to 'inspekt()', each 'proxy()' call site adds to binary size. Wrapping repeated proxy calls in a helper function or using 'proxyFactory' helps to avoid this, as shown in the example. ```kotlin fun createFooProxy(handler: ProxyHandler) = proxy(Foo::class, handler) ``` -------------------------------- ### InspektExtension Configuration Source: https://github.com/rnett/inspekt/blob/context7/docs/api/gradle-plugin/gradle-plugin/dev.rnett.inspekt/index.md Provides configuration details for the Inspekt Gradle plugin. ```APIDOC ## InspektExtension ### Description Configuration for the Inspekt Gradle plugin. ### Class `InspektExtension` ### Type abstract class ### Platform jvm ``` -------------------------------- ### Create Reusable Proxy Factory with Kotlin Source: https://context7.com/rnett/inspekt/llms.txt Demonstrates how to create a reusable proxy factory using `proxyFactory`. This factory can generate multiple proxies with different handlers, optimizing for binary size by incurring compile-time overhead only once. It takes an interface class as input and returns a factory function. ```kotlin import dev.rnett.inspekt.proxy.proxyFactory import dev.rnett.inspekt.proxy.ProxyHandler interface Repository { fun save(data: String): Boolean fun load(id: Int): String } fun main() { // Create factory once (compile-time overhead only here) val repoFactory = proxyFactory(Repository::class) // Create multiple proxies with different handlers (no additional overhead) val mockRepo = repoFactory { when (functionName) { "save" -> true "load" -> "Mock data for ${args.value(0)}" else -> null } } val loggingRepo = repoFactory { println("Repository.${functionName} called") when (functionName) { "save" -> true "load" -> "Logged data for ${args.value(0)}" else -> null } } println(mockRepo.load(1)) // Mock data for 1 println(loggingRepo.load(2)) // Repository.load called // Logged data for 2 } ``` -------------------------------- ### GET /rnett/inspekt/SuperCall/FunctionCall/args Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.proxy/-super-call/-function-call/args.md Retrieves the arguments that the function is being called with. This is part of the SuperCall.FunctionCall context. ```APIDOC ## GET /rnett/inspekt/SuperCall/FunctionCall/args ### Description Retrieves the arguments that the function is being called with. This is part of the SuperCall.FunctionCall context. ### Method GET ### Endpoint /rnett/inspekt/SuperCall/FunctionCall/args ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **args** (ArgumentList) - The arguments the function is being called with. #### Response Example { "args": { "example": "ArgumentList object" } } ``` -------------------------------- ### Create Interface Proxy with Handler Source: https://github.com/rnett/inspekt/blob/context7/docs/proxies.md Demonstrates how to create a proxy for a given interface using the `proxy()` function and a lambda expression for the `ProxyHandler`. This is the primary method for generating proxies in Inspekt. ```kotlin val myProxy = proxy(MyInterface::class) { // handler implementation } ``` -------------------------------- ### Value Retrieval Functions Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model.arguments/-argument-list/index.md Provides functions to get values from the object based on index. ```APIDOC ## GET /v1Get ### Description Gets the argument at the specified global index, or null if it was not set. ### Method GET ### Endpoint /v1Get ### Parameters #### Query Parameters - **globalIndex** (Int) - Required - The global index of the argument to retrieve. ### Request Example None ### Response #### Success Response (200) - **value** (Any?) - The value of the argument, or null if not set. #### Response Example ```json { "value": "some_value" } ``` ``` ```APIDOC ## GET /value ### Description Gets the value parameter at the specified index, if it is set. To distinguish between explicitly passing `null` and using the default value, use `isDefaulted`. ### Method GET ### Endpoint /value ### Parameters #### Query Parameters - **index** (Int) - Required - The index of the value parameter to retrieve. ### Request Example None ### Response #### Success Response (200) - **value** (Any?) - The value of the parameter, or null if not set. #### Response Example ```json { "value": "parameter_value" } ``` ``` -------------------------------- ### Accessing Kotlin Objects and Companion Objects with Inspekt Source: https://context7.com/rnett/inspekt/llms.txt Shows how to access Kotlin object instances and companion objects reflectively using `inspekt`. This includes retrieving properties and invoking functions from both singleton objects and companion objects, requiring the `dev.rnett.inspekt.inspekt` import. ```kotlin import dev.rnett.inspekt.inspekt object AppConfig { val version = "1.0.0" fun getEnvironment() = "production" } class DatabaseManager { companion object { val connectionPool = "default-pool" fun getMaxConnections() = 10 } } fun main() { // Access object instance val configClass = inspekt(AppConfig::class) val configInstance = configClass.objectInstance!! println("Version: ${configClass.getProperty(configInstance, "version")}") // Version: 1.0.0 // Access companion object val dbClass = inspekt(DatabaseManager::class) val companion = dbClass.companionObject!! val companionInstance = dbClass.companionObjectInstance!! println("Pool: ${companion.getProperty(companionInstance, "connectionPool")}") // Pool: default-pool val maxConns = companion.function("getMaxConnections").invoke { dispatchReceiver = companionInstance } println("Max connections: $maxConns") // Max connections: 10 } ``` -------------------------------- ### Combined Inspection and Proxy Creation with Kotlin Source: https://context7.com/rnett/inspekt/llms.txt Demonstrates the `inspektAndProxy` function, which provides both an `Inspektion` object and a proxy factory in a single call. This offers maximum flexibility by allowing access to interface metadata (like function and property names) and the ability to create proxies simultaneously. ```kotlin import dev.rnett.inspekt.proxy.inspektAndProxy interface Service { val name: String fun process(input: String): String } fun main() { val proxyable = inspektAndProxy(Service::class) // Access the Inspektion println("Interface: ${proxyable.inspektion.name}") proxyable.inspektion.functions.forEach { println(" Function: ${it.shortName}") } proxyable.inspektion.properties.forEach { println(" Property: ${it.shortName}") } // Create proxies using the factory val impl = proxyable.createProxy { when { propertyName == "name" -> "MyService" functionName == "process" -> "Processed: ${args.value(0)}" else -> null } } println(impl.name) // MyService println(impl.process("data")) // Processed: data } ``` -------------------------------- ### SpecialNames.propertyForSetter Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model.name/-special-names/property-for-setter.md Gets the property name for a setter named 'setterName', or null if 'setterName' is not the name of a setter. ```APIDOC ## SpecialNames.propertyForSetter ### Description Gets the property name for a setter named `setterName`, or `null` if `setterName` is not the name of a setter. ### Method GET ### Endpoint /rnett/inspekt/dev.rnett.inspekt.model.name/SpecialNames/propertyForSetter ### Parameters #### Query Parameters - **setterName** (String) - Required - The name of the setter to find the corresponding property for. ### Response #### Success Response (200) - **String?** - The name of the property if found, otherwise null. #### Response Example ```json { "propertyName": "exampleProperty" } ``` #### Error Response (400) - **String** - Error message indicating the setter name was not found. #### Error Response Example ```json { "error": "Setter name 'invalidSetter' not found." } ``` ``` -------------------------------- ### Basic Inspekt Usage in Kotlin Source: https://github.com/rnett/inspekt/blob/context7/README.md Demonstrates fundamental Inspekt usage for inspecting a class and invoking a function. It shows how to obtain a class reference and then call a function on an instance of that class. ```kotlin val fooClass = inspekt(Foo::class) foo.function("bar").invoke { dispatchReceiver = Foo() } ``` -------------------------------- ### SpecialNames.propertyForGetter Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model.name/-special-names/property-for-getter.md Gets the property name for a getter named 'getterName', or null if 'getterName' is not the name of a getter. ```APIDOC ## SpecialNames.propertyForGetter ### Description Gets the property name for a getter named `getterName`, or `null` if `getterName` is not the name of a getter. ### Method GET ### Endpoint `/rnett/inspekt/dev.rnett.inspekt.model.name/SpecialNames/propertyForGetter` ### Parameters #### Query Parameters - **getterName** (String) - Required - The name of the getter. ### Response #### Success Response (200) - **propertyName** (String?) - The name of the property associated with the getter, or null if the name is not a getter. ``` -------------------------------- ### Basic Inspekt Usage (Kotlin) Source: https://context7.com/rnett/inspekt/llms.txt Demonstrates the basic usage of Inspekt for inspecting a class member. It highlights the preferred syntax for single member inspection. ```kotlin import inspek.Inspekt class Foo { fun bar() { /* ... */ } } // Preferred syntax for single member inspection val inspection = inspek(Foo::bar) ``` -------------------------------- ### Invoke Functions with Arguments Builder in Kotlin Source: https://context7.com/rnett/inspekt/llms.txt Demonstrates how to invoke regular functions using the `invoke` method with an arguments builder lambda. This allows for dynamic invocation of methods with specified arguments, including handling default parameter values and named parameters. ```kotlin import dev.rnett.inspekt.inspekt class MathService { fun calculate(x: Int, y: Int, operation: String = "add"): Int { return when (operation) { "add" -> x + y "multiply" -> x * y else -> 0 } } } fun main() { val service = MathService() val calcFunc = inspekt(MathService::calculate) // Invoke with all arguments val result1 = calcFunc.invoke { dispatchReceiver = service value(10, 5, "multiply") } println("10 * 5 = $result1") // 10 * 5 = 50 // Invoke with default parameter (omit operation) val result2 = calcFunc.invoke { dispatchReceiver = service value(10, 5) // operation uses default "add" } println("10 + 5 = $result2") // 10 + 5 = 15 // Using named parameters val result3 = calcFunc.invoke { dispatchReceiver = service this["x"] = 20 this["y"] = 3 this["operation"] = "add" } println("20 + 3 = $result3") // 20 + 3 = 23 } ``` -------------------------------- ### GET /rnett/inspekt/dev.rnett.inspekt.model/TypeParameter/variance Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-type-parameter/variance.md Retrieves the variance of a specific TypeParameter. This endpoint is part of the Inspekt project's model. ```APIDOC ## GET /rnett/inspekt/dev.rnett.inspekt.model/TypeParameter/variance ### Description Retrieves the variance of a specific TypeParameter. This endpoint is part of the Inspekt project's model. ### Method GET ### Endpoint /rnett/inspekt/dev.rnett.inspekt.model/TypeParameter/variance ### Parameters #### Query Parameters - **variance** (TypeParameter.Variance) - Required - The variance of the type parameter. ### Request Example ```json { "example": "variance: IN" } ``` ### Response #### Success Response (200) - **variance** (TypeParameter.Variance) - The variance of the type parameter. #### Response Example ```json { "variance": "IN" } ``` ``` -------------------------------- ### Argument Building Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-property-getter/index.md Utility for building argument lists for function calls. ```APIDOC ## POST /arguments/build ### Description Builds an `ArgumentList` for a given callable. Parameters without explicit values will use their default values if available. Ensures all non-default parameters are provided. ### Method POST ### Endpoint `/arguments/build` ### Parameters #### Request Body - **callableReference** (string) - Required - A reference to the callable (e.g., its fully qualified name). - **arguments** (object) - Optional - A map of parameter names to their values. ### Request Example ```json { "callableReference": "com.example.MyClass.myMethod", "arguments": { "param1": "value1", "param2": 123 } } ``` ### Response #### Success Response (200) - **argumentList** (object) - The constructed `ArgumentList`. #### Response Example ```json { "argumentList": { "param1": "value1", "param2": 123, "param3": "defaultValue" } } ``` ``` -------------------------------- ### Get Parameter Annotations Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-parameter/annotations.md Fetches a list of all annotations present on a parameter, encompassing both direct and inherited annotations. ```APIDOC ## GET /rnett/inspekt/model/Parameter/annotations ### Description Retrieves all annotations on this element, including inherited ones. ### Method GET ### Endpoint /rnett/inspekt/model/Parameter/annotations ### Parameters #### Query Parameters None ### Request Example ``` GET /rnett/inspekt/model/Parameter/annotations ``` ### Response #### Success Response (200) - **annotations** (List) - A list of all annotations on the parameter, including inherited ones. #### Response Example ```json { "annotations": [ "com.example.MyAnnotation", "java.Override" ] } ``` ``` -------------------------------- ### GET /rnett/inspekt/dev.rnett.inspekt.model/Inspektion/supertypes Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-inspektion/supertypes.md Retrieves the set of supertypes for a given Inspektion object. This endpoint is part of the dev.rnett.inspekt.model package. ```APIDOC ## GET /rnett/inspekt/dev.rnett.inspekt.model/Inspektion/supertypes ### Description Retrieves the set of supertypes for a given Inspektion object. ### Method GET ### Endpoint /rnett/inspekt/dev.rnett.inspekt.model/Inspektion/supertypes ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **supertypes** (Set) - The set of supertypes for the Inspektion object. #### Response Example { "supertypes": [ { "classifier": "kotlin.Any", "arguments": [], "isMarkedNullable": false } ] } ``` -------------------------------- ### InspektPlugin Source: https://github.com/rnett/inspekt/blob/context7/docs/api/gradle-plugin/gradle-plugin/dev.rnett.inspekt/index.md The main Inspekt Gradle plugin class. ```APIDOC ## InspektPlugin ### Description The Inspekt Gradle plugin. See [InspektExtension](-inspekt-extension/index.md). ### Class `InspektPlugin` ### Constructor `@Inject constructor(providers: ProviderFactory)` ### Type class ### Platform jvm ``` -------------------------------- ### Get Annotation Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/annotation.md Retrieves the first annotation of a specified type from an AnnotatedElement. Returns null if no such annotation is found. ```APIDOC ## GET /rnett/inspekt/model/annotation ### Description Retrieves the first annotation of a specified type from an AnnotatedElement. Returns null if no such annotation is found. ### Method GET ### Endpoint /rnett/inspekt/model/annotation ### Parameters #### Query Parameters - **element** (AnnotatedElement) - Required - The element to inspect for annotations. - **annotationType** (KClass) - Required - The type of annotation to retrieve. ### Request Example ``` GET /rnett/inspekt/model/annotation?element=&annotationType= ``` ### Response #### Success Response (200) - **annotation** (T) - The found annotation, or null if not present. #### Response Example ```json { "annotation": { "@type": "com.example.MyAnnotation", "someField": "someValue" } } ``` #### Error Response (400) - **error** (string) - Description of the error, e.g., "Invalid annotation type specified." ``` -------------------------------- ### Get Property Setter Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-property/setter.md Retrieves the setter function associated with a property. This is useful for inspecting or invoking the setter logic. ```APIDOC ## GET /rnett/inspekt/model/Property/setter ### Description Retrieves the setter function associated with a property. This is useful for inspecting or invoking the setter logic. ### Method GET ### Endpoint /rnett/inspekt/model/Property/setter ### Parameters #### Query Parameters - **propertyName** (string) - Required - The name of the property to get the setter for. ### Response #### Success Response (200) - **setter** (PropertySetter) - The setter function of the property, or null if no setter exists. #### Response Example ```json { "setter": { "description": "Sets the value of the property.", "parameters": [ { "name": "value", "type": "Any?" } ] } } ``` ``` -------------------------------- ### GET /rnett/inspekt/dev.rnett.inspekt.model/Property/getter Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-property/getter.md Retrieves the getter for a given property. This endpoint allows access to the property's getter functionality. ```APIDOC ## GET /rnett/inspekt/dev.rnett.inspekt.model/Property/getter ### Description Retrieves the getter for a given property. This endpoint allows access to the property's getter functionality. ### Method GET ### Endpoint /rnett/inspekt/dev.rnett.inspekt.model/Property/getter ### Parameters #### Query Parameters - **propertyName** (string) - Required - The name of the property whose getter is to be retrieved. ### Request Example ```json { "propertyName": "exampleProperty" } ``` ### Response #### Success Response (200) - **getter** (PropertyGetter) - The getter object for the specified property. #### Response Example ```json { "getter": { "description": "Example getter description" } } ``` ``` -------------------------------- ### Accessing Annotations with Inspekt Source: https://context7.com/rnett/inspekt/llms.txt Illustrates how to access annotation instances on classes, functions, and parameters using `inspekt`. It covers retrieving specific annotations and iterating through all annotations with their source information, requiring the `dev.rnett.inspekt.inspekt` import. ```kotlin import dev.rnett.inspekt.inspekt @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) @Retention(AnnotationRetention.RUNTIME) annotation class Api(val version: String) @Target(AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.RUNTIME) annotation class Required @Api(version = "2.0") class UserService { @Api(version = "1.5") fun getUser(@Required id: Int): String = "User $id" } fun main() { val serviceClass = inspekt(UserService::class) // Get class annotations val classAnnotation = serviceClass.annotations.filterIsInstance().firstOrNull() println("Class API version: ${classAnnotation?.version}") // Class API version: 2.0 // Get function annotations val getUserFunc = serviceClass.function("getUser") val funcAnnotation = getUserFunc.annotations.filterIsInstance().firstOrNull() println("Function API version: ${funcAnnotation?.version}") // Function API version: 1.5 // Access all annotations with source info serviceClass.allAnnotations.forEach { info -> println("Annotation: ${info.annotation}, Source: ${info.source}") } } ``` -------------------------------- ### ArgumentList Function Overloads Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model.arguments/index.md Provides two ways to build an ArgumentList: using a builder lambda or providing a pre-defined list of arguments. ```APIDOC ## Functions: ArgumentList ### Description Builds an `ArgumentList` for a set of parameters. The first overload uses a builder lambda, allowing for default value usage. The second overload requires all argument values to be provided upfront. ### Overload 1: Using Builder #### Method `inline fun ArgumentList(parameters: Parameters, builder: ArgumentsBuilder): ArgumentList` #### Parameters - **parameters** (Parameters) - The set of parameters for which to build arguments. - **builder** (ArgumentsBuilder) - A lambda function to construct the arguments. #### Description Parameters not set in the builder will use their default values if available. Successfully building guarantees values for all non-default parameters. ### Overload 2: Using List of Arguments #### Method `fun ArgumentList(parameters: Parameters, args: List): ArgumentList` #### Parameters - **parameters** (Parameters) - The set of parameters. - **args** (List) - A list containing all argument values. The size must match the number of parameters. #### Description Builds an `ArgumentList` where all argument values are explicitly provided. The size of the `args` list must exactly match the size of the `parameters`. ### Request Example (Overload 1) ```kotlin val params = Parameters(...) val argList = ArgumentList(params) { // set arguments here } ``` ### Request Example (Overload 2) ```kotlin val params = Parameters(...) val args = listOf(value1, value2) val argList = ArgumentList(params, args) ``` ### Response #### Success Response (200) - **ArgumentList** (ArgumentList) - The constructed ArgumentList. ``` -------------------------------- ### Annotation Retrieval Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-function/index.md Functions to retrieve annotations from an AnnotatedElement. You can get a single annotation or a list of all annotations of a specific type. ```APIDOC ## GET /annotation ### Description Retrieves the first annotation of a specified type from an AnnotatedElement. Returns null if no annotation of that type is found. ### Method GET ### Endpoint `/annotation` ### Parameters #### Query Parameters - **T** (Type) - Required - The type of the annotation to retrieve. ### Response #### Success Response (200) - **annotation** (Annotation) - The found annotation, or null if not present. #### Response Example ```json { "annotation": "@MyAnnotation" } ``` ## GET /annotations ### Description Retrieves all annotations of a specified type from an AnnotatedElement. ### Method GET ### Endpoint `/annotations` ### Parameters #### Query Parameters - **T** (Type) - Required - The type of the annotations to retrieve. ### Response #### Success Response (200) - **annotations** (List) - A list of all annotations of the specified type. #### Response Example ```json { "annotations": [ "@MyAnnotation1", "@MyAnnotation2" ] } ``` ``` -------------------------------- ### Apply Inspekt Plugin to Gradle Project (Kotlin) Source: https://github.com/rnett/inspekt/blob/context7/docs/api/gradle-plugin/gradle-plugin/dev.rnett.inspekt/-inspekt-plugin/apply.md This code snippet demonstrates how to apply the Inspekt plugin to a Gradle project using Kotlin. It overrides the `apply` method from the `Project` interface, taking a `Project` object as input. No specific dependencies are mentioned, and the output is the application of the plugin to the target project. ```kotlin open override fun apply(target: Project) ``` -------------------------------- ### Class or Null Helper Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.utils/index.md Provides a utility function to get the base class of a KType, returning null if it doesn't exist. ```APIDOC ## KType.classOrNull ### Description Gets the base class of the type, if it exists. ### Method GET ### Endpoint N/A (Extension function on KType) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin import kotlin.reflect.KType val myType: KType = ... // Obtain a KType instance val baseClass = myType.classOrNull() ``` ### Response #### Success Response (200) - **KClass<*>?**: The base class of the type, or null if it doesn't exist. #### Response Example ```json { "example": "KClass?" } ``` ``` -------------------------------- ### Constructor forClass Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-constructor/for-class.md Provides access to the Inspekt class constructed by this constructor. ```APIDOC ## Constructor forClass ### Description Provides access to the Inspekt class constructed by this constructor. ### Method GET ### Endpoint /rnett/inspekt/constructor/forClass ### Parameters #### Query Parameters - **className** (string) - Required - The name of the class to inspect. ### Request Example ```json { "className": "com.example.MyClass" } ``` ### Response #### Success Response (200) - **inspektion** (Inspektion<*>) - The Inspekt class instance. #### Response Example ```json { "inspektion": { "className": "com.example.MyClass", "fields": [], "methods": [] } } ``` ``` -------------------------------- ### ProxyHandler Interface Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.proxy/-proxy-handler/index.md Documentation for the ProxyHandler interface and its methods. ```APIDOC ## ProxyHandler Interface ### Description A handler for calls to Inspekt proxies. Will be called for all method or property accessors on the proxy object. Any calls to functions, or access of properties, will result in a call to `handle`, or `handleSuspend` for suspending functions. By default, `handleSuspend` simply calls `handle`. ### Methods #### `handle` ##### Description Handle a call to this proxy. ##### Method `abstract fun` ##### Endpoint N/A (Interface method) ##### Parameters None ##### Request Example N/A ##### Response * **Return Type**: `Any?` - The result of the handled call. ##### Response Example N/A #### `handleSuspend` ##### Description Handle a suspending call to this proxy. Defaults to calling `handle`. ##### Method `open suspend fun` ##### Endpoint N/A (Interface method) ##### Parameters None ##### Request Example N/A ##### Response * **Return Type**: `Any?` - The result of the handled suspending call. ##### Response Example N/A ``` -------------------------------- ### Property Setter Name Generation Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model.name/-special-names/setter.md This endpoint allows you to get the name of a setter for a specific property using the Inspekt library. ```APIDOC ## GET /inspekt/model/name/SpecialNames/setter ### Description Retrieves the name of a setter for a given property. ### Method GET ### Endpoint /inspekt/model/name/SpecialNames/setter ### Parameters #### Query Parameters - **property** (String) - Required - The name of the property for which to get the setter name. ### Request Example No request body needed for this GET request. ### Response #### Success Response (200) - **String** (String) - The name of the setter for the specified property. #### Response Example ```json { "setterName": "setPropertyName" } ``` ``` -------------------------------- ### Argument Building Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/-callable/index.md Functionality for building argument lists for callable entities. ```APIDOC ## POST /rnett/inspekt/model/arguments/build-arguments ### Description Builds an ArgumentList for a callable entity, setting provided arguments and using default values for others. Ensures all non-default parameters are satisfied. ### Method POST ### Endpoint /rnett/inspekt/model/arguments/build-arguments ### Parameters #### Request Body - **callable** (Callable) - Required - The callable entity for which to build arguments. - **builder** (ArgumentsBuilder) - Required - A builder object to define the arguments. ### Request Example ```json { "callable": {"name": "myFunction"}, "builder": { "arguments": { "param1": "value1" } } } ``` ### Response #### Success Response (200) - **argumentList** (ArgumentList) - The constructed argument list. #### Response Example ```json { "argumentList": { "param1": "value1", "param2": "defaultValue" } } ``` ``` -------------------------------- ### Get Annotations by Type Source: https://github.com/rnett/inspekt/blob/context7/docs/api/inspekt/inspekt/dev.rnett.inspekt.model/annotations.md Retrieves all annotations of a specified type from an annotated element. This is a common utility function for reflection-based tasks. ```APIDOC ## GET /rnett/inspekt/annotations ### Description Retrieves all annotations of a specific type `T` from an `AnnotatedElement`. ### Method GET ### Endpoint `/rnett/inspekt/annotations` ### Parameters #### Query Parameters - **type** (string) - Required - The fully qualified name of the annotation type to retrieve. ### Request Example ``` GET /rnett/inspekt/annotations?type=com.example.MyAnnotation ``` ### Response #### Success Response (200) - **annotations** (List) - A list of annotations of the specified type `T` found on the element. #### Response Example ```json { "annotations": [ { "@class": "com.example.MyAnnotation", "someField": "someValue" } ] } ``` ```