Support introspection of parameter names and indices in reflection
This commit is contained in:
@@ -31,4 +31,9 @@ public interface KCallable<out R> {
|
||||
* the setter, similarly, will have the name "<set-foo>".
|
||||
*/
|
||||
public val name: String
|
||||
|
||||
/**
|
||||
* Parameters required to make a call to this callable.
|
||||
*/
|
||||
public val parameters: List<KParameter>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.reflect
|
||||
|
||||
/**
|
||||
* Represents a parameter passed to a function or a property getter/setter,
|
||||
* including `this` and extension receiver parameters.
|
||||
*/
|
||||
public interface KParameter {
|
||||
/**
|
||||
* 0-based index of this parameter in the parameter list of its containing callable.
|
||||
*/
|
||||
public val index: Int
|
||||
|
||||
/**
|
||||
* Name of this parameter as it was declared in the source code,
|
||||
* or `null` if the parameter has no name or its name is not available at runtime.
|
||||
* Examples of nameless parameters include `this` instance for member functions,
|
||||
* extension receiver for extension functions or properties, parameters of Java methods
|
||||
* compiled without the debug information, and others.
|
||||
*/
|
||||
public val name: String?
|
||||
}
|
||||
Reference in New Issue
Block a user