Renamed classes

This commit is contained in:
Valentin Kipyatkov
2015-07-17 13:10:32 +03:00
parent eb97005cb5
commit 08ac0ae7a0
7 changed files with 27 additions and 27 deletions
@@ -76,7 +76,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.resolve.scopes.receivers.*; import org.jetbrains.kotlin.resolve.scopes.receivers.*;
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor; import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeProjection;
import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.TypeUtils;
@@ -2145,8 +2145,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@NotNull MethodKind methodKind, @NotNull MethodKind methodKind,
StackValue receiver StackValue receiver
) { ) {
if (propertyDescriptor instanceof SyntheticJavaBeansPropertyDescriptor) { if (propertyDescriptor instanceof SyntheticJavaPropertyDescriptor) {
return intermediateValueForSyntheticExtensionProperty((SyntheticJavaBeansPropertyDescriptor) propertyDescriptor, receiver); return intermediateValueForSyntheticExtensionProperty((SyntheticJavaPropertyDescriptor) propertyDescriptor, receiver);
} }
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration(); DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
@@ -2242,7 +2242,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
} }
@NotNull @NotNull
private StackValue.Property intermediateValueForSyntheticExtensionProperty(@NotNull SyntheticJavaBeansPropertyDescriptor propertyDescriptor, StackValue receiver) { private StackValue.Property intermediateValueForSyntheticExtensionProperty(@NotNull SyntheticJavaPropertyDescriptor propertyDescriptor, StackValue receiver) {
Type type = typeMapper.mapType(propertyDescriptor.getOriginal().getType()); Type type = typeMapper.mapType(propertyDescriptor.getOriginal().getType());
CallableMethod callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetMethod(), false, context); CallableMethod callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetMethod(), false, context);
FunctionDescriptor setMethod = propertyDescriptor.getSetMethod(); FunctionDescriptor setMethod = propertyDescriptor.getSetMethod();
@@ -38,12 +38,12 @@ import org.jetbrains.kotlin.utils.addIfNotNull
import java.beans.Introspector import java.beans.Introspector
import java.util.ArrayList import java.util.ArrayList
interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor { interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
val getMethod: FunctionDescriptor val getMethod: FunctionDescriptor
val setMethod: FunctionDescriptor? val setMethod: FunctionDescriptor?
companion object { companion object {
fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaBeansPropertyDescriptor? { fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaPropertyDescriptor? {
val name = getterOrSetter.getName() val name = getterOrSetter.getName()
if (propertyNameByGetMethodName(name) == null && propertyNameBySetMethodName(name) == null) return null // optimization if (propertyNameByGetMethodName(name) == null && propertyNameBySetMethodName(name) == null) return null // optimization
@@ -51,7 +51,7 @@ interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor {
if (owner !is JavaClassDescriptor) return null if (owner !is JavaClassDescriptor) return null
return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType()) return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType())
.filterIsInstance<SyntheticJavaBeansPropertyDescriptor>() .filterIsInstance<SyntheticJavaPropertyDescriptor>()
.firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod } .firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod }
} }
@@ -73,12 +73,12 @@ interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor {
} }
class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes { class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes {
private val scope = JavaBeansExtensionsScope(storageManager) private val scope = JavaSyntheticExtensionsScope(storageManager)
override fun scopes(file: JetFile) = listOf(scope) override fun scopes(file: JetFile) = listOf(scope)
} }
class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty {
private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues<Triple<JavaClassDescriptor, JetType, Name>, PropertyDescriptor> { triple -> private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues<Triple<JavaClassDescriptor, JetType, Name>, PropertyDescriptor> { triple ->
syntheticPropertyInClassNotCached(triple.first, triple.second, triple.third) syntheticPropertyInClassNotCached(triple.first, triple.second, triple.third)
} }
@@ -158,7 +158,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet
if (classifier is JavaClassDescriptor) { if (classifier is JavaClassDescriptor) {
for (descriptor in classifier.getMemberScope(type.getArguments()).getDescriptors(DescriptorKindFilter.FUNCTIONS)) { for (descriptor in classifier.getMemberScope(type.getArguments()).getDescriptors(DescriptorKindFilter.FUNCTIONS)) {
if (descriptor is FunctionDescriptor) { if (descriptor is FunctionDescriptor) {
val propertyName = SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue
addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName))) addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName)))
} }
} }
@@ -192,7 +192,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet
name: Name, name: Name,
type: JetType, type: JetType,
receiverType: JetType receiverType: JetType
) : SyntheticJavaBeansPropertyDescriptor, PropertyDescriptorImpl( ) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl(
DescriptorUtils.getContainingModule(javaClass)/* TODO:is it ok? */, DescriptorUtils.getContainingModule(javaClass)/* TODO:is it ok? */,
null, null,
Annotations.EMPTY, Annotations.EMPTY,
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.checker.JetTypeChecker
@@ -75,7 +75,7 @@ public class ReferenceVariantsHelper(
if (filterOutJavaGettersAndSetters) { if (filterOutJavaGettersAndSetters) {
val accessorMethodsToRemove = HashSet<FunctionDescriptor>() val accessorMethodsToRemove = HashSet<FunctionDescriptor>()
for (variant in variants) { for (variant in variants) {
if (variant is SyntheticJavaBeansPropertyDescriptor) { if (variant is SyntheticJavaPropertyDescriptor) {
accessorMethodsToRemove.add(variant.getMethod) accessorMethodsToRemove.add(variant.getMethod)
accessorMethodsToRemove.addIfNotNull(variant.setMethod) accessorMethodsToRemove.addIfNotNull(variant.setMethod)
} }
@@ -26,17 +26,17 @@ import org.jetbrains.kotlin.psi.JetNameReferenceExpression
import org.jetbrains.kotlin.psi.JetPsiFactory import org.jetbrains.kotlin.psi.JetPsiFactory
import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset
import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addIfNotNull
sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, private val getter: Boolean) : JetSimpleReference<JetNameReferenceExpression>(expression) { sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, private val getter: Boolean) : JetSimpleReference<JetNameReferenceExpression>(expression) {
override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> { override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {
val descriptors = super.getTargetDescriptors(context) val descriptors = super.getTargetDescriptors(context)
if (descriptors.none { it is SyntheticJavaBeansPropertyDescriptor }) return emptyList() if (descriptors.none { it is SyntheticJavaPropertyDescriptor }) return emptyList()
val result = SmartList<FunctionDescriptor>() val result = SmartList<FunctionDescriptor>()
for (descriptor in descriptors) { for (descriptor in descriptors) {
if (descriptor is SyntheticJavaBeansPropertyDescriptor) { if (descriptor is SyntheticJavaPropertyDescriptor) {
if (getter) { if (getter) {
result.add(descriptor.getMethod) result.add(descriptor.getMethod)
} }
@@ -57,9 +57,9 @@ sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpr
val newNameAsName = Name.identifier(newElementName) val newNameAsName = Name.identifier(newElementName)
val newName = if (getter) val newName = if (getter)
SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(newNameAsName)
else else
SyntheticJavaBeansPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName)
if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method
val nameIdentifier = JetPsiFactory(expression).createNameIdentifier(newName.getIdentifier()) val nameIdentifier = JetPsiFactory(expression).createNameIdentifier(newName.getIdentifier())
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.TypeUtils
import javax.swing.Icon import javax.swing.Icon
@@ -254,7 +254,7 @@ public class LookupElementFactory(
if (descriptor is CallableDescriptor) { if (descriptor is CallableDescriptor) {
when { when {
descriptor is SyntheticJavaBeansPropertyDescriptor -> { descriptor is SyntheticJavaPropertyDescriptor -> {
var from = descriptor.getMethod.getName().asString() + "()" var from = descriptor.getMethod.getName().asString() + "()"
descriptor.setMethod?.let { from += "/" + it.getName().asString() + "()" } descriptor.setMethod?.let { from += "/" + it.getName().asString() + "()" }
element = element.appendTailText(" (from $from)", true) element = element.appendTailText(" (from $from)", true)
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
class UsePropertyAccessSyntaxInspection : IntentionBasedInspection<JetCallExpression>(UsePropertyAccessSyntaxIntention()) class UsePropertyAccessSyntaxInspection : IntentionBasedInspection<JetCallExpression>(UsePropertyAccessSyntaxIntention())
@@ -87,8 +87,8 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent
return property return property
} }
private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaBeansPropertyDescriptor? { private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaPropertyDescriptor? {
SyntheticJavaBeansPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it } SyntheticJavaPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it }
for (overridden in function.getOverriddenDescriptors()) { for (overridden in function.getOverriddenDescriptors()) {
findSyntheticProperty(overridden, resolutionScope)?.let { return it } findSyntheticProperty(overridden, resolutionScope)?.let { return it }
@@ -29,8 +29,8 @@ import org.jetbrains.kotlin.idea.JetFileType
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor
import org.jetbrains.kotlin.psi.JetProperty import org.jetbrains.kotlin.psi.JetProperty
import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.synthetic.JavaBeansExtensionsScope import org.jetbrains.kotlin.synthetic.JavaSyntheticExtensionsScope
public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase<PsiReference, MethodReferencesSearch.SearchParameters>(true) { public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase<PsiReference, MethodReferencesSearch.SearchParameters>(true) {
override fun processQuery(queryParameters: MethodReferencesSearch.SearchParameters, consumer: Processor<PsiReference>) { override fun processQuery(queryParameters: MethodReferencesSearch.SearchParameters, consumer: Processor<PsiReference>) {
@@ -54,8 +54,8 @@ public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase<PsiR
} }
val functionDescriptor = method.getJavaMethodDescriptor() ?: return null val functionDescriptor = method.getJavaMethodDescriptor() ?: return null
val syntheticExtensionsScope = JavaBeansExtensionsScope(LockBasedStorageManager()) val syntheticExtensionsScope = JavaSyntheticExtensionsScope(LockBasedStorageManager())
val property = SyntheticJavaBeansPropertyDescriptor.findByGetterOrSetter(functionDescriptor, syntheticExtensionsScope) ?: return null val property = SyntheticJavaPropertyDescriptor.findByGetterOrSetter(functionDescriptor, syntheticExtensionsScope) ?: return null
return property.getName().asString() return property.getName().asString()
} }