J2K ValueParameterDescriptorImpl: convert and prettify
This commit is contained in:
+44
-119
@@ -14,137 +14,62 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.impl;
|
package org.jetbrains.kotlin.descriptors.impl
|
||||||
|
|
||||||
import kotlin.CollectionsKt;
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import kotlin.jvm.functions.Function1;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
|
||||||
import org.jetbrains.kotlin.name.Name;
|
|
||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
class ValueParameterDescriptorImpl(
|
||||||
|
containingDeclaration: CallableDescriptor,
|
||||||
|
original: ValueParameterDescriptor?,
|
||||||
|
override val index: Int,
|
||||||
|
annotations: Annotations,
|
||||||
|
name: Name,
|
||||||
|
outType: KotlinType,
|
||||||
|
private val declaresDefaultValue: Boolean,
|
||||||
|
override val isCrossinline: Boolean,
|
||||||
|
override val isNoinline: Boolean,
|
||||||
|
override val varargElementType: KotlinType?,
|
||||||
|
source: SourceElement
|
||||||
|
) : VariableDescriptorImpl(containingDeclaration, annotations, name, outType, source), ValueParameterDescriptor {
|
||||||
|
private val original: ValueParameterDescriptor = original ?: this
|
||||||
|
|
||||||
public class ValueParameterDescriptorImpl extends VariableDescriptorImpl implements ValueParameterDescriptor {
|
override fun getContainingDeclaration() = super.getContainingDeclaration() as CallableDescriptor
|
||||||
private final boolean declaresDefaultValue;
|
|
||||||
private final boolean isCrossinline;
|
|
||||||
private final boolean isNoinline;
|
|
||||||
private final KotlinType varargElementType;
|
|
||||||
private final int index;
|
|
||||||
private final ValueParameterDescriptor original;
|
|
||||||
|
|
||||||
public ValueParameterDescriptorImpl(
|
override fun declaresDefaultValue(): Boolean {
|
||||||
@NotNull CallableDescriptor containingDeclaration,
|
return declaresDefaultValue && (containingDeclaration as CallableMemberDescriptor).kind.isReal
|
||||||
@Nullable ValueParameterDescriptor original,
|
|
||||||
int index,
|
|
||||||
@NotNull Annotations annotations,
|
|
||||||
@NotNull Name name,
|
|
||||||
@NotNull KotlinType outType,
|
|
||||||
boolean declaresDefaultValue,
|
|
||||||
boolean isCrossinline,
|
|
||||||
boolean isNoinline,
|
|
||||||
@Nullable KotlinType varargElementType,
|
|
||||||
@NotNull SourceElement source
|
|
||||||
) {
|
|
||||||
super(containingDeclaration, annotations, name, outType, source);
|
|
||||||
this.original = original == null ? this : original;
|
|
||||||
this.index = index;
|
|
||||||
this.declaresDefaultValue = declaresDefaultValue;
|
|
||||||
this.isCrossinline = isCrossinline;
|
|
||||||
this.isNoinline = isNoinline;
|
|
||||||
this.varargElementType = varargElementType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
override fun getOriginal() = if (original === this) this else original.original
|
||||||
@Override
|
|
||||||
public CallableDescriptor getContainingDeclaration() {
|
override fun substitute(substitutor: TypeSubstitutor): ValueParameterDescriptor {
|
||||||
return (CallableDescriptor) super.getContainingDeclaration();
|
if (substitutor.isEmpty) return this
|
||||||
|
throw UnsupportedOperationException() // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
||||||
public int getIndex() {
|
return visitor.visitValueParameterDescriptor(this, data)
|
||||||
return index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun isVar() = false
|
||||||
public boolean declaresDefaultValue() {
|
|
||||||
return declaresDefaultValue && ((CallableMemberDescriptor) getContainingDeclaration()).getKind().isReal();
|
override fun getCompileTimeInitializer() = null
|
||||||
|
|
||||||
|
override fun copy(newOwner: CallableDescriptor, newName: Name): ValueParameterDescriptor {
|
||||||
|
return ValueParameterDescriptorImpl(
|
||||||
|
newOwner, null, index, annotations, newName, type, declaresDefaultValue(),
|
||||||
|
isCrossinline, isNoinline, varargElementType, SourceElement.NO_SOURCE
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun getVisibility() = Visibilities.LOCAL
|
||||||
public boolean isCrossinline() {
|
|
||||||
return isCrossinline;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
override fun getOverriddenDescriptors(): Collection<ValueParameterDescriptor> {
|
||||||
public boolean isNoinline() {
|
return containingDeclaration.overriddenDescriptors.map {
|
||||||
return isNoinline;
|
it.valueParameters[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public KotlinType getVarargElementType() {
|
|
||||||
return varargElementType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public ValueParameterDescriptor getOriginal() {
|
|
||||||
return original == this ? this : original.getOriginal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public ValueParameterDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
|
||||||
if (substitutor.isEmpty()) return this;
|
|
||||||
throw new UnsupportedOperationException(); // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
|
|
||||||
return visitor.visitValueParameterDescriptor(this, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVar() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ConstantValue<?> getCompileTimeInitializer() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public ValueParameterDescriptor copy(@NotNull CallableDescriptor newOwner, @NotNull Name newName) {
|
|
||||||
return new ValueParameterDescriptorImpl(
|
|
||||||
newOwner, null, index, getAnnotations(), newName, getType(), declaresDefaultValue(), isCrossinline(), isNoinline(), varargElementType,
|
|
||||||
SourceElement.NO_SOURCE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Visibility getVisibility() {
|
|
||||||
return Visibilities.LOCAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Collection<ValueParameterDescriptor> getOverriddenDescriptors() {
|
|
||||||
return CollectionsKt.map(
|
|
||||||
getContainingDeclaration().getOverriddenDescriptors(),
|
|
||||||
new Function1<CallableDescriptor, ValueParameterDescriptor>() {
|
|
||||||
@Override
|
|
||||||
public ValueParameterDescriptor invoke(CallableDescriptor descriptor) {
|
|
||||||
return descriptor.getValueParameters().get(getIndex());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user