Renamed classes
This commit is contained in:
@@ -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.JvmMethodSignature;
|
||||
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.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
@@ -2145,8 +2145,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
@NotNull MethodKind methodKind,
|
||||
StackValue receiver
|
||||
) {
|
||||
if (propertyDescriptor instanceof SyntheticJavaBeansPropertyDescriptor) {
|
||||
return intermediateValueForSyntheticExtensionProperty((SyntheticJavaBeansPropertyDescriptor) propertyDescriptor, receiver);
|
||||
if (propertyDescriptor instanceof SyntheticJavaPropertyDescriptor) {
|
||||
return intermediateValueForSyntheticExtensionProperty((SyntheticJavaPropertyDescriptor) propertyDescriptor, receiver);
|
||||
}
|
||||
|
||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||
@@ -2242,7 +2242,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
@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());
|
||||
CallableMethod callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetMethod(), false, context);
|
||||
FunctionDescriptor setMethod = propertyDescriptor.getSetMethod();
|
||||
|
||||
+7
-7
@@ -38,12 +38,12 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.beans.Introspector
|
||||
import java.util.ArrayList
|
||||
|
||||
interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor {
|
||||
interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
|
||||
val getMethod: FunctionDescriptor
|
||||
val setMethod: FunctionDescriptor?
|
||||
|
||||
companion object {
|
||||
fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaBeansPropertyDescriptor? {
|
||||
fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaPropertyDescriptor? {
|
||||
val name = getterOrSetter.getName()
|
||||
if (propertyNameByGetMethodName(name) == null && propertyNameBySetMethodName(name) == null) return null // optimization
|
||||
|
||||
@@ -51,7 +51,7 @@ interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor {
|
||||
if (owner !is JavaClassDescriptor) return null
|
||||
|
||||
return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType())
|
||||
.filterIsInstance<SyntheticJavaBeansPropertyDescriptor>()
|
||||
.filterIsInstance<SyntheticJavaPropertyDescriptor>()
|
||||
.firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod }
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor {
|
||||
}
|
||||
|
||||
class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes {
|
||||
private val scope = JavaBeansExtensionsScope(storageManager)
|
||||
private val scope = JavaSyntheticExtensionsScope(storageManager)
|
||||
|
||||
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 ->
|
||||
syntheticPropertyInClassNotCached(triple.first, triple.second, triple.third)
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet
|
||||
if (classifier is JavaClassDescriptor) {
|
||||
for (descriptor in classifier.getMemberScope(type.getArguments()).getDescriptors(DescriptorKindFilter.FUNCTIONS)) {
|
||||
if (descriptor is FunctionDescriptor) {
|
||||
val propertyName = SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue
|
||||
val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue
|
||||
addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName)))
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet
|
||||
name: Name,
|
||||
type: JetType,
|
||||
receiverType: JetType
|
||||
) : SyntheticJavaBeansPropertyDescriptor, PropertyDescriptorImpl(
|
||||
) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl(
|
||||
DescriptorUtils.getContainingModule(javaClass)/* TODO:is it ok? */,
|
||||
null,
|
||||
Annotations.EMPTY,
|
||||
+2
-2
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
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.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
@@ -75,7 +75,7 @@ public class ReferenceVariantsHelper(
|
||||
if (filterOutJavaGettersAndSetters) {
|
||||
val accessorMethodsToRemove = HashSet<FunctionDescriptor>()
|
||||
for (variant in variants) {
|
||||
if (variant is SyntheticJavaBeansPropertyDescriptor) {
|
||||
if (variant is SyntheticJavaPropertyDescriptor) {
|
||||
accessorMethodsToRemove.add(variant.getMethod)
|
||||
accessorMethodsToRemove.addIfNotNull(variant.setMethod)
|
||||
}
|
||||
|
||||
+5
-5
@@ -26,17 +26,17 @@ import org.jetbrains.kotlin.psi.JetNameReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.JetPsiFactory
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, private val getter: Boolean) : JetSimpleReference<JetNameReferenceExpression>(expression) {
|
||||
override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {
|
||||
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>()
|
||||
for (descriptor in descriptors) {
|
||||
if (descriptor is SyntheticJavaBeansPropertyDescriptor) {
|
||||
if (descriptor is SyntheticJavaPropertyDescriptor) {
|
||||
if (getter) {
|
||||
result.add(descriptor.getMethod)
|
||||
}
|
||||
@@ -57,9 +57,9 @@ sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpr
|
||||
|
||||
val newNameAsName = Name.identifier(newElementName)
|
||||
val newName = if (getter)
|
||||
SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(newNameAsName)
|
||||
SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(newNameAsName)
|
||||
else
|
||||
SyntheticJavaBeansPropertyDescriptor.propertyNameBySetMethodName(newNameAsName)
|
||||
SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName)
|
||||
if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method
|
||||
|
||||
val nameIdentifier = JetPsiFactory(expression).createNameIdentifier(newName.getIdentifier())
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
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.TypeUtils
|
||||
import javax.swing.Icon
|
||||
@@ -254,7 +254,7 @@ public class LookupElementFactory(
|
||||
|
||||
if (descriptor is CallableDescriptor) {
|
||||
when {
|
||||
descriptor is SyntheticJavaBeansPropertyDescriptor -> {
|
||||
descriptor is SyntheticJavaPropertyDescriptor -> {
|
||||
var from = descriptor.getMethod.getName().asString() + "()"
|
||||
descriptor.setMethod?.let { from += "/" + it.getName().asString() + "()" }
|
||||
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.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
|
||||
class UsePropertyAccessSyntaxInspection : IntentionBasedInspection<JetCallExpression>(UsePropertyAccessSyntaxIntention())
|
||||
|
||||
@@ -87,8 +87,8 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent
|
||||
return property
|
||||
}
|
||||
|
||||
private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaBeansPropertyDescriptor? {
|
||||
SyntheticJavaBeansPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it }
|
||||
private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaPropertyDescriptor? {
|
||||
SyntheticJavaPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it }
|
||||
|
||||
for (overridden in function.getOverriddenDescriptors()) {
|
||||
findSyntheticProperty(overridden, resolutionScope)?.let { return it }
|
||||
|
||||
+4
-4
@@ -29,8 +29,8 @@ import org.jetbrains.kotlin.idea.JetFileType
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetProperty
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.JavaBeansExtensionsScope
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.JavaSyntheticExtensionsScope
|
||||
|
||||
public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase<PsiReference, MethodReferencesSearch.SearchParameters>(true) {
|
||||
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 syntheticExtensionsScope = JavaBeansExtensionsScope(LockBasedStorageManager())
|
||||
val property = SyntheticJavaBeansPropertyDescriptor.findByGetterOrSetter(functionDescriptor, syntheticExtensionsScope) ?: return null
|
||||
val syntheticExtensionsScope = JavaSyntheticExtensionsScope(LockBasedStorageManager())
|
||||
val property = SyntheticJavaPropertyDescriptor.findByGetterOrSetter(functionDescriptor, syntheticExtensionsScope) ?: return null
|
||||
return property.getName().asString()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user