Drop PsiBasedMethodSignatureChecker

This commit is contained in:
Alexander Udalov
2015-06-05 20:21:06 +03:00
parent 12d7187394
commit d4c18b3d55
11 changed files with 31 additions and 369 deletions
@@ -1,46 +0,0 @@
/*
* 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 org.jetbrains.kotlin.load.java.components;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
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,
@NotNull SimpleFunctionDescriptor descriptor,
@NotNull List<String> signatureErrors,
@NotNull List<FunctionDescriptor> superFunctions
);
}
@@ -17,18 +17,21 @@
package org.jetbrains.kotlin.load.java.lazy
import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.load.java.JavaClassFinder
import org.jetbrains.kotlin.load.java.components.*
import org.jetbrains.kotlin.load.java.components.ExternalAnnotationResolver
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
import org.jetbrains.kotlin.load.java.components.JavaResolverCache
import org.jetbrains.kotlin.load.java.components.SamConversionResolver
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver
import org.jetbrains.kotlin.load.java.sources.JavaSourceElementFactory
import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameterListOwner
import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver
import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder
import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator
import org.jetbrains.kotlin.load.java.sources.JavaSourceElementFactory
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameterListOwner
import org.jetbrains.kotlin.serialization.deserialization.*
import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter
import org.jetbrains.kotlin.storage.StorageManager
open class GlobalJavaResolverContext(
val storageManager: StorageManager,
@@ -38,7 +41,6 @@ open class GlobalJavaResolverContext(
val externalAnnotationResolver: ExternalAnnotationResolver,
val externalSignatureResolver: ExternalSignatureResolver,
val errorReporter: ErrorReporter,
val methodSignatureChecker: MethodSignatureChecker,
val javaResolverCache: JavaResolverCache,
val javaPropertyInitializerEvaluator: JavaPropertyInitializerEvaluator,
val samConversionResolver: SamConversionResolver,
@@ -61,7 +63,6 @@ open class LazyJavaResolverContext(
globalContext.externalAnnotationResolver,
globalContext.externalSignatureResolver,
globalContext.errorReporter,
globalContext.methodSignatureChecker,
globalContext.javaResolverCache,
globalContext.javaPropertyInitializerEvaluator,
globalContext.samConversionResolver,
@@ -125,14 +125,15 @@ public class LazyJavaClassMemberScope(
valueParameters: LazyJavaMemberScope.ResolvedValueParameters
): LazyJavaMemberScope.MethodSignatureData {
val propagated = c.externalSignatureResolver.resolvePropagatedSignature(
method, getContainingDeclaration(), returnType, null, valueParameters.descriptors, methodTypeParameters)
val superFunctions = propagated.getSuperMethods()
method, getContainingDeclaration(), returnType, null, valueParameters.descriptors, methodTypeParameters
)
val effectiveSignature = c.externalSignatureResolver.resolveAlternativeMethodSignature(
method, !superFunctions.isEmpty(), propagated.getReturnType(),
method, !propagated.getSuperMethods().isEmpty(), propagated.getReturnType(),
propagated.getReceiverType(), propagated.getValueParameters(), propagated.getTypeParameters(),
propagated.hasStableParameterNames())
propagated.hasStableParameterNames()
)
return LazyJavaMemberScope.MethodSignatureData(effectiveSignature, superFunctions, propagated.getErrors() + effectiveSignature.getErrors())
return LazyJavaMemberScope.MethodSignatureData(effectiveSignature, propagated.getErrors() + effectiveSignature.getErrors())
}
private fun resolveConstructor(constructor: JavaConstructor): JavaConstructorDescriptor {
@@ -98,7 +98,6 @@ public abstract class LazyJavaMemberScope(
protected data class MethodSignatureData(
val effectiveSignature: ExternalSignatureResolver.AlternativeMethodSignature,
val superFunctions: List<FunctionDescriptor>,
val errors: List<String>
)
@@ -109,7 +108,6 @@ public abstract class LazyJavaMemberScope(
valueParameters: ResolvedValueParameters): MethodSignatureData
fun resolveMethodToFunctionDescriptor(method: JavaMethod, record: Boolean = true): JavaMethodDescriptor {
val annotations = c.resolveAnnotations(method)
val functionDescriptorImpl = JavaMethodDescriptor.createJavaMethod(
containingDeclaration, annotations, method.getName(), c.sourceElementFactory.source(method)
@@ -122,7 +120,7 @@ public abstract class LazyJavaMemberScope(
val returnType = computeMethodReturnType(method, annotations, c)
val (effectiveSignature, superFunctions, signatureErrors) = resolveMethodSignature(method, methodTypeParameters, returnType, valueParameters)
val (effectiveSignature, signatureErrors) = resolveMethodSignature(method, methodTypeParameters, returnType, valueParameters)
functionDescriptorImpl.initialize(
effectiveSignature.getReceiverType(),
@@ -141,7 +139,9 @@ public abstract class LazyJavaMemberScope(
c.javaResolverCache.recordMethod(method, functionDescriptorImpl)
}
c.methodSignatureChecker.checkSignature(method, record, functionDescriptorImpl, signatureErrors, superFunctions)
if (signatureErrors.isNotEmpty()) {
c.externalSignatureResolver.reportSignatureErrors(functionDescriptorImpl, signatureErrors)
}
return functionDescriptorImpl
}
@@ -16,10 +16,14 @@
package org.jetbrains.kotlin.load.java.lazy.descriptors
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.*
import org.jetbrains.kotlin.descriptors.ClassOrPackageFragmentDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
import org.jetbrains.kotlin.load.java.structure.JavaMethod
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.JetType
public abstract class LazyJavaStaticScope(
@@ -41,7 +45,7 @@ public abstract class LazyJavaStaticScope(
): LazyJavaMemberScope.MethodSignatureData {
val effectiveSignature = c.externalSignatureResolver.resolveAlternativeMethodSignature(
method, false, returnType, null, valueParameters.descriptors, methodTypeParameters, false)
return LazyJavaMemberScope.MethodSignatureData(effectiveSignature, listOf(), effectiveSignature.getErrors())
return LazyJavaMemberScope.MethodSignatureData(effectiveSignature, effectiveSignature.getErrors())
}
override fun computeNonDeclaredProperties(name: Name, result: MutableCollection<PropertyDescriptor>) {