### Get Annotations from AnnotatedElement in Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-function-like/index Provides examples of retrieving annotations from an AnnotatedElement using extension functions. 'annotation()' gets the first annotation of a specific type, while 'annotations()' retrieves all annotations of that type. ```kotlin inline fun AnnotatedElement.annotation(): T? inline fun AnnotatedElement.annotations(): List ``` -------------------------------- ### Get and Set Property Values Source: https://inspekt.rnett.dev/latest/invoking Illustrates how to get and set property values using Inspekt. This includes configuring the dispatch receiver and providing values for setting operations. Property getters can also be invoked directly. ```kotlin val value = prop.get { dispatchReceiver = foo } prop.set { dispatchReceiver = foo value(newValue) } prop.getter.invoke { dispatchReceiver = foo } ``` -------------------------------- ### Get All Value Parameters Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/value Retrieves the entire list of value parameters for the project. This method does not create a new list, providing efficient access. ```APIDOC ## GET /websites/inspekt_rnett_dev/value ### Description Gets the list of all value parameters for the project. This operation is optimized to avoid allocating a new list. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/value ### Response #### Success Response (200) - **value** (List) - A list of all value parameters. ``` -------------------------------- ### Basic Inspekt Usage in Kotlin Source: https://inspekt.rnett.dev/latest/index Demonstrates fundamental Inspekt operations in Kotlin. It shows how to get a class reference using `inspekt` and how to invoke a function on an instance. The `dispatchReceiver` is set to an instance of the class for the invocation. ```kotlin val fooClass = inspekt(Foo::class) foo.function("bar").invoke { dispatchReceiver = Foo() } ``` -------------------------------- ### Get All Context Parameters Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/context Retrieves the list of all context parameters without allocating a new list. ```APIDOC ## GET /websites/inspekt_rnett_dev/context ### Description Gets the list of context parameters. This method does not allocate a new list. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/context ### Response #### Success Response (200) - **List** (Array) - A list of context parameters. ### Response Example ```json [ { "source": "example_source_1", "name": "example_name_1" }, { "source": "example_source_2", "name": "example_name_2" } ] ``` ``` -------------------------------- ### Getting All Class Functions with Inspektion Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-inspektion/index Returns a list of all functions associated with the class, including inherited functions but excluding property accessors. Each function is represented by a SimpleFunction object. ```kotlin val functions: List ``` -------------------------------- ### Getting the Primary Constructor with Inspektion Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-inspektion/index Returns the primary constructor of the inspected class, if it has one. The result is a Constructor? object, which can be null. ```kotlin val primaryConstructor: Constructor? ``` -------------------------------- ### Getting and Setting MutableProperty Values (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-mutable-property/index Illustrates how to retrieve and modify the value of a mutable property using its getter and setter. This involves constructing argument lists for the getter and setter operations. ```kotlin val property: MutableProperty = ... // Assume property is initialized // Getting the value val argumentsForGet = ArgumentList(...) // Construct argument list if needed val value: Any? = property.get(argumentsForGet) // Setting the value val argumentsForSet = ArgumentList(...) // Construct argument list if needed property.set(argumentsForSet) ``` -------------------------------- ### Getting Property Value (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-property/index Demonstrates how to retrieve the value of a property using its getter. It supports providing arguments either as an 'ArgumentList' or an 'ArgumentsBuilder'. ```kotlin fun get(arguments: ArgumentList): Any? fun get(arguments: ArgumentsBuilder): Any? ``` -------------------------------- ### Get Package Name from Source Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-callable-name/package-name Retrieves the name of the package containing the declaration or its parent class. This is an abstract value that needs to be implemented by concrete classes. ```kotlin abstract val packageName: PackageName(source) ``` -------------------------------- ### Get All Value Parameters Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/value Returns the complete list of value parameters without allocating a new list. This provides efficient access to all value parameters for inspection or further processing within the Inspektr.rnett.dev project. ```kotlin val value: List(source) Gets the value parameters. Does not allocate a new list. ``` -------------------------------- ### Member Functions (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-callable-name/-member/index Outlines the functions available for the Member data class. Includes asString for string representation, segments to get name parts, sibling to create a related name, and toString for the object's string representation. ```kotlin open override fun asString(): String open override fun segments(): List open override fun sibling(name: String): CallableName override fun toString(): String ``` -------------------------------- ### Get Parameter by Kind and Index - Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/get Retrieves a parameter based on its kind (e.g., VALUE, CONTEXT) and its index within that kind. For example, `get(Kind.VALUE, 2)` retrieves the third value parameter. See also Parameters.value, Parameters.context, Parameters.dispatch, Parameters.extension. ```kotlin operator fun get(kind: Parameter.Kind, indexInKind: Int): Parameter?(source) // Get a parameter by its index in its own kind. For example, `get(Kind.VALUE, 2)` gets the third value parameter. ``` -------------------------------- ### PackageName Constructors Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-package-name/index Provides information on how to create PackageName instances. ```APIDOC ## PackageName Constructors ### Description Constructors for creating `PackageName` objects. ### Constructors 1. **PackageName(packageNames: List)** Creates a `PackageName` from a list of strings. 2. **PackageName(vararg packageNames: String)** Creates a `PackageName` from a variable number of string arguments. ``` -------------------------------- ### Call Functions and Properties on Objects (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-inspektion/index Provides functions to dynamically call methods or access properties on an object. `callFunction` and `invoke` can execute methods with specified arguments, while `get` and `getProperty` retrieve property values. `set` and `setProperty` allow modification of property values. ```kotlin inline fun callFunction(receiver: T?, name: String, argumentsBuilder: ArgumentsBuilder = {}): Any? inline operator fun invoke(receiver: T?, name: String, argumentsBuilder: ArgumentsBuilder = {}): Any? inline operator fun get(receiver: T?, name: String, crossinline argumentsBuilder: ArgumentsBuilder = {}): Any? inline fun getProperty(receiver: T?, name: String, crossinline argumentsBuilder: ArgumentsBuilder = {}): Any? operator fun set(receiver: T?, name: String, value: Any?) operator fun set(receiver: T?, name: String, argumentsBuilder: ArgumentsBuilder) inline fun setProperty(receiver: T?, name: String, crossinline argumentsBuilder: ArgumentsBuilder = {}) inline fun setProperty(receiver: T?, name: String, value: Any?, crossinline argumentsBuilder: ArgumentsBuilder = {}) ``` -------------------------------- ### Constructor Functions Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-constructor/index Details about the functions of the Constructor class. ```APIDOC ## Constructor Functions ### Description Details about the functions of the Constructor class. ### Functions - **annotation** (`inline fun AnnotatedElement.annotation(): T?`) - Description: Get the first annotation of type T, or null if none is found. - **annotations** (`inline fun AnnotatedElement.annotations(): List`) - Description: Get all annotations of type T. - **buildArguments** (`inline fun Callable.buildArguments(builder: ArgumentsBuilder): ArgumentList`) - Description: Builds an ArgumentList for a set of parameters. Parameters which are not set will use their default values if they have one. - **equals** (`open operator override fun equals(other: Any?): Boolean`) - Description: Checks for equality with another object. - **hashCode** (`open override fun hashCode(): Int`) - Description: Returns the hash code of the object. - **invoke** (`operator fun invoke(arguments: ArgumentList): Any?`) - Description: Invoke the referenced function with the given parameters. Will error if the underlying function is `suspend`. - **invokeSuspend** (`suspend fun invokeSuspend(arguments: ArgumentList): Any?`) - Description: Invoke the referenced `suspend` function with the given parameters. If the function is not suspend, this will still invoke it without an error. - **toString** (`override fun toString(): String`) - Description: Returns a string representation of the object. ``` -------------------------------- ### Optimize Proxy Calls with Helper Function in Kotlin Source: https://inspekt.rnett.dev/latest/binary-size Illustrates how to wrap repeated proxy calls for the same interface in a helper function to avoid adding binary size. This is an alternative to using 'proxyFactory'. ```kotlin fun createFooProxy(handler: ProxyHandler) = proxy(Foo::class, handler) ``` -------------------------------- ### Get Parameter Kind Start Offset (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/start-offset This Kotlin function, `startOffset`, takes a `Parameter.Kind` as input and returns an `Int` representing the starting offset of that kind within a parameter list. The function's return value indicates the potential start position but does not guarantee that parameters of the specified kind are actually present. ```kotlin fun startOffset(kind: Parameter.Kind): Int(source) 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. ``` -------------------------------- ### Get Class Names (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-class-name/class-names Retrieves a list of strings representing the class's name and any parent classes. This is useful for understanding the inheritance hierarchy or for reflection-based operations. The example shows how a nested class 'B' within 'A' would result in classNames '["A", "B"]'. ```kotlin val classNames: List(source) ``` -------------------------------- ### Setting Parameter Values with Builder - Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.arguments/-argument-list/-builder/index Demonstrates how to set individual parameter values using the Builder class in Kotlin. This includes setting values by parameter name, global index, or specific kind and index within that kind. These methods are essential for constructing the final ArgumentList. ```kotlin operator fun set(parameter: Parameter, value: Any?) operator fun set(globalIndex: Int, value: Any?) operator fun set(name: String, value: Any?) operator fun set(kind: Parameter.Kind, indexInKind: Int, value: Any?) ``` -------------------------------- ### Get Property Value using Inline Operator (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-inspektion/get Retrieves the value of a property using the 'get' inline operator. It supports static and non-static properties, with receiver and arguments customization. Throws exceptions for invocation errors, missing properties, or duplicate properties. ```kotlin inline operator fun get( receiver: T?, name: String, crossinline argumentsBuilder: ArgumentsBuilder = {}): Any? ``` -------------------------------- ### Helper Method for Reusing Inspektion Objects in Kotlin Source: https://inspekt.rnett.dev/latest/binary-size Shows how a helper method can be used to encapsulate the 'inspekt()' call, allowing for reuse. However, it notes that this still needlessly re-creates the object each time compared to a singleton approach. ```kotlin fun getFooInspektion() = inspekt(Foo::class) ``` -------------------------------- ### Member API - Constructors and Properties Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-callable-name/-member/index This section details the constructor for the Member class and its accessible properties. ```APIDOC ## Member ### Description Represents a qualified name of a member of a class. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "Not applicable for constructor" } ``` ### Response #### Success Response (200) N/A #### Response Example ```json { "example": "Not applicable for constructor" } ``` ## Properties ### className - **className** (ClassName) - Required - The class this declaration is a member of. ### isConstructor - **isConstructor** (Boolean) - Required - Whether this name refers to a constructor. ### isPropertyAccessor - **isPropertyAccessor** (Boolean) - Required - Whether this is the name of a property accessor. ### isPropertyGetter - **isPropertyGetter** (Boolean) - Required - Whether this is the name of a property getter. ### isPropertySetter - **isPropertySetter** (Boolean) - Required - Whether this is the name of a property setter. ### name - **name** (String) - Required - The declaration's own name. ### packageName - **packageName** (PackageName) - Required - The name of the package that contains this declaration or its parent class. ### propertyIfAccessor - **propertyIfAccessor** (CallableName.Member?) - Optional - Get the corresponding property name if this is the name of a property accessor. ``` -------------------------------- ### GET Property Value (ArgumentList) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-property/get Retrieves the value of a property by calling its getter using an ArgumentList. This method might throw a FunctionInvocationException if the invocation fails. ```APIDOC ## GET /websites/inspekt_rnett_dev/get ### Description Gets the value of a property by calling its getter. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/get ### Parameters #### Query Parameters - **arguments** (ArgumentList) - Required - The list of arguments to pass to the getter. ### Request Example ``` GET /websites/inspekt_rnett_dev/get?arguments=[...] ``` ### Response #### Success Response (200) - **result** (Any?) - The retrieved property value. #### Error Response (400) - **error** (string) - Description of the error, e.g., "FunctionInvocationException: invocation failed". #### Response Example ```json { "result": "property_value" } ``` ``` -------------------------------- ### Create Interface Proxy with Inspekt Source: https://inspekt.rnett.dev/latest/proxies Demonstrates how to create a proxy for an interface using the `proxy()` function and providing a `ProxyHandler` implementation. This is the primary method for generating proxies in Inspekt. ```kotlin val myProxy = proxy(MyInterface::class) { // handler implementation } ``` -------------------------------- ### GET Property Value (ArgumentsBuilder) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-property/get Retrieves the value of a property by calling its getter using an ArgumentsBuilder. This method might throw a FunctionInvocationException if the invocation fails. ```APIDOC ## GET /websites/inspekt_rnett_dev/get ### Description Get the value of a property by calling its getter. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/get ### Parameters #### Query Parameters - **arguments** (ArgumentsBuilder) - Required - The builder for arguments to pass to the getter. ### Request Example ``` GET /websites/inspekt_rnett_dev/get?arguments={...} ``` ### Response #### Success Response (200) - **result** (Any?) - The retrieved property value. #### Error Response (400) - **error** (string) - Description of the error, e.g., "FunctionInvocationException: invocation failed". #### Response Example ```json { "result": "property_value" } ``` ``` -------------------------------- ### Get Parameter by Name - Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/get Retrieves a parameter by its string name. This function throws an IllegalArgumentException if the name is 'this'. It cannot be used with 'this' as it might refer to the dispatch or extension receiver. ```kotlin operator fun get(name: String): Parameter?(source) // Get the parameter named name, if present. Cannot be used with "this", as it could refer to the dispatch or extension receiver. // Throws IllegalArgumentException if name is "this" ``` -------------------------------- ### Declare Context Parameter Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameter/-kind/-c-o-n-t-e-x-t/index Demonstrates how to declare a context parameter using the `context(parameter: Type, ...)` syntax. This is a fundamental step in defining context-aware functionalities within the project. ```kotlin context(parameter: Type, ...) ``` -------------------------------- ### Build ArgumentList with Parameters and List of Arguments (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.arguments/-argument-list Creates an ArgumentList for a given set of Parameters where all argument values are explicitly provided. The number of arguments in the list must precisely match the number of parameters. ```kotlin fun ArgumentList(parameters: Parameters, args: List): ArgumentList(source) ``` -------------------------------- ### Get Property Value (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-property/get Retrieves the value of a property by invoking its getter. This function can accept different argument types for property access. It may throw a FunctionInvocationException if the getter invocation fails. ```kotlin fun get(arguments: ArgumentsBuilder): Any?(source) // Gets the value of a property by calling its getter. // Throws FunctionInvocationException if invocation fails ``` ```kotlin fun get(arguments: ArgumentList): Any?(source) // Gets the value of a property by calling its getter. // Throws FunctionInvocationException if invocation fails ``` -------------------------------- ### PackageName member Function Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-package-name/index Creates a top-level callable name within this package, with the specified simple name. ```kotlin fun member(name: String): CallableName.TopLevel ``` -------------------------------- ### Setting Multiple Parameter Values with Builder - Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.arguments/-argument-list/-builder/index Illustrates methods for setting multiple argument values simultaneously using the Builder class in Kotlin. This includes setting values by parameter name, context, value, or general arguments with optional offsets. These functions streamline the process of populating the ArgumentList. ```kotlin fun context(vararg values: Any?, offset: Int = 0) fun set(vararg values: Pair) fun setAll(vararg args: Any?, offset: Int = 0) fun setAll(args: Array, offset: Int = 0) fun setAll(args: Iterable, offset: Int = 0) fun value(vararg values: Any?, offset: Int = 0) ``` -------------------------------- ### Get Argument by Index - Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.arguments/-argument-list/get Retrieves the argument for a parameter at a specific integer index. Returns null if the argument is not set. Use 'isDefaulted' to check if the argument was explicitly set to null or if it's using a default value. This function is part of the Inspektr.rnett.dev project. ```kotlin open operator fun get(index: Int): Any?(source) // Get the argument for the parameter at index, or null if one was not set. // To distinguish between explicitly passing `null` and using the default value, use isDefaulted. ``` -------------------------------- ### PackageName Constructors Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-package-name/index Constructs a PackageName object. It can be initialized with a list of strings or a variable number of string arguments. ```kotlin constructor(packageNames: List) constructor(vararg packageNames: String) ``` -------------------------------- ### Get Argument by Kind and Index - Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.arguments/-argument-list/get Retrieves an argument based on its Parameter.Kind and its index within that kind. Returns null if the argument is not set. Use 'isDefaulted' to check for explicitly set nulls versus default values. This method is useful for structured argument access. ```kotlin operator fun get(kind: Parameter.Kind, indexInKind: Int): Any?(source) // Get the argument for the kind parameter at indexInKind, or null if one was not set. // To distinguish between explicitly passing `null` and using the default value, use isDefaulted. ``` -------------------------------- ### Get Argument by Parameter Object - Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.arguments/-argument-list/get Fetches the argument associated with a given Parameter object. If the argument is not set, it returns null. The 'isDefaulted' method helps differentiate between an explicitly passed null value and a default value. This is a core function for argument retrieval in Inspektr.rnett.dev. ```kotlin operator fun get(parameter: Parameter): Any?(source) // Get the argument for parameter, or null if one was not set. // To distinguish between explicitly passing `null` and using the default value, use isDefaulted. ``` -------------------------------- ### Constructor Properties Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-constructor/index Details about the properties of the Constructor class. ```APIDOC ## Constructor Properties ### Description Details about the properties of the Constructor class. ### Properties - **annotations** (List) - The annotations of the constructor. - **classTypeParameters** (List) - The type parameters of the constructor. - **forClass** (Inspektion<*>) - The class constructed by this constructor. - **inheritedFrom** (KClass<*>?) - If the declaration is inherited from a superclass, the superclass it is inherited from. - **isAbstract** (Boolean) - Whether the declaration is abstract. - **isDeclared** (Boolean) - Whether the declaration is declared in its owning class. - **isInvokable** (Boolean) - Whether the method can be invoked. - **isPrimary** (Boolean) - Whether this is the primary constructor. - **isSuspend** (Boolean) - Whether the referenced function is suspending. - **isTopLevel** (Boolean) - Whether the declaration is top-level. - **kotlin** (KFunction<*>) - A reference to the Kotlin declaration this represents. - **name** (CallableName.Member) - The fully qualified name of the declaration. - **parameters** (Parameters) - The parameters of the declaration. - **returnType** (KType) - The return type of the function. - **shortName** (String) - The short name of the declaration. ``` -------------------------------- ### Get Argument by Name - Kotlin Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.arguments/-argument-list/get Retrieves the argument for a parameter identified by its string name. Returns null if no argument is found for the given name. The 'isDefaulted' property can be used to determine if the argument was explicitly provided as null or if it's a default value. Throws IllegalArgumentException if the name is 'this' due to ambiguity. ```kotlin operator fun get(name: String): Any?(source) // Get the argument for the parameter with the given name, or null if one was not set. // To distinguish between explicitly passing `null` and using the default value, use isDefaulted. // Throws IllegalArgumentException if name == "this", because the parameter would be ambiguous. ``` -------------------------------- ### inspektAndProxy Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.proxy/index Creates an Inspektion and a proxy object factory for interfaces. The proxy responds to all method or accessor calls using the provided handler. ```APIDOC ## inspektAndProxy ### Description Creates an Inspektion and a proxy object factory. The generated proxy implements the specified interface `T` and handles all method or accessor calls via the factory's handler. ### Method `fun inspektAndProxy(@ReferenceLiteral(mustBeInterface = true) toImplement: KClass, @StringLiteral name: String? = null): ProxyableInspektion` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin // Example usage (conceptual, requires Inspekt setup) val proxyable = inspektAndProxy(MyInterface::class) val handler: ProxyHandler = { call -> /* handle call */ } val proxyInstance = proxyable.factory(handler) ``` ### Response #### Success Response (200) - **ProxyableInspektion** (ProxyableInspektion) - An object containing the Inspektion and a factory for creating proxy instances. #### Response Example ```json { "example": "ProxyableInspektion object containing Inspektion and factory" } ``` ``` -------------------------------- ### Parameters Functions Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/index This section outlines the functions available for the Parameters object, enabling operations such as building argument lists, checking for parameter containment, and retrieving specific parameters by index or name. ```APIDOC ## Parameters Functions ### Description Provides various utility functions for working with Parameters, including creating argument lists, checking for parameter existence, and retrieving parameters based on kind, index, or name. ### Functions - **arguments(args: Array): ArgumentList** - Creates an ArgumentList from an array of arguments. Requires specifying a value for all parameters. - **arguments(args: Iterable): ArgumentList** - Creates an ArgumentList from an iterable of arguments. Requires specifying a value for all parameters. - **buildArguments(builder: ArgumentsBuilder): ArgumentList** - Builds an ArgumentList using a builder function. - **contains(element: Parameter): Boolean** - Checks if the Parameters object contains the specified Parameter. - **containsAll(elements: Collection): Boolean** - Checks if the Parameters object contains all specified Parameters. - **context(indexInContextParameters: Int): Parameter** - Gets the context parameter at the specified index in the context parameters list. - **count(kind: Parameter.Kind): Int** - Gets the number of parameters of a given kind. - **get(name: String): Parameter?** - Gets the parameter named `name`, if present. Cannot be used with `"this"`. - **get(kind: Parameter.Kind, indexInKind: Int): Parameter** - Gets a parameter by its index within its specific kind. - **get(index: Int): Parameter** - Gets the parameter at the specified overall index. - **globalIndex(kind: Parameter.Kind, indexInKind: Int): Int** - Gets the overall index in the list for a parameter at a specific index within its kind. - **indexOf(element: Parameter): Int** - Returns the index of the first occurrence of the specified element. - **isEmpty(): Boolean** - Checks if the Parameters object is empty. - **iterator(): Iterator** - Returns an iterator over the parameters. - **lastIndexOf(element: Parameter): Int** - Returns the index of the last occurrence of the specified element. - **listIterator(): ListIterator** - Returns a list iterator over the parameters. - **listIterator(index: Int): ListIterator** - Returns a list iterator starting at the specified index. - **startOffset(kind: Parameter.Kind): Int** - Gets the start offset in the parameter list for the given kind. - **subList(fromIndex: Int, toIndex: Int): List** - Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. - **toString(): String** - Returns a string representation of the Parameters object. - **value(indexInValueParameters: Int): Parameter** - Gets the value parameter at the specified index in the value parameters list. ``` -------------------------------- ### TypeParameter Constructor Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-type-parameter/-type-parameter Details the parameters and their types for the TypeParameter constructor. ```APIDOC ## TypeParameter Constructor ### Description Constructs a new TypeParameter instance. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "Not applicable for constructor" } ``` ### Response #### Success Response (200) TypeParameter instance #### Response Example ```json { "example": "Not applicable for constructor" } ``` ### Parameters - **name** (String) - Required - The name of the type parameter. - **index** (Int) - Required - The index of the type parameter. - **variance** (TypeParameter.Variance) - Required - The variance of the type parameter. - **erasedUpperBounds** (List) - Required - The erased upper bounds of the type parameter. - **isReified** (Boolean) - Required - Indicates if the type parameter is reified. - **annotations** (List) - Required - The annotations applied to the type parameter. - **source** - Required - The source of the type parameter. ``` -------------------------------- ### GET /websites/inspekt_rnett_dev/values Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-type-parameter/-variance/values Retrieves an array containing all the constants of the TypeParameter.Variance enum type, in the order they are declared. This method can be used for iterating over the enum constants. ```APIDOC ## GET /websites/inspekt_rnett_dev/values ### Description Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/values ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **values** (Array) - An array containing the enum constants. #### Response Example ```json { "values": [ "INVARIANT", "IN", "OUT" ] } ``` ``` -------------------------------- ### Building Arguments for Callables (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-mutable-property/index Demonstrates the use of `buildArguments` to create an `ArgumentList` for a callable. This function handles default parameter values, ensuring all non-default parameters are provided. ```kotlin val callable: Callable = ... // Assume callable is initialized val argumentList: ArgumentList = callable.buildArguments { // Provide values for parameters here, e.g.: // put("paramName", value) } // The resulting argumentList can be used for invoking the callable. ``` -------------------------------- ### Get Context Parameter by Index Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/context Retrieves a specific context parameter from the list of context parameters using its index. ```APIDOC ## GET /websites/inspekt_rnett_dev/context/{indexInContextParameters} ### Description Gets the context parameter at the specified index from the list of context parameters. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/context/{indexInContextParameters} ### Parameters #### Path Parameters - **indexInContextParameters** (Int) - Required - The index of the context parameter to retrieve. ### Response #### Success Response (200) - **Parameter(source)** (Object) - The context parameter at the specified index. #### Error Response (400) - **IndexOutOfBoundsException** - If indexInContextParameters is out of bounds for the context parameters. ### Response Example ```json { "source": "example_source", "name": "example_name" } ``` ``` -------------------------------- ### InspektExtension Configuration Source: https://inspekt.rnett.dev/latest/api/gradle-plugin/dev.rnett.inspekt/-inspekt-extension/index Configure properties for the Inspekt Gradle plugin, such as automatically adding Inspekt dependencies and warning about default parameters. ```APIDOC ## InspektExtension Configuration ### Description Configuration for the Inspekt Gradle plugin. This class allows you to control aspects like automatic dependency inclusion and warnings related to default function parameters. ### Properties #### `addInspektDependencies` - **Type**: `Property` - **Default**: `true` - **Description**: If true, the `inspekt` runtime library dependency is automatically added to all source sets as an `implementation` dependency. This is required for the `inspekt` compiler plugin to function. #### `warnOnDefaultParameters` - **Type**: `Property` - **Default**: `5` - **Description**: If this value is greater than 0, the plugin will issue warnings for functions with more default arguments than this number. This is because the invocation lambda can lead to performance issues and increased binary size due to the exponential number of cases generated for default argument combinations. ``` -------------------------------- ### GET /websites/inspekt_rnett_dev/sealedSubclasses Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-inspektion/sealed-subclasses Fetches a list of all direct sealed subclasses for a given Inspektion class. This is useful for understanding the inheritance hierarchy of sealed classes. ```APIDOC ## GET /websites/inspekt_rnett_dev/sealedSubclasses ### Description Retrieves a list of direct sealed subclasses for a given class. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/sealedSubclasses ### Parameters #### Query Parameters - **source** (String) - Required - The source identifier for the inspection. ### Request Example ``` GET /websites/inspekt_rnett_dev/sealedSubclasses?source=example_source ``` ### Response #### Success Response (200) - **sealedSubclasses** (List>) - A list of direct sealed subclasses. #### Response Example ```json { "sealedSubclasses": [ { "type": "Inspektion", "source": "example_source" } ] } ``` ``` -------------------------------- ### Get Property Name from Accessor Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-callable-name/property-if-accessor Retrieves the property name associated with a given property accessor. This is useful for introspection and understanding the underlying property structure. ```APIDOC ## GET /websites/inspekt_rnett_dev/propertyIfAccessor ### Description Get the corresponding property name if this is the name of a property accessor. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/propertyIfAccessor ### Parameters #### Query Parameters - **source** (string) - Optional - The source string to check. ### Request Example ```json { "example": "/websites/inspekt_rnett_dev/propertyIfAccessor?source=someAccessorName" } ``` ### Response #### Success Response (200) - **CallableName** (string) - The name of the callable, if it's a property accessor. #### Response Example ```json { "example": "propertyName" } ``` ``` -------------------------------- ### Reuse Inspection Objects in Kotlin Source: https://inspekt.rnett.dev/latest/binary-size Demonstrates the recommended approach of reusing an 'Inspektion' object by storing it in an object or singleton to minimize binary size. Contrasts this with the less efficient method of calling 'inspekt()' at each call site. ```kotlin object MyReflection { val fooInspektion = inspekt(Foo::class) } // Bad: Each call adds to the binary fun doSomething() { val foo = inspekt(Foo::class) } ``` -------------------------------- ### Implement ProxyHandler for Method Calls Source: https://inspekt.rnett.dev/latest/proxies Shows how to implement a `ProxyHandler` to intercept and manage calls made to a proxy's methods. The `handle()` function within the handler dictates the response to each method invocation. ```kotlin val handler = ProxyHandler { // This block is called for every function call on the proxy println("Calling ${functionName} with arguments: $args") // Return the result of the call "Return value" } ``` -------------------------------- ### Get Property If Accessor Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-callable-name/-top-level/property-if-accessor Retrieves the corresponding property name if the provided accessor is a property accessor. This is useful for introspection and code analysis. ```APIDOC ## GET /websites/inspekt_rnett_dev/propertyIfAccessor ### Description Get the corresponding property name if this is the name of a property accessor. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/propertyIfAccessor ### Parameters #### Query Parameters - **source** (string) - Optional - The source context for the accessor. ### Response #### Success Response (200) - **CallableName.TopLevel?** (object) - The corresponding property name if it exists, otherwise null. #### Response Example { "example": "{\"name\": \"propertyName\", \"type\": \"property\"}" } ``` -------------------------------- ### Get Annotation Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/annotation Retrieves the first annotation of a specified type from an annotated element. Returns null if no annotation of that type is found. ```APIDOC ## GET /websites/inspekt_rnett_dev/annotation ### Description Retrieves the first annotation of a specified type from an annotated element. Returns null if no annotation of that type is found. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/annotation ### Parameters #### Query Parameters - **type** (string) - Required - The type of annotation to retrieve (e.g., "com.example.MyAnnotation"). ### Request Example GET /websites/inspekt_rnett_dev/annotation?type=com.example.MyAnnotation ### Response #### Success Response (200) - **annotation** (object | null) - The annotation object if found, otherwise null. #### Response Example ```json { "annotation": { "value": "example" } } ``` #### Success Response (200) - No Annotation Found - **annotation** (null) - Indicates that no annotation of the specified type was found. #### Response Example ```json { "annotation": null } ``` ``` -------------------------------- ### PropertyGet Constructor (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.proxy/-super-call/-property-get/index The constructor for the PropertyGet class. It initializes a new instance with the super property, super function (getter), and the arguments list. ```kotlin constructor( superProperty: Property, superFun: PropertyGetter, args: ArgumentList) ``` -------------------------------- ### Getting the Short Class Name with Inspektion Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-inspektion/index Returns the short name of the inspected class, which is its own declaration name. The name is returned as a String. ```kotlin val shortName: String ``` -------------------------------- ### Get Function by Name Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-inspektion/function Retrieves a single function by its name. Throws exceptions if the function is not found or if multiple functions share the same name. ```APIDOC ## GET /websites/inspekt_rnett_dev/function/{name} ### Description Gets the single function named `name`. Throws `NoSuchElementException` if no function with that name exists, or `IllegalArgumentException` if more than one function with that name exists. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/function/{name} ### Parameters #### Path Parameters - **name** (String) - Required - The name of the function to retrieve. ### Response #### Success Response (200) - **SimpleFunction** (object) - An object representing the function, including its source. #### Response Example ```json { "source": "function body here" } ``` #### Error Response (404) - **message** (string) - Description of the error (e.g., "No function found with the specified name.") #### Error Response (400) - **message** (string) - Description of the error (e.g., "Multiple functions found with the specified name.") ``` -------------------------------- ### applyToCompilation Function (Kotlin) Source: https://inspekt.rnett.dev/latest/api/gradle-plugin/dev.rnett.inspekt/-inspekt-plugin/index Configures the plugin to be applied to a specific Kotlin compilation. It returns a Provider for a list of SubpluginOption. ```kotlin open override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider> ``` -------------------------------- ### Property Name Accessor Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.proxy/-super-call/property-name This section details how to use the `propertyName` accessor to get the short name of a property, particularly in the context of accessor calls. ```APIDOC ## PropertyName Accessor ### Description If this is an accessor call, return the short name of the property. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/propertyName ### Parameters #### Query Parameters - **source** (String) - Optional - The source from which to retrieve the property name. ### Request Example ```json { "source": "example_source" } ``` ### Response #### Success Response (200) - **propertyName** (String) - The short name of the property. #### Response Example ```json { "propertyName": "shortPropertyName" } ``` ### See also - Callable.shortName ``` -------------------------------- ### TopLevel Name and Package Properties (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-callable-name/-top-level/index Exposes the simple name and package of the callable represented by the TopLevel instance. ```kotlin open override val name: String open override val packageName: PackageName ``` -------------------------------- ### Parameter and Parameters API Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/index Documentation for the Parameter data class and the Parameters data class. ```APIDOC ## Parameter and Parameters API ### Description Provides details about function parameters and their collections. ### Types #### `data class Parameter : AnnotatedElement` ##### Description A parameter of a function or other callable declaration. #### `data class Parameters : List` ##### Description The parameters of a callable. Parameters are ordered by kind (Parameter.Kind). ### Response #### Success Response (200) - **Parameter**: Represents a single parameter. - **Parameters**: Represents a list of parameters. #### Response Example ```json { "parameter": { "name": "myParam", "kind": "VALUE", "type": "String", "annotations": [] } } ``` ```json { "parameters": [ { "name": "param1", "kind": "VALUE", "type": "Int", "annotations": [] }, { "name": "param2", "kind": "VALUE", "type": "String", "annotations": [] } ] } ``` ``` -------------------------------- ### PackageName child Function Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-package-name/index Creates a child PackageName by appending a given name segment to the current package name. ```kotlin fun child(name: String): PackageName ``` -------------------------------- ### PropertyAccess Functions (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.proxy/-super-call/-property-access/index Outlines the functions available for PropertyAccess, including methods to call the super function with different argument configurations and suspend capabilities. ```kotlin fun callSuper(): Any? inline fun callSuper(builder: ArgumentsBuilder): Any? suspend fun callSuperSuspend(): Any? inline suspend fun callSuperSuspend(builder: ArgumentsBuilder): Any? ``` -------------------------------- ### Get Value Parameter by Index Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-parameters/value Retrieves a specific value parameter from the list of value parameters using its index. Throws an exception if the index is out of bounds. ```APIDOC ## GET /websites/inspekt_rnett_dev/value/{indexInValueParameters} ### Description Gets the value parameter at the specified index from the list of value parameters. ### Method GET ### Endpoint /websites/inspekt_rnett_dev/value/{indexInValueParameters} ### Parameters #### Path Parameters - **indexInValueParameters** (Int) - Required - The index of the value parameter to retrieve. ### Response #### Success Response (200) - **Parameter(source)** (Object) - The value parameter found at the specified index. #### Error Response (400) - **IndexOutOfBoundsException** - Thrown if indexInValueParameters is out of bounds for the value parameters. ``` -------------------------------- ### Get Annotation by Type (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-annotated-element/index Retrieves the first annotation of a specified type from an AnnotatedElement. Returns null if no annotation of that type is found. This is an extension function for AnnotatedElement. ```Kotlin inline fun AnnotatedElement.annotation(): T? Get the first annotation of type T, or null if none is found. ``` -------------------------------- ### Inspektion Companion Object Access Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-inspektion/companion-object This section details how to access the companion object instance of an Inspektion class. It explains the type and availability of the companion object. ```APIDOC ## Inspektion Companion Object ### Description Represents the companion object instance of an `Inspektion` class. This property will hold the instance if the class has a companion object, otherwise it will be null. ### Method Access (Read-only) ### Endpoint N/A (This is a property access, not an HTTP endpoint) ### Parameters None ### Request Example N/A ### Response #### Success Response (Property Value) - **companionObject** (`Inspektion?`) - The companion object instance, or null if the class does not have one. #### Response Example ```json { "companionObject": { "instance": "..." } } ``` #### See also - `Inspektion.companionObjectInstance` ``` -------------------------------- ### Get Context Parameter Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.arguments/-argument-list/context Retrieves the context parameter at a specified index. This function allows access to context parameters and can distinguish between explicitly set null values and default values using `isDefaulted`. ```APIDOC ## GET /websites/inspekt_rnett_dev/context/{index} ### Description Gets the context parameter at the specified index. Use `isDefaulted` to differentiate between an explicitly passed `null` and a default value. ### Method GET ### Endpoint `/websites/inspekt_rnett_dev/context/{index}` ### Parameters #### Path Parameters - **index** (Int) - Required - The index of the context parameter to retrieve. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **source** (Any?) - The context parameter value at the specified index, or null if not set. #### Response Example ```json { "source": "some_value" } ``` #### Error Response (400) - **message** (String) - Description of the error. #### Error Response Example ```json { "message": "IndexOutOfBoundsException: Index is out of bounds for the context parameters." } ``` ``` -------------------------------- ### Proxy Creation API Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.proxy/proxy Creates a proxy object that implements a given interface and responds to all method or accessor calls using a specified handler. The interface must be a class reference literal. ```APIDOC ## POST /websites/inspekt_rnett_dev/proxy ### Description Creates a proxy object that implements a specified interface (`toImplement`) and handles all method or accessor calls using the provided `handler`. The `toImplement` parameter must be a class reference literal of an interface. The `name` parameter can optionally specify a name for the proxy class. ### Method POST ### Endpoint /websites/inspekt_rnett_dev/proxy ### Parameters #### Query Parameters - **toImplement** (KClass) - Required - The interface class that the proxy object will implement. Must be a class reference literal of an interface. - **name** (String?) - Optional - The name to be used for the proxy class. Must be a constant value. - **handler** (ProxyHandler) - Required - The handler that will respond to all method or accessor calls on the proxy object. ### Request Body This endpoint does not have a request body. All parameters are passed as query parameters or function arguments. ### Response #### Success Response (200) - **T** (Object) - The created proxy object that implements the specified interface. #### Response Example ```json { "proxyObject": "" } ``` ### Errors - **InspektNotIntrinsifiedException**: Thrown if the code was not intrinsified by the Inspekt compiler plugin. ``` -------------------------------- ### Member Constructor (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model.name/-callable-name/-member/index Provides the constructor for the Member data class. It initializes a Member object with its associated ClassName and a String representing the member's name. ```kotlin constructor(className: ClassName, name: String) ``` -------------------------------- ### Get All Annotations by Type (Kotlin) Source: https://inspekt.rnett.dev/latest/api/inspekt/dev.rnett.inspekt.model/-annotated-element/index Retrieves a list of all annotations of a specified type from an AnnotatedElement. Returns an empty list if no annotations of that type are found. This is an extension function for AnnotatedElement. ```Kotlin inline fun AnnotatedElement.annotations(): List Get all annotations of type T. ``` -------------------------------- ### Apply Inspekt Gradle Plugin Source: https://inspekt.rnett.dev/latest/index This snippet shows how to apply the Inspekt Gradle plugin to your project. Ensure you replace '' with the actual version number found on Maven Central. This is the primary step to integrate Inspekt into your build process. ```gradle plugins { id("dev.rnett.inspekt") version "" // see the Maven Central badge above } ```