Initial support of descriptor loading at runtime
This commit is contained in:
+15
@@ -23,8 +23,23 @@ import org.jetbrains.kotlin.load.java.structure.JavaAnnotationOwner;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public interface ExternalAnnotationResolver {
|
||||
ExternalAnnotationResolver EMPTY = new ExternalAnnotationResolver() {
|
||||
@Nullable
|
||||
@Override
|
||||
public JavaAnnotation findExternalAnnotation(@NotNull JavaAnnotationOwner owner, @NotNull FqName fqName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<JavaAnnotation> findExternalAnnotations(@NotNull JavaAnnotationOwner owner) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
JavaAnnotation findExternalAnnotation(@NotNull JavaAnnotationOwner owner, @NotNull FqName fqName);
|
||||
|
||||
|
||||
+47
@@ -28,6 +28,53 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public interface ExternalSignatureResolver {
|
||||
ExternalSignatureResolver DO_NOTHING = new ExternalSignatureResolver() {
|
||||
@NotNull
|
||||
@Override
|
||||
public PropagatedMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
) {
|
||||
return new PropagatedMethodSignature(
|
||||
returnType, receiverType, valueParameters, typeParameters, Collections.<String>emptyList(), false,
|
||||
Collections.<FunctionDescriptor>emptyList()
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
) {
|
||||
return new AlternativeMethodSignature(
|
||||
returnType, receiverType, valueParameters, typeParameters, Collections.<String>emptyList(), hasStableParameterNames
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field, @NotNull JetType returnType, boolean isVar
|
||||
) {
|
||||
return new AlternativeFieldSignature(returnType, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List<String> signatureErrors) {
|
||||
throw new UnsupportedOperationException("Should not be called");
|
||||
}
|
||||
};
|
||||
|
||||
abstract class MemberSignature {
|
||||
private final List<String> signatureErrors;
|
||||
|
||||
|
||||
+24
@@ -29,6 +29,30 @@ import org.jetbrains.kotlin.load.java.structure.JavaMethod;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
|
||||
public interface JavaResolverCache {
|
||||
JavaResolverCache EMPTY = new JavaResolverCache() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassDescriptor getClassResolvedFromSource(@NotNull FqName fqName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordMethod(@NotNull JavaMethod method, @NotNull SimpleFunctionDescriptor descriptor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordConstructor(@NotNull JavaElement element, @NotNull ConstructorDescriptor descriptor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordField(@NotNull JavaField field, @NotNull PropertyDescriptor descriptor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordClass(@NotNull JavaClass javaClass, @NotNull ClassDescriptor descriptor) {
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
ClassDescriptor getClassResolvedFromSource(@NotNull FqName fqName);
|
||||
|
||||
|
||||
+12
@@ -24,6 +24,18 @@ import org.jetbrains.kotlin.load.java.structure.JavaMethod;
|
||||
import java.util.List;
|
||||
|
||||
public interface MethodSignatureChecker {
|
||||
MethodSignatureChecker DO_NOTHING = new MethodSignatureChecker() {
|
||||
@Override
|
||||
public void checkSignature(
|
||||
@NotNull JavaMethod method,
|
||||
boolean reportSignatureErrors,
|
||||
@NotNull SimpleFunctionDescriptor descriptor,
|
||||
@NotNull List<String> signatureErrors,
|
||||
@NotNull List<FunctionDescriptor> superFunctions
|
||||
) {
|
||||
}
|
||||
};
|
||||
|
||||
void checkSignature(
|
||||
@NotNull JavaMethod method,
|
||||
boolean reportSignatureErrors,
|
||||
|
||||
+12
-4
@@ -16,15 +16,23 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.components
|
||||
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
|
||||
public trait SamConversionResolver {
|
||||
public default object EMPTY : SamConversionResolver {
|
||||
override fun <D : FunctionDescriptor> resolveSamAdapter(original: D) = null
|
||||
override fun resolveSamConstructor(name: Name, scope: JetScope) = null
|
||||
override fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): JetType? = null
|
||||
}
|
||||
|
||||
public fun resolveSamConstructor(name: Name, scope: JetScope): SamConstructorDescriptor?
|
||||
|
||||
public fun <D : FunctionDescriptor> resolveSamAdapter(original: D): D?
|
||||
|
||||
+3
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.structure;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -30,6 +31,7 @@ public interface JavaClassifierType extends JavaType {
|
||||
JavaTypeSubstitutor getSubstitutor();
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
Collection<JavaClassifierType> getSupertypes();
|
||||
|
||||
@NotNull
|
||||
@@ -38,5 +40,6 @@ public interface JavaClassifierType extends JavaType {
|
||||
boolean isRaw();
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
List<JavaType> getTypeArguments();
|
||||
}
|
||||
|
||||
+13
@@ -22,6 +22,19 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||
|
||||
public interface JavaPropertyInitializerEvaluator {
|
||||
JavaPropertyInitializerEvaluator DO_NOTHING = new JavaPropertyInitializerEvaluator() {
|
||||
@Nullable
|
||||
@Override
|
||||
public CompileTimeConstant<?> getInitializerConstant(@NotNull JavaField field, @NotNull PropertyDescriptor descriptor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotNullCompileTimeConstant(@NotNull JavaField field) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
CompileTimeConstant<?> getInitializerConstant(@NotNull JavaField field, @NotNull PropertyDescriptor descriptor);
|
||||
|
||||
|
||||
+2
@@ -18,11 +18,13 @@ package org.jetbrains.kotlin.load.java.structure;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface JavaTypeParameter extends JavaClassifier {
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
Collection<JavaClassifierType> getUpperBounds();
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
@@ -17,10 +17,12 @@
|
||||
package org.jetbrains.kotlin.load.java.structure;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface JavaTypeParameterListOwner extends JavaElement {
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
List<JavaTypeParameter> getTypeParameters();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user