Property descriptor initialization moved to DescriptorResolver
This commit is contained in:
@@ -820,6 +820,7 @@ public class DescriptorResolver {
|
||||
BindingTrace trace
|
||||
) {
|
||||
DeclarationDescriptor containingDeclaration = scope.getContainingDeclaration();
|
||||
// SCRIPT: Create property descriptors
|
||||
if (JetPsiUtil.isScriptDeclaration(variable)) {
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||
containingDeclaration,
|
||||
@@ -836,6 +837,7 @@ public class DescriptorResolver {
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = ((ScriptDescriptor) containingDeclaration).getThisAsReceiverParameter();
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), receiverParameter, (JetType) null);
|
||||
initializeWithDefaultGetterSetter(propertyDescriptor);
|
||||
trace.record(BindingContext.VARIABLE, variable, propertyDescriptor);
|
||||
return propertyDescriptor;
|
||||
}
|
||||
@@ -850,6 +852,20 @@ public class DescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private static void initializeWithDefaultGetterSetter(PropertyDescriptorImpl propertyDescriptor) {
|
||||
PropertyGetterDescriptorImpl getter = propertyDescriptor.getGetter();
|
||||
if (getter == null && propertyDescriptor.getVisibility() != Visibilities.PRIVATE) {
|
||||
getter = DescriptorFactory.createDefaultGetter(propertyDescriptor);
|
||||
getter.initialize(propertyDescriptor.getType());
|
||||
}
|
||||
|
||||
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
||||
if (setter == null && propertyDescriptor.isVar()) {
|
||||
setter = DescriptorFactory.createDefaultSetter(propertyDescriptor);
|
||||
}
|
||||
propertyDescriptor.initialize(getter, setter);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public VariableDescriptorImpl resolveLocalVariableDescriptorWithType(
|
||||
@NotNull JetScope scope,
|
||||
|
||||
@@ -70,7 +70,8 @@ public class ScriptBodyResolver {
|
||||
if (jetDeclaration instanceof JetProperty) {
|
||||
if (!shouldBeScriptClassMember(jetDeclaration)) continue;
|
||||
|
||||
properties.add((PropertyDescriptorImpl) bindingContext.get(BindingContext.VARIABLE, jetDeclaration));
|
||||
PropertyDescriptorImpl propertyDescriptor = (PropertyDescriptorImpl) bindingContext.get(BindingContext.VARIABLE, jetDeclaration);
|
||||
properties.add(propertyDescriptor);
|
||||
}
|
||||
else if (jetDeclaration instanceof JetNamedFunction) {
|
||||
if (!shouldBeScriptClassMember(jetDeclaration)) continue;
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.*;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorFactory;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
@@ -94,7 +93,6 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple
|
||||
classScope.addPropertyDescriptor(propertyDescriptor);
|
||||
|
||||
for (PropertyDescriptorImpl property : properties) {
|
||||
initializeWithDefaultGetterSetter(property);
|
||||
classScope.addPropertyDescriptor(property);
|
||||
}
|
||||
|
||||
@@ -103,20 +101,6 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple
|
||||
}
|
||||
}
|
||||
|
||||
public static void initializeWithDefaultGetterSetter(PropertyDescriptorImpl propertyDescriptor) {
|
||||
PropertyGetterDescriptorImpl getter = propertyDescriptor.getGetter();
|
||||
if (getter == null && propertyDescriptor.getVisibility() != Visibilities.PRIVATE) {
|
||||
getter = DescriptorFactory.createDefaultGetter(propertyDescriptor);
|
||||
getter.initialize(propertyDescriptor.getType());
|
||||
}
|
||||
|
||||
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
||||
if (setter == null && propertyDescriptor.isVar()) {
|
||||
setter = DescriptorFactory.createDefaultSetter(propertyDescriptor);
|
||||
}
|
||||
propertyDescriptor.initialize(getter, setter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
|
||||
Reference in New Issue
Block a user